diff --git a/.github/workflows/CI-posix.yml b/.github/workflows/CI-posix.yml index b46283a3..b9be6a09 100644 --- a/.github/workflows/CI-posix.yml +++ b/.github/workflows/CI-posix.yml @@ -28,6 +28,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Check free space + run: | + df -h + shell: bash + - name: Bootstrapping on ${{ matrix.os }} with ${{ matrix.ccomp }} run: | cp .github/workflows/conf-template-${{ matrix.ccomp }}.bash c-plus-plus.conf.sh @@ -42,6 +47,14 @@ jobs: autotests/__error.txt autotests/__dump.txt autotests/__log.txt + autotests/__dump_rlc-core.txt + autotests/any-random-test + autotests/positive-random-test bin - src retention-days: 5 + + - name: Bootstrapping on ${{ matrix.os }} with ${{ matrix.ccomp }} and -OiADPRS + run: | + cp .github/workflows/conf-template-${{ matrix.ccomp }}.bash c-plus-plus.conf.sh + RLMAKE_FLAGS="-X-OiADPRS" ./bootstrap.sh --no-tests + shell: bash diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index dbbad96d..ef469986 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -19,6 +19,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Check free space + run: | + dir + shell: cmd + - name: Bootstrapping with ${{ matrix.ccomp }} run: | copy .github\workflows\conf-template-${{ matrix.ccomp }}.bat c-plus-plus.conf.bat @@ -33,6 +38,15 @@ jobs: autotests\__error.txt autotests\__dump.txt autotests\__log.txt + autotests\__dump_rlc-core.txt + autotests\any-random-test + autotests\positive-random-test bin - src retention-days: 5 + + - name: Bootstrapping with ${{ matrix.ccomp }} and -OiADPRS + run: | + copy .github\workflows\conf-template-${{ matrix.ccomp }}.bat c-plus-plus.conf.bat + set RLMAKE_FLAGS=-X-OiADPRS + bootstrap.bat --no-tests + shell: cmd diff --git a/autotests/@refal-5-lambda-diagnostics.ini b/autotests/@refal-5-lambda-diagnostics.ini index 4dd0cdad..8872a726 100644 --- a/autotests/@refal-5-lambda-diagnostics.ini +++ b/autotests/@refal-5-lambda-diagnostics.ini @@ -1,4 +1,4 @@ -memory-limit = 20000000 -step-limit = 1000000000 -idents-limit = 5000 +memory-limit = 2000000 +step-limit = 20000000 +idents-limit = 5000 enable-debugger = false diff --git a/autotests/Library/@refal-5-lambda-diagnostics.ini b/autotests/Library/@refal-5-lambda-diagnostics.ini index 400dfce4..297f1fa7 100644 --- a/autotests/Library/@refal-5-lambda-diagnostics.ini +++ b/autotests/Library/@refal-5-lambda-diagnostics.ini @@ -1,4 +1,4 @@ -memory-limit = 10000000 -step-limit = 100000000 -idents-limit = 5000 +memory-limit = 1000000 +step-limit = 2000000 +idents-limit = 5000 enable-debugger = false diff --git a/autotests/any-random-test/@refal-5-lambda-diagnostics.ini b/autotests/any-random-test/@refal-5-lambda-diagnostics.ini index 400dfce4..12dc6ac1 100644 --- a/autotests/any-random-test/@refal-5-lambda-diagnostics.ini +++ b/autotests/any-random-test/@refal-5-lambda-diagnostics.ini @@ -1,4 +1,4 @@ -memory-limit = 10000000 -step-limit = 100000000 -idents-limit = 5000 +memory-limit = 500000 +step-limit = 50000000 +idents-limit = 5000 enable-debugger = false diff --git a/autotests/any-random-test/run.bat b/autotests/any-random-test/run.bat index b04b61bb..6b1092c9 100644 --- a/autotests/any-random-test/run.bat +++ b/autotests/any-random-test/run.bat @@ -52,10 +52,6 @@ setlocal 2>%FILE%.err >%FILE%.out if errorlevel 100 ( echo ...COMPILER FAILS ON %FILE%, see %FILE%.err - echo FILE %FILE%.ref: - echo ============================================================ - type %FILE%.ref - echo ============================================================ exit /b 1 ) if exist %FILE%.rasl erase %FILE%.rasl diff --git a/autotests/any-random-test/run.sh b/autotests/any-random-test/run.sh index 15f4728c..e6fc3449 100755 --- a/autotests/any-random-test/run.sh +++ b/autotests/any-random-test/run.sh @@ -48,10 +48,6 @@ run_test() { if [[ $? -gt 99 ]]; then echo "...COMPILER FAILS ON $FILE, see $FILE.err" - echo FILE "$FILE.ref": - echo ============================================================ - cat "$FILE.ref" - echo ============================================================ return 1 fi rm -f "$FILE.rasl" diff --git a/autotests/compatibility/@refal-5-lambda-diagnostics.ini b/autotests/compatibility/@refal-5-lambda-diagnostics.ini index 400dfce4..297f1fa7 100644 --- a/autotests/compatibility/@refal-5-lambda-diagnostics.ini +++ b/autotests/compatibility/@refal-5-lambda-diagnostics.ini @@ -1,4 +1,4 @@ -memory-limit = 10000000 -step-limit = 100000000 -idents-limit = 5000 +memory-limit = 1000000 +step-limit = 2000000 +idents-limit = 5000 enable-debugger = false diff --git a/autotests/compatibility/escapes1.SYNTAX-ERROR.ref b/autotests/compatibility/escapes1.SYNTAX-ERROR.ref index 14582e70..e76d968f 100644 --- a/autotests/compatibility/escapes1.SYNTAX-ERROR.ref +++ b/autotests/compatibility/escapes1.SYNTAX-ERROR.ref @@ -1,3 +1,3 @@ $ENTRY Go { = 'abcd\ -} \ No newline at end of file +} diff --git a/autotests/compatibility/escapes2.SYNTAX-ERROR.ref b/autotests/compatibility/escapes2.SYNTAX-ERROR.ref index a6e5497a..752e682b 100644 --- a/autotests/compatibility/escapes2.SYNTAX-ERROR.ref +++ b/autotests/compatibility/escapes2.SYNTAX-ERROR.ref @@ -1,3 +1,3 @@ $ENTRY Go { = 'abcd\q'; -} \ No newline at end of file +} diff --git a/autotests/compatibility/tab.OK.ref b/autotests/compatibility/tab.OK.ref index 5eb0e940..7b52ed6a 100644 --- a/autotests/compatibility/tab.OK.ref +++ b/autotests/compatibility/tab.OK.ref @@ -1,4 +1,4 @@ $ENTRY Go { * tabs, don't change to spaces: = ; -} \ No newline at end of file +} diff --git a/autotests/compatibility/unnamed-adt.SYNTAX-ERROR.ref b/autotests/compatibility/unnamed-adt.SYNTAX-ERROR.ref index b351e076..d0805443 100644 --- a/autotests/compatibility/unnamed-adt.SYNTAX-ERROR.ref +++ b/autotests/compatibility/unnamed-adt.SYNTAX-ERROR.ref @@ -1,3 +1,3 @@ $ENTRY Go { = [1 2 3]; -} \ No newline at end of file +} diff --git a/autotests/deprecated-drive.WARNING.ref b/autotests/deprecated-drive.WARNING.ref new file mode 100644 index 00000000..ff723a40 --- /dev/null +++ b/autotests/deprecated-drive.WARNING.ref @@ -0,0 +1,9 @@ +* WARNING deprecated + +$ENTRY Go { + = +} + +$DRIVE F; + +F { = } diff --git a/autotests/deprecated-inline.WARNING.ref b/autotests/deprecated-inline.WARNING.ref new file mode 100644 index 00000000..c7792a58 --- /dev/null +++ b/autotests/deprecated-inline.WARNING.ref @@ -0,0 +1,9 @@ +* WARNING deprecated + +$ENTRY Go { + = +} + +$INLINE F; + +F { = } diff --git a/autotests/deprecated-refal5-keyword-label.WARNING.ref b/autotests/deprecated-refal5-keyword-label.WARNING.ref new file mode 100644 index 00000000..cebbf23a --- /dev/null +++ b/autotests/deprecated-refal5-keyword-label.WARNING.ref @@ -0,0 +1,17 @@ +* WARNING deprecated + +$LABEL _-x; + +$ENTRY Go { +%% + (void) arg_begin; + (void) arg_end; + + refalrts::RefalIdentifier mingled = refalrts::ident_implode(vm, "_-x"); + if (mingled != identifiers[ident_u_m_x]) { + return refalrts::cRecognitionImpossible; + } + + return refalrts::cSuccess; +%% +} diff --git a/autotests/deprecated-spec.WARNING.ref b/autotests/deprecated-spec.WARNING.ref new file mode 100644 index 00000000..1bba37d2 --- /dev/null +++ b/autotests/deprecated-spec.WARNING.ref @@ -0,0 +1,9 @@ +* WARNING deprecated + +$ENTRY Go { + = +} + +$SPEC F e.X; + +F { e.X = e.X } diff --git a/autotests/intrinsic-for-defined-function.WARNING.ref b/autotests/intrinsic-for-defined-function.WARNING.ref new file mode 100644 index 00000000..8108d065 --- /dev/null +++ b/autotests/intrinsic-for-defined-function.WARNING.ref @@ -0,0 +1,9 @@ +* WARNING intrinsic + +$INTRINSIC Add; + +$ENTRY Go { + = +} + +Add { 100 500 = 100500 } diff --git a/autotests/lexgen/strange-alternative.BAD-SYNTAX-LEXGEN.sref b/autotests/lexgen/strange-alternative.BAD-SYNTAX-LEXGEN.sref index adf7f01d..df28a3bc 100644 --- a/autotests/lexgen/strange-alternative.BAD-SYNTAX-LEXGEN.sref +++ b/autotests/lexgen/strange-alternative.BAD-SYNTAX-LEXGEN.sref @@ -1,3 +1,3 @@ /*GEN:TOKENS Root = 'x' . -GEN:END*/ \ No newline at end of file +GEN:END*/ diff --git a/autotests/meta-call.FAILURE.ref b/autotests/meta-call.FAILURE.ref new file mode 100644 index 00000000..b42984bf --- /dev/null +++ b/autotests/meta-call.FAILURE.ref @@ -0,0 +1,13 @@ +* TREE + +$META MetaCall; + +$ENTRY Go { + = +} + +__Meta_MetaCall { + e._ s.Table = +} + +__Step-Drop { = } diff --git a/autotests/opt-pattern5.SATELITE.ref b/autotests/opt-pattern5.SATELITE.ref new file mode 100644 index 00000000..d51e48b3 --- /dev/null +++ b/autotests/opt-pattern5.SATELITE.ref @@ -0,0 +1,4 @@ +$ENTRY Inc { + 0 = 1; 1 = 2; 2 = 3; 3 = 4; 4 = 5; + 5 = 6; 6 = 7; 7 = 8; 8 = 9; 9 = 0; +} diff --git a/autotests/opt-pattern5.ref b/autotests/opt-pattern5.ref new file mode 100644 index 00000000..b7548b02 --- /dev/null +++ b/autotests/opt-pattern5.ref @@ -0,0 +1,362 @@ +/* TREE */ + +$ENTRY Go { + = + (0 ) + (0 ) + (0 ) + (LABEL 1 ) + (CmdVar AlgLeft 2 't' 5 ) + (CmdVariableDebugTable 't.Config#1' 5 ) + (CmdVariableDebugTable 'e.Message#1' 2 ) + (CmdCreateElem Allocate 7 ElName 'Prout' ) + (CmdCreateElem Allocate 8 ElString 'LINK ERROR: ' ) + (CmdCreateElem Allocate 12 ElName 'CreateErrorFileMark' ) + (CmdCreateElem Allocate 15 ElName 'Exit' ) + (CmdCreateElem Allocate 16 ElNumber 1 ) + (CmdInsertRange 8 ) + (LABEL 141 ) + (CmdCallSave AlgLeft 0 2 ) + (CmdChar AlgRight 2 'l' ) + (CmdChar AlgRight 2 's' ) + (CmdChar AlgRight 2 'a' ) + (CmdChar AlgRight 2 'r' ) + (CmdChar AlgRight 2 '.' ) + (CmdVariableDebugTable 'e.FileName#1' 2 ) + (CmdCreateElem Allocate 6 ElName 'Lower' ) + (CmdCreateElem Allocate 8 ElName 'GetLastPartName' ) + (LABEL 142 ) + (CmdCallSave AlgLeft 0 2 ) + (CmdVariableDebugTable 'e.FileName#1' 2 ) + (CmdCreateElem Allocate 6 ElName 'DoGetFileName' ) + (LABEL 146 ) + (CmdCallSave AlgLeft 0 2 ) + (CmdOnFailGoTo 145 "Func name:" 'DoGetFileName' ) + (CmdSave 2 5 ) + (CmdVar AlgRight 5 's' 7 ) + (CmdOnFailGoTo 143 "Func name:" 'DoGetFileName' ) + (CmdChar AlgTerm 7 '/' ) + (CmdVariableDebugTable 'e.FileName#1' 5 ) + (LABEL 143 ) + (CmdProfilerStopSentence ) + (CmdOnFailGoTo 144 "Func name:" 'DoGetFileName' ) + (CmdChar AlgTerm 7 '\\' ) + (CmdVariableDebugTable 'e.FileName#1' 5 ) + (LABEL 144 ) + (CmdProfilerStopSentence ) + (CmdVariableDebugTable 's.Last#1' 7 ) + (CmdVariableDebugTable 'e.FileName#1' 5 ) + (CmdCreateElem Allocate 9 ElName 'DoGetFileName' ) + (LABEL 145 ) + (CmdProfilerStopSentence ) + (CmdEmpty AlgLeft 2 ) + + > + >; +} + +gen_e__ { e.arg = e.arg; } + +RESULT { + (CmdFuncArray 6 + ('DoGetFileName' ) + ('GetLastPartName' ) + ('Lower' ) + ('Exit' ) + ('CreateErrorFileMark' ) + ('Prout' ) + ) + (CmdIdentArray 0 + ) + (CmdStringArray 5 + ('e.FileName#1' ) + ('s.Last#1' ) + ('LINK ERROR: ' ) + ('e.Message#1' ) + ('t.Config#1' ) + ) + (LABEL 1 ) + (CmdVar AlgLeft 2 't' 5 ) + (CmdVariableDebugTable 4 5 ) + (CmdVariableDebugTable 3 2 ) + (CmdCreateElem Allocate 7 ElName 5 ) + (CmdCreateElem Allocate 8 ElString 2 ) + (CmdCreateElem Allocate 12 ElName 4 ) + (CmdCreateElem Allocate 15 ElName 3 ) + (CmdCreateElem Allocate 16 ElNumber 1 ) + (CmdInsertRange 8 ) + (LABEL 141 ) + (CmdCallSave AlgLeft 0 2 ) + (CmdChar AlgRight 2 'l' ) + (CmdChar AlgRight 2 's' ) + (CmdChar AlgRight 2 'a' ) + (CmdChar AlgRight 2 'r' ) + (CmdChar AlgRight 2 '.' ) + (CmdVariableDebugTable 0 2 ) + (CmdCreateElem Allocate 6 ElName 2 ) + (CmdCreateElem Allocate 8 ElName 1 ) + (LABEL 142 ) + (CmdCallSave AlgLeft 0 2 ) + (CmdVariableDebugTable 0 2 ) + (CmdCreateElem Allocate 6 ElName 0 ) + (LABEL 146 ) + (CmdCallSave AlgLeft 0 2 ) + (CmdOnFailGoTo 145 "Func name:" 'DoGetFileName' ) + (CmdSave 2 5 ) + (CmdVar AlgRight 5 's' 7 ) + (CmdOnFailGoTo 143 "Func name:" 'DoGetFileName' ) + (CmdChar AlgTerm 7 '/' ) + (CmdVariableDebugTable 0 5 ) + (LABEL 143 ) + (CmdProfilerStopSentence ) + (CmdOnFailGoTo 144 "Func name:" 'DoGetFileName' ) + (CmdChar AlgTerm 7 '\\' ) + (CmdVariableDebugTable 0 5 ) + (LABEL 144 ) + (CmdProfilerStopSentence ) + (CmdVariableDebugTable 1 7 ) + (CmdVariableDebugTable 0 5 ) + (CmdCreateElem Allocate 9 ElName 0 ) + (LABEL 145 ) + (CmdProfilerStopSentence ) + (CmdEmpty AlgLeft 2 ) + = ; +} + + +$EXTERN Inc; +$INTRINSIC Inc; + +Map-RemoveNumber { + (s.Number e.Name) e.Rest = (e.Name) ; + /* пусто */ = /* пусто */; +} + +OutlineConstants { + (s.NextFunc e.Funcs) + (s.NextIdent e.Idents) + (s.NextString e.Strings) + /* пусто */ = + (CmdFuncArray s.NextFunc ) + (CmdIdentArray s.NextIdent ) + (CmdStringArray s.NextString ); + + (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) + (e.Strings) + e.Commands + (CmdName s.Direction s.BracketNum e.Func) = + + (CmdName s.Direction s.BracketNum s.Num); + + (s.NextFunc e.Funcs) (e.Idents) (e.Strings) + e.Commands + (CmdName s.Direction s.BracketNum e.Func) = + e.Funcs (s.NextFunc e.Func)) (e.Idents) + (e.Strings) + e.Commands + > + (CmdName s.Direction s.BracketNum s.NextFunc); + + (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) + (e.Strings) + e.Commands + (CmdNameSave s.Direction s.BracketNum s.SaveOffset e.Func) = + + (CmdNameSave s.Direction s.BracketNum s.SaveOffset s.Num); + + (s.NextFunc e.Funcs) (e.Idents) (e.Strings) + e.Commands + (CmdNameSave s.Direction s.BracketNum s.SaveOffset e.Func) = + e.Funcs (s.NextFunc e.Func)) (e.Idents) + (e.Strings) + e.Commands + > + (CmdNameSave s.Direction s.BracketNum s.SaveOffset s.NextFunc); + + (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) + (e.Strings) + e.Commands + (CmdCreateElem s.CreateMode s.ElemNo ElName e.Func) = + + (CmdCreateElem s.CreateMode s.ElemNo ElName s.Num); + + (s.NextFunc e.Funcs) (e.Idents) (e.Strings) + e.Commands + (CmdCreateElem s.CreateMode s.ElemNo ElName e.Func) = + e.Funcs (s.NextFunc e.Func)) (e.Idents) + (e.Strings) + e.Commands + > + (CmdCreateElem s.CreateMode s.ElemNo ElName s.NextFunc); + + (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) + (e.Strings) + e.Commands + (CmdADT s.Direction s.BracketNum s.InnerBrackets e.Func) = + + (CmdADT s.Direction s.BracketNum s.InnerBrackets s.Num); + + (s.NextFunc e.Funcs) (e.Idents) (e.Strings) + e.Commands + (CmdADT s.Direction s.BracketNum s.InnerBrackets e.Func) = + e.Funcs (s.NextFunc e.Func)) (e.Idents) + (e.Strings) + e.Commands + > + (CmdADT s.Direction s.BracketNum s.InnerBrackets s.NextFunc); + + (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) + (e.Strings) + e.Commands + (CmdADTSave s.Direction s.BracketNum s.InnerBrackets e.Func) = + + (CmdADTSave s.Direction s.BracketNum s.InnerBrackets s.Num); + + (s.NextFunc e.Funcs) (e.Idents) (e.Strings) + e.Commands + (CmdADTSave s.Direction s.BracketNum s.InnerBrackets e.Func) = + e.Funcs (s.NextFunc e.Func)) (e.Idents) + (e.Strings) + e.Commands + > + (CmdADTSave s.Direction s.BracketNum s.InnerBrackets s.NextFunc); + + (e.Funcs) (s.NextIdent e.Idents-B (s.Num e.Ident) e.Idents-E) + (e.Strings) + e.Commands + (CmdIdent s.Direction s.BracketNum e.Ident) = + + (CmdIdent s.Direction s.BracketNum s.Num); + + (e.Funcs) (s.NextIdent e.Idents) (e.Strings) + e.Commands + (CmdIdent s.Direction s.BracketNum e.Ident) = + e.Idents (s.NextIdent e.Ident)) + (e.Strings) + e.Commands + > + (CmdIdent s.Direction s.BracketNum s.NextIdent); + + (e.Funcs) (s.NextIdent e.Idents-B (s.Num e.Ident) e.Idents-E) + (e.Strings) + e.Commands + (CmdIdentSave s.Direction s.BracketNum s.SaveOffset e.Ident) = + + (CmdIdentSave s.Direction s.BracketNum s.SaveOffset s.Num); + + (e.Funcs) (s.NextIdent e.Idents) (e.Strings) + e.Commands + (CmdIdentSave s.Direction s.BracketNum s.SaveOffset e.Ident) = + e.Idents (s.NextIdent e.Ident)) + (e.Strings) + e.Commands + > + (CmdIdentSave s.Direction s.BracketNum s.SaveOffset s.NextIdent); + + (e.Funcs) (s.NextIdent e.Idents-B (s.Num e.Ident) e.Idents-E) + (e.Strings) + e.Commands + (CmdCreateElem s.CreateMode s.ElemNo ElIdent e.Ident) = + + (CmdCreateElem s.CreateMode s.ElemNo ElIdent s.Num); + + (e.Funcs) (s.NextIdent e.Idents) (e.Strings) + e.Commands + (CmdCreateElem s.CreateMode s.ElemNo ElIdent e.Ident) = + e.Idents (s.NextIdent e.Ident)) + (e.Strings) + e.Commands + > + (CmdCreateElem s.CreateMode s.ElemNo ElIdent s.NextIdent); + + (e.Funcs) (e.Idents) + (s.NextStringId e.Strings-B (s.Id e.String) e.Strings-E) + e.Commands + (CmdCreateElem s.CreateMode s.ElemNo ElString e.String) = + + (CmdCreateElem s.CreateMode s.ElemNo ElString s.Id); + + (e.Funcs) (e.Idents) (s.NextStringId e.Strings) + e.Commands + (CmdCreateElem s.CreateMode s.ElemNo ElString e.String) = + e.Strings (s.NextStringId e.String)) + e.Commands + > + (CmdCreateElem s.CreateMode s.ElemNo ElString s.NextStringId); + + (e.Funcs) (e.Idents) + (s.NextStringId e.Strings-B (s.Id e.VarName) e.Strings-E) + e.Commands + (CmdVariableDebugTable e.VarName s.Offset) = + + (CmdVariableDebugTable s.Id s.Offset); + + (e.Funcs) (e.Idents) + (s.NextStringId e.Strings) + e.Commands + (CmdVariableDebugTable e.VarName s.Offset) = + e.Strings (s.NextStringId e.VarName)) + e.Commands + > + (CmdVariableDebugTable s.NextStringId s.Offset); + + (e.Funcs) (e.Idents) (e.Strings) + e.Commands + t.OtherCommand = + + t.OtherCommand; +} diff --git a/autotests/opt-pattern5.sref b/autotests/opt-pattern5.sref deleted file mode 100644 index 9f61f9e9..00000000 --- a/autotests/opt-pattern5.sref +++ /dev/null @@ -1,361 +0,0 @@ -//FROM refalrts -/* TREE */ - -$ENTRY Go { - = - >; -} - -RESULT { - (#CmdFuncArray 6 - ('DoGetFileName' ) - ('GetLastPartName' ) - ('Lower' ) - ('Exit' ) - ('CreateErrorFileMark' ) - ('Prout' ) - ) - (#CmdIdentArray 0 - ) - (#CmdStringArray 5 - ('e.FileName#1' ) - ('s.Last#1' ) - ('LINK ERROR: ' ) - ('e.Message#1' ) - ('t.Config#1' ) - ) - (#LABEL 1 ) - (#CmdVar #AlgLeft 2 't' 5 ) - (#CmdVariableDebugTable 4 5 ) - (#CmdVariableDebugTable 3 2 ) - (#CmdCreateElem #Allocate 7 #ElName 5 ) - (#CmdCreateElem #Allocate 8 #ElString 2 ) - (#CmdCreateElem #Allocate 12 #ElName 4 ) - (#CmdCreateElem #Allocate 15 #ElName 3 ) - (#CmdCreateElem #Allocate 16 #ElNumber 1 ) - (#CmdInsertRange 8 ) - (#LABEL 141 ) - (#CmdCallSave #AlgLeft 0 2 ) - (#CmdChar #AlgRight 2 'l' ) - (#CmdChar #AlgRight 2 's' ) - (#CmdChar #AlgRight 2 'a' ) - (#CmdChar #AlgRight 2 'r' ) - (#CmdChar #AlgRight 2 '.' ) - (#CmdVariableDebugTable 0 2 ) - (#CmdCreateElem #Allocate 6 #ElName 2 ) - (#CmdCreateElem #Allocate 8 #ElName 1 ) - (#LABEL 142 ) - (#CmdCallSave #AlgLeft 0 2 ) - (#CmdVariableDebugTable 0 2 ) - (#CmdCreateElem #Allocate 6 #ElName 0 ) - (#LABEL 146 ) - (#CmdCallSave #AlgLeft 0 2 ) - (#CmdOnFailGoTo 145 "Func name:" 'DoGetFileName' ) - (#CmdSave 2 5 ) - (#CmdVar #AlgRight 5 's' 7 ) - (#CmdOnFailGoTo 143 "Func name:" 'DoGetFileName' ) - (#CmdChar #AlgTerm 7 '/' ) - (#CmdVariableDebugTable 0 5 ) - (#LABEL 143 ) - (#CmdProfilerStopSentence ) - (#CmdOnFailGoTo 144 "Func name:" 'DoGetFileName' ) - (#CmdChar #AlgTerm 7 '\\' ) - (#CmdVariableDebugTable 0 5 ) - (#LABEL 144 ) - (#CmdProfilerStopSentence ) - (#CmdVariableDebugTable 1 7 ) - (#CmdVariableDebugTable 0 5 ) - (#CmdCreateElem #Allocate 9 #ElName 0 ) - (#LABEL 145 ) - (#CmdProfilerStopSentence ) - (#CmdEmpty #AlgLeft 2 ) - = ; -} - - -Inc { - 0 = 1; 1 = 2; 2 = 3; 3 = 4; 4 = 5; - 5 = 6; 6 = 7; 7 = 8; 8 = 9; 9 = 0; -} - -Map-RemoveNumber { - (s.Number e.Name) e.Rest = (e.Name) ; - /* пусто */ = /* пусто */; -} - -OutlineConstants { - (s.NextFunc e.Funcs) - (s.NextIdent e.Idents) - (s.NextString e.Strings) - /* пусто */ = - (#CmdFuncArray s.NextFunc ) - (#CmdIdentArray s.NextIdent ) - (#CmdStringArray s.NextString ); - - (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) - (e.Strings) - e.Commands - (#CmdName s.Direction s.BracketNum e.Func) = - - (#CmdName s.Direction s.BracketNum s.Num); - - (s.NextFunc e.Funcs) (e.Idents) (e.Strings) - e.Commands - (#CmdName s.Direction s.BracketNum e.Func) = - e.Funcs (s.NextFunc e.Func)) (e.Idents) - (e.Strings) - e.Commands - > - (#CmdName s.Direction s.BracketNum s.NextFunc); - - (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) - (e.Strings) - e.Commands - (#CmdNameSave s.Direction s.BracketNum s.SaveOffset e.Func) = - - (#CmdNameSave s.Direction s.BracketNum s.SaveOffset s.Num); - - (s.NextFunc e.Funcs) (e.Idents) (e.Strings) - e.Commands - (#CmdNameSave s.Direction s.BracketNum s.SaveOffset e.Func) = - e.Funcs (s.NextFunc e.Func)) (e.Idents) - (e.Strings) - e.Commands - > - (#CmdNameSave s.Direction s.BracketNum s.SaveOffset s.NextFunc); - - (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) - (e.Strings) - e.Commands - (#CmdCreateElem s.CreateMode s.ElemNo #ElName e.Func) = - - (#CmdCreateElem s.CreateMode s.ElemNo #ElName s.Num); - - (s.NextFunc e.Funcs) (e.Idents) (e.Strings) - e.Commands - (#CmdCreateElem s.CreateMode s.ElemNo #ElName e.Func) = - e.Funcs (s.NextFunc e.Func)) (e.Idents) - (e.Strings) - e.Commands - > - (#CmdCreateElem s.CreateMode s.ElemNo #ElName s.NextFunc); - - (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) - (e.Strings) - e.Commands - (#CmdADT s.Direction s.BracketNum s.InnerBrackets e.Func) = - - (#CmdADT s.Direction s.BracketNum s.InnerBrackets s.Num); - - (s.NextFunc e.Funcs) (e.Idents) (e.Strings) - e.Commands - (#CmdADT s.Direction s.BracketNum s.InnerBrackets e.Func) = - e.Funcs (s.NextFunc e.Func)) (e.Idents) - (e.Strings) - e.Commands - > - (#CmdADT s.Direction s.BracketNum s.InnerBrackets s.NextFunc); - - (s.NextFunc e.Funcs-B (s.Num e.Func) e.Funcs-E) (e.Idents) - (e.Strings) - e.Commands - (#CmdADTSave s.Direction s.BracketNum s.InnerBrackets e.Func) = - - (#CmdADTSave s.Direction s.BracketNum s.InnerBrackets s.Num); - - (s.NextFunc e.Funcs) (e.Idents) (e.Strings) - e.Commands - (#CmdADTSave s.Direction s.BracketNum s.InnerBrackets e.Func) = - e.Funcs (s.NextFunc e.Func)) (e.Idents) - (e.Strings) - e.Commands - > - (#CmdADTSave s.Direction s.BracketNum s.InnerBrackets s.NextFunc); - - (e.Funcs) (s.NextIdent e.Idents-B (s.Num e.Ident) e.Idents-E) - (e.Strings) - e.Commands - (#CmdIdent s.Direction s.BracketNum e.Ident) = - - (#CmdIdent s.Direction s.BracketNum s.Num); - - (e.Funcs) (s.NextIdent e.Idents) (e.Strings) - e.Commands - (#CmdIdent s.Direction s.BracketNum e.Ident) = - e.Idents (s.NextIdent e.Ident)) - (e.Strings) - e.Commands - > - (#CmdIdent s.Direction s.BracketNum s.NextIdent); - - (e.Funcs) (s.NextIdent e.Idents-B (s.Num e.Ident) e.Idents-E) - (e.Strings) - e.Commands - (#CmdIdentSave s.Direction s.BracketNum s.SaveOffset e.Ident) = - - (#CmdIdentSave s.Direction s.BracketNum s.SaveOffset s.Num); - - (e.Funcs) (s.NextIdent e.Idents) (e.Strings) - e.Commands - (#CmdIdentSave s.Direction s.BracketNum s.SaveOffset e.Ident) = - e.Idents (s.NextIdent e.Ident)) - (e.Strings) - e.Commands - > - (#CmdIdentSave s.Direction s.BracketNum s.SaveOffset s.NextIdent); - - (e.Funcs) (s.NextIdent e.Idents-B (s.Num e.Ident) e.Idents-E) - (e.Strings) - e.Commands - (#CmdCreateElem s.CreateMode s.ElemNo #ElIdent e.Ident) = - - (#CmdCreateElem s.CreateMode s.ElemNo #ElIdent s.Num); - - (e.Funcs) (s.NextIdent e.Idents) (e.Strings) - e.Commands - (#CmdCreateElem s.CreateMode s.ElemNo #ElIdent e.Ident) = - e.Idents (s.NextIdent e.Ident)) - (e.Strings) - e.Commands - > - (#CmdCreateElem s.CreateMode s.ElemNo #ElIdent s.NextIdent); - - (e.Funcs) (e.Idents) - (s.NextStringId e.Strings-B (s.Id e.String) e.Strings-E) - e.Commands - (#CmdCreateElem s.CreateMode s.ElemNo #ElString e.String) = - - (#CmdCreateElem s.CreateMode s.ElemNo #ElString s.Id); - - (e.Funcs) (e.Idents) (s.NextStringId e.Strings) - e.Commands - (#CmdCreateElem s.CreateMode s.ElemNo #ElString e.String) = - e.Strings (s.NextStringId e.String)) - e.Commands - > - (#CmdCreateElem s.CreateMode s.ElemNo #ElString s.NextStringId); - - (e.Funcs) (e.Idents) - (s.NextStringId e.Strings-B (s.Id e.VarName) e.Strings-E) - e.Commands - (#CmdVariableDebugTable e.VarName s.Offset) = - - (#CmdVariableDebugTable s.Id s.Offset); - - (e.Funcs) (e.Idents) - (s.NextStringId e.Strings) - e.Commands - (#CmdVariableDebugTable e.VarName s.Offset) = - e.Strings (s.NextStringId e.VarName)) - e.Commands - > - (#CmdVariableDebugTable s.NextStringId s.Offset); - - (e.Funcs) (e.Idents) (e.Strings) - e.Commands - t.OtherCommand = - - t.OtherCommand; -} diff --git a/autotests/opt-tree-bloat-basic._ref b/autotests/opt-tree-bloat-basic._ref new file mode 100644 index 00000000..76617e18 --- /dev/null +++ b/autotests/opt-tree-bloat-basic._ref @@ -0,0 +1,10 @@ +$ENTRY START { + (e.A) t.B (e.C) = ; +} + +Loop { + (e.Acc) e.Begin t.U t.V W e.End + = ; + + (e.Acc) e.Rest = e.Acc e.Rest; +} diff --git a/autotests/opt-tree-bloat-condition._ref b/autotests/opt-tree-bloat-condition._ref new file mode 100644 index 00000000..c27d0922 --- /dev/null +++ b/autotests/opt-tree-bloat-condition._ref @@ -0,0 +1,8 @@ +$ENTRY Block { + e.A t.B t.C X e.D + , : e.X A e.Y e.D + , : + = ; + + e.X = e.X; +} diff --git a/autotests/opt-tree-drive-spec1.ref b/autotests/opt-tree-drive-spec1.ref index cd84da21..b0f44d02 100644 --- a/autotests/opt-tree-drive-spec1.ref +++ b/autotests/opt-tree-drive-spec1.ref @@ -7,18 +7,21 @@ $ENTRY Go { } $ENTRY F { - s.X = ; - t.X = ; + s.X = { = s.X }> ; + t.X = { = t.X }> ; } -$SPEC EqS t.x t.Y; +*TODO: заменить на gen_s__ +gen_e__ { e.arg = e.arg } + +*$SPEC EqS; EqS { t.X t.X = True; t.X t.Y = False; } -$DRIVE EqD; +*$DRIVE EqD; EqD { t.X t.X = True; diff --git a/autotests/opt-tree-drive-spec2.ref b/autotests/opt-tree-drive-spec2.ref index 99332850..188bfac3 100644 --- a/autotests/opt-tree-drive-spec2.ref +++ b/autotests/opt-tree-drive-spec2.ref @@ -12,8 +12,7 @@ Test { e.X = ; } -$DRIVE DS; -$SPEC DS s.STAT e.dyn; +*$OPT DS; DS { s.Mark /* empty */ = s.Mark s.Mark; diff --git a/autotests/opt-tree-drive-spec3-block.ref b/autotests/opt-tree-drive-spec3-block.ref index 29bbc714..ca5d42fd 100644 --- a/autotests/opt-tree-drive-spec3-block.ref +++ b/autotests/opt-tree-drive-spec3-block.ref @@ -9,7 +9,7 @@ $ENTRY Go { = /* empty */; } -$SPEC F s.STAT e.dyn; +*$SPEC F; F { s.Mark e.X diff --git a/autotests/opt-tree-drive-spec3-closure.ref b/autotests/opt-tree-drive-spec4-closure.ref similarity index 97% rename from autotests/opt-tree-drive-spec3-closure.ref rename to autotests/opt-tree-drive-spec4-closure.ref index c5439d17..adf36b07 100644 --- a/autotests/opt-tree-drive-spec3-closure.ref +++ b/autotests/opt-tree-drive-spec4-closure.ref @@ -10,7 +10,7 @@ Test { s.X = } -$DRIVE F; +*$DRIVE F; F { t.Mark diff --git a/autotests/opt-tree-drive-spec5.ref b/autotests/opt-tree-drive-spec5.ref new file mode 100644 index 00000000..70dd1639 --- /dev/null +++ b/autotests/opt-tree-drive-spec5.ref @@ -0,0 +1,11 @@ +* TREE + +$ENTRY Go { + (e.A) (e.B) (e.C) (e.D) (e.E) (e.F) (e.G 'a' H e.H e.H) e.K e.E + , : e.G + , e.B e.A ADAC : e.H + , : G + = /* empty */; + + /* empty */ = /* empty */; +} diff --git a/autotests/opt-tree-drive1-merged.ref b/autotests/opt-tree-drive1-merged.ref index 09b9e322..b3d5afdd 100644 --- a/autotests/opt-tree-drive1-merged.ref +++ b/autotests/opt-tree-drive1-merged.ref @@ -8,7 +8,7 @@ Go1 { e.X = ; } -$DRIVE F1; +*$DRIVE F1; F1 { e.X = e.X; @@ -23,7 +23,7 @@ Q { e.X '=' e.Y = ; } -$DRIVE EQ; +*$DRIVE EQ; EQ { (e.X) e.X = EQ; @@ -37,20 +37,20 @@ Go3 { B = 4; } -$DRIVE Go3; +*$DRIVE Go3; Go4 { e.X = ; } -$SPEC S s.X; +*$SPEC S; S { s.X = s.X } -$DRIVE D; +*$DRIVE D; D { s.X = s.X } -$INLINE I; +*$INLINE I; I { s.X = s.X } @@ -58,7 +58,7 @@ Go5 { e.X = [Go5 ]; } -$DRIVE F2; +*$DRIVE F2; F2 { A e.Z = e.Z; @@ -80,7 +80,7 @@ F3 { e.Z s.X = e.Z; } -$DRIVE F3; +*$DRIVE F3; Go-h1 { = > } @@ -89,7 +89,7 @@ fact { = (fact DUP (0) '=' if (DROP (1)) else (DUP (1) '-' fact '*')); } -$INLINE Lookup; +*$INLINE Lookup; Lookup { s.Func (s.Func e.Code) e.Program = e.Code; diff --git a/autotests/opt-tree-drive2-identic-equals.ref b/autotests/opt-tree-drive2-identic-equals.ref index ccabb957..8111c6dc 100644 --- a/autotests/opt-tree-drive2-identic-equals.ref +++ b/autotests/opt-tree-drive2-identic-equals.ref @@ -16,7 +16,7 @@ Test { s.X e.Y = ; } -$DRIVE F; +*$DRIVE F; F { e.Y s.X s.X = True (e.Y); diff --git a/autotests/opt-tree-drive3-cond-last-sentence.ref b/autotests/opt-tree-drive3-cond-last-sentence.ref index 83fbf4df..aa6d550c 100644 --- a/autotests/opt-tree-drive3-cond-last-sentence.ref +++ b/autotests/opt-tree-drive3-cond-last-sentence.ref @@ -10,7 +10,7 @@ Test { e.X = ; } -$DRIVE D; +*$DRIVE D; D { e.X, e.X : '***' = Ok; diff --git a/autotests/opt-tree-drive4-empty.ref b/autotests/opt-tree-drive4-empty.ref new file mode 100644 index 00000000..6cae9c5a --- /dev/null +++ b/autotests/opt-tree-drive4-empty.ref @@ -0,0 +1,9 @@ +* TREE + +$ENTRY Go { + /* empty */ = /* empty */; + ZZ = ; +} + +*$DRIVE D; +D {} diff --git a/autotests/opt-tree-drive5-active-call.ref b/autotests/opt-tree-drive5-active-call.ref new file mode 100644 index 00000000..045655a8 --- /dev/null +++ b/autotests/opt-tree-drive5-active-call.ref @@ -0,0 +1,23 @@ +* TREE + +$ENTRY Go { + /* empty */ + = : Z Z + = : DD + = /* empty */ +} + +F { + s.7 = s.7> +} + +*$DRIVE D + +D { + e.6 DD = e.6; + e.Z = e.Z; +} + +*$NOOPT N + +N { e.X = e.X } diff --git a/autotests/opt-tree-spec-higman-kruskal-relation1.ref b/autotests/opt-tree-higman-kruskal-relation1-spec.ref similarity index 87% rename from autotests/opt-tree-spec-higman-kruskal-relation1.ref rename to autotests/opt-tree-higman-kruskal-relation1-spec.ref index 85940949..a3f32d8d 100644 --- a/autotests/opt-tree-spec-higman-kruskal-relation1.ref +++ b/autotests/opt-tree-higman-kruskal-relation1-spec.ref @@ -6,7 +6,7 @@ $ENTRY Go { = /* empty */; } -$SPEC Test t.STAT e.dyn; +*$SPEC; Test { t.Acc s._ e.Rest = ; diff --git a/autotests/opt-tree-spec-higman-kruskal-relation3.ref b/autotests/opt-tree-higman-kruskal-relation2-spec.ref similarity index 67% rename from autotests/opt-tree-spec-higman-kruskal-relation3.ref rename to autotests/opt-tree-higman-kruskal-relation2-spec.ref index d725c87a..b5b28cc6 100644 --- a/autotests/opt-tree-spec-higman-kruskal-relation3.ref +++ b/autotests/opt-tree-higman-kruskal-relation2-spec.ref @@ -2,11 +2,13 @@ $ENTRY Go { /* empty */ - = : 'bzb' + = > : 'bzb' = /* empty */; } -$SPEC Test (e.ACC) e.input; +gen_e__ { e.arg = e.arg } + +*$SPEC Test; Test { (e.Acc) 'a' e.Rest = ; diff --git a/autotests/opt-tree-spec-higman-kruskal-relation2.ref b/autotests/opt-tree-higman-kruskal-relation3-spec.ref similarity index 67% rename from autotests/opt-tree-spec-higman-kruskal-relation2.ref rename to autotests/opt-tree-higman-kruskal-relation3-spec.ref index ae2d151c..2baea7ea 100644 --- a/autotests/opt-tree-spec-higman-kruskal-relation2.ref +++ b/autotests/opt-tree-higman-kruskal-relation3-spec.ref @@ -2,11 +2,13 @@ $ENTRY Go { /* empty */ - = : 'bzb' + = > : 'bzb' = /* empty */; } -$SPEC Test (e.ACC) e.input; +gen_e__ { e.arg = e.arg } + +*$SPEC Test; Test { (e.Acc) 'a' e.Rest = ; diff --git a/autotests/opt-tree-spec-higman-kruskal-relation4.ref b/autotests/opt-tree-higman-kruskal-relation4-spec.ref similarity index 67% rename from autotests/opt-tree-spec-higman-kruskal-relation4.ref rename to autotests/opt-tree-higman-kruskal-relation4-spec.ref index 2ad71791..68f1bb49 100644 --- a/autotests/opt-tree-spec-higman-kruskal-relation4.ref +++ b/autotests/opt-tree-higman-kruskal-relation4-spec.ref @@ -2,11 +2,13 @@ $ENTRY Go { /* empty */ - = : (X) (Y) (Z) (T) + = )> : (X) (Y) (Z) (T) = /* empty */; } -$SPEC Loop (e.UNUSED) (e.RES) (e.items); +gen_e__ { e.arg = e.arg } + +*$SPEC Loop; Loop { (e.Unused) (e.Res) (t.Item e.Items) diff --git a/autotests/opt-tree-spec-higman-kruskal-relation5.ref b/autotests/opt-tree-higman-kruskal-relation5-spec.ref similarity index 86% rename from autotests/opt-tree-spec-higman-kruskal-relation5.ref rename to autotests/opt-tree-higman-kruskal-relation5-spec.ref index 3707ac22..c8db75ec 100644 --- a/autotests/opt-tree-spec-higman-kruskal-relation5.ref +++ b/autotests/opt-tree-higman-kruskal-relation5-spec.ref @@ -6,8 +6,8 @@ $ENTRY Go { = /* empty */; } -$INLINE F; -$SPEC F (e.ACC) s.mark e.string; +*$INLINE F; +*$SPEC F; F { (e.Acc) 5 e.String = 5; diff --git a/autotests/opt-tree-spec-higman-kruskal-relation6.ref b/autotests/opt-tree-higman-kruskal-relation6-spec.ref similarity index 100% rename from autotests/opt-tree-spec-higman-kruskal-relation6.ref rename to autotests/opt-tree-higman-kruskal-relation6-spec.ref diff --git a/autotests/opt-tree-higman-kruskal-relation7-drive.ref b/autotests/opt-tree-higman-kruskal-relation7-drive.ref new file mode 100644 index 00000000..5491faf4 --- /dev/null +++ b/autotests/opt-tree-higman-kruskal-relation7-drive.ref @@ -0,0 +1,53 @@ +* TREE + +$ENTRY Go { + /* empty */ + = : e.Trash + = : e.MarkedResult + = + : (a RemovedTile (Tile 'hello')) (b RemovedTile (Tile 'world')) + = /* empty */ +} + +gen_e__ { e.arg = e.arg } + +GST3 { + (e.Trash) (e.MarkedResult) + = () (); +} + +*$DRIVE Mapa1, Boom; + +Mapa1 { + (Num1 s.Trash1 t.Trash2) e.Trash0 = ; + RemovedTile1 e.Trash0 = RemovedTile ; + (Tile1 e.Trash1) e.Trash0 = (Tile e.Trash1) ; + + (Num2 s.Trash1 t.Trash2) e.Trash0 = ; + RemovedTile2 e.Trash0 = RemovedTile ; + (Tile2 e.Trash1) e.Trash0 = (Tile e.Trash1) ; + + (Num3 s.Trash1 t.Trash2) e.Trash0 = ; + RemovedTile3 e.Trash0 = RemovedTile ; + (Tile3 e.Trash1) e.Trash0 = (Tile e.Trash1) ; + + (Num4 s.Trash1 t.Trash2) e.Trash0 = ; + RemovedTile4 e.Trash0 = RemovedTile ; + (Tile4 e.Trash1) e.Trash0 = (Tile e.Trash1) ; + + (Num5 s.Trash1 t.Trash2) e.Trash0 = ; + RemovedTile5 e.Trash0 = RemovedTile ; + (Tile5 e.Trash1) e.Trash0 = (Tile e.Trash1) ; + + (Num6 s.Trash1 t.Trash2) e.Trash0 = ; + RemovedTile6 e.Trash0 = RemovedTile ; + (Tile6 e.Trash1) e.Trash0 = (Tile e.Trash1) ; + + Z e.X = Z ; + + /* empty */ = /* empty */; +} + +Boom { + A = a; B = b; C = c; D = d; E = e; F = f; G = g; H = h; +} diff --git a/autotests/opt-tree-markup6-inline.ref b/autotests/opt-tree-markup6-inline.ref index 184b8a9e..e52f36c7 100644 --- a/autotests/opt-tree-markup6-inline.ref +++ b/autotests/opt-tree-markup6-inline.ref @@ -5,7 +5,7 @@ $ENTRY Go { e.X = ; } -$INLINE Basic; +*$INLINE Basic; Basic { e.X = ; diff --git a/autotests/opt-tree-match1.ref b/autotests/opt-tree-match1.ref new file mode 100644 index 00000000..789dc4cb --- /dev/null +++ b/autotests/opt-tree-match1.ref @@ -0,0 +1,12 @@ +* TREE + +$ENTRY Go { + e.X + = { = e.X } + : { + X = False; + s._ = True; + } + : True + = /* empty */; +} diff --git a/autotests/opt-tree-match2.ref b/autotests/opt-tree-match2.ref new file mode 100644 index 00000000..bee2aea0 --- /dev/null +++ b/autotests/opt-tree-match2.ref @@ -0,0 +1,7 @@ +* TREE + +$ENTRY Go { + e.X = e.X () e.X : e._ = /* empty */; +} + +gen_e__ { e.X = e.X } diff --git a/autotests/opt-tree-match3.ref b/autotests/opt-tree-match3.ref new file mode 100644 index 00000000..df0024bf --- /dev/null +++ b/autotests/opt-tree-match3.ref @@ -0,0 +1,17 @@ +* TREE + +$ENTRY Go { + /* empty */ + = : e.A + = : e.B + = : e.C + + = ((x) e.A) (x) e.A (e.B) (x) e.A e.C + : { + (e.X) e.X (e.Y) t.Z e.T = (e.X) (e.Y) t.Z (e.T) + } + : ((x) 'aa') ('bb') (x) ('aacc') + = /* empty */; +} + +gen_e__ { e.arg = e.arg } diff --git a/autotests/opt-tree-no-drive.ref b/autotests/opt-tree-no-drive.ref new file mode 100644 index 00000000..4c8489c4 --- /dev/null +++ b/autotests/opt-tree-no-drive.ref @@ -0,0 +1,19 @@ +* TREE + +$ENTRY Go { + /* empty */ = /* empty */; + + X = ; +} + +*$NODRIVE Test, Double + +Test { + '*' e.Count (e.Acc) = )>; + + /* empty */ (e.Acc) = e.Acc; +} + +Double { + (e.Acc) = (e.Acc) (e.Acc) +} diff --git a/autotests/opt-tree-no-opt-misplaced.ref b/autotests/opt-tree-no-opt-misplaced.ref new file mode 100644 index 00000000..2b6a19f5 --- /dev/null +++ b/autotests/opt-tree-no-opt-misplaced.ref @@ -0,0 +1,15 @@ +* TREE + +$ENTRY Go { + /* empty */ = /* empty */; + + X = ; +} + +Test { + '*' e.Count (e.Acc) = ; + +*$NOOPT Test + + /* empty */ (e.Acc) = e.Acc; +} diff --git a/autotests/opt-tree-no-opt.ref b/autotests/opt-tree-no-opt.ref new file mode 100644 index 00000000..8ddcd463 --- /dev/null +++ b/autotests/opt-tree-no-opt.ref @@ -0,0 +1,15 @@ +* TREE + +$ENTRY Go { + /* empty */ = /* empty */; + + X = ; +} + +*$NOOPT Test + +Test { + '*' e.Count (e.Acc) = ; + + /* empty */ (e.Acc) = e.Acc; +} diff --git a/autotests/opt-tree-no-spec.ref b/autotests/opt-tree-no-spec.ref new file mode 100644 index 00000000..672f74ce --- /dev/null +++ b/autotests/opt-tree-no-spec.ref @@ -0,0 +1,16 @@ +* TREE + +$ENTRY Go { + /* empty */ = /* empty */; + + X = ; +} + +*$NODRIVE Test +*$NOSPEC Test + +Test { + '*' e.Count (e.Acc) = ; + + /* empty */ (e.Acc) = e.Acc; +} diff --git a/autotests/opt-tree-spec-intrinsic.ref b/autotests/opt-tree-spec-intrinsic.ref index 3ca9648a..3e1ff2a0 100644 --- a/autotests/opt-tree-spec-intrinsic.ref +++ b/autotests/opt-tree-spec-intrinsic.ref @@ -8,7 +8,7 @@ $ENTRY Go { = /* empty */; } -$SPEC EnumExprs s.NUM (e.PAT) (e.pat) (e.RES) (e.res); +*$SPEC EnumExprs; EnumExprs { s.Num diff --git a/autotests/opt-tree-spec1-merged.ref b/autotests/opt-tree-spec1-merged.ref index e94a0194..effdd51f 100644 --- a/autotests/opt-tree-spec1-merged.ref +++ b/autotests/opt-tree-spec1-merged.ref @@ -8,7 +8,7 @@ Go1 { = ; } -$SPEC Test1 [Go e.STAT] e.dyn; +*$SPEC Test1; Test1 { [Go e.Stat] e.Dyn = e.Stat e.Dyn; @@ -26,7 +26,7 @@ Test2 { = ; } -$SPEC S2 (e.S1) (e.d2) (e.S3) (e.d4) (e.S5) (e.d6); +*$SPEC S2; S2 { (e.a) (e.b) (e.c) (e.d) (e.f) (e.g) @@ -44,7 +44,7 @@ F3 { (e.X) (e.X1) = ; } -$SPEC S3 (e.S) e.d; +*$SPEC S3; S3 { (e.A) e.X (e.X0) = e.A e.X e.X0; @@ -57,7 +57,7 @@ Go4 { = /* пусто */; } -$SPEC Spec (e.STATIC) e.dynamic; +*$SPEC Spec; Spec { (e.X) e.y, 'abc' : e.X, 'def' : e.y = e.X e.y; @@ -72,7 +72,7 @@ Go5 { $SWAP DATA; -$SPEC SF e.dyn (e.STAT); +*$SPEC SF; SF { e.Dyn (e.Stat) = e.Stat e.Dyn e.Stat; @@ -84,7 +84,7 @@ Go6 { = ; } -$SPEC Eq6 t.X t.y; +*$SPEC Eq6; Eq6 { t.Eq t.Eq = True; @@ -94,7 +94,7 @@ Eq6 { F6 { = '*' } -$SPEC F7 t.STAT e.dyn; +*$SPEC F7; F7 { t.Stat e.Dyn = STAT t.Stat DYN e.Dyn } @@ -105,7 +105,7 @@ Go7 { } -$SPEC F8 t.dyn e.STAT; +*$SPEC F8; F8 { t.Dyn e.Stat = DYN t.Dyn STAT e.Stat } @@ -120,7 +120,7 @@ Go9 { e.X = ; } -$SPEC Eq9 t.STAT t.dyn; +*$SPEC Eq9; Eq9 { t.X t.X = True; @@ -135,6 +135,6 @@ Go10 { = /* пусто */ } -$SPEC S10 (e.S1) (e.S2); +*$SPEC S10; S10 { (e.X) (e.Y) = e.Y '+' e.X } diff --git a/autotests/opt-tree-spec10.ref b/autotests/opt-tree-spec10.ref index 74265b75..d3047752 100644 --- a/autotests/opt-tree-spec10.ref +++ b/autotests/opt-tree-spec10.ref @@ -8,7 +8,7 @@ F { t.X = } -$SPEC Eq e.arg; +*$SPEC Eq; Eq { t.Eq t.Eq = True; diff --git a/autotests/opt-tree-spec11.ref b/autotests/opt-tree-spec11.ref index 537d6e1f..d8bd3fed 100644 --- a/autotests/opt-tree-spec11.ref +++ b/autotests/opt-tree-spec11.ref @@ -8,7 +8,7 @@ F { e.X = } -$SPEC G e.arg; +*$SPEC G; G { (e.A '@' e.B) s.R (e.C '#' e.D) = (e.A) s.R (e.B) s.R (e.C) s.R (e.D); diff --git a/autotests/opt-tree-spec12.ref b/autotests/opt-tree-spec12.ref index 529ec13a..ac72072f 100644 --- a/autotests/opt-tree-spec12.ref +++ b/autotests/opt-tree-spec12.ref @@ -17,11 +17,13 @@ $ENTRY Go { = /* empty */; } +gen_e__ { e.arg = e.arg } + F { (e.1) (e.2) = ; } -$SPEC S e.arg; +*$SPEC S; S { e.A e.B e.A e.C 9 e.D diff --git a/autotests/opt-tree-spec13.ref b/autotests/opt-tree-spec13.ref index 3f9e1831..0dcc3dc8 100644 --- a/autotests/opt-tree-spec13.ref +++ b/autotests/opt-tree-spec13.ref @@ -8,7 +8,7 @@ F { (e.A) (e.B) = } -$SPEC S e.arg; +*$SPEC S; S { (e.Z) (e.1 A s.X e.2) (e.3 B s.X e.4) diff --git a/autotests/opt-tree-spec14.ref b/autotests/opt-tree-spec14.ref index 58b8b69b..80e93d05 100644 --- a/autotests/opt-tree-spec14.ref +++ b/autotests/opt-tree-spec14.ref @@ -11,7 +11,7 @@ F { (e.A) (e.B) (e.C) (e.D) = ; } -$SPEC S (e.S) e.d; +*$SPEC S; S { (e.A) 'B' e.A e.E, e.E : e.E = '1'; diff --git a/autotests/opt-tree-spec15.ref b/autotests/opt-tree-spec15.ref new file mode 100644 index 00000000..a83a28d3 --- /dev/null +++ b/autotests/opt-tree-spec15.ref @@ -0,0 +1,27 @@ +* TREE + +$ENTRY Go { + /* empty */ + = : (R5 (Config) 'srcname.ref') + = <> : s.Fn + = : (R5 (Config) 'srcname-decompiled.ref') + = : (FileRowCol (1 1) 'srcname-decompiled.ref') + = /* empty */; +} + +LoadAST { + t.Config R5 e.SrcName = (R5 t.Config e.SrcName); + + t.Config RSL e.SrcName + = e.SrcName : e.BaseName '.rsl' + = e.BaseName '-decompiled.ref' : e.DecompiledName + = (FileRowCol (1 1) e.DecompiledName) : t.ErrorPos + = { + /* empty */ + = : t.AST + = { + True = t.AST; + False = t.ErrorPos; + }; + } +} diff --git a/autotests/opt-tree-spec16-vars-in-closure.ref b/autotests/opt-tree-spec16-vars-in-closure.ref new file mode 100644 index 00000000..77cdcd6b --- /dev/null +++ b/autotests/opt-tree-spec16-vars-in-closure.ref @@ -0,0 +1,14 @@ +* TREE + +$ENTRY Go { + e.A + = { A B C = e.A } e.A 1> : s.F + = : /* empty */ + = /* empty */ +} + +S { + s.X s.Y e.Z = s.X +} + +gen_e__ { e.X = e.X } diff --git a/autotests/opt-tree-spec17.ref b/autotests/opt-tree-spec17.ref new file mode 100644 index 00000000..0160d348 --- /dev/null +++ b/autotests/opt-tree-spec17.ref @@ -0,0 +1,20 @@ +* TREE + +$ENTRY Go { + /* empty */ + = : e.B + = : e.D + = : e.0 + = : () ('ABB') ('Czzz') + = : ('BB') ('zzz') + = /* empty */ +} + +gen_e__ { e.arg = e.arg } + +*$SPEC S; + +S { + (e.Y e.Z) e.R e.R = (e.Y) (e.Z) (e.R); + (e.X) e.Y = (e.X) (e.Y); +} diff --git a/autotests/opt-tree-spec2.ref b/autotests/opt-tree-spec2.ref index 5e1e14f7..0e42ddc8 100644 --- a/autotests/opt-tree-spec2.ref +++ b/autotests/opt-tree-spec2.ref @@ -43,7 +43,7 @@ Symb { 1 = '1'; 2 = '2'; 3 = '3'; } -$SPEC Map s.FUNC e.items; +*$SPEC Map; Map { s.Fn t.Next e.Rest = ; diff --git a/autotests/opt-tree-spec3-in-condition.ref b/autotests/opt-tree-spec3-in-condition.ref index 7d28dd97..2173f09d 100644 --- a/autotests/opt-tree-spec3-in-condition.ref +++ b/autotests/opt-tree-spec3-in-condition.ref @@ -7,7 +7,7 @@ $ENTRY Go { = /* пусто */; } -$SPEC S s.A e.rest; +*$SPEC S; S { s.A s.X e.Rest = s.A ; diff --git a/autotests/opt-tree-spec4-x-vars.ref b/autotests/opt-tree-spec4-x-vars.ref index ef6706b8..fc042651 100644 --- a/autotests/opt-tree-spec4-x-vars.ref +++ b/autotests/opt-tree-spec4-x-vars.ref @@ -7,13 +7,13 @@ $ENTRY Go { = /* empty */; } -$SPEC F (e.LEFT) e.RIGHT; +*$SPEC F; F { (e.Left) e.Right = ; } -$SPEC G (e.LEFT) e.right; +*$SPEC G; G { (e.Left) '*' e.Right = ; diff --git a/autotests/opt-tree-spec5-call-vars.ref b/autotests/opt-tree-spec5-call-vars.ref index e7a3170a..81221f3c 100644 --- a/autotests/opt-tree-spec5-call-vars.ref +++ b/autotests/opt-tree-spec5-call-vars.ref @@ -7,7 +7,7 @@ $ENTRY Go { = /* empty */; } -$SPEC G (e.RES) e.str; +*$SPEC G; G { (e.Res) t.Term e.Tail = ) e.Tail>; diff --git a/autotests/opt-tree-spec6-closure-gen.ref b/autotests/opt-tree-spec6-closure-gen.ref index 57b83206..8a21b7a5 100644 --- a/autotests/opt-tree-spec6-closure-gen.ref +++ b/autotests/opt-tree-spec6-closure-gen.ref @@ -2,12 +2,14 @@ $ENTRY Go { e.X - = : s.Closure + = > : s.Closure = <<<>>> : e.X = /* empty */; } -$SPEC S s.CLOSURE e.items; +gen_e__ { e.arg = e.arg } + +*$SPEC S; S { s.Closure s._ e.Y = ; diff --git a/autotests/opt-tree-spec7.ref b/autotests/opt-tree-spec7.ref index a786632f..232187fd 100644 --- a/autotests/opt-tree-spec7.ref +++ b/autotests/opt-tree-spec7.ref @@ -4,7 +4,7 @@ $ENTRY Go { e.X = : False = /* empty */; } -$SPEC S s.X; +*$SPEC S; S { s.X, A : s.X = True; diff --git a/autotests/opt-tree-spec8.ref b/autotests/opt-tree-spec8.ref index b0c699a8..9a24b105 100644 --- a/autotests/opt-tree-spec8.ref +++ b/autotests/opt-tree-spec8.ref @@ -1,6 +1,6 @@ * TREE -$SPEC Rot e.dyn; +*$SPEC Rot; Rot { e.1 s.2 = s.2 e.1; diff --git a/autotests/opt-tree-spec9.ref b/autotests/opt-tree-spec9.ref index fc62bcb3..e6b23086 100644 --- a/autotests/opt-tree-spec9.ref +++ b/autotests/opt-tree-spec9.ref @@ -4,7 +4,7 @@ $ENTRY Go { e.X = ; } -$SPEC Eq e.arg; +*$SPEC Eq; Eq { t.X t.X = True t.X; diff --git a/autotests/varcopy-fail.ref b/autotests/opt-tree-varcopy-fail.ref similarity index 85% rename from autotests/varcopy-fail.ref rename to autotests/opt-tree-varcopy-fail.ref index c67c3d85..7f2561a7 100644 --- a/autotests/varcopy-fail.ref +++ b/autotests/opt-tree-varcopy-fail.ref @@ -26,8 +26,7 @@ MapAccum { t.Fn t.Acc e.Tail = ; } -$SPEC MapAccum t.FUNC t.accum e.items; -$INLINE MapAccum; +*$OPT MapAccum; DoMapAccum { t.Fn t.Acc (e.Scanned) t.Next e.Tail @@ -39,6 +38,4 @@ DoMapAccum { t.Fn t.Acc (e.Scanned) /* пусто */ = t.Acc e.Scanned; } -$SPEC DoMapAccum t.FUNC t.acc (e.scanned) e.items; - - +*$SPEC DoMapAccum; diff --git a/autotests/positive-random-test/@refal-5-lambda-diagnostics.ini b/autotests/positive-random-test/@refal-5-lambda-diagnostics.ini index 4dd0cdad..403ae40d 100644 --- a/autotests/positive-random-test/@refal-5-lambda-diagnostics.ini +++ b/autotests/positive-random-test/@refal-5-lambda-diagnostics.ini @@ -1,4 +1,5 @@ -memory-limit = 20000000 -step-limit = 1000000000 -idents-limit = 5000 +memory-limit = 5000000 +step-limit = 200000000 +idents-limit = 5000 enable-debugger = false +dump-file = __dump.txt diff --git a/autotests/positive-random-test/prelude-for-test.refi b/autotests/positive-random-test/prelude-for-test.refi index 6d6afd10..41320150 100644 --- a/autotests/positive-random-test/prelude-for-test.refi +++ b/autotests/positive-random-test/prelude-for-test.refi @@ -1,14 +1,4 @@ *$EXTENDED -Chr { = } -Ev-met { = } -Lenw { = } -Lower { = } -Mu { = } -Ord { = } -Print { = } -Prout { = } -Type { = } -Upper { = } - +$EXTERN Chr, Ev-met, Lenw, Lower, Mu, Ord, Print, Prout, Type, Upper; $INTRINSIC Chr, Lenw, Lower, Mu, Ord, Type, Upper; diff --git a/autotests/positive-random-test/run.bat b/autotests/positive-random-test/run.bat index f79c4bd4..bf86286e 100644 --- a/autotests/positive-random-test/run.bat +++ b/autotests/positive-random-test/run.bat @@ -7,6 +7,7 @@ goto :EOF :MAIN setlocal + if exist __dump.txt erase __dump.txt call :REGRESSION || exit /b 1 call :NEW_TESTS || exit /b 1 endlocal @@ -14,6 +15,7 @@ goto :EOF :REGRESSION setlocal + dir saved-test-*.ref for %%r in (saved-test-*.ref) do ( call :RUN_TEST "%%r" ^ && call :RUN_TEST "%%r" -Wall ^ @@ -63,6 +65,7 @@ setlocal set NOW=%NOW:/=-% ..\..\bin\nemytykh-random-program-generator.exe %LOOPS% _%NOW% echo gen (%NOW%) %TIME%>>time.txt + dir test-*.ref for %%r in (test-*.ref) do ( call :RUN_TEST "%%r" ^ && call :RUN_TEST "%%r" -Wall ^ @@ -114,10 +117,9 @@ setlocal 2>%FILE%.err%FLAGS% >%FILE%.out%FLAGS% if not exist %FILE%.rasl ( - echo FILE %FILE%.ref: - echo ============================================================ - type %FILE%.ref - echo ============================================================ + exit /b 1 + ) + if exist __dump.txt ( exit /b 1 ) erase %FILE%.rasl diff --git a/autotests/positive-random-test/run.sh b/autotests/positive-random-test/run.sh index d01c5f72..bbe596e6 100755 --- a/autotests/positive-random-test/run.sh +++ b/autotests/positive-random-test/run.sh @@ -9,11 +9,14 @@ if [[ -n "$1" ]]; then fi main() { + rm -f __dump.txt regression || return 1 new_tests || return 1 } regression() { + ls -l saved-test-*.ref + df -h . for r in saved-test-*.ref; do if run_test "$r" \ && run_test "$r" -Wall \ @@ -62,6 +65,9 @@ new_tests() { ../../bin/nemytykh-random-program-generator "$LOOPS" "_$NOW" echo "gen ($NOW) $(date)" >> time.txt + ls -l test-*.ref + df -h . + for r in test-*.ref; do if run_test "$r" \ && run_test "$r" -Wall \ @@ -113,11 +119,7 @@ run_test() { ../../bin/rlc-core --classic -C "$FILE" --prelude=prelude-for-test "$FLAGS" \ 2>"$FILE.err$FLAGS" >"$FILE.out$FLAGS" - if [[ ! -e "$FILE.rasl" ]]; then - echo FILE "$FILE.ref": - echo ============================================================ - cat "$FILE.ref" - echo ============================================================ + if [[ ! -e "$FILE.rasl" ]] || [[ -e __dump.txt ]]; then return 1 fi rm -f "$FILE.rasl" diff --git a/autotests/positive-random-test/saved-test-10_Mon-Aug-23-21-51-16-UTC-2021.ref b/autotests/positive-random-test/saved-test-10_Mon-Aug-23-21-51-16-UTC-2021.ref new file mode 100644 index 00000000..bf418145 --- /dev/null +++ b/autotests/positive-random-test/saved-test-10_Mon-Aug-23-21-51-16-UTC-2021.ref @@ -0,0 +1,334 @@ +$EXTERN ExtBBAB ; + + + +DDCAC { + e.4 'c' DBCD e.9 + ,1 e.4 2 CD ABBD ('d' > e.4 e.4 (4 D +D 'd' ) ) : + { + + ,: s.13 () ('c' 10 ) + ,: + { + s.3 + ,: ('b' ) + ,: + ,: 8 (e.8 ) + ,: s.10 = + ; + }; + e.7 t.12 'd' = + ; + e.7 t.12 t.4 ((AC DCBA (e.8 'd' AA 'cb' 2 ) 'a' ) (C 4 () ) ) 0 'd' e.2 B ACCA 'd' + + ,: CCA (e.10 8 e.1 e.2 'b' ) 'b' 2 (e.3 AADB 'aa' CCCB ) + ,: + = + ; + }; + e.4 e.6 (('b' () ) CAC t.7 ((CC ) 6 ) s.3 ) e.6 s.9 + , (('b' 7 3 ) AA ) () +ACD > > 10 'c' : + { + 10 t.2 + ,C s.3 : e.7 (5 ) + ,( (() 'd' () +) ) (e.7 () t.7 ) : e.8 e.10 + ,: DCA 'dd' + ,: e.12 'd' + = + () ; + 10 t.2 1 s.8 + ,A : = + 'd' ; + }; + e.4 e.6 (('b' () ) CAC t.7 ((CC ) 6 ) s.3 ) e.6 e.4 BBD (DACC 'b' ) t.2 CD = + 3 BDB () CBAC 10 'a' 5 t.2 10 ; +} + +$ENTRY CCD { + 6 e.3 1 8 'a' 9 'c' + ,('a' ) 3 e.3 D (2 1 'dc' ) 'c' e.3 : + + { + 'd' DCBC (DAAA ) (7 3 ) 'c' + ,: = + 'c' e.3 e.3 e.3 'd' ; + }; +} + +$ENTRY BCDC { + () s.11 10 ('c' ) 5 + ,s.11 A +ADD 2 ) > D CD > AB 'c' 0 : + { + 2 s.6 DBDC 8 6 5 AAA 6 s.13 + ,: CBAB + ,: D + ,DC : e.11 t.12 BADC + +,: = + 1 ; + }; + () s.11 (s.13 (BBD 2 ) 'd' ) e.11 2 e.4 (9 'b' ) + ,() : + { + e.13 () 7 7 'c' + ,'b' e.11 : 'd' BA 5 (e.6 D (1 ) ) + ,1 s.11 0 : + + { + 'c' B + ,: t.13 + ,7 'a' 5 : + ,() e.11 : + ,'d' +: e.13 s.9 DDC e.1 = + (9 ) ; + s.13 'd' B 1 2 B + ,: 9 + ,: 'd' + ,4 : AB BC + ,3 : +s.7 = + B ; + s.13 'd' B 1 e.4 e.12 8 (DD (3 'c' t.6 B ) 'd' s.7 ('d' 10 e.12 ) ) ((BDD 'a' +) ) 2 B + ,10 s.11 : = + ; + }; + 7 () 'c' + ,: (e.11 ) BA e.5 DDB BDD () + ,: 5 6 + ,AC : e.13 = + 'a' ; + }; + () s.11 (s.13 (BBD 2 ) 'd' ) ('a' 3 (e.2 CC s.3 ) ) 2 DDCD 6 e.11 e.7 = + CC 5 e.2 (A ) ; + () s.11 (s.13 (BBD 2 ) 'd' ) ('a' 3 (e.2 CC s.3 ) ) A s.8 B e.2 'b' e.2 (3 CAA s.8 BBDB 9 () +CAA ) 'b' 9 A t.2 (t.1 BAD ) s.11 = + ; + () s.11 (s.13 (BBD 2 ) 'd' ) ('a' 3 (e.2 CC s.3 ) ) A 'aa' B A t.2 (t.1 BAD ) +s.11 + ,DA 'a' s.11 s.11 : + { + 'c' 9 5 (6 'b' e.8 ) s.1 8 'c' + ,: + , : + ,: + + ,5 BDA 6 : 8 2 e.10 e.1 ('d' ) + ,: + { + 5 s.9 ('b' ((s.10 s.10 ) t.11 () ) ('b' ) ) s.4 + ,CB 2 t.2 : + = + s.1 ; + 5 s.9 ('b' ((s.10 s.10 ) t.11 () ) ('b' ) ) s.4 DDB e.8 e.6 DAB (e.12 ('b' +) 8 e.10 ) 10 + ,: DBB = + DBA BDCA ; + }; + 'c' (10 e.1 ) t.11 8 DC s.13 e.2 0 10 s.1 8 'c' = + e.2 ; + 'c' (10 e.1 ) t.11 8 t.2 () (e.12 ) ((9 ) (e.4 10 e.5 ) (e.7 (2 BB e.7 ) +'d' ) ) 'd' s.3 'cd' 4 10 s.1 8 'c' + ,BADA : 'b' e.11 'a' ACB + + ,10 s.11 : + ,: + ,('ad' ) : C (e.10 ) + ,: A 'd' +() () CD () 'c' + ,: + { + C 'a' e.9 () + , : = + s.3 ; + e.7 'ca' e.9 () + ,: ADDB + ,: + ,'c' CC : + ,: +(3 0 ) s.8 + ,: = + AC e.10 ; + e.7 BAA 4 10 ('a' 0 A ) (0 ) 'a' e.9 () + ,3 : 3 AAA + ,2 (9 ) e.2 ADA : + + , : = + 'd' 1 ; + }; + }; + () s.11 (s.13 (BBD 2 ) 'd' ) ('a' 3 (e.2 CC s.3 ) ) A 'aa' D 'b' e.12 (B 3 9 ) +DD (9 DB ) 0 (BA t.11 'd' ) A t.2 (t.1 BAD ) s.11 + ,10 DDAD DDBA (C ) ('b' ) t.2 ) 10 'd' 6 ('b' 3 5 C ) +'d' > > : + { + s.7 e.3 'bd' 0 + ,BAB : e.11 'b' CC + , : + ,: +e.7 e.2 e.6 3 AA + ,: A = + ; + s.7 DA () 'b' (8 6 ) BBB 0 + ,t.1 DCD > : AB 'a' (D ) e.5 = + ; + s.7 'd' C s.12 'c' 7 'b' (8 6 ) BBB 0 = + s.13 ; + }; +} + +DA { + (0 'a' ) 'a' + ,DB 2 (10 ) 'a' > : + { + s.7 0 + ,CDB 0 > : 'd' e.10 'aa' (DCA 'c' e.7 ) + + ,: 'a' + ,e.10 BABA : 2 2 + ,10 : 'a' CDA 7 = + e.10 ; + }; + (0 'a' ) BC DCBD 'a' (CDDD 7 e.10 s.2 1 ADDC CA ) D 'a' 3 (6 2 ) + ,'a' : + { + 3 e.10 BCBC 8 e.8 + ,: + ,9 'b' AA () (CABD ) s.2 : + + { + 0 'c' (e.4 2 'b' ) 'd' + ,1 8 : 0 BDA + ,: + ,(s.2 +) : CDC = + ; + }; + 8 t.9 e.12 5 'a' e.8 + ,t.9 : = + 10 'b' ; + }; + (0 'a' ) 'b' s.3 t.6 ('c' t.10 ) 4 e.13 (t.1 'a' D 'd' s.4 ) 7 + + ,C : + { + 'b' 2 CABB DB 2 9 + ,: + ,4 t.1 t.6 : + ,e.13 +: = + ('da' ) 5 > > > ; + 'b' 2 (ADBA ) t.6 A ('a' ) 3 D (t.5 CBDA AAD 1 ) + ,s.4 s.3 t.6 () : 'd' + + ,: + ,ADA 9 'c' : + , > : 10 = + ; + }; + (0 'a' ) 'b' s.3 t.6 ('c' t.10 ) 4 (BA ) (DA 'b' ) CDB 'dd' (t.1 'a' +D 'd' s.4 ) 7 + ,(t.1 () ) : + { + 'b' e.6 'c' 10 0 8 BDBC 3 + , 9 5 : + ,: 8 (BAA CDA ) + ,: +5 (e.3 5 'a' ) t.4 (DA DB 4 ) + ,: = + AAC > ; + }; + (0 'a' ) 'b' s.3 t.6 ('c' t.10 ) 4 (BA ) () 0 t.10 DC 1 ('db' 4 e.9 10 5 'd' +e.9 'c' ) (A ) e.6 () ('d' A ADBC D e.12 e.2 ('dc' ) BB ) 3 8 'ba' e.11 ('b' +0 BA 'b' e.12 'd' A e.8 DC e.13 ) 'dd' (t.1 'a' D 'd' s.4 ) 7 = + > e.11 (e.9 ) ; +} + +BCCDB { + BBC e.13 e.4 CDAA + , 6 A 5 (1 D ) 'b' : + { + e.9 5 () D BBB + ,: + ,'d' : + { + s.2 e.12 s.12 + ,: 9 'c' (e.7 ) BDC + , > : 2 = + s.12 ; + }; + 0 2 t.5 'd' 1 ('d' ADC ) e.5 'a' () D BBB + ,'a' +A > e.4 e.13 > : + ,: (e.4 e.3 BDCB ) 3 + , +5 8 t.5 > A (e.3 ) : + ,: DB DC 8 + ,: + { + t.10 t.10 + ,(5 e.3 'c' ) 'a' C e.4 : 'c' (DCB ) + ,: s.6 BDAB 4 = + ; + t.10 s.10 'a' ACB 5 t.10 + ,9 9 : (B ) = + ; + t.10 s.10 'a' CDBB t.9 ACB 5 t.10 + ,e.4 : + ,B : 8 + ,'a' : +e.3 + , AC t.9 : AB = + ; + }; + 0 2 t.5 6 (B e.7 ) 1 DDD 'a' () D BBB + ,: = + 1 8 1 ; + }; + 'd' s.2 'c' CDAA = + 'd' s.2 > 3 s.2 CAC 2 > 3 s.2 s.2 +'d' BA 'b' ) (s.2 'a' s.2 ) s.2 'b' 8 s.2 DCC C 5 > > ; + 2 D s.2 'c' CDAA + ,s.2 s.2 s.2 > : + { + 2 CB DC (7 ) 'c' = + ; + }; +} + +$ENTRY DADD { + 'c' s.5 e.5 t.12 3 + , : + { + (e.2 ((t.10 0 6 ) ) DB 4 t.5 ) e.2 6 (e.3 6 0 e.10 ) 'dc' s.4 e.8 (A 9 e.12 'd' +9 'b' ) 'a' + ,'c' : + ,9 'c' : (8 CD 2 'ab' ) ((B 2 ) +) ('c' e.1 e.7 DDBC 9 ) 'c' e.3 = + e.7 e.1 ( ('dcc' ) +) (t.5 'a' ) ; + (e.2 ((t.10 0 6 ) ) DB 4 t.5 ) e.2 6 C 7 'b' 4 (CBCD ) + ,: ('b' e.7 'c' +9 ) (1 3 'a' ) AA BCCD + ,: e.10 () + ,'c' e.2 0 e.5 : s.12 () +4 e.3 + ,: e.6 8 BAAD + ,: = + ; + }; + 'c' s.5 e.10 e.7 'd' 7 (s.1 s.6 DD ) = + ; + 'c' s.5 e.10 s.6 (e.2 e.9 ) (9 'cbc' ) 8 'd' 7 'b' (s.1 s.6 DD ) + = + DDCC 2 s.6 BCBA 2 ; +} diff --git a/autotests/positive-random-test/saved-test-10_Tue-Sep-21-22-36-44-UTC-2021.ref b/autotests/positive-random-test/saved-test-10_Tue-Sep-21-22-36-44-UTC-2021.ref new file mode 100644 index 00000000..201ce422 --- /dev/null +++ b/autotests/positive-random-test/saved-test-10_Tue-Sep-21-22-36-44-UTC-2021.ref @@ -0,0 +1,366 @@ +$EXTERN ExtBAD ; + + + +$ENTRY DDB { + DAC 'c' BB (e.9 (DDDD BBDB 'a' 2 e.7 (8 e.6 'b' ) () e.13 6 ) ) e.11 (e.5 ) +e.5 ACBA 'c' 1 'c' e.6 'b' 9 7 e.12 + ,: + { + 2 e.11 'cd' + ,'ba' e.11 : 7 () CCAC 'a' + ,1 : 'c' CDCD = + 0 ; + 'a' ADC 'b' = + AAA AB CCAC ; + 'a' + ,'c' ( BCC e.6 ) : 4 = + e.11 e.13 A ; + }; + DAC 'c' BB 8 BAAD e.10 s.7 BD e.12 + ,BDBA 'c' + (s.7 'a' ) 'a' > DD 'c' DDBB 'd' ( +AAB 'b' e.10 ) > : + { + + ,: DCD (1 'a' ) + ,: = + ; + }; + DAC 'c' BB 4 CCAC s.13 s.7 BD e.12 + ,e.12 s.13 (D (AC CADB 7 ) ( > 9 ) s.13 'a' +e.12 s.7 CB ) 1 (DB s.13 'a' 6 1 7 > ) 3 s.7 : + { + e.6 DD + ,: 7 + ,: 4 + ,: + ,D 2 : (4 2 5 CCD 'c' ) 9 + + ,: = + ; + }; + DAC 'c' BB () (CDD s.4 BC (() 'a' ADAA ) 'b' ) DB 6 'ab' e.3 s.4 'a' e.13 s.13 s.7 BD e.12 = + 7 ; + DAC 'c' BB () (CDD s.4 BC (() 'a' ADAA ) 'b' ) DB 6 'ab' (ACAB ) 4 2 s.13 s.7 BD e.12 + + ,s.4 'a' : + { + 'a' e.8 CAA 5 2 + ,(AAA ) : CBBC A e.1 BCCA s.5 + ,e.12 : = + 3 ; + 'a' () B s.9 6 (0 s.9 () ) ACDA 'd' CB 1 e.12 4 CC AC 7 1 5 2 + ,: + +,: C (CCDB e.6 DC ) e.1 (e.6 ) 'c' BD + ,: + ,1 : 'c' = + ('b' A ) 3 BBBC 10 ; + }; +} + +$ENTRY DAC { + e.9 () + ,CC : + { + ('d' C ) + ,'a' : + ,'d' : + , (e.9 0 e.9 ) + 6 : + ,3 5 B 'd' : + ,: = + ; + 0 'b' 9 ('d' C ) + ,BA : 3 9 CC 'c' D 'ab' + ,: 4 'b' + + ,(DAA () C e.9 ) 'c' : + ,: + { + 'b' (t.2 ) 'a' BDB 3 e.6 2 DB + ,t.2 : + ,e.9 e.9 : 'b' e.6 2 + + ,: e.13 CCC e.13 + ,: + ,: 3 = + D ; + 'b' (t.2 ) 'a' A e.2 (s.11 ) 4 2 DB BA A 'b' + ,: 8 = + s.11 ; + }; + BAD s.7 4 s.12 9 ('d' C ) + ,() 'd' : 'daa' (e.10 ('b' e.13 0 ) +BC ) + ,: D e.5 BAD 4 = + 'c' e.9 DA ; + }; + 'a' () = + 'c' ; + (s.8 t.11 DDD 1 ) 0 () = + ; + (s.8 t.11 DDD 1 ) e.12 7 'da' 8 'a' 0 () + ,t.11 : + { + 0 (e.4 'c' ) 8 0 9 s.7 BA 8 + ,: + , B C > +'c' : () DBCC = + 9 ; + 0 (4 ) CAA ('c' ) AAD 'b' 9 s.7 BA 8 + , : 0 + ,CB : e.4 2 e.7 (e.6 CDA t.3 ) + + ,: (CD 7 e.12 'd' e.5 (2 DDCC 'd' (8 4 B ) ) ((e.9 'cdc' e.13 ) +2 'c' 3 A ) ) ADDA ('d' ) e.4 'dd' = + t.11 t.11 1 ; + }; +} + +$ENTRY DCBDC { + DAA e.5 t.11 BA 1 'b' CD + , : + { + A + ,CAAB DB (CACB 'a' (() ) ) : + , : + ,B 7 e.5 (() +) : e.3 'b' + ,(BBDA 'bb' ) (BAD ) 'd' : (AAB ) + = + ; + }; + DAA e.5 t.11 BA e.1 'a' AD ABAD e.6 s.3 (AD ) s.12 DBAC = + 2 s.3 'c' ; + DAA e.5 t.11 BA e.1 'a' 9 1 s.3 (AD ) s.12 DBAC + ,( e.1 > ) (4 (6 8 e.1 'd' C 'ac' ) s.12 4 (BCDB e.5 e.5 AAAC A ) > e.1 ) 2 : + { + DADD e.6 e.10 + ,: + ,: + { + + ,: CDAC (e.1 'b' ) + ,: 'b' DB + ,: 'c' () + +,: e.5 'a' + ,: = + ; + }; + e.11 e.10 D CBA (s.11 s.10 ('c' s.10 CD ('d' ) ) 1 ) 'c' + ,: (e.11 ) +s.6 BC = + ; + }; + DAA e.5 t.11 BA e.1 'ab' 5 'b' 1 s.3 (AD ) s.12 DBAC + ,: + { + AA e.7 CA DC BD = + ; + AA s.2 BC DC BD + ,6 : ('d' e.2 4 e.13 ) + ,: e.7 + ,e.2 s.12 e.1 : + = + e.2 5 ; + }; + DAA e.5 t.11 BA e.1 'ab' 5 10 1 s.3 (AD ) s.12 DBAC + ,: + { + (D DBC ) AB s.1 ADA 'c' + ,'cd' : = + ; + }; +} + +$ENTRY CBCC { + 'c' 10 0 s.4 + ,'c' : + { + 2 e.11 + ,: + ,: + ,: ABA BBAD 'c' + ,'a' (3 'b' ) +: e.11 + ,C : + { + 8 (6 ) 0 ADD 'd' = + ; + 8 (6 ) 0 ADD 8 3 'ad' + ,: 'b' ((t.4 e.6 D 10 ) (2 ) ) e.9 e.2 2 + + ,10 1 e.6 7 : + ,DCA e.2 DDDB : + ,t.4 2 C : 'c' 10 () + ,: +3 = + ; + }; + 2 (s.2 'dc' ) B 'a' s.6 + ,5 : + { + DDAD 'b' 3 e.8 2 8 + ,(DDDC e.8 ) : + ,(BCC ) 'c' +e.8 : () + ,: CDA e.7 e.5 (e.4 (5 e.7 ) (e.8 D DA DDD ) e.5 ) = + 'd' 1 ; + DDAD 'b' 3 BB 'b' A e.8 2 8 + ,: 1 3 e.3 + ,: A + ,s.6 8 : 9 (BAAD 'c' +e.10 ) + ,: e.7 'c' + ,: = + 'ad' ; + DDAD 'b' 3 BB 'b' A e.8 2 8 + ,'a' : B + ,: e.10 9 + ,'ac' +: + ,8 : = + (1 ) > ; + }; + 2 (s.2 'dc' ) DBC 0 'da' e.6 10 t.12 s.6 + ,10 DA : + ,(C (9 BC ('d' 6 'd' ) 9 ) ) 0 CD s.6 'b' : + ,: + ,C 'db' 'a' > : + { + t.2 t.5 e.6 AD AC e.12 A CA (() 2 BDB () 0 ) 9 + ,(e.6 ) : + ,: + + ,: t.4 (s.7 (e.3 e.11 'd' ) ) + ,: = + ; + t.2 t.5 t.1 DBDC s.8 t.1 t.10 ACBC AACA A CA (() 2 BDB () 0 ) 9 + , : +s.12 + ,: = + ; + t.2 t.5 t.1 DBDC s.8 10 t.11 (0 8 ) t.3 'd' 1 t.1 t.10 ACBC AACA A CA (() 2 BDB () 0 ) +9 + ,: 0 DBCA 9 + ,: AA 'c' + ,'c' t.2 2 'b' : 5 8 0 = + ; + }; + }; + 'c' 0 (e.7 BA e.8 e.1 ) B D 'a' BDC () t.6 'd' s.4 + ,'b' 10 : + { + 4 'd' DA + ,'bd' : BCD = + A 'd' ; + 4 'c' 9 (10 ) 'd' AC = + 2 A ; + 4 'c' (4 4 'd' ) t.1 'd' e.10 (e.2 BDD ) (t.1 7 ) 9 (10 ) 'd' AC = + ; + }; + 'cd' ('d' CABA ADA 8 e.1 ) e.12 'b' DDAA 'c' s.4 + ,() 'd' ADBB : + + { + (B t.2 ) s.7 'a' + , 'c' > DDA : CBB 1 = + 'ac' ; + (B t.2 ) s.7 (s.10 e.5 ) 10 t.4 'a' e.6 6 'bcba' + ,'b' 10 s.4 : +ACAB = + ; + (B t.2 ) s.7 (s.10 e.5 ) 10 t.4 'cba' + ,e.12 s.4 : + ,'c' +: + ,'b' 0 : e.13 7 'c' DCA CABB + ,: = + 7 s.7 > DA ; + }; + 'c' ('b' ) ('c' ) t.3 0 2 s.8 s.4 + ,8 'bad' 10 3 : + { + DAB 7 e.3 + ,: t.2 BDDB = + 'd' 4 s.4 'a' ; + }; + 'c' ('b' ) ('c' ) t.3 AAAB 'c' ABB B DABD 'cb' 0 2 s.8 s.4 + ,: + { + D t.1 'b' 6 'b' + ,'a' s.4 'c' : 7 0 + ,: AD 'a' DAC + + , > : 'a' + ,(ABAC 'd' () ) : (BAD e.8 ) 'd' + + ,10 5 : = + ; + 8 'b' + ,'cc' : () + ,: C ABD e.12 + ,7 : e.4 8 'cc' +0 e.4 5 + ,0 : DCC 3 0 + ,'d' : s.8 DDCD = + ; + }; +} + +AAA { + 'c' 2 = + ; + CAC 9 'd' e.5 10 'c' + ,: + { + 'b' 8 8 + ,BCCA 3 ( ) ABC DDBD 'b' : 4 'd' ACA + + ,: = + 'b' BDAB ; + 'b' s.9 'c' DDCD t.8 + ,: CCCD 'da' e.10 'a' + ,BB DCDC : DA e.7 = + ; + }; + t.10 (e.11 ) DC 'c' = + t.10 5 C 'aa' ; +} + +CC { + s.13 6 e.2 + , 'b' +8 'bc' : + { + 'a' 0 'b' s.12 9 (AACC ) C = + s.12 ; + }; + s.13 e.1 e.11 DCD = + 5 C ; + s.13 e.1 10 B () e.3 s.2 t.13 = + ; + s.13 e.1 10 B () 7 'd' () 'd' e.13 e.12 5 t.2 t.13 + ,DDB 'd' +BA : + { + + ,: 'd' CB e.2 + ,e.1 'd' : + ,: 'a' + ,: AB 4 (C e.3 e.10 ) +e.13 e.6 + , > B > (DD 4 ) BDD : DCBB 7 BA = + t.2 ; + }; + s.13 e.1 10 B () 7 'd' () 'd' 6 CAD e.6 AA e.13 e.12 5 t.2 t.13 = + 4 ; +} diff --git a/autotests/positive-random-test/saved-test-77_14.08.2021_20-00-01,67-big.ref b/autotests/positive-random-test/saved-test-77_14.08.2021_20-00-01,67-big.ref new file mode 100644 index 00000000..d986b3e9 --- /dev/null +++ b/autotests/positive-random-test/saved-test-77_14.08.2021_20-00-01,67-big.ref @@ -0,0 +1,408 @@ +* Этот тест требует более 100 000 000 шагов в режиме -OADS, ради него +* лимит был повышен до 200 000 000 шагов. Если при оптимизации компилятора +* этот тест сможет проходить менее чем за 100 000 000 шагов, лимиты нужно +* будет поправить. + +$EXTERN ExtD ; + + + +$ENTRY C { + CB t.10 BB () s.13 = + s.13 (t.10 s.13 s.13 'b' A 6 ACD ABDA ) C s.13 9 DCA ; + CB C 'a' (D e.2 2 4 ) 'a' AD 6 'b' t.10 BB () s.13 + ,10 (9 0 'a' 1 5 A 'a' > 'd' ) : + { + C e.13 BCC () 'c' 9 + ,: + ,'d' : ((e.10 'b' AC s.11 ('c' +) 6 ) D 'd' 5 BDC e.2 ) ('a' (BC 9 A CDC CA ) 10 ABA t.3 'a' ) ('da' ) 'a' + + ,t.10 e.10 : + ,CBA : e.3 'b' + , (6 'cc' +AACC ) > 'c' (() ) : + { + C 10 6 DA = + ; + 10 6 DA + ,: CBBC + ,: + ,: + ,: C B e.3 + ,: () +9 (e.2 ) 1 = + ; + 'd' 3 10 6 DA + ,: CDD e.3 + ,: + ,: 0 e.5 + ,: + + ,: = + ; + }; + C CDC 'a' 9 'c' 9 + ,e.2 : + ,'d' : = + 'd' ; + }; + CB C 'a' () CC 3 () () 1 'b' t.10 BB () s.13 + ,(CAA ( 9 s.13 10 t.10 7 'a' > ) ABB D ) 7 'c' s.13 () > ) : + { + t.6 CC s.12 A t.3 + ,: CBA + ,: + ,: + ,: BCD + ,: +1 + ,: + { + 'b' s.13 + ,: = + ; + }; + }; + CB C 'a' () CC 3 () 1 'b' t.10 BB () s.13 + ,: + { + 'b' e.9 (2 'a' BDBA e.5 'd' ) e.5 'ac' (CCDA ) + ,'c' : BDB C + + , e.5 ('d' 5 ) BA : + ,: 'a' 5 BC = + ; + (BAA ) 8 1 () CBC 'a' 4 5 + ,s.13 4 'a' : + ,3 t.10 4 CCCC s.13 : +8 () 2 + ,'d' 4 : + ,: 'a' 8 'cdc' 10 = + ; + }; + CB C 'a' () CC 3 () s.6 C CC s.1 'dd' s.8 s.1 BB 'a' 8 1 'b' t.10 BB () s.13 + + ,s.6 : + { + s.11 A 1 1 10 t.6 t.8 'a' + ,: CBC e.5 + ,0 : + + ,s.11 t.8 ( ) (() s.1 ) : + { + CD e.11 + ,s.6 (10 ) : 10 6 'd' + , : + ,: DCDA e.11 5 = + ; + CD 'a' e.11 = + ; + CD 'c' s.5 'a' e.11 + ,1 10 : C 'c' e.3 + ,: (D ABCA ) + ,5 : + + ,'a' 1 : + ,: = + 10 ; + }; + s.11 DCB 3 7 ACBC e.10 s.13 'd' 10 t.6 t.8 'a' + ,: 8 BC 'd' + ,BB t.6 'a' +: + ,: + ,: ('acd' ((DBBC 'dc' ) e.1 'a' ) 7 DDD ) = + ; + s.11 DCB CCDA 10 'a' CDCC 10 DDDB ((B ) 'ab' ) 3 'd' t.5 'b' e.10 s.13 'd' 10 t.6 t.8 'a' + + ,9 'a' : + ,: e.11 'a' e.8 8 (e.1 1 'c' e.8 10 () 4 ) () +e.4 + ,4 : + { + 2 'c' + ,: + ,: e.13 'a' + ,CDCC : + ,CBC : e.9 'a' +e.3 = + t.6 C t.10 ; + }; + }; + CB C 'a' () CC 3 () s.6 C CC e.6 e.4 AC DCD e.13 4 8 9 ('b' s.2 ) 4 'c' 1 'b' +t.10 BB () s.13 = + BB 7 ; +} + +B { + s.11 5 'c' + , s.11 0 : + { + 2 () t.2 = + ; + }; + s.11 5 'ca' BCB DBCB e.8 'd' (B DDCC D 'cc' e.5 e.7 BD ) 0 t.8 () = + 'add' e.7 CAA 'a' ((() D 'c' ACA 6 > 2 ) 'bd' e.5 BBBB 'c' +('c' e.7 t.8 ) ) (t.8 3 3 s.11 ) ; + s.11 5 'c' s.5 BAA 8 e.7 t.8 () + , e.7 ( 'd' () BCC 'a' (t.8 ) ) 10 'a' ( ) 5 : + { + () DCD + ,1 B : BA e.8 + , : + ,: e.7 () + + ,'d' : 2 = + ; + }; +} + +A { + 'abdb' t.6 6 + ,'b' () t.6 ((2 ACA A ) ('a' BCDB t.6 C ) ('cb' +7 9 t.6 'cd' 10 t.6 t.6 ('b' t.6 t.6 10 ) ) 'd' BC ) : + { + (C ) () e.1 t.2 'd' ADBB (9 (s.9 2 ) ) + ,: t.4 + ,: e.11 'b' +e.5 e.9 2 6 'd' + ,: + ,: + ,: (DA e.3 ) (e.9 ) e.11 s.12 e.2 CCD = + ; + }; + CACC 'd' (BAAC e.3 ) e.8 'b' BABD CAAC e.10 = + e.8 ; + 'a' + ,10 ('ad' BDA ) 4 2 : + { + e.13 2 B = + ( ) 0 'c' > ; + 0 'd' BDAD = + ; + }; +} + +D { + 'a' (AACC 3 ) 'b' 5 e.1 'd' 5 = + e.1 ; + 10 t.11 10 D 'c' t.1 'd' 5 + ,'c' t.1 5 9 t.1 t.11 +BCC : + { + 'b' BC () e.12 ('aa' e.1 CB 'dc' BBBB ) 6 = + > ( 'a' e.12 t.11 > t.1 > 7 e.12 ) ; + 'b' 9 t.4 'ddd' B e.12 3 (e.11 'a' BD ) 8 C 3 6 = + ; + 'b' 9 t.4 s.5 'a' 8 C 3 6 + , 3 : + { + 'c' (2 DBBB e.2 (e.3 'b' ) t.9 ) 'ca' + ,t.9 : 10 + ,: + + ,: e.11 e.5 'd' 6 + ,: + ,: = + ; + 'c' (2 DBBB e.2 (e.3 'b' ) t.9 ) DD 'a' + ,: + ,'d' : ACB + ,DAA AAC 8 : + , : 'd' 7 BA = + ; + }; + }; + 10 CDA 'b' t.5 'a' BD e.10 5 t.11 10 D 'c' t.1 'd' 5 = + ; +} + +BBBDB { + () e.12 (1 ) 4 = + ; + 'b' (1 ) 4 + ,: + { + s.5 e.13 t.3 4 5 + ,C e.13 s.5 : + ,: 'b' (e.13 ) e.7 9 + + ,: + { + A 6 s.2 + ,C e.7 : e.2 e.8 5 + ,() : ('b' ) = + ; + A 6 s.2 'd' 5 = + 0 ; + }; + s.5 e.13 e.9 e.9 ADD + ,e.13 : e.2 'a' + ,: BCA 'a' e.11 e.6 = + ; + s.5 e.13 0 'a' e.9 'bc' ADBC t.11 CDC + ,: + ,7 : + + ,e.9 s.5 : 9 t.10 + , 6 CD B : 'd' + ,: DADA e.11 e.11 = + ; + }; + BA 'c' 4 'b' (1 ) 4 = + 8 ; + BA 'd' e.6 6 'b' (1 ) 4 + ,: + { + 4 + ,e.6 2 3 1 5 : BD ('d' 8 e.4 e.3 e.7 ) 6 0 + ,((e.6 +) ) (e.7 7 4 ) 0 : t.13 + ,'dacd' 4 : e.13 + ,: s.6 1 = + e.6 10 6 e.3 9 ) A > ; + (AAB BABB ) 4 + ,: e.1 'ad' + ,(DD ) ('dc' (0 4 ) ) 'a' : 'b' +C e.12 + ,: 'b' e.9 + ,e.9 ('d' ) : 'bc' = + BD ; + }; + BA ('b' ) t.4 'bb' 6 'b' (1 ) 4 + ,: + { + s.8 ('bc' AA ) 10 'b' 3 = + 3 ; + s.8 2 t.8 'a' 3 3 + ,BCBB : + ,: + ,t.8 > : + ,: + ,: = + ; + s.8 2 t.8 'a' ('a' CDD ) 5 s.13 3 = + t.8 ; + }; + BA ('b' ) t.4 'b' CBB DA t.13 'a' 6 'b' (1 ) 4 = + 2 'c' CDC ; +} + +DDAA { + CAD e.10 t.12 = + ; + e.3 t.11 t.12 = + 6 ((5 t.12 'a' 'c' + > AAB t.12 > ) ) ; + s.5 (CB ) 'ccabb' (s.9 'c' 0 CBCB e.5 'c' ('a' DDBD DA 'c' 9 e.10 BAA e.13 ) +'d' (A BDAA CBBB e.3 'd' ) 'a' 10 ) BD e.4 7 2 3 e.4 t.11 t.12 = + 'd' (BCB e.10 'b' A t.12 e.5 t.11 B 5 'c' ) ; + s.5 (CB ) A t.10 ((e.8 (7 8 e.8 C ) BCC (D 'c' 8 10 ) BBAA e.2 DCB 'a' BBDA 8 e.2 'a' +) DAB CDDB 0 'b' ('b' e.6 'b' (e.8 t.7 C ) 2 () ) 6 (0 ('a' e.4 B e.10 e.6 CABA 1 e.9 e.10 ) +1 ) ) 8 DAC e.1 4 e.9 'a' BACC CDA e.2 t.1 9 2 t.11 t.12 + ,CB : + { + e.9 ('c' ) CCC 'a' e.2 'd' t.10 + ,: + ,e.10 (5 'd' 10 e.8 ) +: + ,e.6 (() DB ) e.10 : 'c' 10 + ,3 'a' 1 e.6 : 3 = + ; + e.9 'd' 10 10 + ,CB t.1 'b' e.9 () : 'b' ((e.8 ('a' ) ) ) 0 + + ,BCAC 'ac' ACCC : 1 = + 'a' > ; + e.9 e.5 (CABC ) () 10 10 + , : e.2 e.2 DD CABA 9 e.11 + ,('c' + ) : 'c' (BBBB e.3 'd' DAA ('c' (s.8 'b' CBB 'c' ) (5 A 2 e.10 e.7 ) +) ) e.3 + , C : + ,D e.8 e.11 : () 'b' + + ,: = + (7 ADC t.10 (e.4 ) ) 1 8 e.10 ; + }; +} + +AD { + + , CC (6 'b' ABCC ) 'd' () 'a' AADB > : + + { + A D DAD C = + 2 ; + }; + 'b' AC BB 'd' s.3 + ,: + { + B e.6 () e.1 e.12 0 = + ; + B ('da' ) t.5 BDB e.13 e.5 s.4 'd' (e.12 2 'cc' e.9 s.2 (s.2 C 7 (e.10 e.3 2 BBAD 3 'a' +) (8 BBA 0 AD e.12 ) ('d' ) 0 ) ) BDAA (BA ) 'c' 6 BCDC e.1 e.12 0 + ,(CAA 'ca' +e.9 e.10 ) 'd' 8 DACD AD : + ,: t.3 + ,'b' ('a' ) : (6 A ) +(CCC DA ) + ,: e.7 ('d' 2 ) = + ; + }; + 'b' BBA t.11 t.9 s.13 (5 1 ACD ('d' ((DDA 'd' ) DBC CAD 'd' ) 'd' s.13 ((CBAA D ) +(BAD 'b' t.3 7 e.7 ) 0 ) ) (0 (9 t.3 'c' ) 4 ) ) t.2 AC BB 'd' s.3 + + ,( > BDC () (( 'b' (A 9 6 3 BCA ) (AC s.3 4 'b' ) ADD ) ) ) : + { + BBAC 6 (('a' 9 ) ) B + ,: + ,: AD + ,: + ,: + +,: = + ; + BBAC 6 t.3 3 + ,: 9 4 e.2 10 'd' + ,: e.4 4 B A 8 + ,: (6 DA 10 () +t.2 4 ) 'c' 7 (e.6 (e.3 ) e.9 e.3 e.13 ) C (((BABD ) e.10 e.7 (CB 5 e.4 'a' +) ) AC AC A 'b' (s.11 1 ) ) 0 = + ; + BBAC 6 t.3 'b' 5 s.6 'c' 3 + ,: 'cb' 5 8 ('db' (BA ) 6 ) = + ; + }; + 'b' BBA t.11 t.9 9 CA 'c' s.13 (5 1 ACD ('d' ((DDA 'd' ) DBC CAD 'd' ) 'd' s.13 ((CBAA D ) +(BAD 'b' t.3 7 e.7 ) 0 ) ) (0 (9 t.3 'c' ) 4 ) ) t.2 AC BB 'd' s.3 + + , s.3 > 10 : + { + t.10 DCD e.5 0 'a' DBA B + ,: 'a' CAB (e.12 ) CD = + 7 ; + t.10 s.5 6 'd' 1 'bc' e.13 B + ,ADD 6 : + ,'b' CAD : + ,: +e.5 = + ; + t.10 s.5 'c' CBCB 6 s.4 'd' BBB B + ,t.9 e.7 : 'd' AABD 'bca' + ,: +2 e.4 + ,DA (() 10 ) 6 4 t.10 > > : BCC D e.9 = + t.2 ; + }; +} diff --git a/autotests/pseudocomments-error-misplaced.BAD-SYNTAX.ref b/autotests/pseudocomments-error-misplaced.BAD-SYNTAX.ref deleted file mode 100644 index f3cc880f..00000000 --- a/autotests/pseudocomments-error-misplaced.BAD-SYNTAX.ref +++ /dev/null @@ -1,12 +0,0 @@ -*$EXTENDED; - -Func { - s.Stat (s.Dyn) = s.Stat s.Dyn; -*$SPEC Func s.STAT (s.dyn); -} - -$ENTRY Go { - /* empty */ - = : 'ab' - = /* empty */ -} diff --git a/autotests/pseudocomments-ok-multiline.ref b/autotests/pseudocomments-ok-multiline.ref index d4632b76..b9d4bca3 100644 --- a/autotests/pseudocomments-ok-multiline.ref +++ b/autotests/pseudocomments-ok-multiline.ref @@ -1,3 +1,5 @@ +* NO-WARNINGS + *$EXTENDED; *$DRIVE Foo, diff --git a/autotests/pseudocomments-ok.ref b/autotests/pseudocomments-ok.ref index 0511c2c5..b63cbcae 100644 --- a/autotests/pseudocomments-ok.ref +++ b/autotests/pseudocomments-ok.ref @@ -1,6 +1,8 @@ +* NO-WARNINGS + *$EXTENDED; -*$SPEC Func s.STAT (s.dyn); +*$SPEC Func;,;,; Func { s.Stat (s.Dyn) = s.Stat s.Dyn; diff --git a/autotests/pseudocomments-warnings-classic.WARNING.ref b/autotests/pseudocomments-warning-classic.WARNING.ref similarity index 88% rename from autotests/pseudocomments-warnings-classic.WARNING.ref rename to autotests/pseudocomments-warning-classic.WARNING.ref index a87d9301..ef00f607 100644 --- a/autotests/pseudocomments-warnings-classic.WARNING.ref +++ b/autotests/pseudocomments-warning-classic.WARNING.ref @@ -1,4 +1,4 @@ -* WARNING ignored-pseudocomments +* WARNING pseudocomment *$CLASSIC; diff --git a/autotests/pseudocomments-warning-conflict.WARNING.ref b/autotests/pseudocomments-warning-conflict.WARNING.ref new file mode 100644 index 00000000..0e11891f --- /dev/null +++ b/autotests/pseudocomments-warning-conflict.WARNING.ref @@ -0,0 +1,6 @@ +* WARNING pseudocomment + +*$SPEC S; +*$NOSPEC S; + +$ENTRY S { = } diff --git a/autotests/pseudocomments-warning-dangling.WARNING.ref b/autotests/pseudocomments-warning-dangling.WARNING.ref new file mode 100644 index 00000000..c8085611 --- /dev/null +++ b/autotests/pseudocomments-warning-dangling.WARNING.ref @@ -0,0 +1,5 @@ +* WARNING pseudocomment + +*$OPT Undefined; + +$ENTRY Go { = } diff --git a/autotests/pseudocomments-warning-empty.WARNING.ref b/autotests/pseudocomments-warning-empty.WARNING.ref new file mode 100644 index 00000000..a539a6b9 --- /dev/null +++ b/autotests/pseudocomments-warning-empty.WARNING.ref @@ -0,0 +1,7 @@ +* WARNING pseudocomment + +*$OPT + +$ENTRY Test { + /* empty */ = /* empty */ +} diff --git a/autotests/pseudocomments-warning-gen_e-drive.WARNING.ref b/autotests/pseudocomments-warning-gen_e-drive.WARNING.ref new file mode 100644 index 00000000..dbe94e0a --- /dev/null +++ b/autotests/pseudocomments-warning-gen_e-drive.WARNING.ref @@ -0,0 +1,7 @@ +* WARNING pseudocomment + +$ENTRY Go { = } + +*$DRIVE gen_e__ + +gen_e__ { e.arg = e.arg } diff --git a/autotests/pseudocomments-warning-extended.WARNING.ref b/autotests/pseudocomments-warning-lexer1.WARNING.ref similarity index 50% rename from autotests/pseudocomments-warning-extended.WARNING.ref rename to autotests/pseudocomments-warning-lexer1.WARNING.ref index b5bcdd0a..88845330 100644 --- a/autotests/pseudocomments-warning-extended.WARNING.ref +++ b/autotests/pseudocomments-warning-lexer1.WARNING.ref @@ -1,8 +1,8 @@ -* WARNING nul-in-compound +* WARNING pseudocomment *$EXTENDED; -*$SPEC Func s.STAT "ABC\x00DEF" s.dyn; +*$SPEC Func "unclosed quote; $ENTRY Func { s.Stat ABC s.Dyn = s.Stat s.Dyn; diff --git a/autotests/pseudocomments-error-lexer.BAD-SYNTAX.ref b/autotests/pseudocomments-warning-lexer2.WARNING.ref similarity index 56% rename from autotests/pseudocomments-error-lexer.BAD-SYNTAX.ref rename to autotests/pseudocomments-warning-lexer2.WARNING.ref index 765a8e8b..52d84d4c 100644 --- a/autotests/pseudocomments-error-lexer.BAD-SYNTAX.ref +++ b/autotests/pseudocomments-warning-lexer2.WARNING.ref @@ -1,6 +1,8 @@ +* WARNING pseudocomment + *$EXTENDED; -*$SPEC Func s.STAT 'unclosed quote; +*$SPEC Func "ABC\x00DEF"; $ENTRY Func { s.Stat ABC s.Dyn = s.Stat s.Dyn; diff --git a/autotests/pseudocomments-error-multiunit.BAD-SYNTAX.ref b/autotests/pseudocomments-warning-multiunit.WARNING.ref similarity index 75% rename from autotests/pseudocomments-error-multiunit.BAD-SYNTAX.ref rename to autotests/pseudocomments-warning-multiunit.WARNING.ref index ea01d08e..26c7f5d1 100644 --- a/autotests/pseudocomments-error-multiunit.BAD-SYNTAX.ref +++ b/autotests/pseudocomments-warning-multiunit.WARNING.ref @@ -1,3 +1,5 @@ +* WARNING pseudocomment + *$EXTENDED; *$DRIVE D; $INLINE F; diff --git a/autotests/pseudocomments-warning-native-drive.WARNING.ref b/autotests/pseudocomments-warning-native-drive.WARNING.ref new file mode 100644 index 00000000..7df47504 --- /dev/null +++ b/autotests/pseudocomments-warning-native-drive.WARNING.ref @@ -0,0 +1,12 @@ +* WARNING pseudocomment + +*$DRIVE D; + +$ENTRY Go { = } + +D { +%% + refalrts::splice_to_freelist(vm, arg_begin, arg_end); + return refalrts::cSuccess; +%% +} diff --git a/autotests/pseudocomments-warning-native-opt.WARNING.ref b/autotests/pseudocomments-warning-native-opt.WARNING.ref new file mode 100644 index 00000000..e3deead6 --- /dev/null +++ b/autotests/pseudocomments-warning-native-opt.WARNING.ref @@ -0,0 +1,12 @@ +* WARNING pseudocomment + +*$OPT S; + +$ENTRY Go { = } + +S { +%% + refalrts::splice_to_freelist(vm, arg_begin, arg_end); + return refalrts::cSuccess; +%% +} diff --git a/autotests/pseudocomments-warning-native-spec.WARNING.ref b/autotests/pseudocomments-warning-native-spec.WARNING.ref new file mode 100644 index 00000000..ad714451 --- /dev/null +++ b/autotests/pseudocomments-warning-native-spec.WARNING.ref @@ -0,0 +1,12 @@ +* WARNING pseudocomment + +*$SPEC S; + +$ENTRY Go { = } + +S { +%% + refalrts::splice_to_freelist(vm, arg_begin, arg_end); + return refalrts::cSuccess; +%% +} diff --git a/autotests/pseudocomments-error-syntax.BAD-SYNTAX.ref b/autotests/pseudocomments-warning-syntax.WARNING.ref similarity index 78% rename from autotests/pseudocomments-error-syntax.BAD-SYNTAX.ref rename to autotests/pseudocomments-warning-syntax.WARNING.ref index 2fb61167..482e3798 100644 --- a/autotests/pseudocomments-error-syntax.BAD-SYNTAX.ref +++ b/autotests/pseudocomments-warning-syntax.WARNING.ref @@ -1,3 +1,5 @@ +* WARNING pseudocomment + *$EXTENDED; *$SPEC Func s.STAT (s.dyn; diff --git a/autotests/pseudocomments-error-semantics.BAD-SYNTAX.ref b/autotests/pseudocomments-warning-unexpected-format.WARNING.ref similarity index 78% rename from autotests/pseudocomments-error-semantics.BAD-SYNTAX.ref rename to autotests/pseudocomments-warning-unexpected-format.WARNING.ref index 34184a5e..995e384e 100644 --- a/autotests/pseudocomments-error-semantics.BAD-SYNTAX.ref +++ b/autotests/pseudocomments-warning-unexpected-format.WARNING.ref @@ -1,3 +1,5 @@ +* WARNING pseudocomment + *$EXTENDED; *$SPEC Func (s.STAT) s.dyn; diff --git a/autotests/refal5-pseudocomment-ident.ref b/autotests/refal5-pseudocomment-ident.ref new file mode 100644 index 00000000..8a2481cc --- /dev/null +++ b/autotests/refal5-pseudocomment-ident.ref @@ -0,0 +1,15 @@ +*$IDENT _-x; + +$ENTRY Go { +%% + (void) arg_begin; + (void) arg_end; + + refalrts::RefalIdentifier mingled = refalrts::ident_implode(vm, "_-x"); + if (mingled != identifiers[ident_u_m_x]) { + return refalrts::cRecognitionImpossible; + } + + return refalrts::cSuccess; +%% +} diff --git a/autotests/repeated.WARNING.ref b/autotests/repeated.WARNING.ref index 2a7ee50b..6413d034 100644 --- a/autotests/repeated.WARNING.ref +++ b/autotests/repeated.WARNING.ref @@ -35,4 +35,4 @@ TestLastSentence { SomeProcessing { e.Any = e.Any -} \ No newline at end of file +} diff --git a/autotests/rlc-core.exe@refal-5-lambda-diagnostics.ini b/autotests/rlc-core.exe@refal-5-lambda-diagnostics.ini new file mode 100644 index 00000000..d9cad389 --- /dev/null +++ b/autotests/rlc-core.exe@refal-5-lambda-diagnostics.ini @@ -0,0 +1 @@ +dump-file = __dump_rlc-core.txt diff --git a/autotests/rlc-core@refal-5-lambda-diagnostics.ini b/autotests/rlc-core@refal-5-lambda-diagnostics.ini new file mode 100644 index 00000000..d9cad389 --- /dev/null +++ b/autotests/rlc-core@refal-5-lambda-diagnostics.ini @@ -0,0 +1 @@ +dump-file = __dump_rlc-core.txt diff --git a/autotests/run.bat b/autotests/run.bat index a545aa3c..3736ae25 100644 --- a/autotests/run.bat +++ b/autotests/run.bat @@ -26,7 +26,7 @@ goto :EOF ..\bin\rlc-core -o _test_prefix.exe-prefix ^ %COMMON_SRFLAGS% %SRFLAGS_NAT% 2>__error.txt if not exist _test_prefix.exe-prefix ( - echo CAN'T CREATE COMMON PREFIX, SEE __error.txt + echo CAN'T CREATE COMMON PREFIX, SEE __error.txt or __dump_rlc-core.txt exit /b 1 ) erase __error.txt @@ -226,8 +226,10 @@ setlocal ..\bin\rlc-core --no-sources -o _int_test.exe ^ %COMMON_SRFLAGS% %SRFLAGS_PREF% ^ --reference=%REFERENCE% >__out.txt 2> __error.txt + set MSG=COMPILER FAILS ON CREATING _int_test.exe + set MSG=%MSG%, SEE __error.txt or __dump_rlc-core.txt if errorlevel 100 ( - echo COMPILER FAILS ON CREATING _int_test.exe, SEE __error.txt + echo %MSG% exit /b 1 ) if not exist _int_test.exe ( @@ -257,10 +259,11 @@ setlocal if not exist "%SATELITE%" set SATELITE= + if exist __dump_rlc-core.txt erase __dump_rlc-core.txt ..\bin\rlc-core %SREF% --makelib %COMMON_SRFLAGS% %SRFLAGS% %SRFLAGS_PLUS% ^ --keep-rasls %SATELITE% 2> __error.txt if errorlevel 100 ( - echo COMPILER ON %1 FAILS, SEE __error.txt + echo COMPILER ON %1 FAILS, SEE __error.txt or __dump_rlc-core.txt exit /b 1 ) if not exist %LIBR% if not exist %LIBN% ( @@ -309,10 +312,11 @@ setlocal if not exist "%SATELITE%" set SATELITE= + if exist __dump_rlc-core.txt erase __dump_rlc-core.txt ..\bin\rlc-core %SREF% --makelib %COMMON_SRFLAGS% %SRFLAGS% %SRFLAGS_PLUS% ^ --keep-rasls %SATELITE% 2> __error.txt if errorlevel 100 ( - echo COMPILER ON %1 FAILS, SEE __error.txt + echo COMPILER ON %1 FAILS, SEE __error.txt or __dump_rlc-core.txt exit /b 1 ) if not exist %LIBR% if not exist %LIBN% ( @@ -349,9 +353,10 @@ setlocal set SREF=%1 set RASL=%~n1.rasl + if exist __dump_rlc-core.txt erase __dump_rlc-core.txt ..\bin\rlc-core --prelude=test-prelude.srefi -C %SRFLAGS% %1 2> __error.txt if errorlevel 100 ( - echo COMPILER ON %1 FAILS, SEE __error.txt + echo COMPILER ON %1 FAILS, SEE __error.txt or __dump_rlc-core.txt exit /b 1 ) if exist %RASL% ( @@ -374,12 +379,14 @@ setlocal set SREF=%1 set RASL=%~n1.rasl + set CPP=%~n1.cpp set WARN=-W echo Passing %1 (flag %WARN%%FLAG%)... + if exist __dump_rlc-core.txt erase __dump_rlc-core.txt ..\bin\rlc-core %WARN%%FLAG% --prelude=test-prelude.srefi -C %SRFLAGS% %1 ^ 2> __error.txt if errorlevel 100 ( - echo COMPILER ON %1 FAILS, SEE __error.txt + echo COMPILER ON %1 FAILS, SEE __error.txt or __dump_rlc-core.txt exit /b 1 ) if not exist %RASL% ( @@ -390,15 +397,17 @@ setlocal type __error.txt erase __error.txt erase %RASL% + if exist %CPP% erase %CPP% echo Ok! Compilation didn't abort echo. set WARN=-Werror= echo Passing %1 (flag %WARN%%FLAG%)... + if exist __dump_rlc-core.txt erase __dump_rlc-core.txt ..\bin\rlc-core %WARN%%FLAG% --prelude=test-prelude.srefi -C %SRFLAGS% %1 ^ 2> __error.txt if errorlevel 100 ( - echo COMPILER ON %1 FAILS, SEE __error.txt + echo COMPILER ON %1 FAILS, SEE __error.txt or __dump_rlc-core.txt exit /b 1 ) if exist %RASL% ( diff --git a/autotests/run.sh b/autotests/run.sh index 296e0e9a..dd4dd668 100755 --- a/autotests/run.sh +++ b/autotests/run.sh @@ -23,7 +23,7 @@ prepare_prefix() { ../bin/rlc-core -o _test_prefix.exe-prefix \ "${COMMON_SRFLAGS[@]}" ${SRFLAGS_NAT} 2>__error.txt if [[ $? -ge 100 ]] || [[ ! -e _test_prefix.exe-prefix ]]; then - echo "CAN'T CREATE COMMON PREFIX, SEE __error.txt" + echo "CAN'T CREATE COMMON PREFIX, SEE __error.txt or __dump_rlc-core.txt" exit 1 fi echo @@ -115,7 +115,8 @@ prepare_int_test() { "${COMMON_SRFLAGS[@]}" ${SRFLAGS_PREF} \ --reference=${REFERENCE} >__out.txt 2>__error.txt if [[ $? -ge 100 ]] || [[ ! -e ${INT} ]]; then - echo COMPILER FAILS ON CREATING ${INT}, SEE __error.txt + echo COMPILER FAILS ON CREATING ${INT}, \ + SEE __error.txt or __dump_rlc-core.txt exit 1 fi rm __out.txt __error.txt @@ -139,10 +140,11 @@ run_test_aux_with_flags() { SATELITE= fi + rm -f __dump_rlc-core.txt ../bin/rlc-core --keep-rasls ${SREF} --makelib "${COMMON_SRFLAGS[@]}" \ ${SRFLAGS} ${SRFLAGS_PLUS} "$SATELITE" 2>__error.txt if [[ $? -ge 100 ]]; then - echo COMPILER ON ${SREF} FAILS, SEE __error.txt + echo COMPILER ON ${SREF} FAILS, SEE __error.txt or __dump_rlc-core.txt exit 1 elif [[ ! -e ${LIBR} ]] && [[ ! -e ${LIBN} ]]; then echo COMPILATION FAILED, __error.txt: @@ -174,10 +176,11 @@ run_test_aux.BAD-SYNTAX() { RASL=${SREF%.*}.rasl EXE=${SREF%.*}$(platform_exe_suffix) + rm -f __dump_rlc-core.txt ../bin/rlc-core --prelude=test-prelude.srefi -C ${SRFLAGS} ${SREF} \ 2>__error.txt if [[ $? -ge 100 ]]; then - echo COMPILER ON ${SREF} FAILS, SEE __error.txt + echo COMPILER ON ${SREF} FAILS, SEE __error.txt or __dump_rlc-core.txt exit 1 fi if [[ -e ${RASL} ]]; then @@ -200,12 +203,14 @@ run_test_aux.WARNING() { echo Passing $1 \(flag "${WARN}"\)... SREF=$1 RASL=${SREF%.*}.rasl + CPP=${SREF%.*}.cpp EXE=${SREF%.*}$(platform_exe_suffix) + rm -f __dump_rlc-core.txt ../bin/rlc-core ${WARN} --prelude=test-prelude.srefi -C ${SRFLAGS} ${SREF} \ 2>__error.txt if [[ $? -ge 100 ]]; then - echo COMPILER ON ${SREF} FAILS, SEE __error.txt + echo COMPILER ON ${SREF} FAILS, SEE __error.txt or __dump_rlc-core.txt exit 1 fi if [[ ! -e ${RASL} ]]; then @@ -215,16 +220,17 @@ run_test_aux.WARNING() { fi cat __error.txt rm __error.txt - rm ${RASL} + rm -f ${RASL} ${CPP} echo "Ok! Compiler didn't abort" echo WARN="-Werror=${array[2]}" echo Passing $1 \(flags "${WARN}"\)... + rm -f __dump_rlc-core.txt ../bin/rlc-core ${WARN} --prelude=test-prelude.srefi -C ${SRFLAGS} ${SREF} \ 2>__error.txt if [[ $? -ge 100 ]]; then - echo COMPILER ON ${SREF} FAILS, SEE __error.txt + echo COMPILER ON ${SREF} FAILS, SEE __error.txt or __dump_rlc-core.txt exit 1 fi if [[ -e ${RASL} ]]; then @@ -257,10 +263,11 @@ run_test_aux_with_flags.FAILURE() { SATELITE= fi + rm -f __dump_rlc-core.txt ../bin/rlc-core --keep-rasls ${SREF} --makelib "${COMMON_SRFLAGS[@]}" \ ${SRFLAGS} ${SRFLAGS_PLUS} "$SATELITE" 2>__error.txt if [[ $? -ge 100 ]] || [[ ! -e ${LIBR} ]] && [[ ! -e ${LIBN} ]]; then - echo COMPILER ON ${SREF} FAILS, SEE __error.txt + echo COMPILER ON ${SREF} FAILS, SEE __error.txt or __dump_rlc-core.txt exit 1 fi rm __error.txt diff --git a/autotests/screening-1.WARNING.ref b/autotests/screening-1.WARNING.ref new file mode 100644 index 00000000..b35598ba --- /dev/null +++ b/autotests/screening-1.WARNING.ref @@ -0,0 +1,13 @@ +* WARNING screening + +$ENTRY AADC { + 2 DCBD e.5 ((ADBA s.10)) e.1 e.9 5 + e.7 + 4 2 AADA (t.2) + = '$1'; + + 2 DCBD e.5 ((ADBA s.10)) e.1 t.4 5 + 10 (7 6 t.11) AD ((s.8) 10 ()) + 4 2 AADA (t.2) + = '$2'; +} diff --git a/autotests/screening-2.WARNING.ref b/autotests/screening-2.WARNING.ref new file mode 100644 index 00000000..550b309f --- /dev/null +++ b/autotests/screening-2.WARNING.ref @@ -0,0 +1,13 @@ +* WARNING screening + +$ENTRY B { + C CCBC 0 (10) () DCAD (s.3 () 1) t.11 5 DA + e.10 + 'c' DBB () e.2 s.12 0 BBB 'd' t.4 () 'd' ABCD 'c' (s.4 (s.7) () (s.7 9 8)) + = '$1'; + + C CCBC 0 (10) () DCAD (s.3 () 1) t.11 5 DA + ('b') s.3 'c' B ((e.6 4 'dc' BCC) 1 7 9) () + 'c' DBB () e.2 s.12 0 BBB 'd' t.4 () 'd' ABCD 'c' (s.4 (s.7) () (s.7 9 8)) + = '$2'; +} diff --git a/autotests/screening-3.WARNING.ref b/autotests/screening-3.WARNING.ref new file mode 100644 index 00000000..c4fa7eb0 --- /dev/null +++ b/autotests/screening-3.WARNING.ref @@ -0,0 +1,15 @@ +* WARNING screening + +$ENTRY CDACA1 { + 2 10 t.13 'b' + e.11 + 'c' + e.2 CDB t.3 2 + = '$1'; + + 2 10 'd' 'b' + e.6 s.3 'd' CD ('ba' 5) 'b' 2 e.6 3 (t.1 C ACD) e.13 CB 3 + 'c' CAD (10) D + e.2 CDB t.3 2 + = '$2'; +} diff --git a/autotests/screening-4.WARNING.ref b/autotests/screening-4.WARNING.ref new file mode 100644 index 00000000..2e2db3c2 --- /dev/null +++ b/autotests/screening-4.WARNING.ref @@ -0,0 +1,13 @@ +* WARNING screening + +$ENTRY CDACA2 { + 2 10 'db' + e.6 + s.3 CAD (10) D e.2 CDB t.3 2 + = '$1'; + + 2 10 'db' + e.6 s.3 'd' CD ('ba' 5) 'b' 2 e.6 3 (t.1 C ACD) e.13 CB 3 + 'c' CAD (10) D e.2 CDB t.3 2 + = '$2'; +} diff --git a/autotests/screening-5.WARNING.ref b/autotests/screening-5.WARNING.ref new file mode 100644 index 00000000..b3129107 --- /dev/null +++ b/autotests/screening-5.WARNING.ref @@ -0,0 +1,13 @@ +* WARNING screening + +$ENTRY BAD { + ((t.10 'b' s.12 s.12)) 10 DD 'ba' ABCB 'c' s.3 0 s.12 + e.8 + (CCCB 2 e.1 3) e.5 2 AA DCDD 1 (t.1 (t.7 8 ('c' 2)) C 'a') DBC + = '$1'; + + ((t.10 'b' s.12 s.12)) 10 DD 'ba' ABCB 'c' s.3 0 s.12 + 'd' s.1 DCCD 'c' ACBD e.8 e.8 + (CCCB 2 e.1 3) e.5 2 AA DCDD 1 (t.1 (t.7 8 ('c' 2)) C 'a') DBC + = '$2'; +} diff --git a/src/common/Escape.ref b/src/common/Escape.ref index 2b50548e..1949eb72 100644 --- a/src/common/Escape.ref +++ b/src/common/Escape.ref @@ -30,7 +30,7 @@ $ENTRY EscapeChar { }; } -$DRIVE EscapeChar; +*$xDRIVE EscapeChar $ENTRY EscapeString { e.String = ; @@ -48,7 +48,7 @@ $ENTRY CharFromNum { { s.Accum s.Next = s.Next>; } - 0 + 0 > > >; } @@ -83,22 +83,22 @@ gen_e__ { e.Arg = e.Arg } DoUnEscapeString-SR { (e.Scanned) '\\x' e.HexAndTail = ) (/* scanned number */) e.HexAndTail + (e.Scanned) () () e.HexAndTail >; (e.Scanned) '\\X' e.HexAndTail = ) (/* scanned number */) e.HexAndTail + (e.Scanned) () () e.HexAndTail >; (e.Scanned) '\\d' e.DecAndTail = ) (/* scanned number */) e.DecAndTail + (e.Scanned) (10 ) () e.DecAndTail >; (e.Scanned) '\\D' e.DecAndTail = ) (/* scanned number */) e.DecAndTail + (e.Scanned) (10 ) () e.DecAndTail >; (e.Scanned) '\\' e.EscapedAndTail @@ -156,13 +156,15 @@ DoUnEscapeString-SR-DecOct { DoUnEscapeString-SR-Escape { (e.Scanned) (e.Octs-B s.Oct e.Octs-E) s.Oct e.Tail = ) e.Tail >; (e.Scanned) (e.Octs) s.Next e.Tail = : { - Success s.Char = ; + Success s.Char + = ) e.Tail>; + Fails = Fails BadEscapeSymbol '\\' s.Next; }; diff --git a/src/common/FindFile.ref b/src/common/FindFile.ref index 1ab55ba8..01b640e5 100644 --- a/src/common/FindFile.ref +++ b/src/common/FindFile.ref @@ -5,7 +5,7 @@ $EXTERN Map; $EXTERN DirectorySeparator, PathSeparator; -$INLINE DS; +*$xDRIVE DS DS { = } diff --git a/src/compiler/@refal-5-lambda-diagnostics.ini b/src/compiler/@refal-5-lambda-diagnostics.ini index d2d8c2b7..4cdb62b3 100644 --- a/src/compiler/@refal-5-lambda-diagnostics.ini +++ b/src/compiler/@refal-5-lambda-diagnostics.ini @@ -1,4 +1,4 @@ -memory-limit = 70000000 -step-limit = 1000000000 +memory-limit = 100000000 +step-limit = 2000000000 idents-limit = 5000 enable-debugger = false diff --git a/src/compiler/Checker-Screening.ref b/src/compiler/Checker-Screening.ref index 7e54bf69..404b333b 100644 --- a/src/compiler/Checker-Screening.ref +++ b/src/compiler/Checker-Screening.ref @@ -3,15 +3,9 @@ $INCLUDE "LibraryEx"; *$FROM GenericMatch $EXTERN GenericMatch; -*$FROM ObjectMatch -$EXTERN ObjectMatch; - -*$FROM GlobalGen -$EXTERN GlobalGen; - *$FROM Desugaring -$EXTERN CreateContext, RemovePos-Expr, ExtractVariables-Expr, - Pass-EnumerateVariables, Pass-RemovePos; +$EXTERN Pass-RemovePos, Pass-EnumerateVariables, Pass-ExtractEntries, + ExtractVariables-Expr, CreateContext; /* : (e.FunctionsPos) e.AST^ - = : e.AST^ - = : e.AST^ - = : e.FunctionsWithPos - = ; - - (e._) (e.AST) = /* пусто */ + (e._ screening e._) (e.AST) + = : (e.FunctionsPos) e.AST^ + = : e.AST^ + = : e.AST-B (Entries e.Entries) e.AST-E + = : e.AST^ + = : e.FunctionsWithPos + = ; + + (e._) (e.AST) = /* пусто */ } /* @@ -44,7 +39,7 @@ FindFunctionsPosInAST { (e.Positions) (Function t.SrcPos s.ScopeClass (e.Name) Sentences e.Sentences) = (e.Positions t.SrcPos) - (Function t.SrcPos s.ScopeClass (e.Name) Sentences e.Sentences); + (Function t.SrcPos s.ScopeClass (e.Name) Sentences e.Sentences); (e.Positions) t.Other = (e.Positions) /* пусто */ } @@ -79,8 +74,8 @@ MakePairs { CheckFunction проверяет тело функции на экранирование. */ CheckFunction { - ((Function s.ScopeClass (e.Name) Sentences e.Sentences) t.SrcPos) - = + ((Function (e.Name) Sentences e.Sentences) t.SrcPos) + = ) () (e.Sentences)> } /* @@ -114,8 +109,8 @@ CheckSentences { : e.Prefix^ - = e.ContextVars e.Pattern : e.ContextVars^ + = > : e.Prefix^ + = : e.ContextVars^ = ) ((e.Pattern) e.AssignsOrConds (e.Result) (e.Blocks)) > ) ((e.Pattern) e.AssignsOrConds (e.Result) (e.Blocks)) > } @@ -171,8 +166,10 @@ FilterConditions { /*( t.NumberedSentence-L - ((t.Pattern e._ (e._ (CallBrackets e.1) e._) ((Sentences e.2) e._)) s.Num) - + ( + (t.Pattern e._ (e._ (CallBrackets e._) e._) ((Sentences e._) e._)) + s.Num + ) ) = пусто ;*/ @@ -220,7 +217,7 @@ CheckBlocks { ) + (>) (e.ContextVars) (e.Sentences) >; @@ -232,6 +229,8 @@ CheckBlocks { >; } +gen_e__ { e.Arg = e.Arg } + /* : e.Prefix^ + = > : e.Prefix^ = ( e.ContextVars e.Pattern) ) + (>) (e.ContextVars) (e.Sentences) >; @@ -400,42 +399,24 @@ CheckPatternPairs { (((e.Pattern-L) e._ (e._) (e._)) s.Num-L) (((e.Pattern-R) e._ (e._) (e._)) s.Num-R) ) - = + = e.ContextVars e.Pattern-L : e.Pattern-L^ + = e.ContextVars e.Pattern-R : e.Pattern-R^ + = e.Prefix '$' : e.R-id + = e.Prefix '$' : e.L-id + = /* пусто */ : { - e._, (e.Pattern-L) (e.Pattern-R) : () () + , : Clear e._ = ) - (e.Prefix '$' ) + t.SrcPos (e.FuncName) (e.R-id) (e.L-id) >; - Clear e._ + + , : True = ) - (e.Prefix '$' ) + t.SrcPos (e.FuncName) (e.R-id) (e.L-id) >; - e._ = - : { - True e.Other - = ) - (e.Prefix '$' ) - >; - - False = /* пусто */; - } - } + = /* нет предупреждений */; + } } e.Pairs >; @@ -444,8 +425,7 @@ CheckPatternPairs { } /* - - == t.Warning* + == s.Bool PatternLanguagesCheck проверяет пару предложений на экранирование алгоритмом, основанном на языках образцов. @@ -454,154 +434,31 @@ PatternLanguagesCheck { (e.Pattern-L) (e.Pattern-R) , : e.FlattenedPattern-R , : True - = : e.Pattern-R^ - = : e.Pattern-L^ = : e.Pattern-R^ - = : e.Generalized - = : e.Generalized^ - = : Clear e.Tuple-R - = : Clear e.Tuple-L - = : e.Tuples - = ; - + = : e.Pattern-L^ + = + : { + Clear e._ = True; + e._ = False; + }; - (e.Pattern-L) (e.Pattern-R) - = False; + (e.Pattern-L) (e.Pattern-R) = False; } -/* - Заменяет АДТ-скобки -*/ -ReplaceADTBrackets { - e.Pattern +ScreenVars { + e.Expression = )); + (Var s.Mode e.Index) = (ScrVar s.Mode e.Index); - (Brackets e.Inner) - = (Brackets (Symbol Char '*') ); + (Brackets e.Nested) = (Brackets ); + + (ADT-Brackets (e.Name) e.Nested) + = (ADT-Brackets (e.Name) ); t.Other = t.Other; } - e.Pattern - >; -} - - -/* - - == True - == False - - t.Tuple ::= (t.Pattern-L t.Pattern-R) - - CheckEveryMatch сверяет пары кортежей. - Возвращает True, если все совпали, иначе False. -*/ -CheckEveryMatch { - ((e.Pattern-L) (e.Pattern-R)) e.Tuples (e.Assigns) - = - : { - Clear e.NewAssigns - = - : { - Success e.UpdatedAssigns - = ; - - Fails - = False; - }; - - e.Other - = False; - }; - - /* пусто */ (e.Assigns) = True (e.Assigns); -} - - -/* - - == Success t.Assign* - == Fails - - AppendAssigns пополняет список присваиваний новыми. - Если новое присваивание содержится в списке, список не изменяется. - Если новое присваивание противоречит старрому, возвращается Fails. -*/ -AppendAssigns { - /* если старое значение совпало с новым */ - (e.Assigns-L (e.Vars-L ':' e.Vars-R) e.Assigns-R) - (e.Vars-L ':' e.Vars-R) e.NewAssignsTail - = ; - - /* если старое не совпало с новым */ - (e.Assigns-L (e.Vars-L ':' e.Vars-R) e.Assigns-R) - (e.Vars-L-Other ':' e.Vars-R) e.NewAssignsTail - = Fails; - - /* если новая переменная */ - (e.Assigns) - (e.Vars-L ':' e.Vars-R) e.NewAssignsTail - = ; - - (e.Assigns) /* пусто */ = Success e.Assigns; -} - -/* - - == t.Tuple* - - t.Assign ::= ((t.Pattern*) ':' (t.Pattern*)) - - CreateTuplePairs сверяет пары кортежей, - возвращает True, если все совпали, иначе False. - Правая часть выражения нормализуется. -*/ -CreateTuplePairs { - (e.Tuple-L) (e.Tuple-R) - = - >; -} - -/* - - == e.Pattern - - RenameVars добавляет суффиксы переменным, полученным из ГСО. -*/ -RenameVars { - (e.Prefix) e.Pattern - = - (Var s.Type e.Index e.Prefix 's' ); - s.Count (Brackets e.Other) - = - (Brackets ) e.Other>); - s.Count t.Other - = s.Count t.Other; - } - 1 e.Pattern - > + e.Expression >; } @@ -640,6 +497,8 @@ DeleteMarkup { (Float t.Item) = t.Item; (Anchor t.Item) = t.Item; (MarkedBrackets e.Brackets) = (Brackets ); + (MarkedADTBrackets (e.Name) e.Brackets) + = (ADT-Brackets (e.Name) ); t.Item = t.Item; } @@ -707,7 +566,16 @@ InsertFakeEVars { e.Suffix >; - e.Other = e.Other; + e.Prefix + (ADT-Brackets (e.Name) e.Brackets) + e.Suffix + = ) + e.Suffix + >; + + e.Other = e.Other; } /* @@ -719,35 +587,40 @@ InsertFakeEVars { */ MarkupNeighbourAnchorTVars { e.MarkedPattern - = ; + = ; } -MarkupNeighbourHelper { +DoMarkupNeighbourAnchorTVars { (e.Prefix) ((Var 't' e.Index) e.Suffix) , : True , : True - = ; (e.Prefix) ((Brackets e.Brackets) e.Suffix) - = ) + (Brackets ) ) (e.Suffix) >; - (e.Prefix) (t.Item e.Suffix) - = ) + ) (e.Suffix) >; - (e.Prefix) () - = e.Prefix; + (e.Prefix) (t.Item e.Suffix) + = ; + + (e.Prefix) () = e.Prefix; } /* @@ -760,21 +633,11 @@ MarkupNeighbourHelper { (2-ая часть определения) */ HasAnchorsPrefix { - e.Prefix (Anchor (Var 't' e.Index)) - = True; - - e.Prefix (Symbol s.Mode e.Index) - = True; - - e.Prefix (Var 'e' e.Index) - = False; - - e.Prefix (Brackets e._) - = True; - - e.Prefix t.Other - = ; - + e.Prefix (Anchor (Var 't' e.Index)) = True; + e.Prefix (Symbol s.Mode e.Index) = True; + e.Prefix (Var 'e' e.Index) = False; + e.Prefix (Brackets e._) = True; + e.Prefix t.Other = ; /* пусто */ = True; } @@ -788,21 +651,11 @@ HasAnchorsPrefix { (2-ая часть определения) */ HasAnchorsSuffix { - (Anchor (Var 't' e.Index)) e.Suffix - = True; - - (Symbol s.Mode e.Index) e.Suffix - = True; - - (Var 'e' e.Index) e.Suffix - = False; - - (Brackets e._) e.Suffix - = True; - - t.Other e.Suffix - = ; - + (Anchor (Var 't' e.Index)) e.Suffix = True; + (Symbol s.Mode e.Index) e.Suffix = True; + (Var 'e' e.Index) e.Suffix = False; + (Brackets e._) e.Suffix = True; + t.Other e.Suffix = ; /* пусто */ = True; } @@ -826,6 +679,11 @@ MarkupMultipleAnchorTVars { ); + (ADT-Brackets (e.Name) e.Brackets) + = (ADT-Brackets (e.Name) + + ); + t.Other = t.Other; } e.Pattern @@ -933,21 +791,6 @@ IsPatternLinear { = True; } -/* - - == True - == False - - IsPatternFlat возвращает True, если образец e.Pattern - плоский - (не содержит круглых скобок), иначе False. -*/ -IsPatternFlat { - e._ (Brackets e._) e._ - = False; - e._ - = True; -} - /* == (e.FlatPattern) @@ -961,24 +804,14 @@ FlattenPattern { (Brackets e.Inner) = ; + (ADT-Brackets (e.Name) e.Inner) = ; + t.Other = t.Other; } e.Pattern > } -/* - - == e.GeneralizedPattern - - Generalize реконструирует общий формат двух образцов (ГСО) -*/ -Generalize { - (e.Pattern-L) (e.Pattern-R) - = : e.GlobalComplexGeneralization - = e.GlobalComplexGeneralization -} - /* == t.Warning diff --git a/src/compiler/Checker.ref b/src/compiler/Checker.ref index fcb33a16..3514e440 100644 --- a/src/compiler/Checker.ref +++ b/src/compiler/Checker.ref @@ -10,7 +10,7 @@ $EXTERN GenericMatch; $EXTERN RemovePos-Expr; *$FROM TreeUtils -$EXTERN ExtractVariables-Expr; +$EXTERN ExtractVariables-Expr, IsGenFunctionName; *$FROM Checker-Screening $EXTERN CheckScreening; @@ -70,7 +70,17 @@ PrepareMessage { DanglingDrive e.Name = '$DRIVE ' e.Name '; drive label for missed function'; NativeOptimizable s.Label e.Name - = 'Function ' e.Name ' can\'t be $' >; + = s.Label + : { + LegacyDrive = '$DRIVE'; + LegacyInline = '$INLINE'; + LegacySpec = '$SPEC'; + Drive = '*$DRIVE'; + Spec = '*$SPEC'; + Opt = '*$OPT'; + } + : e.Keyword + = 'Function ' e.Name ' can\'t be ' e.Keyword; /* Ошибки специализации */ RedefineSpec e.FnName = 'Specialization of function ' e.FnName 'is redefined'; @@ -122,6 +132,19 @@ PrepareMessage { BadPseudofunctionBody e.Name = 'Pseudofunction ' e.Name ' should have a body { e.X = e.X }, ' 'in other case function can\'t be encountered as pseudofunction'; + + IntrinsicForDefined e.Name + = 'Function ' e.Name ' is defined, ' + '$INTRINSIC declaration for it will be ignored'; + + OptFeaturesConflict s.Label1 s.Label2 e.Name + = 'Conflict between pseudocomments ' + '$' > ' ' e.Name '; and ' + '$' > ' ' e.Name ';, ' + '$NO... pseudocomment has priority'; + + DanglingOptPseudocomment s.Label e.Name + = '$' > ' ' e.Name '; label for missed function'; } FindErrors { @@ -143,20 +166,25 @@ CheckPseudofunctions { = : e._ (e.Name) e._ + , LegacyDrive LegacyInline Intrinsic : e._ s.Tag e._ + , : True = (Error t.SrcPos TaggedPseudofunction s.Tag e.Name); - (Spec t.SrcPos (e.Name) e._) - , : e._ (e.Name) e._ + (s.Tag t.SrcPos e.Name) + , Opt Drive Spec : e._ s.Tag e._ + , : True + = (Warning pseudocomment t.SrcPos TaggedPseudofunction s.Tag e.Name); + + (LegacySpec t.SrcPos (e.Name) e._) + , : True = (Error t.SrcPos TaggedPseudofunction Spec e.Name); (Entry t.SrcPos GN-Entry e.Name) - , : e._ (e.Name) e._ + , : True = (Warning pseudofunctions t.SrcPos EntryPseudofunction e.Name); (Function t.SrcPos s.ScopeClass (e.Name) e.Body) - , : e._ (e.Name) e._ + , : True = (Function t.SrcPos s.ScopeClass (e.Name) e.Body) ; @@ -182,10 +210,6 @@ SeparateErrors { > } -Pseudofunctions { - = ('gen_e__') ('gen-e__') -} - CheckPseudofunctions-Entry { t.SrcPos e.Name GN-Local = /* нет ошибок */; @@ -220,11 +244,11 @@ CheckSpecs { * Проверка переопределения специализации CheckSpecs-Redefine { e.AST-B - (Spec t.SrcPos1 (e.Name) e.Pattern1) e.AST-M - (Spec t.SrcPos2 (e.Name) e.Pattern2) e.AST-E + (LegacySpec t.SrcPos1 (e.Name) e.Pattern1) e.AST-M + (LegacySpec t.SrcPos2 (e.Name) e.Pattern2) e.AST-E = ; @@ -236,13 +260,13 @@ CheckSpecs-Formats { e.AST = : { True = : { - /* пусто */ = (Spec t.SrcPos (e.Name) e.Pattern); + /* пусто */ = (LegacySpec t.SrcPos (e.Name) e.Pattern); e.Errors = e.Errors; }; @@ -357,7 +381,7 @@ FindVariables { * Проверка, что упоминаемые функции определены CheckSpecs-Functions { e.AST-B - (Spec t.SrcPos1 (e.Name) e.Pattern) e.AST-M + (LegacySpec t.SrcPos1 (e.Name) e.Pattern) e.AST-M (Function t.SrcPos2 s.ScopeClass (e.Name) e.Body) e.AST-E = : { @@ -384,7 +408,7 @@ CheckSpecs-Functions { e.AST-B (Function t.SrcPos1 s.ScopeClass (e.Name) e.Body) e.AST-M - (Spec t.SrcPos2 (e.Name) e.Pattern) e.AST-E + (LegacySpec t.SrcPos2 (e.Name) e.Pattern) e.AST-E = : { True = @@ -408,7 +432,7 @@ CheckSpecs-Functions { : e.AST = ; - e.AST-B (Spec t.SrcPos (e.Name) e.Pattern) e.AST-E + e.AST-B (LegacySpec t.SrcPos (e.Name) e.Pattern) e.AST-E = ; @@ -425,7 +449,8 @@ ValidBodyForSpec { : (s.BoolResult e.Messages) = s.BoolResult e.Messages; - (e.Name) t.Pattern NativeBody e.Code = False (NativeOptimizable Spec e.Name); + (e.Name) t.Pattern NativeBody e.Code + = False (NativeOptimizable LegacySpec e.Name); } ValidBodyForSpec-CheckSentensePattern { @@ -547,11 +572,20 @@ SeparateDefines { (e.Declarations) (Entry t.SrcPos GN-Entry e.Name) = (e.Declarations (Entry t.SrcPos e.Name)); - (e.Declarations) (Inline t.SrcPos s.ScopeClass e.Name) = - (e.Declarations (Inline t.SrcPos e.Name)); + (e.Declarations) (LegacyInline t.SrcPos s.ScopeClass e.Name) = + (e.Declarations (LegacyInline t.SrcPos e.Name)); + + (e.Declarations) (LegacyDrive t.SrcPos s.ScopeClass e.Name) = + (e.Declarations (LegacyDrive t.SrcPos e.Name)); - (e.Declarations) (Drive t.SrcPos s.ScopeClass e.Name) = - (e.Declarations (Drive t.SrcPos e.Name)); + (e.Declarations) (s.OptNode t.SrcPos e.Name) + , (Opt Drive Spec Yes) (Drive Drive Yes) (Spec Spec Yes) + (NoOpt Drive Spec No) (NoDrive Drive No) (NoSpec Spec No) + : e._ (s.OptNode e.Features s.Enable) e._ + = ( + e.Declarations + (Opt s.OptNode (e.Features) s.Enable t.SrcPos e.Name) + ); (e.Declarations) (Intrinsic t.SrcPos s.ScopeClass e.Name) = (e.Declarations (Intrinsic t.SrcPos e.Name)); @@ -563,7 +597,7 @@ SeparateDefines { (e.Declarations) (NativeBlock e.Block) = (e.Declarations); } - (/* объявления */) + () e.AST >; } @@ -580,6 +614,10 @@ CheckDeclarations { &FindInvalidDriveInline &CheckRedefinitions &FindFinalInitEntry + &CheckIntrinsics + &CheckConflictOptPseudocomments + &CleanupValidOptPseudocomments + &CheckDanglingOptPseudocomments > > } @@ -590,11 +628,11 @@ FindInvalidDriveInline { /* находим все $DRIVE и $INLINE */ = @@ -772,9 +815,124 @@ CheckRedefinitions { e.Declarations = e.Declarations; } +CheckIntrinsics { + e.Declarations-B + (Intrinsic t.SrcPosIntrinsic e.Name) e.Declarations-M + (Define t.SrcPosDefine s.ScopeClass e.Name) e.Declarations-E + = ; + + e.Declarations-B + (Define t.SrcPosDefine s.ScopeClass e.Name) e.Declarations-M + (Intrinsic t.SrcPosIntrinsic e.Name) e.Declarations-E + = ; + + e.Declarations = e.Declarations; +} + +CheckConflictOptPseudocomments { + e.Declarations-B + (Opt s.OptNode1 (e.Feat1-B s.Feature e.Feat1-E) Yes t.YesPos e.Name) + e.Declarations-M + (Opt s.OptNode2 (e.Feat2-B s.Feature e.Feat2-E) No t.NoPos e.Name) + e.Declarations-E + = ; + + e.Declarations-B + (Opt s.OptNode1 (e.Feat1-B s.Feature e.Feat1-E) No t.NoPos e.Name) + e.Declarations-M + (Opt s.OptNode2 (e.Feat2-B s.Feature e.Feat2-E) Yes t.YesPos e.Name) + e.Declarations-E + = ; + + e.Declarations = e.Declarations; +} + +CleanupValidOptPseudocomments { + e.Declarations-B + (Opt s.OptNode (e.Features) Yes t.OptPos e.Name) e.Declarations-M + (NativeBody e.Name) e.Declarations-E + = ; + + e.Declarations-B (NativeBody e.Name) e.Declarations-M + (Opt s.OptNode (e.Features) Yes t.OptPos e.Name) e.Declarations-E + = ; + + e.Declarations-B + (Opt s.OptNode (e.Features) s.Enable t.OptPos e.Name) e.Declarations-M + (Define t.SrcPos s.ScopeClass e.Name) e.Declarations-E + = ; + + e.Declarations-B + (Define t.SrcPos s.ScopeClass e.Name) e.Declarations-M + (Opt s.OptNode (e.Features) s.Enable t.OptPos e.Name) e.Declarations-E + = ; + + e.Declarations = e.Declarations; +} + +CheckDanglingOptPseudocomments { + e.Declarations + = +} + CheckFunctionBody { (e.Body) = - ; + ) e.Body>; } CheckFunctionBodyRec { @@ -854,14 +1012,18 @@ DoCheckAssignments { = s.Backtrack >; } +gen_e__ { e.arg = e.arg } + FixBacktrackForOpenEVars { e.Pattern OneWay, : /* пусто */ = OneWay; @@ -1064,62 +1226,62 @@ CheckValidUsings { (Declare t.SrcPos s.ScopeClass e.Name) e.DeclarationsAndErrors-E ) - (Symbol Name t.SrcPosName e.Name) e.NameRefsAndErrors = - ; + (Symbol Name t.SrcPosName e.Name) e.NameRefsAndErrors + = ; ( e.DeclarationsAndErrors-B (Define t.SrcPos s.ScopeClass e.Name) e.DeclarationsAndErrors-E ) - (Symbol Name t.SrcPosName e.Name) e.NameRefsAndErrors = - ; + (Symbol Name t.SrcPosName e.Name) e.NameRefsAndErrors + = ; (e.DeclarationsAndErrors) - (Symbol Name t.SrcPos e.Name) e.NameRefsAndErrors = - ; + (Symbol Name t.SrcPos e.Name) e.NameRefsAndErrors + = ; (e.DeclarationsAndErrors) - (Error t.SrcPos s.Type e.Info) e.NameRefsAndErrors = - ; + (Error t.SrcPos s.Type e.Info) e.NameRefsAndErrors + = ; (e.DeclarationsAndErrors) - (Warning s.WarningId t.SrcPos s.Type e.Info) e.NameRefsAndErrors = - ; - (e.DeclarationsAndErrors) /* кончились ошибки и имена */ = - ; + t.OtherItem = /* пропускаем */; + } + e.DeclarationsAndErrors + >; } diff --git a/src/compiler/Config.ref b/src/compiler/Config.ref index 58b2e510..5b196d95 100644 --- a/src/compiler/Config.ref +++ b/src/compiler/Config.ref @@ -18,7 +18,10 @@ $ENTRY Config-Create { (/* конец командной строки для библиотек */) ) (Optimize /* пусто */) - (WarningIds nul-in-compound pseudofunctions repeated deprecated) + (WarningIds + nul-in-compound pseudofunctions repeated deprecated intrinsic + pseudocomment + ) (WarningIdsAsErrors /* пусто */) (ErrorFile /* пусто */) (DebugMode NoMarkupContext NoDebugInfo) @@ -533,17 +536,23 @@ WarningForName { 'multiscreening' = True multiscreening; 'multiscreening5' = True multiscreening5; 'nul-in-compound' = True nul-in-compound; - 'ignored-pseudocomments' = True ignored-pseudocomments; + 'pseudocomments' = True pseudocomment; /* синоним */ + 'pseudocomment' = True pseudocomment; 'pseudofunctions' = True pseudofunctions; - 'pseudofunction' = True pseudofunctions; /* синоним */ + 'pseudofunction' = True pseudofunctions; /* синоним */ 'repeated' = True repeated; 'deprecated' = True deprecated; + 'intrinsic' = True intrinsic; e.Other = False } $ENTRY Config-AllWarningIds { - /* пусто */ = (screening nul-in-compound pseudofunctions repeated deprecated) + /* пусто */ + = ( + screening nul-in-compound pseudocomment pseudofunctions repeated + deprecated intrinsic + ) } WarningIds-Add { diff --git a/src/compiler/Desugaring-UnCondition.ref b/src/compiler/Desugaring-UnCondition.ref index 7d01f92c..e1de69f7 100644 --- a/src/compiler/Desugaring-UnCondition.ref +++ b/src/compiler/Desugaring-UnCondition.ref @@ -1,7 +1,7 @@ $INCLUDE "LibraryEx"; *$FROM TreeUtils -$EXTERN AddSuffix, ExtractVariables, CreateSpecPatternForContext, +$EXTERN AddSuffix, ExtractVariables, CreateContext, ExtractVariables-Expr, NewVarName; @@ -18,11 +18,11 @@ $ENTRY Pass-UnCondition { ** НАМЕРЕННО ОТКАЗЫВАЕМСЯ ОТ ОТСЛЕЖИВАНИЯ КОПИРОВАНИЯ ПОВТОРНЫХ ПЕРЕМЕННЫХ /** - + == e.NewFunctions */ UnCondition-Unit { - s.MarkupContext (Function s.Scope (e.Name) Sentences e.Sentences) + s.MarkupContext (Function (e.Name) Sentences e.Sentences) = 1 : s.SkipNo = /* пусто */ : e.RemNames @@ -34,7 +34,7 @@ UnCondition-Unit { > : (s.SkipNo^ e.RemNames^ (e.NewFunctions^)) e.Sentences^ - = (Function s.Scope (e.Name) Sentences e.Sentences) + = (Function (e.Name) Sentences e.Sentences) ; @@ -63,7 +63,7 @@ UnCondition-RemFunctions { t.RemainderName { (e.RemainderName) - = (Function GN-Local (e.RemainderName) Sentences e.Sentences); + = (Function (e.RemainderName) Sentences e.Sentences); '-' = /* пусто */; } @@ -84,10 +84,13 @@ UnCondition-RemFunctions { PatternSteps { (e.UsedVariables) e.Pattern = ) + >; } +gen_e__ { e.arg = e.arg } + DoPatternSteps { t.UsedVariables (e.BoundEVariables) e.HolesAndItems , e.HolesAndItems @@ -220,7 +223,7 @@ HardItem { } BindBrackets { - (e.Expr) = (); + (e.Expr) = () e.Expr>); } DoBindBrackets { @@ -444,7 +447,7 @@ UnCondition-Sentence { e.PatternSteps > : (e.ContSentence) e.OpenEFunctions - , (Function GN-Local (e.CheckFunction) Sentences + , (Function (e.CheckFunction) Sentences ((e.Context e.CondPattern) e.SentenceTail) e.ContSentence ) @@ -457,8 +460,8 @@ UnCondition-Sentence { ) ) ) - (Drive e.CheckFunction) - (Spec (e.CheckFunction) ) + (GROUP Drives (e.CheckFunction)) + (GROUP Specs (e.CheckFunction)) t.CheckFunction e.OpenEFunctions; } @@ -536,12 +539,12 @@ MakeOpenE-ForwardNext { (e.T1) (e.T2) (e.T3) (e.T4) (e.T5) (e.T5-sub) (e.T6) (e.T7) , e.ConditionName '?' <+ 1 s.CurrentForwardId> : e.NextName , : e.CheckFuncArgSubst - = (Function GN-Local (e.CurrentForwardName) Sentences + = (Function (e.CurrentForwardName) Sentences ((e.T1) ((CallBrackets (Symbol Name e.NextName) e.T2))) ((e.T3) ((CallBrackets (Symbol Name e.ContName) e.T4))) ) - (Drive e.CurrentForwardName) - (Function GN-Local (e.NextName) Sentences + (GROUP Drives (e.CurrentForwardName)) + (Function (e.NextName) Sentences ( (e.T5) ((CallBrackets (Symbol Name e.CheckFunction) e.CheckFuncArgSubst)) diff --git a/src/compiler/Desugaring.ref b/src/compiler/Desugaring.ref index 06ec0bd2..f39456ed 100644 --- a/src/compiler/Desugaring.ref +++ b/src/compiler/Desugaring.ref @@ -4,7 +4,8 @@ $INCLUDE "LibraryEx"; $EXTERN Pass-UnCondition; *$FROM TreeUtils -$EXTERN NewVarName, AddSuffix, CreateContext, CreateSpecPatternForContext; +$EXTERN NewVarName, AddSuffix, CreateContext, ExtractVariables-Expr, + IsGenFunctionDecoratedName; $ENTRY Desugar { @@ -13,8 +14,8 @@ $ENTRY Desugar { e.AST - &Pass-CleanupRedudandExterns - &Pass-UnfoldEnums + &Pass-DisableGenFunctionOptimizations + &Pass-CollectDeclarations > >; } @@ -40,14 +40,15 @@ $ENTRY Pass-RemovePos { (Function t.SrcPos s.ScopeClass (e.Name) e.Body) = (Function s.ScopeClass (e.Name) ); - (Ident t.SrcPos e.Name) - = (Ident e.Name); + (Ident t.SrcPos e.Name) = (Ident e.Name); + + (NativeBlock t.SrcPos e.Code) = (NativeBlock t.SrcPos e.Code); - (NativeBlock t.SrcPos e.Code) - = (NativeBlock t.SrcPos e.Code); + (LegacySpec t.SrcPos (e.Name) e.Pattern) = (LegacySpec e.Name); - (Spec t.SrcPos (e.Name) e.Pattern) - = (Spec (e.Name) ); + (s.OptMarkup t.SrcPos e.Name) + , Opt Drive Spec NoOpt NoDrive NoSpec : e._ s.OptMarkup e._ + = (s.OptMarkup e.Name); (s.EnumSwapDeclaration t.SrcPos s.ScopeClass e.Name) = (s.EnumSwapDeclaration s.ScopeClass e.Name); @@ -137,39 +138,15 @@ $ENTRY RemovePos-Expr { >; } -Pass-AttachEntries { +Pass-UnfoldEnumsAndSwaps { e.AST - = - : (e.Entries) e.AST^ = ; } -Pass-RemoveRedundantDriveInlineIntrinsic { +$ENTRY Pass-ExtractEntries { e.AST = ) + (Function (e.Name) e.Body); - (e.Labels) (Drive e.Name) - = (e.Labels (e.Name Drive)) (Drive e.Name); + (e.Entries) (LegacyDrive s.ScopeClass e.Name) + = (e.Entries) (LegacyDrive e.Name); - (e.Labels) (Inline e.Name) - = (e.Labels (e.Name Inline)) (Inline e.Name); + (e.Entries) (LegacyInline s.ScopeClass e.Name) + = (e.Entries) (LegacyInline e.Name); - (e.Labels) (Intrinsic e.Name) - = (e.Labels (e.Name Intrinsic)) (Intrinsic e.Name); + (e.Entries) (Intrinsic s.ScopeClass e.Name) + = (e.Entries) (Intrinsic e.Name); - (e.Labels) t.Other = (e.Labels) t.Other; + (e.Entries) t.Other = (e.Entries) t.Other; } - (/* labels */) e.AST + (/* имена entry-функций */) + e.AST > - : (e.Labels) e.AST^ - - = ) e.AST; +} - (e.Labels^) t.Other = (e.Labels) t.Other; - } - (e.Labels) e.AST - > - : () e.AST^ - = e.AST; +Entry { + GN-Entry e.Name = (e.Name); + GN-Local e.Name = /* пропускаем */; } $ENTRY Pass-EnumerateVariables { e.AST = - ); + (Function (e.Name) e.Body) + = (Function (e.Name) ); t.OtherProgramElement = t.OtherProgramElement; } @@ -275,6 +222,7 @@ EnumerateVars-Body { (e.ScopeVars) NativeBody t.SrcPos e.Code = NativeBody t.SrcPos e.Code; (e.ScopeVars) Metatable e.Metatable = Metatable e.Metatable; + (e.ScopeVars) Swap = Swap; } EnumerateVars-Blocks { @@ -297,7 +245,7 @@ EnumerateVars-Assignments { = : e.Blocks^ = : (e.ScopeVars^) e.Pattern^ = ) (e.ScopeVars) e.Assignments >; } @@ -385,11 +333,8 @@ Pass-NameNestedFuncs { e.AST = ) e.Body> - ); + (Function (e.Name) e.Body) + = (Function (e.Name) ) e.Body>); t.OtherProgramElement = t.OtherProgramElement; } @@ -428,10 +373,9 @@ NameNestedBody { > >; - (e.MainName) NativeBody t.SrcPos e.Code - = NativeBody t.SrcPos e.Code; - + (e.MainName) NativeBody t.SrcPos e.Code = NativeBody t.SrcPos e.Code; (e.MainName) Metatable e.Metatable = Metatable e.Metatable; + (e.MainName) Swap = Swap; } NameNestedBlocks { @@ -519,11 +463,8 @@ Pass-RemoveBlocksAndAssigns { e.AST = - ); + (Function (e.Name) e.Body) + = (Function (e.Name) ); t.OtherProgramElement = t.OtherProgramElement; } @@ -531,24 +472,17 @@ Pass-RemoveBlocksAndAssigns { >; } -RemoveAssigns-Sentences { - Sentences e.Sentences = - Sentences - ; - - NativeBody t.SrcPos e.Code = - NativeBody t.SrcPos e.Code; - +RemoveAssigns-Body { + Sentences e.Sentences = Sentences ; + NativeBody t.SrcPos e.Code = NativeBody t.SrcPos e.Code; Metatable e.Metatable = Metatable e.Metatable; + Swap = Swap; } RemoveAssigns-Sentence { /* Присваивание есть синтаксический сахар — выражается через блок: - … = R : { B }… P … ---> … = R : { B }… : { P … } + … = R : { B }… : P … ---> … = R : { B }… : { P … } */ ( (e.Pattern) e.Conditions @@ -581,15 +515,10 @@ RemoveAssigns-Conditions { e.Conditions = : (e.Result^) - = (Condition - (e.ConditionName) - () - (e.Pattern) - ); + = : e.Result^ + = (Condition (e.ConditionName) (e.Result) (e.Pattern)); } e.Conditions >; @@ -620,7 +549,7 @@ RemoveAssigns-Result { = (CallBrackets ); (Closure (e.ClosureName) e.Sentences) - = (Closure (e.ClosureName) ); + = (Closure (e.ClosureName) ); t.OtherTerm = t.OtherTerm; } @@ -632,10 +561,10 @@ Pass-FlatNestedFuncs { s.MarkupContext e.AST = : (e.NestedFuncs) e.Body^ = e.NestedFuncs - (Function s.ScopeClass (e.Name) e.Body); + (Function (e.Name) e.Body); t.OtherProgramElement = t.OtherProgramElement; } @@ -646,7 +575,7 @@ Pass-FlatNestedFuncs { ExtractNested { s.MarkupContext e.Sentences = ) e.Sentences > : (/* заимстовованных переменных нет */) (e.NestedFuncs) e.Sentences^ = (e.NestedFuncs) e.Sentences; @@ -656,7 +585,10 @@ ExtractNestedRec { s.MarkupContext (e.ScopeVars) Sentences e.Sentences = ) + () + ) e.Sentences > : ((e.NestedFuncs) (e.BorrowedVars)) e.Sentences^ @@ -669,6 +601,10 @@ ExtractNestedRec { s.MarkupContext (e.ScopeVars) Metatable e.Metatable = (/* нет заимстовованных переменных */) (/* нет вложенных функций */) Metatable e.Metatable; + + s.MarkupContext (e.ScopeVars) Swap + = (/* нет заимстовованных переменных */) (/* нет вложенных функций */) + Swap; } ExtractNested-Sentence { @@ -709,7 +645,7 @@ ExtractNested-Conditions { = : (e.BorrowedVars^) e.PatternLocalVars - = : e.LocalVars^ + = : e.LocalVars^ = + > >; } -ExtractAllVars { - (Var s.Mode e.Index) e.Tail = - (s.Mode e.Index) ; - - (Brackets e.Inner) e.Tail = ; - (ADT-Brackets e.Inner) e.Tail = ; - - t.OtherTerm e.Tail = ; - - /* пусто */ = /* пусто */; -} - -Uniq { - e.Uniqs t.Repeated e.NotScanned-M t.Repeated e.NotScanned-E = - e.Uniqs ; - - e.Uniqs = e.Uniqs; -} - UpdateBorrowedVars { e.ScopeVars (e.BorrowedVars-B (s.Mode e.Index) e.BorrowedVars-E) @@ -834,11 +751,11 @@ ExtractNested-Result-Term { (/* нет захваченных переменных */) e.Body^ = e.Body : { - Sentences e.Sentences = (Drive e.ClosureName); + Sentences e.Sentences = (GROUP Drives (e.ClosureName)); NativeBody e.NativeBody = /* нет меток */; } : e.DriveLabelOpt - = (Function GN-Local (e.ClosureName) e.Body) + = (Function (e.ClosureName) e.Body) e.DriveLabelOpt (e.BorrowedVars) (Symbol Name e.ClosureName); @@ -847,7 +764,7 @@ ExtractNested-Result-Term { (e.NestedBorrowedVars^) Sentences e.Sentences = : e.Context = (Function - GN-Local (e.ClosureName) + (e.ClosureName) Sentences ) - (Drive e.ClosureName) - (Spec (e.ClosureName) ) + (GROUP Drives (e.ClosureName)) + (GROUP Specs (e.ClosureName)) : True + = (e.GenFunctions (e.FuncName)) + (Function + (e.FuncName) Sentences + (((Var 'e' e.Index)) /*=*/ ((Var 'e' e.Index))) + ); - (e.DefinedFunctions) (Inline e.Name) - = (e.DefinedFunctions) (Inline e.Name); + (e.GenFunctions) t.Other = (e.GenFunctions) t.Other; + } + (/* gen functions */) e.AST + > + : (e.GenFunctions) e.AST^ + = (GROUP NoDrives e.GenFunctions) + (GROUP NoSpecs e.GenFunctions) + e.AST +} - (e.DefinedFunctions) (Drive e.Name) - = (e.DefinedFunctions) (Drive e.Name); +Pass-CollectDeclarations { + e.AST + = ; - (e.DefinedFunctions) (Ident e.Name) - = (e.DefinedFunctions) (Ident e.Name); + (Function (e.Name) Sentences e.Sentences) + = (GROUP DefinedFunctions (e.Name)) + (GROUP RefalFunctions (e.Name)) + (Function (e.Name) Sentences e.Sentences); - (e.DefinedFunctions) (NativeBlock t.SrcPos e.Code) - = (e.DefinedFunctions) (NativeBlock t.SrcPos e.Code); + (Function (e.Name) e.Body) + = (GROUP DefinedFunctions (e.Name)) (Function (e.Name) e.Body); - (e.DefinedFunctions) (Spec t.SrcPos t.Name e.Pattern) - = (e.DefinedFunctions) (Spec t.SrcPos t.Name e.Pattern) - } - (/* defined functions */) - e.AST + t.Other = t.Other; + } + e.AST > - : (e.DefinedFunctions) e.AST^ - = - : (e.DefinedFunctions^) e.AST^ + : e.AST^ - = + : e.AST^ + (GROUP Externs e.Externs) + (GROUP Drives e.Drives) + (GROUP Intrinsics e.Intrinsics) + (GROUP Specs e.Specs) + (GROUP NoDrives e.NoDrives) + (GROUP NoSpecs e.NoSpecs) + (GROUP DefinedFunctions e.DefinedFunctions) + (GROUP RefalFunctions e.RefalFunctions) + + = : e.Externs^ + = : e.Drives^ + = : e.Intrinsics^ + = : e.Specs^ + = : e.NoDrives^ + = : e.NoSpecs^ + + = : e.Drives^ + = : e.Specs^ + + = : e.Externs^ + = : e.Intrinsics^ + + = (Externs e.Externs) (Intrinsics e.Intrinsics) + (Drives e.Drives) (Specs e.Specs) + (NoDrives e.NoDrives) (NoSpecs e.NoSpecs) + e.AST +} - (e.DeclaredFunctions) (Declaration s.ScopeClass e.Name) - = (e.DeclaredFunctions (e.Name)) - (Declaration s.ScopeClass e.Name); +CollectDeclarations-Group { + e.AST-B (GROUP s.Group e.Names-B) e.AST-M (GROUP s.Group e.Names-E) e.AST-E + = e.AST-B + ; - (e.DeclaredFunctions) t.Other - = (e.DeclaredFunctions) t.Other; - } - (/* declared functions */) e.AST - > - : (e._) e.AST^ - = e.AST; + e.AST = e.AST; } -FilterDeclarations { - (e.DefinedFunctions-B (e.Name) e.DefinedFunctions-E) - (Declaration s.ScopeClass e.Name) - = (e.DefinedFunctions-B (e.Name) e.DefinedFunctions-E) - /* пусто */; +Set-Intersect { + (e.Set1-B t.Repeated e.Set1-E) (e.Set2-B t.Repeated e.Set2-E) + = t.Repeated ; - (e.DefinedFunctions) t.OtherItem = (e.DefinedFunctions) t.OtherItem; + (e.Set1) (e.Set2) = /* нет общих элементов */; } -Pass-UnfoldEnums { - e.AST - = ; - t.Other = t.Other; - } - e.AST - >; + (e.Minuent) (e.Subtrahend) = e.Minuent; } diff --git a/src/compiler/Engine.ref b/src/compiler/Engine.ref index b5421631..3329990a 100644 --- a/src/compiler/Engine.ref +++ b/src/compiler/Engine.ref @@ -201,6 +201,8 @@ LoadAST { } } +*$NOOPT ResolveIncludes + ResolveIncludes { t.Config (e.BadIncludes-B (e.IncludeName) e.BadIncludes-E) e.Units-B @@ -404,14 +406,13 @@ PatchASTSrcPos { = ; } -$SPEC PatchAST s.FN-PATCH e.ast; +*$xSPEC PatchAST, PatchAST-Item, PatchAST-Body, PatchAST-Sentence, +*$ PatchAST-Chain, PatchAST-Blocks, PatchAST-Expr PatchAST { s.FnPatch e.AST = ; } -$SPEC PatchAST-Item s.FN-PATCH t.item; - PatchAST-Item { s.FnPatch (Function t.SrcPos s.ScopeClass (e.Name) e.Body) = (Function @@ -429,22 +430,25 @@ PatchAST-Item { s.FnPatch (Include t.SrcPos e.IncludeName) = /* пропускаем */; s.FnPatch (s.Label t.SrcPos s.ScopeClass e.Name) - , : True + , Enum Swap Declaration Entry LegacyInline LegacyDrive Intrinsic Meta + : e._ s.Label e._ = (s.Label s.ScopeClass ); - s.FnPatch (Spec t.SrcPos (e.Name) e.Pattern) + s.FnPatch (s.Label t.SrcPos e.Name) + , Opt Drive Spec NoOpt NoDrive NoSpec : e._ s.Label e._ + = (s.Label ); + + s.FnPatch (LegacySpec t.SrcPos (e.Name) e.Pattern) = ( - Spec () + LegacySpec () ); } -$SPEC PatchAST-Body s.FN-PATCH e.body; - PatchAST-Body { s.FnPatch Sentences e.Sentences = Sentences ; @@ -465,8 +469,6 @@ PatchAST-Body { >; } -$SPEC PatchAST-Sentence s.FN-PATCH t.sentence; - PatchAST-Sentence { s.FnPatch ((e.Pattern) e.ConditionsAndAssigns (e.Result) (e.Blocks)) = { e.Expr = ; } : s.FnPatchExpr @@ -478,8 +480,6 @@ PatchAST-Sentence { ); } -$SPEC PatchAST-Chain s.FN-PATCH s.FN-PATCH-EXPR e.chain; - PatchAST-Chain { s.FnPatch s.FnPatchExpr e.ConditionsAndAssigns = ; } -$SPEC PatchAST-Blocks s.FN-PATCH e.blocks; - PatchAST-Blocks { s.FnPatch e.Blocks = ; } -$SPEC PatchAST-Expr s.FN-PATCH e.expr; - PatchAST-Expr { s.FnPatch e.Expression = : ((e.NewEntries) (e.Locals)) e.AST^ + = : e.AST^ + = : e.Locals^ = e.NewEntries e.Entries : e.Entries^ @@ -758,6 +756,27 @@ UpdateAccum { = ((e.Entries) (e.Locals (e.Name t.SrcPos))); } +CleanupUndefinedOpts { + (e.Entries) (e.Locals) e.AST + = : e.Entries^ + = : e.Locals^ + = : e.Defined + = +} + CleanupLocals { e.Locals-B (e.Name t._) e.Locals-E (e.Entries) , e.Entries : e._ ((e.Name) t.SrcPos) e._ diff --git a/src/compiler/GST.ref b/src/compiler/GST.ref index 8c4b2581..bd7a36a6 100644 --- a/src/compiler/GST.ref +++ b/src/compiler/GST.ref @@ -72,7 +72,8 @@ TileCandidates { { (e.AlignedPattern t.Last) (t.First e.AlignedResult) = ; } >; @@ -155,6 +156,8 @@ OverlapChain { >; } +*$NOOPT ZipItems + ZipItems { ((s.CurIndexP t.PatternItem) e.Pattern) ((s.CurIndexR t.ResultItem) e.Result) = @@ -242,9 +245,9 @@ FindHeavyTile { { (s.MaxWeight s.IndexP s.IndexR e.MaxItems) (s.Weight s.CurIndexP s.CurIndexR e.Items) - = + = : { - '<' = + '-' = (s.Weight s.CurIndexP s.CurIndexR e.Items) (s.MaxWeight s.IndexP s.IndexR e.MaxItems); diff --git a/src/compiler/Generator-Native.ref b/src/compiler/Generator-Native.ref index a8a1bf72..89a6e356 100644 --- a/src/compiler/Generator-Native.ref +++ b/src/compiler/Generator-Native.ref @@ -118,19 +118,11 @@ NameAndCookies { '"' '", COOKIE1_, COOKIE2_'; } -FormatOffsets { - e.Chars Offset s.Offset e.Text - = e.Chars ; - - e.Chars = e.Chars; -} - GenCommand-Native { /* -------------------------------------------------------------------------*/ /* Создания глобальных объектов, общие команды */ - (e.Indent) (CmdComment e.Text) - = (e.Indent) (e.Indent '//' ); + (e.Indent) (CmdComment s.FnText) = (e.Indent) (e.Indent '//' ); (e.Indent) (CmdCEnum-Start e.Prefix) = (e.Indent) () (e.Indent 'enum ' e.Prefix ' {'); diff --git a/src/compiler/Generator-RASL.ref b/src/compiler/Generator-RASL.ref index 2964ce76..a9c29d33 100644 --- a/src/compiler/Generator-RASL.ref +++ b/src/compiler/Generator-RASL.ref @@ -8,7 +8,7 @@ $EXTERN PrintErr; $INCLUDE "Opcodes"; -$DRIVE NumberFromOpcode, NumberFromBracket, BlockTypeNumber; +*$xDRIVE NumberFromOpcode, NumberFromBracket, BlockTypeNumber $ENTRY GenProgram-RASL { ( @@ -93,19 +93,19 @@ BytesFromStringList { >; } -$INLINE BytesFromString; +*$xDRIVE BytesFromString BytesFromString { e.String = ; } -$INLINE Asciiz; +*$xDRIVE Asciiz Asciiz { e.String = 0; } -$INLINE PutBlock; +*$xDRIVE PutBlock PutBlock { s.Type e.Bytes = @@ -126,7 +126,7 @@ PutWordLE { = ; } -$DRIVE NameWithSign-Bytes; +*$xDRIVE NameWithSign-Bytes NameWithSign-Bytes { GN-Entry e.Name = >; @@ -149,12 +149,12 @@ GenCommand-Globals { >; - (e.Labels) (CmdMetatable s.ScopeClass (e.Name) e.Table) + (e.Labels) (CmdMetatable (e.Name) e.Table) = : s.Count e.Table^ = (e.Labels) + >; - (e.Labels) (CmdConditionFuncDecsrRasl s.ScopeClass e.Name) + (e.Labels) (CmdConditionFuncDecsrRasl e.Name) = (e.Labels) - >; + >; - (e.Labels) (CmdConditionFuncDecsrNative s.ScopeClass e.Name) + (e.Labels) (CmdConditionFuncDecsrNative e.Name) = (e.Labels) - >; + >; (e.Labels) (CmdNativeFuncDescr s.ScopeClass e.Name) = (e.Labels) @@ -389,7 +389,7 @@ GenCommand-RASL { ; } -$INLINE PutCommand; +*$xDRIVE PutCommand PutCommand { s.Symbolic = ( 0 0 0); @@ -410,7 +410,7 @@ PutCommand { }; } -$DRIVE CreateCommandTag; +*$xDRIVE CreateCommandTag CreateCommandTag { ElOpenBracket = ElBracket; @@ -423,7 +423,7 @@ CreateCommandTag { s.Other = s.Other; } -$DRIVE CreateCommandInfo; +*$xDRIVE CreateCommandInfo CreateCommandInfo { ElChar s.Char = ; @@ -471,9 +471,9 @@ ResolveLabeledDestinations { = : s.RelativeJump - = + = : { - '<' + '-' = : (s.JumpHigh) s.JumpLow = e.ReadyRASL diff --git a/src/compiler/GenericMatch.ref b/src/compiler/GenericMatch.ref index 053e754d..752a8042 100644 --- a/src/compiler/GenericMatch.ref +++ b/src/compiler/GenericMatch.ref @@ -1,7 +1,10 @@ $INCLUDE "LibraryEx"; *$FROM TreeUtils -$EXTERN ExtractVariables, NewVarName; +$EXTERN ExtractVariables, NewVarName, ApplyContractions; + + +gen_e__ { e.arg = e.arg } /** @@ -36,64 +39,99 @@ $ENTRY GenericMatch { ((e.Pattern) ':' (e.LPattern)) > : { - Success (() (e.Assigns)) = Clear ; + /* Если все решения без сужений, то берём первое */ + Success (e._ () (e.Assigns)) e.OtherSolutions + , : True + = Clear ; + + Success /* пусто */ = Failure; + Success e.Solutions = Contracted e.Solutions; - Failure = Failure; + Undefined = Undefined; } } +AllUncontracted { + e.Solutions + = + : { + /* пусто */ = True; + e._ = False; + } +} + /** - == Success t.Result* | Undefined | Failure + == Success t.Result* | Undefined t.Contr ::= (t.Var ':' e.Val) t.Equation ::= ((e.Expr) ':' (e.LExpr)) t.Assign ::= (e.Val ':' t.Var) - t.Result ::= ((t.Contr*) (t.Assign*)) + t.Result ::= (e.UsedVars^ (t.Contr*) (t.Assign*)) */ $ENTRY Solve-Drive { (e.UsedVars) ((e.Expr) ':' (e.Lexpr)) - = : e.Contrs = : e.Expr^ = : { - e.Begin Generalize (e.Intervals) e.End = Undefined; + e._ (Generalize (e.Intervals)) e._ = Undefined; + e._ Undefined e._ = Undefined; + e._ (Success (e._) AfterOpen (e._) (e._)) e._ = Undefined; - /* пусто */ = Failure; - - e.Success - = - : { - True = Undefined; - - False = Success ; - }; + e.Success = Success ; }; } /* Проверка на наличие поднятого флага в решениях */ IsFlagOpen { - Success AfterOpen (e.Contrs) (e.Assigns) e.Rest - = True; + e._ (Success (e._) AfterOpen (e._) (e._)) e._ = True; + + e._ = False; +} - Success None (e.Contrs) (e.Assigns) e.Rest - = ; +/* + Преобразует решения в нужный формат для Solve-Drive + + == t.Sol* - /* пусто */ = False; + t.Sol ::= (e.UsedVars (t.Contr*) (t.Assign*)) + e.RawSol ::= (Success (e.UsedVars) s.OpenFlag (t.Contr*) (t.Assign*)) +*/ +CombineResults-Drive { + e.RawSolutions + = ':' t.Var) + } + e.Assigns + > + : e.Assigns^ + = (e.UsedVars (e.Contrs) (e.Assigns)); + } + e.RawSolutions + >; } /** - == Success ((t.Contr*) (t.Assign*))* (t.Assign*) (e.Left^) - | Failure + == (e.UsedVars^) ((t.Contr*) (t.Assign*))* (t.Assign*) (e.Left^) t.Contr ::= (t.Var ':' e.Val) t.Assign ::= (e.Val ':' t.Var) @@ -102,75 +140,40 @@ IsFlagOpen { $ENTRY Solve-Spec { (e.UsedVars) (e.Left) (e.Right) = : e.Left^ - = ; } -Solve-Spec-Aux { +Solve-Spec-DoFindGeneralization { (e.UsedVars) ((e.L) ':' (e.R)) (e.GenAssigns) = ) - ((e.L) ':' (e.R)) - (/* пусто */) + (None /* сужения */) + (E (e.L) ':' (e.R)) + (/* присваивания */) > : { - e.Begin Generalize (e.Intervals) e.End + e._ (Generalize (e.Intervals)) e._ = (e.L) (e.GenAssigns) > : (e.UsedVars^) (e.L^) (e.GenAssigns^) - = ; - /* пусто */ = Failure; - e.Success - = Success - + = (e.UsedVars) + (e.GenAssigns) (); } } -/* - Инициализирует список сужений тривиальными сужениями - - == t.Contr* -*/ - -InitContractions { - e.Expr - = : e.Vars - = -} - -/* - Удаляет тривиальные сужения из набора сужений - - == t.Contr* -*/ - -RemoveTrivialContractions { - e.Contrs - = -} - /* Объединяет два интервала, если они пересекаются. В остальных случаях возвращает исходный список интервалов. @@ -218,36 +221,30 @@ GetExtremum { } /* - Преобразует решения в нужный формат для Solve-Drive и Solve-Spec + Преобразует решения в нужный формат для Solve-Spec - == t.Sol* + == t.Sol* t.Sol ::= ((t.Contr*) (t.Assign*)) - e.RawSol ::= Success s.OpenFlag (t.Contr*) (t.Assign*) + e.RawSol ::= (Success (e.UsedVars) s.OpenFlag (t.Contr*) (t.Assign*)) */ -CombineResults { - (e.Solutions) - Success s.OpenFlag (e.Contrs) (e.Assigns) e.Rest - = ) - ( ':' t.Var) - } - e.Assigns - >) - ) - ) - e.Rest +CombineResults-Spec { + e.RawSolutions + = ':' t.Var) + } + e.Assigns + > + : e.Assigns^ + = ((e.Contrs) (e.Assigns)); + } + e.RawSolutions >; - - (e.Solutions) /* пусто */ - = e.Solutions; } /* @@ -259,70 +256,58 @@ CombineResults { t.Interval ::= ('{' s.A s.B '}') */ +*$NOOPT DoGeneralize, DoGeneralize-Rec + DoGeneralize { - (e.UsedVars) (t.Interval e.Intervals) - (e.Expr) (e.Assigns) - = : (e.UsedVars^) (e.Expr^) (e.Assigns^) - = ; + = ; - (e.UsedVars) () - (e.Expr) (e.Assigns) + (e.UsedVars) (/* кончились интервалы */) (e.Expr) (e.Assigns) = (e.UsedVars) (e.Expr) (e.Assigns); } -DoGeneralize-Aux { - (e.UsedVars) ('{' s.A s.B '}') (e.Begin) - (e.E1 ('{'s.A'}') e.Inner ('{'s.B'}') e.E2) (e.Assigns) +DoGeneralize-Rec { + (e.UsedVars) ('{' s.A s.B '}') + (e.Begin) (e.E1 ('{'s.A'}') e.Inner ('{'s.B'}') e.E2) (e.Assigns) = : s.VarType - = - > - : e.VarVal + = : e.VarVal = : (e.UsedVars^) s.VarType^ e.New = (e.UsedVars) - (e.E1 ('{'s.A'}') (Var s.VarType e.New) ('{'s.B'}') e.E2) - (e.Assigns (e.VarVal ':' (s.VarType e.New))); + (e.Begin e.E1 ('{'s.A'}') (Var s.VarType e.New) ('{'s.B'}') e.E2) + ((e.VarVal ':' (Var s.VarType e.New)) e.Assigns); - (e.UsedVars) t.Interval (e.Begin) - ((Brackets e.E) e.Rest) (e.Assigns) - = - : (e.UsedVars^) (e.E^) (e.Assigns^) - = ; (e.UsedVars) t.Interval (e.Begin) - ((ADT-Brackets (e.Name) e.E) e.Rest) (e.Assigns) - = - : (e.UsedVars^) (e.E^) (e.Assigns^) - = ; - (e.UsedVars) t.Interval (e.Begin) - (t.T e.Rest) (e.Assigns) - = ; - (e.UsedVars) t.Interval (e.Begin) - () (e.Assigns) + (e.UsedVars) t.Interval (e.Begin) () (e.Assigns) = (e.UsedVars) (e.Begin) (e.Assigns); } @@ -334,35 +319,6 @@ GetVarType { e.Other = 'e'; } -ApplyAssignments-toExpr { - (t.Assign e.Rest) e.Expr - = - >; - - () e.Expr = e.Expr; -} - -ApplyAssignment-toExpr { - (e.Val ':' (s.Type e.Index)) e.Begin (Var s.Type e.Index) e.End - = - e.Val - ; - - t.Assign e.Begin (Brackets e.E) e.End - = - (Brackets ) - ; - - t.Assign e.Begin (ADT-Brackets e.E) e.End - = - (ADT-Brackets ) - ; - - t.Assign e.E = e.E; -} - /* Добавляет в левую часть уравнения метки координат @@ -387,6 +343,14 @@ DoAddCoordinateLabels { = (Var s.Mode e.Index) ('{'s.CoordNumber'}') >; + ((ScrVar s.Mode e.Index) e.Rest) s.CoordNumber + = (ScrVar s.Mode e.Index) ('{'s.CoordNumber'}') + >; + + ((WhVar s.Mode e.Index) e.Rest) s.CoordNumber + = (WhVar s.Mode e.Index) ('{'s.CoordNumber'}') + >; + ((ClosureBrackets e.Inner) e.Rest) s.CoordNumber = (ClosureBrackets e.Inner) ('{'s.CoordNumber'}') >; @@ -395,9 +359,15 @@ DoAddCoordinateLabels { = (CallBrackets e.Inner) ('{'s.CoordNumber'}') >; + ((ColdCallBrackets e.Inner) e.Rest) s.CoordNumber + = (CallBrackets e.Inner) ('{'s.CoordNumber'}') + >; + ((Brackets e.Expr) e.Rest) s.CoordNumber - = (Brackets ('{'s.CoordNumber'}') - >) + = (Brackets + ('{'s.CoordNumber'}') + > + ) : { (Brackets e.Inner ('{'s.LastCoord'}')) = (Brackets e.Inner ('{'s.LastCoord'}')) @@ -406,8 +376,10 @@ DoAddCoordinateLabels { }; ((ADT-Brackets (e.Name) e.Expression) e.Rest) s.CoordNumber - = (ADT-Brackets (e.Name) ('{'s.CoordNumber'}') - >) + = (ADT-Brackets + (e.Name) ('{'s.CoordNumber'}') + > + ) : { (ADT-Brackets e.Inner ('{'s.LastCoord'}')) = (ADT-Brackets e.Inner ('{'s.LastCoord'}')) @@ -415,82 +387,37 @@ DoAddCoordinateLabels { > }; - (e.Other) s.CoordNumber - = e.Other; + (/* пусто */) s.CoordNumber = /* пусто */; } /* Упрощение координат (редуцирование их бессмысленного скопления) - - - == (e.Contractions) t.Clash^* (t.Assign^*) */ -SimplifyCoordinates { - (e.Contrs) e.Clashes (e.Assigns) - = (e.Contrs) - - () -} - -SimplifyCoordinates-Symm { - (e.Contrs) e.SymmClashes (e.Assigns) - = (e.Contrs) - - () -} - -SimplifyCoordinates-Clash { - ((e.Left) ':' (e.Right)) - = (() ':' (e.Right)) -} - SimplifyCoordinates-SymmClash { - (e.L '=' e.R) - = ( '=' ) -} - -SimplifyCoordinates-Assign { - (e.Left ':' t.Right) - = ( ':' t.Right) + (s.Type e.L '=' e.R) + = (s.Type '=' ) } -SimplifyCoordinates-Expr { +SimplifyCoordinates { /* {k} {m} E {n} ↦ {m} E {n} */ ('{'s.K'}') ('{'s.M'}') e.E ('{'s.N'}') - = ; + = ; /* {k} E {m} {n} ↦ {k} E {m} */ ('{'s.K'}') e.E ('{'s.M'}') ('{'s.N'}') - = ; + = ; /* {m} {n} ↦ ε */ ('{'s.M'}') ('{'s.N'}') = /* пусто */; - ('{'s.M'}') e.E ('{'s.N'}') - = ('{'s.M'}') ('{'s.N'}'); + ('{'s.M'}') e.E ('{'s.N'}') = ('{'s.M'}') e.E ('{'s.N'}'); - e.E = ; + /* пусто */ = /* пусто */; } -SimplifyCoordinates-Expr-Inner { - /* Ê1{k} {m} {n}Ê2 ↦ Ê1{k} {n}Ê2 */ - e.E1 ('{'s.K'}') ('{'s.M'}') ('{'s.N'}') e.E2 - = ; - - e.Begin (Brackets e.E) e.End - = - (Brackets ) - ; - - e.Begin (ADT-Brackets (e.Name) e.E) e.End - = - (ADT-Brackets (e.Name) ) - ; - - e.E = e.E; -} +*$NOOPT Solve-Clashes /* @@ -499,199 +426,250 @@ SimplifyCoordinates-Expr-Inner { e.Contractions ::= s.OpenFlag t.Contr* s.OpenFlag ::= None | AfterOpen t.Contr ::= (t.Var ':' e.Val) - t.Clash ::= ((e.L) ':' (e.R)) + t.Clash ::= (s.ClashType (e.L) ':' (e.R)) + s.ClashType ::= E | T t.Assign ::= (e.Val ':' t.Var) t.Result - ::= Success s.OpenFlag (t.Contr*) (t.Assign*) - | Generalize ( ('{' s.BeginCoord s.EndCoord '}')+ ) - | ε + ::= (Success (e.UsedVars) s.OpenFlag (t.Contr*) (t.Assign*)) + | (Generalize ( ('{' s.BeginCoord s.EndCoord '}')+ )) */ Solve-Clashes { /* {m} T {n} : t.X ↦ {m} T {n} ← t.X */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.T ('{'s.N'}')) ':' (t.X)) + (T (('{'s.M'}') t.T ('{'s.N'}')) ':' ((Var 't' e.Index))) e.ClashesEnd (e.Assigns) - , : True - , t.X : (Var 't' e.Tindex) = ; /* {m} Sym {n} : s.X ↦ {m} Sym {n} ← s.X */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.Sym ('{'s.N'}')) ':' (t.X)) + (T (('{'s.M'}') t.Sym ('{'s.N'}')) ':' ((Var 's' e.Index))) e.ClashesEnd (e.Assigns) , : True - , t.X : (Var 's' e.Sindex) = ; + /* {m} #var {n} : s.X ↦ нет решений */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') (ScrVar e._) ('{'s.N'}')) ':' ((Var 's' e.Index))) + e.ClashesEnd (e.Assigns) + = /* нет решений */; + + /* {m} !var {n} : s.X ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') (WhVar e._) ('{'s.N'}')) ':' ((Var 's' e.Index))) + e.ClashesEnd (e.Assigns) + = Undefined; + /* {m} (E) {n} : (P) ↦ {m} E {n} : P */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.L ('{'s.N'}')) ':' (t.R)) + (T (('{'s.M'}') (Brackets e.LBody) ('{'s.N'}')) ':' ((Brackets e.RBody))) e.ClashesEnd (e.Assigns) - , t.L : (Brackets e.LBody) - , t.R : (Brackets e.RBody) = + (E + () + ':' (e.RBody) + ) e.ClashesEnd (e.Assigns) >; - /* {m} [X E] {n} : [X P] ↦ {m} E {n} : P */ + /* {m} [X E] {n} : [X P] ↦ {m} [X E] {n} : P */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.L ('{'s.N'}')) ':' (t.R)) + (T + (('{'s.M'}') (ADT-Brackets (e.Name) e.LBody) ('{'s.N'}')) + ':' ((ADT-Brackets (e.Name) e.RBody)) + ) e.ClashesEnd (e.Assigns) - , t.L : (ADT-Brackets (e.Name) e.LBody) - , t.R : (ADT-Brackets (e.Name) e.RBody) = + (E () ':' (e.RBody)) e.ClashesEnd (e.Assigns) >; /* {m} [X E] {n} : [Y P] ↦ нет решений */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.L ('{'s.N'}')) ':' (t.R)) + (T (('{'s.M'}') (ADT-Brackets e._) ('{'s.N'}')) ':' ((ADT-Brackets e._))) e.ClashesEnd (e.Assigns) - , t.L : (ADT-Brackets e._) - , t.R : (ADT-Brackets e._) = /* нет решений */; - /* {m} [E] {n} : (P) ↦ нет решений */ + /* {m} [X E] {n} : (P) ↦ нет решений */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.L ('{'s.N'}')) ':' (t.R)) + (T (('{'s.M'}') (ADT-Brackets e._) ('{'s.N'}')) ':' ((Brackets e._))) e.ClashesEnd (e.Assigns) - , t.L : (ADT-Brackets e._) - , t.R : (Brackets e._) = /* нет решений */; - /* {m} (E) {n} : [P] ↦ нет решений */ + /* {m} (E) {n} : [X P] ↦ нет решений */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.L ('{'s.N'}')) ':' (t.R)) + (T (('{'s.M'}') (Brackets e._) ('{'s.N'}')) ':' ((ADT-Brackets e._))) e.ClashesEnd (e.Assigns) - , t.R : (ADT-Brackets e._) - , t.L : (Brackets e._) = /* нет решений */; /* {m} (E) {n} : Psym ↦ нет решений */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.L ('{'s.N'}')) ':' (t.Psym)) + (T (('{'s.M'}') (Brackets e._) ('{'s.N'}')) ':' (t.Psym)) e.ClashesEnd (e.Assigns) - , t.L : (Brackets e.LBody) , : True = /* нет решений */; - /* {m} [E] {n} : Psym ↦ нет решений */ + /* {m} [X E] {n} : Psym ↦ нет решений */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.L ('{'s.N'}')) ':' (t.Psym)) + (T (('{'s.M'}') (ADT-Brackets e._) ('{'s.N'}')) ':' (t.Psym)) e.ClashesEnd (e.Assigns) - , t.L : (ADT-Brackets (e.LName) e.LBody) , : True = /* нет решений */; /* {m} Sym {n} : (P) ↦ нет решений */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.Sym ('{'s.N'}')) ':' (t.R)) + (T (('{'s.M'}') t.Sym ('{'s.N'}')) ':' ((Brackets e._))) e.ClashesEnd (e.Assigns) , : True - , t.R : (Brackets e.RBody) = /* нет решений */; - /* {m} Sym {n} : [P] ↦ нет решений */ + /* {m} #var {n} : (P) ↦ нет решений */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.Sym ('{'s.N'}')) ':' (t.R)) + (T (('{'s.M'}') (ScrVar e._) ('{'s.N'}')) ':' ((Brackets e._))) + e.ClashesEnd (e.Assigns) + = /* нет решений */; + + /* {m} !var {n} : (P) ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') (WhVar e._) ('{'s.N'}')) ':' ((Brackets e._))) + e.ClashesEnd (e.Assigns) + = Undefined; + + /* {m} Sym {n} : [X P] ↦ нет решений */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') t.Sym ('{'s.N'}')) ':' ((ADT-Brackets e._))) e.ClashesEnd (e.Assigns) , : True - , t.R : (ADT-Brackets (e.RName) e.RBody) = /* нет решений */; + /* {m} #var {n} : [X P] ↦ нет решений */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') (ScrVar e._) ('{'s.N'}')) ':' ((ADT-Brackets e._))) + e.ClashesEnd (e.Assigns) + = /* нет решений */; + + /* {m} !var {n} : [X P] ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') (WhVar e._) ('{'s.N'}')) ':' ((ADT-Brackets e._))) + e.ClashesEnd (e.Assigns) + = Undefined; + /* {m} t.X {n} : (P) ↦ t.X → (e.NEW) */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.X ('{'s.N'}')) ':' (t.P)) + (T (('{'s.M'}') (Var 't' e.Index) ('{'s.N'}')) ':' ((Brackets e.PBody))) e.ClashesEnd (e.Assigns) - , t.X : (Var 't' e.Tindex) - , t.P : (Brackets e.PBody) - = : t.NewVars 'e' e.NewIndex + = : t.NewVars 'e' e.NewIndex = >; - /* {m} t.X {n} : [P] ↦ t.X → [e.NEW] */ + /* {m} !t.X {n} : (P) ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') (WhVar 't' e.Index) ('{'s.N'}')) ':' ((Brackets e.PBody))) + e.ClashesEnd (e.Assigns) + = Undefined; + + /* {m} t.X {n} : [X P] ↦ t.X → [X e.NEW] */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.X ('{'s.N'}')) ':' (t.P)) + (T + (('{'s.M'}') (Var 't' e.Index) ('{'s.N'}')) + ':' ((ADT-Brackets (e.Name) e.PBody)) + ) e.ClashesEnd (e.Assigns) - , t.X : (Var 't' e.Tindex) - , t.P : (ADT-Brackets (e.PName) e.PBody) - = : t.NewVars 'e' e.NewIndex + = : t.NewVars 'e' e.NewIndex = >; + /* {m} !t.X {n} : [X P] ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T + (('{'s.M'}') (WhVar 't' e.Index) ('{'s.N'}')) + ':' ((ADT-Brackets (e.Name) e.PBody)) + ) + = Undefined; + /* {m} t.X {n} : Psym ↦ t.X → s.NEW */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.X ('{'s.N'}')) ':' (t.Psym)) + (T (('{'s.M'}') (Var 't' e.Index) ('{'s.N'}')) ':' (t.Psym)) e.ClashesEnd (e.Assigns) - , t.X : (Var 't' e.Tindex) , : True - = : t.NewVars 's' e.NewIndex + = : t.NewVars 's' e.NewIndex = >; + /* {m} t.X {n} : Psym ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') (WhVar 't' e.Index) ('{'s.N'}')) ':' (t.Psym)) + e.ClashesEnd (e.Assigns) + = Undefined; + /* {m} s.X {n} : X ↦ s.X → X */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.X ('{'s.N'}')) ':' (t.S)) + (T (('{'s.M'}') (Var 's' e.Index) ('{'s.N'}')) ':' ((Symbol s.Type e.Info))) e.ClashesEnd (e.Assigns) - , t.X : (Var 's' e.Sindex) - , t.S : (Symbol e._) = >; + /* {m} s.X {n} : X ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (T (('{'s.M'}') (WhVar 's' e.Index) ('{'s.N'}')) ':' ((Symbol s.Type e.Info))) + e.ClashesEnd (e.Assigns) + = Undefined; + /* {m} X {n} : X ↦ стираем */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.X ('{'s.N'}')) ':' (t.X)) + (T + (('{'s.M'}') (Symbol s.Type e.Info) ('{'s.N'}')) + ':' ((Symbol s.Type e.Info)) + ) e.ClashesEnd (e.Assigns) - , t.X : (Symbol e._) = : True + = /* решений нет */; + /* E : e.X ↦ E ← e.X */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((e.E) ':' (t.X)) + (E (e.E) ':' ((Var 'e' e.Index))) e.ClashesEnd (e.Assigns) - , t.X : (Var 'e' e.XIndex) = ; /* {m} e.X E {n} : ε ↦ e.X → ε */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.X e.E ('{'s.N'}')) ':' (/* пусто */)) + (E (('{'s.M'}') (Var 'e' e.Index) e.E ('{'s.N'}')) ':' (/* пусто */)) e.ClashesEnd (e.Assigns) - , t.X : (Var 'e' e.XIndex) = >; + /* {m} !e.X E {n} : ε ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (E (('{'s.M'}') (WhVar 'e' e.Index) e.E ('{'s.N'}')) ':' (/* пусто */)) + e.ClashesEnd (e.Assigns) + = Undefined; + /* {m} T E {n} : ε ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.T e.E ('{'s.N'}')) ':' (/* пусто */)) + (E (('{'s.M'}') t.T e.E ('{'s.N'}')) ':' (/* пусто */)) e.ClashesEnd (e.Assigns) , : True = /* решений нет */; /* ε : E1 Pt E2 ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((/* пусто */) ':' (e.E1 t.Pt e.E2)) + (E (/* пусто */) ':' (e.E1 t.Pt e.E2)) e.ClashesEnd (e.Assigns) , : True = /* решений нет */; /* ε : ε ↦ стираем */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((/* пусто */) ':' (/* пусто */)) + (E (/* пусто */) ':' (/* пусто */)) e.ClashesEnd (e.Assigns) = : True , : True - , : True - = - : (e.Left1) (e.Left2) + = : (e.Left1) (e.Left2) = ; /* E {m} T {n} : P Pt ↦ E {m} : P && {m} T {n} : Pt */ /* E {m} E* T {n} : P Pt ↦ E {m} E* {n} : P && {m} T {n} : Pt */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((e.E t.T ('{'s.N'}')) ':' (e.P t.Pt)) + (E (e.E t.T ('{'s.N'}')) ':' (e.P t.Pt)) e.ClashesEnd (e.Assigns) , : True , : True - , : True - = - : (e.Left1) (e.Left2) + = : (e.Left1) (e.Left2) = ; /* {m} e.X E {n} : Pt P ↦ e.X → t.NEW1 e.NEW2 || e.X → ε */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') t.X e.E ('{'s.N'}')) ':' (t.Pt e.P)) + (E (('{'s.M'}') (Var 'e' e.Index) e.E ('{'s.N'}')) ':' (t.Pt e.P)) e.ClashesEnd (e.Assigns) - , t.X : (Var 'e' e.XIndex) , : True - = : t.NewVars1 't' e.New1 - = : t.NewVars2 'e' e.New2 + = : t.NewVars1 't' e.New1 + = : t.NewVars2 'e' e.New2 + = + : (e.Left1) (e.Left2) = : e.Branch1 = : e.Branch2 + /* + Сначала ищем решение для более короткой ветки вычислений (где + переменная стирается), а затем для более длинной. Если сначала + решать уравнения для более длинной ветки, то в патологических + случаях вида + e.X : 'abc...xyz' + размер поля зрения в пике будет квадратичным: + + + + + ... + + но при этом все ветви, кроме первой, обрежутся. + + Поэтому сначала решаем вторую ветвь, а потом первую. При этом + относительный порядок решений важен — решения второй ветви + должны располагаться после решений первой. + */ + = : e.Solutions2 = - ; + e.Solutions2; /* {m} E e.X {n} : P Pt ↦ e.X → e.NEW1 t.NEW2 || e.X → ε */ (e.UsedVars) (e.Contrs) e.ClashesStart - ((('{'s.M'}') e.E t.X ('{'s.N'}')) ':' (e.P t.Pt)) + (E (('{'s.M'}') e.E (Var 'e' e.Index) ('{'s.N'}')) ':' (e.P t.Pt)) e.ClashesEnd (e.Assigns) - , t.X : (Var 'e' e.XIndex) , : True - = : t.NewVars1 'e' e.New1 - = : t.NewVars2 't' e.New2 + = : t.NewVars1 'e' e.New1 + = : t.NewVars2 't' e.New2 + = + : (e.Left1) (e.Left2) = : e.Branch1 = : e.Branch2 + /* См. комментарий в предыдущем предложении. */ + = : e.Solutions2 = - ; + e.Solutions2; + + /* {m} !e.X E {n} : Pt P ↦ e.X → t.NEW1 e.NEW2 || e.X → ε */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (E (('{'s.M'}') (WhVar 'e' e.Index) e.E ('{'s.N'}')) ':' (t.Pt e.P)) + e.ClashesEnd (e.Assigns) + = Undefined; + + /* {m} E !e.X {n} : P Pt ↦ e.X → e.NEW1 t.NEW2 || e.X → ε */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (E (('{'s.M'}') e.E (WhVar 'e' e.Index) ('{'s.N'}')) ':' (e.P t.Pt)) + e.ClashesEnd (e.Assigns) + = Undefined; /* могли остаться только клэши вида E : e.X P e.Y */ (e.UsedVars) (s.OpenFlag e.Contrs) - ((e.E) ':' (t.eX e.P t.eY)) + (E (e._ (WhVar e._) e._) ':' ((Var 'e' e._) e.P (Var 'e' e._))) + e.ClashesEnd (e.Assigns) + = Undefined; + + (e.UsedVars) (s.OpenFlag e.Contrs) + (E (e.E) ':' ((Var 'e' e._) e.P (Var 'e' e._))) e.ClashesEnd (e.Assigns) - , t.eX : (Var 'e' e.XIndex) - , t.eY : (Var 'e' e.YIndex) , e.E : ('{'s.M'}') e.Inner ('{'s.N'}') , : False , s.OpenFlag : AfterOpen - = Generalize (('{' s.M s.N '}')); + = (Generalize (('{' s.M s.N '}'))); (e.UsedVars) (e.Contrs) - ((('{'s.M'}') t.eVar ('{'s.N'}')) ':' (t.eX e.P t.eY)) + (E (('{'s.M'}') t.eVar ('{'s.N'}')) ':' ((Var 'e' e._) e.P (Var 'e' e._))) e.ClashesEnd (e.Assigns) , t.eVar : (Var 'e' e.Index) - , t.eX : (Var 'e' e.XIndex) - , t.eY : (Var 'e' e.YIndex) , : True - = Generalize (('{' s.M s.N '}')); + = (Generalize (('{' s.M s.N '}'))); (e.UsedVars) (e.Contrs) - ((e.E) ':' (t.eX e.P t.eY)) + (E (e.E) ':' ((Var 'e' e.OpenIndex) e.P (Var 'e' e.ClosedIndex))) e.ClashesEnd (e.Assigns) - , t.eX : (Var 'e' e.XIndex) - , t.eY : (Var 'e' e.YIndex) = : (e.Parts) = } @@ -881,7 +927,7 @@ Solve-Clashes { /* клэши закончились */ (e.UsedVars) (e.Contrs) (e.Assigns) - = : (e.Assigns^) (e.SymmClashes) + = : (e.Assigns^) (e.SymmClashes) = : True + , : True = ; +} + SplitLeftPart-Aux { /* Точки разбиения добавляются между двумя смежными термами */ (e.Begin) (t.T1 t.T2 e.Rest) (e.Parts) - , : True - , : True + , : True + , : True = : True - , : True + , : True + , : True = : True + , : True = (e.Parts (e.Begin t.T ('sp' ('{'s.Coord'}')))); (e.Begin) (t.T e.Rest) (e.Parts) - , : True + , : True = ; /* Точки разбиения находятся «внутри» e-параметров */ @@ -1047,20 +1096,20 @@ SplitSolve { * {m} E {n} : e.X P e.Y ↦ ε ← e.X, {m} E {n} : P e.Y * ↑ (e.UsedVars) (e.Contrs) - ((('sp' ('{'s.M'}')) e.E ('{'s.N'}')) ':' (t.eX e.P t.eY)) + (E (('sp' ('{'s.M'}')) e.E ('{'s.N'}')) ':' (t.eX e.P t.eY)) e.ClashesEnd (e.Assigns) , t.eX : (Var 'e' e.XIndex) , t.eY : (Var 'e' e.YIndex) = ; * {k} E1 T2 {m} T3 E4 {n} : e.X P e.Y ↦ {k} E1 T2 {m} ← e.X, * ↑ {m} T3 E4 {n} : P e.Y (e.UsedVars) (e.Contrs) - ( + (E ( ('{'s.K'}') e.E1 t.T2 ('sp' ('{'s.M'}')) @@ -1069,20 +1118,20 @@ SplitSolve { ':' (t.eX e.P t.eY) ) e.ClashesEnd (e.Assigns) - , : True - , : True + , : True + , : True , t.eX : (Var 'e' e.XIndex) , t.eY : (Var 'e' e.YIndex) = ; * E1 {m} E2* T3 . T4 E5* {n} E6 : e.X P e.Y ↦ E1 {m} E2* T3 {n} ← e.X, * ↑ {m} T4 E5* {n} E6 : P e.Y (e.UsedVars) (e.Contrs) - ( + (E ( e.E1 ('{'s.M'}') e.E2 t.T3 ('sp') t.T4 @@ -1092,14 +1141,14 @@ SplitSolve { ) e.ClashesEnd (e.Assigns) , : False - , : True - , : True + , : True + , : True , : False , t.eX : (Var 'e' e.XIndex) , t.eY : (Var 'e' e.YIndex) = ; @@ -1107,7 +1156,7 @@ SplitSolve { * {m} E {n} : e.X P e.Y ↦ {m} E {n} ← e.X, ε : P e.Y * ↑ (e.UsedVars) (e.Contrs) - ( + (E (('{'s.M'}') e.E ('sp' ('{'s.N'}'))) ':' (t.eX e.P t.eY) ) @@ -1116,21 +1165,21 @@ SplitSolve { , t.eY : (Var 'e' e.YIndex) = ; * ε : e.X P e.Y ↦ ε ← e.X, ε : P e.Y * ↑ (e.UsedVars) (e.Contrs) - ((('sp')) ':' (t.eX e.P t.eY)) + (E (('sp')) ':' (t.eX e.P t.eY)) e.ClashesEnd (e.Assigns) , t.eX : (Var 'e' e.XIndex) , t.eY : (Var 'e' e.YIndex) = ; * E1 e.X {m} e.Y E2 : e.L P e.R ↦ e.X → e.NEW1! t.NEW2 e.NEW3, @@ -1138,7 +1187,7 @@ SplitSolve { * {n} t.NEW2 e.NEW3 {m} e.Y E2 : P e.R * где E1 = E3 {n} E4* (e.UsedVars) (e.Contrs) - ((e.E1 ('sp' t.eX) ('{'s.M'}') t.eY e.E2) ':' (t.eL e.P t.eR)) + (E (e.E1 ('sp' t.eX) ('{'s.M'}') t.eY e.E2) ':' (t.eL e.P t.eR)) e.ClashesEnd (e.Assigns) , e.E1 : e.E3 ('{'s.N'}') e.E4 , : False @@ -1157,8 +1206,12 @@ SplitSolve { >; @@ -1168,7 +1221,7 @@ SplitSolve { * где E1 = E3 {n} E4* * E2 = E5* {m} E6 (e.UsedVars) (e.Contrs) - ((e.E1 ('sp' t.eX) e.E2) ':' (t.eL e.P t.eR)) + (E (e.E1 ('sp' t.eX) e.E2) ':' (t.eL e.P t.eR)) e.ClashesEnd (e.Assigns) , e.E1 : e.E3 ('{'s.N'}') e.E4 , : False @@ -1186,8 +1239,8 @@ SplitSolve { >; } @@ -1196,16 +1249,17 @@ SplitSolve { Формирует по списку присваиваний список симметричных клэшей и обновленный список присваиваний - + == (t.Assign*) (t.SymmClash*) == (t.Assign*) (t.SymmClash*) - t.SymmClash ::= (e.L '=' e.R) + t.SymmClash ::= (s.ClashType e.L '=' e.R) */ CreateSymmClashes { - (e.Assigns) + (e.Contrs) (e.Assigns) + = : e.Assigns^ = : (e.Assigns^) (e.SymmClashes) = (e.Assigns) (); @@ -1271,7 +1325,7 @@ CreateSymmClashesFromGroup { () >; @@ -1284,7 +1338,7 @@ CreateSymmClashesFromGroup-Aux { = ; t.CurrentAssign () (e.SymmClashes) @@ -1328,41 +1382,39 @@ ClearCoordinates { */ SeparateTermLeft { -* {a} T {b} E ↦ {a} T {b}, {b} E - ('{'s.A'}') t.T ('{'s.B'}') e.E - , : True - = - : { - True = (('{'s.A'}') t.T ('{'s.B'}')) (/* пусто */); +* {a} T {b} ε ↦ {a} T {b}, ε + ('{'s.A'}') t.T ('{'s.B'}') /* пусто */ + = (('{'s.A'}') t.T ('{'s.B'}')) (/* пусто */); - False = (('{'s.A'}') t.T ('{'s.B'}')) (('{'s.B'}') e.E); - }; + ('{'s.A'}') t.T ('{'s.B'}') e.E + = (('{'s.A'}') t.T ('{'s.B'}')) (); * {a} T E1* {b} E2 ↦ {a} T {b}, {a} E1* {b} E2 ('{'s.A'}') t.T e.E1 ('{'s.B'}') e.E2 - , : True - , : False = (('{'s.A'}') t.T ('{'s.B'}')) (('{'s.A'}') e.E1 ('{'s.B'}') e.E2); } SeparateTermRight { +* ε {a} T {b} ↦ ε, {a} T {b} + /* пусто */ ('{'s.A'}') t.T ('{'s.B'}') + = (/* пусто */) (('{'s.A'}') t.T ('{'s.B'}')); + * E {a} T {b} ↦ E {a}, {a} T {b} e.E ('{'s.A'}') t.T ('{'s.B'}') - , : True - = - : { - True = (/* пусто */) (('{'s.A'}') t.T ('{'s.B'}')); - - False = (e.E ('{'s.A'}')) (('{'s.A'}') t.T ('{'s.B'}')); - }; + = () (('{'s.A'}') t.T ('{'s.B'}')); * E1 {a} E2* T {b} ↦ E1 {a} E2* {b}, {a} T {b} - e.E1 ('{'s.A'}') e.E2 t.T ('{'s.B'}') - , : False - , : True - = (e.E1 ('{'s.A'}') e.E2 ('{'s.B'}')) - (('{'s.A'}') t.T ('{'s.B'}')); + e.Expr t.T ('{'s.B'}') + = : e.Expr^ s.A + = (e.Expr ('{'s.B'}')) (('{'s.A'}') t.T ('{'s.B'}')); +} + +LastCoordinate { + ('{'s.A'}') e.Begin ('{'s.B'}') e.End + = ('{'s.A'}') e.Begin ; + + ('{'s.A'}') e.Expr = ('{'s.A'}') e.Expr s.A; } /* @@ -1372,7 +1424,7 @@ SeparateTermRight { */ IsTautology { - (e.L '=' e.R) + (s._ e.L '=' e.R) = : e.LWithoutCoords = : e.RWithoutCoords = @@ -1407,177 +1459,95 @@ Solve-SymmClashes { (e.UsedVars) (e.Contrs) e.SymmClashes (e.Assigns) = : e.SymmClashes^ = ; } -Solve-SymmClashes-Aux { - /* {a} e.X {b} = {c} e.Y {d} ↦ e.X → e.NEW, e.Y → e.NEW */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.eX ('{'s.B'}') '=' ('{'s.C'}') t.eY ('{'s.D'}')) - e.ClashesEnd (e.Assigns) - , t.eX : (Var 'e' e.XIndex) - , t.eY : (Var 'e' e.YIndex) - = : (e.UsedVars^) 'e' e.New - = (Var 'e' e.New) : t.eNew - = - >; +MinMode { + e._ ('s' e.Index) e._ = 's' e.Index; + e._ ('t' e.Index) e._ = 't' e.Index; + ('e' e.Index) ('e' e._) = 'e' e.Index; +} - /* {a} e.X {b} = {c} t.Y {d} ↦ e.X → t.NEW, t.Y → t.NEW */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.eX ('{'s.B'}') '=' ('{'s.C'}') t.tY ('{'s.D'}')) - e.ClashesEnd (e.Assigns) - , t.eX : (Var 'e' e.XIndex) - , t.tY : (Var 't' e.YIndex) - = : (e.UsedVars^) 't' e.New - = (Var 't' e.New) : t.tNew - = - >; +*$NOOPT Solve-SymmClashes-Aux - /* {a} t.Y {b} = {c} e.X {d} ↦ t.Y → t.NEW, e.X → t.NEW */ +Solve-SymmClashes-Aux { + /* {a} u.X {b} = {c} v.Y {d} ↦ u.X → w.NEW, v.Y → w.NEW, w = min(u,v) */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.tY ('{'s.B'}') '=' ('{'s.C'}') t.eX ('{'s.D'}')) + (s._ ('{'s.A'}') t.uX ('{'s.B'}') '=' ('{'s.C'}') t.vY ('{'s.D'}')) e.ClashesEnd (e.Assigns) - , t.eX : (Var 'e' e.XIndex) - , t.tY : (Var 't' e.YIndex) - = : (e.UsedVars^) 't' e.New - = (Var 't' e.New) : t.tNew + , t.uX : (Var s.uMode e.XIndex) + , t.vY : (Var s.vMode e.YIndex) + = : s.wMode e.wIndex + = : (e.UsedVars^) e.wNew + = (Var e.wNew) : t.wNew = >; - /* {a} e.X {b} = {c} s.Y {d} ↦ e.X → s.NEW, s.Y → s.NEW */ + /* {a} #var E1 {b} = {c} #var E2 {d} ↦ {a} E1 {b} = {c} E2 {d} */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.eX ('{'s.B'}') '=' ('{'s.C'}') t.sY ('{'s.D'}')) + (s.Type + ('{'s.A'}') t.Var e.E1 ('{'s.B'}') '=' ('{'s.C'}') t.Var e.E2 ('{'s.D'}') + ) e.ClashesEnd (e.Assigns) - , t.eX : (Var 'e' e.XIndex) - , t.sY : (Var 's' e.YIndex) - = : (e.UsedVars^) 's' e.New - = (Var 's' e.New) : t.sNew + , t.Var : (ScrVar e.Var) = + e.ClashesEnd (e.Assigns) >; - /* {a} s.Y {b} = {c} e.X {d} ↦ s.Y → s.NEW, e.X → s.NEW */ + /* {a} E1 #var {b} = {c} E2 #var {d} ↦ {a} E1 {b} = {c} E2 {d} */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.sY ('{'s.B'}') '=' ('{'s.C'}') t.eX ('{'s.D'}')) + (s.Type + ('{'s.A'}') e.E1 t.Var ('{'s.B'}') '=' ('{'s.C'}') e.E2 t.Var ('{'s.D'}') + ) e.ClashesEnd (e.Assigns) - , t.eX : (Var 'e' e.XIndex) - , t.sY : (Var 's' e.YIndex) - = : (e.UsedVars^) 's' e.New - = (Var 's' e.New) : t.sNew + , t.Var : (ScrVar e.Var) = + e.ClashesEnd (e.Assigns) >; - /* {a} t.X {b} = {c} t.Y {d} ↦ t.X → t.NEW, t.Y → t.NEW */ + /* {a} #var E1 {b} = {c} E2 {d} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.tX ('{'s.B'}') '=' ('{'s.C'}') t.tY ('{'s.D'}')) + (s._ ('{'s.A'}') (ScrVar e._) e.E1 ('{'s.B'}') '=' ('{'s.C'}') e.E2 ('{'s.D'}')) e.ClashesEnd (e.Assigns) - , t.tX : (Var 't' e.XIndex) - , t.tY : (Var 't' e.YIndex) - = : (e.UsedVars^) 't' e.New - = (Var 't' e.New) : t.tNew - = - >; + = /* решений нет */; - /* {a} t.X {b} = {c} s.Y {d} ↦ t.X → s.NEW, s.Y → s.NEW */ + /* {a} E1 {b} = {c} #var E2 {d} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.tX ('{'s.B'}') '=' ('{'s.C'}') t.sY ('{'s.D'}')) + (s._ ('{'s.A'}') e.E1 ('{'s.B'}') '=' ('{'s.C'}') (ScrVar e._) e.E2 ('{'s.D'}')) e.ClashesEnd (e.Assigns) - , t.tX : (Var 't' e.XIndex) - , t.sY : (Var 's' e.YIndex) - = : (e.UsedVars^) 's' e.New - = (Var 's' e.New) : t.sNew - = - >; + = /* решений нет */; - /* {a} s.Y {b} = {c} t.X {d} ↦ s.Y → s.NEW, t.X → s.NEW */ + /* {a} E1 #var {b} = {c} E2 {d} ↦ решений нет*/ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.sY ('{'s.B'}') '=' ('{'s.C'}') t.tX ('{'s.D'}')) + (s._ ('{'s.A'}') e.E1 (ScrVar e._) ('{'s.B'}') '=' ('{'s.C'}') e.E2 ('{'s.D'}')) e.ClashesEnd (e.Assigns) - , t.tX : (Var 't' e.XIndex) - , t.sY : (Var 's' e.YIndex) - = : (e.UsedVars^) 's' e.New - = (Var 's' e.New) : t.sNew - = - >; + = /* решений нет */; - /* {a} s.X {b} = {c} s.Y {d} ↦ s.X → s.NEW, s.Y → s.NEW */ + /* {a} E1 {b} = {c} E2 #var2 {d} ↦ решений нет*/ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.sX ('{'s.B'}') '=' ('{'s.C'}') t.sY ('{'s.D'}')) + (s._ ('{'s.A'}') e.E1 ('{'s.B'}') '=' ('{'s.C'}') e.E2 (ScrVar e._) ('{'s.D'}')) e.ClashesEnd (e.Assigns) - , t.sX : (Var 's' e.XIndex) - , t.sY : (Var 's' e.YIndex) - = : (e.UsedVars^) 's' e.New - = (Var 's' e.New) : t.sNew - = - >; + = /* решений нет */; /* ε = {m} e.X E {n} ↦ e.X → ε, ε = {m} E {n} */ (e.UsedVars) (e.Contrs) e.ClashesStart - (/* пусто */ '=' ('{'s.M'}') t.eX e.E ('{'s.N'}')) + (E /* пусто */ '=' ('{'s.M'}') t.eX e.E ('{'s.N'}')) e.ClashesEnd (e.Assigns) , t.eX : (Var 'e' e.XIndex) = >; + /* ε = {m} !e.X E {n} ↦ не определено */ + (e.UsedVars) (e.Contrs) e.ClashesStart + (E /* пусто */ '=' ('{'s.M'}') t.eX e.E ('{'s.N'}')) + e.ClashesEnd (e.Assigns) + , t.eX : (WhVar 'e' e.XIndex) + = Undefined; + /* {m} e.X E {n} = ε ↦ e.X → ε, {m} E {n} = ε */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.M'}') t.eX e.E ('{'s.N'}') '=' /* пусто */) + (E ('{'s.M'}') t.eX e.E ('{'s.N'}') '=' /* пусто */) e.ClashesEnd (e.Assigns) , t.eX : (Var 'e' e.XIndex) = : True = /* решений нет */; - /* {a} t.X {b} = {c} {{ &F e.X }} {d} ↦ обобщаем {c−d} */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.tX ('{'s.B'}') '=' ('{'s.C'}') t.Closure ('{'s.D'}')) - e.ClashesEnd (e.Assigns) - , t.tX : (Var 't' e._) - , t.Closure : (ClosureBrackets e._) - = Generalize (('{' s.C s.D '}')); - - /* {c} {{ &F e.X }} {d} = {a} t.X {b} ↦ обобщаем {c−d} */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.Closure ('{'s.D'}') '=' ('{'s.A'}') t.tX ('{'s.B'}')) - e.ClashesEnd (e.Assigns) - , t.tX : (Var 't' e._) - , t.Closure : (ClosureBrackets e._) - = Generalize (('{' s.C s.D '}')); - - /* {a} s.X {b} = {c} {{ &F e.X }} {d} ↦ обобщаем {c−d} */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.sX ('{'s.B'}') '=' ('{'s.C'}') t.Closure ('{'s.D'}')) - e.ClashesEnd (e.Assigns) - , t.sX : (Var 's' e._) - , t.Closure : (ClosureBrackets e._) - = Generalize (('{' s.C s.D '}')); - - /* {c} {{ &F e.X }} {d} = {a} s.X {b} ↦ обобщаем {c−d} */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.Closure ('{'s.D'}') '=' ('{'s.A'}') t.sX ('{'s.B'}')) - e.ClashesEnd (e.Assigns) - , t.sX : (Var 's' e._) - , t.Closure : (ClosureBrackets e._) - = Generalize (('{' s.C s.D '}')); - - /* {a} X {b} = {c} {{ &F e.X }} {d} ↦ решений нет */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.X ('{'s.B'}') '=' ('{'s.C'}') t.Closure ('{'s.D'}')) - e.ClashesEnd (e.Assigns) - , t.X : (Symbol e._) - , t.Closure : (ClosureBrackets e._) - = /* решений нет */; - - /* {c} {{ &F e.X }} {d} = {a} X {b} ↦ решений нет */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.Closure ('{'s.D'}') '=' ('{'s.A'}') t.X ('{'s.B'}')) - e.ClashesEnd (e.Assigns) - , t.X : (Symbol e._) - , t.Closure : (ClosureBrackets e._) - = /* решений нет */; - - /* {a} (E) {b} = {c} {{ &F e.X }} {d} ↦ решений нет */ + /* {m} T E {n} = ε ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.BrE ('{'s.B'}') '=' ('{'s.C'}') t.Closure ('{'s.D'}')) + (E ('{'s.M'}') t.T e.E ('{'s.N'}') '=' /* пусто */) e.ClashesEnd (e.Assigns) - , t.BrE : (Brackets e._) - , t.Closure : (ClosureBrackets e._) + , : True = /* решений нет */; - /* {c} {{ &F e.X }} {d} = {a} (E) {b} ↦ решений нет */ - (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.Closure ('{'s.D'}') '=' ('{'s.A'}') t.BrE ('{'s.B'}')) - e.ClashesEnd (e.Assigns) - , t.BrE : (Brackets e._) - , t.Closure : (ClosureBrackets e._) - = /* решений нет */; + /* + {a} T {b} = {c} {{ &F e.X }} {d} ↦ обобщаем {c−d} + {a} {{ &F e.X }} {b} = {c} T {d} ↦ обобщаем {a−b} - /* {a} [E] {b} = {c} {{ &F e.X }} {d} ↦ решений нет */ + Случай {{ &F e.X }} = {{ &F e.X }} не рассматриваем, + т.к. он обрабатывается как тавтология. + */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.BrE ('{'s.B'}') '=' ('{'s.C'}') t.Closure ('{'s.D'}')) + (T ('{'s.A'}') t._ ('{'s.B'}') '=' ('{'s.C'}') t.Closure ('{'s.D'}')) e.ClashesEnd (e.Assigns) - , t.BrE : (ADT-Brackets e._) , t.Closure : (ClosureBrackets e._) - = /* решений нет */; + = (Generalize (('{' s.C s.D '}'))); - /* {c} {{ &F e.X }} {d} = {a} [E] {b} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.Closure ('{'s.D'}') '=' ('{'s.A'}') t.BrE ('{'s.B'}')) + (T ('{'s.A'}') t.Closure ('{'s.B'}') '=' ('{'s.C'}') t._ ('{'s.D'}')) e.ClashesEnd (e.Assigns) - , t.BrE : (ADT-Brackets e._) , t.Closure : (ClosureBrackets e._) - = /* решений нет */; + = (Generalize (('{' s.A s.B '}'))); - /* {a} [E1] {b} = {c} (E2) {d} ↦ решений нет */ + /* {a} [X E1] {b} = {c} (E2) {d} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.Br1 ('{'s.B'}') '=' ('{'s.C'}') t.Br2 ('{'s.D'}')) + (T ('{'s.A'}') t.Br1 ('{'s.B'}') '=' ('{'s.C'}') t.Br2 ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br1 : (ADT-Brackets e._) , t.Br2 : (Brackets e._) = /* решений нет */; - /* {c} (E2) {d} = {a} [E1] {b} ↦ решений нет */ + /* {c} (E2) {d} = {a} [X E1] {b} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.Br2 ('{'s.D'}') '=' ('{'s.A'}') t.Br1 ('{'s.B'}')) + (T ('{'s.C'}') t.Br2 ('{'s.D'}') '=' ('{'s.A'}') t.Br1 ('{'s.B'}')) e.ClashesEnd (e.Assigns) , t.Br1 : (ADT-Brackets e._) , t.Br2 : (Brackets e._) @@ -1717,7 +1640,7 @@ Solve-SymmClashes-Aux { /* {a} t.X {b} = {c} X {d} ↦ t.X → X */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.tX ('{'s.B'}') '=' ('{'s.C'}') t.X ('{'s.D'}')) + (T ('{'s.A'}') t.tX ('{'s.B'}') '=' ('{'s.C'}') t.X ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.tX : (Var 't' e.XIndex) , t.X : (Symbol e._) @@ -1733,7 +1656,7 @@ Solve-SymmClashes-Aux { /* {c} X {d} = {a} t.X {b} ↦ t.X → X */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.X ('{'s.D'}') '=' ('{'s.A'}') t.tX ('{'s.B'}')) + (T ('{'s.C'}') t.X ('{'s.D'}') '=' ('{'s.A'}') t.tX ('{'s.B'}')) e.ClashesEnd (e.Assigns) , t.tX : (Var 't' e.XIndex) , t.X : (Symbol e._) @@ -1749,7 +1672,7 @@ Solve-SymmClashes-Aux { /* {a} s.X {b} = {c} X {d} ↦ s.X → X */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.sX ('{'s.B'}') '=' ('{'s.C'}') t.X ('{'s.D'}')) + (T ('{'s.A'}') t.sX ('{'s.B'}') '=' ('{'s.C'}') t.X ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.sX : (Var 's' e.XIndex) , t.X : (Symbol e._) @@ -1765,7 +1688,7 @@ Solve-SymmClashes-Aux { /* {c} X {d} = {a} s.X {b} ↦ s.X → X */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.X ('{'s.D'}') '=' ('{'s.A'}') t.sX ('{'s.B'}')) + (T ('{'s.C'}') t.X ('{'s.D'}') '=' ('{'s.A'}') t.sX ('{'s.B'}')) e.ClashesEnd (e.Assigns) , t.sX : (Var 's' e.XIndex) , t.X : (Symbol e._) @@ -1781,7 +1704,7 @@ Solve-SymmClashes-Aux { /* {a} X {b} = {c} Y {d} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.X ('{'s.B'}') '=' ('{'s.C'}') t.Y ('{'s.D'}')) + (T ('{'s.A'}') t.X ('{'s.B'}') '=' ('{'s.C'}') t.Y ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.X : (Symbol e._) , t.Y : (Symbol e._) @@ -1790,7 +1713,7 @@ Solve-SymmClashes-Aux { /* {a} (E1) {b} = {c} (E2) {d} ↦ {a} E1 {b} = {c} E2 {d} */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.Br1 ('{'s.B'}') '=' ('{'s.C'}') t.Br2 ('{'s.D'}')) + (T ('{'s.A'}') t.Br1 ('{'s.B'}') '=' ('{'s.C'}') t.Br2 ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br1 : (Brackets e.E1) , t.Br2 : (Brackets e.E2) @@ -1798,14 +1721,14 @@ Solve-SymmClashes-Aux { (e.UsedVars) (e.Contrs) e.ClashesStart e.ClashesEnd (e.Assigns) >; /* {a} [X E1] {b} = {c} [X E2] {d} ↦ {a} E1 {b} = {c} E2 {d} */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.Br1 ('{'s.B'}') '=' ('{'s.C'}') t.Br2 ('{'s.D'}')) + (T ('{'s.A'}') t.Br1 ('{'s.B'}') '=' ('{'s.C'}') t.Br2 ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br1 : (ADT-Brackets (e.Name) e.E1) , t.Br2 : (ADT-Brackets (e.Name) e.E2) @@ -1813,7 +1736,7 @@ Solve-SymmClashes-Aux { (e.UsedVars) (e.Contrs) e.ClashesStart e.ClashesEnd (e.Assigns) >; @@ -1828,7 +1751,7 @@ Solve-SymmClashes-Aux { /* {a} ({b} E {c}) {d} = {e} t.X {f} ↦ t.X → (e.NEW) */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.Br ('{'s.D'}') '=' ('{'s.E'}') t.tX ('{'s.F'}')) + (T ('{'s.A'}') t.Br ('{'s.D'}') '=' ('{'s.E'}') t.tX ('{'s.F'}')) e.ClashesEnd (e.Assigns) , t.Br : (Brackets ('{'s.B'}') e.E ('{'s.C'}')) , t.tX : (Var 't' e.XIndex) @@ -1838,7 +1761,7 @@ Solve-SymmClashes-Aux { >; @@ -1850,15 +1773,15 @@ Solve-SymmClashes-Aux { на стадии отделения термов */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.Br ('{'s.D'}') '=' ('{'s.E'}') t.tX ('{'s.F'}')) + (T ('{'s.A'}') t.Br ('{'s.D'}') '=' ('{'s.E'}') t.tX ('{'s.F'}')) e.ClashesEnd (e.Assigns) , t.Br : (Brackets e._) , t.tX : (Var 't' e._) - = Generalize (('{' s.A s.D '}') ('{' s.E s.F '}')); + = (Generalize (('{' s.A s.D '}') ('{' s.E s.F '}'))); /* {e} t.X {f} = {a} ({b} E {c}) {d} ↦ t.X → (e.NEW) */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.E'}') t.tX ('{'s.F'}') '=' ('{'s.A'}') t.Br ('{'s.D'}')) + (T ('{'s.E'}') t.tX ('{'s.F'}') '=' ('{'s.A'}') t.Br ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br : (Brackets ('{'s.B'}') e.E ('{'s.C'}')) , t.tX : (Var 't' e.XIndex) @@ -1868,20 +1791,20 @@ Solve-SymmClashes-Aux { >; /* {e} t.X {f} = {a} (E) {d} ↦ обобщение */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.E'}') t.tX ('{'s.F'}') '=' ('{'s.A'}') t.Br ('{'s.D'}')) + (T ('{'s.E'}') t.tX ('{'s.F'}') '=' ('{'s.A'}') t.Br ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br : (Brackets e._) , t.tX : (Var 't' e._) - = Generalize (('{' s.E s.F '}') ('{' s.A s.D '}')); + = (Generalize (('{' s.E s.F '}') ('{' s.A s.D '}'))); - /* {a} [{b} E {c}] {d} = {e} t.X {f} ↦ t.X → [e.NEW] */ + /* {a} [X {b} E {c}] {d} = {e} t.X {f} ↦ t.X → [e.NEW] */ (e.UsedVars) (e.Contrs) e.ClashesStart (('{'s.A'}') t.Br ('{'s.D'}') '=' ('{'s.E'}') t.tX ('{'s.F'}')) e.ClashesEnd (e.Assigns) @@ -1893,22 +1816,22 @@ Solve-SymmClashes-Aux { >; - /* {a} [E] {d} = {e} t.X {f} ↦ обобщение */ + /* {a} [X E] {d} = {e} t.X {f} ↦ обобщение */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.Br ('{'s.D'}') '=' ('{'s.E'}') t.tX ('{'s.F'}')) + (T ('{'s.A'}') t.Br ('{'s.D'}') '=' ('{'s.E'}') t.tX ('{'s.F'}')) e.ClashesEnd (e.Assigns) , t.Br : (ADT-Brackets (e.Name) e._) , t.tX : (Var 't' e._) - = Generalize (('{' s.A s.D '}') ('{' s.E s.F '}')); + = (Generalize (('{' s.A s.D '}') ('{' s.E s.F '}'))); - /* {e} t.X {f} = {a} [{b} E {c}] {d} ↦ t.X → [e.NEW] */ + /* {e} t.X {f} = {a} [X {b} E {c}] {d} ↦ t.X → [e.NEW] */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.E'}') t.tX ('{'s.F'}') '=' ('{'s.A'}') t.Br ('{'s.D'}')) + (T ('{'s.E'}') t.tX ('{'s.F'}') '=' ('{'s.A'}') t.Br ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br : (ADT-Brackets (e.Name) ('{'s.B'}') e.E ('{'s.C'}')) , t.tX : (Var 't' e.XIndex) @@ -1918,22 +1841,22 @@ Solve-SymmClashes-Aux { >; - /* {e} t.X {f} = {a} [E] {d} ↦ обобщение */ + /* {e} t.X {f} = {a} [X E] {d} ↦ обобщение */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.E'}') t.tX ('{'s.F'}') '=' ('{'s.A'}') t.Br ('{'s.D'}')) + (T ('{'s.E'}') t.tX ('{'s.F'}') '=' ('{'s.A'}') t.Br ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br : (ADT-Brackets (e.Name) e._) , t.tX : (Var 't' e._) - = Generalize (('{' s.E s.F '}') ('{' s.A s.D '}')); + = (Generalize (('{' s.E s.F '}') ('{' s.A s.D '}'))); /* {a} (E) {b} = {c} Sym {d} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.Br ('{'s.B'}') '=' ('{'s.C'}') t.Sym ('{'s.D'}')) + (T ('{'s.A'}') t.Br ('{'s.B'}') '=' ('{'s.C'}') t.Sym ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br : (Brackets e.E) , : True @@ -1941,23 +1864,23 @@ Solve-SymmClashes-Aux { /* {c} Sym {d} = {a} (E) {b} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.Sym ('{'s.D'}') '=' ('{'s.A'}') t.Br ('{'s.B'}')) + (T ('{'s.C'}') t.Sym ('{'s.D'}') '=' ('{'s.A'}') t.Br ('{'s.B'}')) e.ClashesEnd (e.Assigns) , t.Br : (Brackets e.E) , : True = /* решений нет */; - /* {a} [E] {b} = {c} Sym {d} ↦ решений нет */ + /* {a} [X E] {b} = {c} Sym {d} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.Br ('{'s.B'}') '=' ('{'s.C'}') t.Sym ('{'s.D'}')) + (T ('{'s.A'}') t.Br ('{'s.B'}') '=' ('{'s.C'}') t.Sym ('{'s.D'}')) e.ClashesEnd (e.Assigns) , t.Br : (ADT-Brackets e._) , : True = /* решений нет */; - /* {c} Sym {d} = {a} [E] {b} ↦ решений нет */ + /* {c} Sym {d} = {a} [X E] {b} ↦ решений нет */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.Sym ('{'s.D'}') '=' ('{'s.A'}') t.Br ('{'s.B'}')) + (T ('{'s.C'}') t.Sym ('{'s.D'}') '=' ('{'s.A'}') t.Br ('{'s.B'}')) e.ClashesEnd (e.Assigns) , t.Br : (ADT-Brackets e._) , : True @@ -1967,7 +1890,7 @@ Solve-SymmClashes-Aux { * где {c} T1 {d}, {g} E1′ := TERM_LEFT({a} T1 E1) * {e} T2 {f}, {h} E2′ := TERM_LEFT({b} T2 E2) (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.T1 e.E1 '=' ('{'s.B'}') t.T2 e.E2) + (E ('{'s.A'}') t.T1 e.E1 '=' ('{'s.B'}') t.T2 e.E2) e.ClashesEnd (e.Assigns) , : True , : True @@ -1977,7 +1900,7 @@ Solve-SymmClashes-Aux { = : (e.Right1) (e.Right2) = ; @@ -1985,7 +1908,7 @@ Solve-SymmClashes-Aux { * где E1′ {c}, {e} T1 {f} := TERM_RIGHT(E1 T1 {a}) * E2′ {d}, {g} T2 {h} := TERM_RIGHT(E2 T2 {b}) (e.UsedVars) (e.Contrs) e.ClashesStart - (e.E1 t.T1 ('{'s.A'}') '=' e.E2 t.T2 ('{'s.B'}')) + (E e.E1 t.T1 ('{'s.A'}') '=' e.E2 t.T2 ('{'s.B'}')) e.ClashesEnd (e.Assigns) , : True , : True @@ -1995,13 +1918,13 @@ Solve-SymmClashes-Aux { = : (e.Right1) (e.Right2) = ; /* {a} T {b} E1 = {c} e.X E2 ↦ e.X → t.NEW1 e.NEW2 || e.X → ε */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') t.T ('{'s.B'}') e.E1 '=' ('{'s.C'}') t.eX e.E2) + (E ('{'s.A'}') t.T ('{'s.B'}') e.E1 '=' ('{'s.C'}') t.eX e.E2) e.ClashesEnd (e.Assigns) , : True , t.eX : (Var 'e' e.XIndex) @@ -2012,14 +1935,14 @@ Solve-SymmClashes-Aux { = : e.Branch1 = : e.Branch2 @@ -2028,7 +1951,7 @@ Solve-SymmClashes-Aux { /* {c} e.X E2 = {a} T {b} E1 ↦ e.X → t.NEW1 e.NEW2 || e.X → ε */ (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.C'}') t.eX e.E2 '=' ('{'s.A'}') t.T ('{'s.B'}') e.E1) + (E ('{'s.C'}') t.eX e.E2 '=' ('{'s.A'}') t.T ('{'s.B'}') e.E1) e.ClashesEnd (e.Assigns) , : True , t.eX : (Var 'e' e.XIndex) @@ -2039,14 +1962,14 @@ Solve-SymmClashes-Aux { = : e.Branch1 = : e.Branch2 @@ -2055,7 +1978,7 @@ Solve-SymmClashes-Aux { /* E1 {a} T {b} = E2 e.X {c} ↦ e.X → e.NEW1 t.NEW2 || e.X → ε */ (e.UsedVars) (e.Contrs) e.ClashesStart - (e.E1 ('{'s.A'}') t.T ('{'s.B'}') '=' e.E2 t.eX ('{'s.C'}')) + (E e.E1 ('{'s.A'}') t.T ('{'s.B'}') '=' e.E2 t.eX ('{'s.C'}')) e.ClashesEnd (e.Assigns) , : True , t.eX : (Var 'e' e.XIndex) @@ -2066,14 +1989,14 @@ Solve-SymmClashes-Aux { = : e.Branch1 = : e.Branch2 @@ -2082,7 +2005,7 @@ Solve-SymmClashes-Aux { /* E2 e.X {c} = E1 {a} T {b} ↦ e.X → e.NEW1 t.NEW2 || e.X → ε */ (e.UsedVars) (e.Contrs) e.ClashesStart - (e.E2 t.eX ('{'s.C'}') '=' e.E1 ('{'s.A'}') t.T ('{'s.B'}')) + (E e.E2 t.eX ('{'s.C'}') '=' e.E1 ('{'s.A'}') t.T ('{'s.B'}')) e.ClashesEnd (e.Assigns) , : True , t.eX : (Var 'e' e.XIndex) @@ -2093,14 +2016,14 @@ Solve-SymmClashes-Aux { = : e.Branch1 = : e.Branch2 @@ -2110,13 +2033,14 @@ Solve-SymmClashes-Aux { * Если остались клэши, к которым не применимы вышеперечисленные правила, * то производим запрос на обобщение (e.UsedVars) (e.Contrs) e.ClashesStart - (('{'s.A'}') e.E1 ('{'s.B'}') '=' ('{'s.C'}') e.E2 ('{'s.D'}')) + (s._ ('{'s.A'}') e.E1 ('{'s.B'}') '=' ('{'s.C'}') e.E2 ('{'s.D'}')) e.ClashesEnd (e.Assigns) - = Generalize (('{' s.A s.B '}') ('{' s.C s.D '}')); + = (Generalize (('{' s.A s.B '}') ('{' s.C s.D '}'))); * Если клэши кончились, возвращаем решение - (e.UsedVars) (s.OpenFlag e.Contrs) (e.Assigns) - = Success s.OpenFlag (e.Contrs) (e.Assigns); + (e.UsedVars) (s.OpenFlag e.Contrs) /* пусто */ (e.Assigns) + = : e.Assigns^ + = (Success (e.UsedVars) s.OpenFlag (e.Contrs) (e.Assigns)); } /* Проверка на эквивалентность */ @@ -2132,6 +2056,8 @@ Eq { IsSVarSubset { (Symbol s.Type e.Info) = True; (Var 's' e.Tindex) = True; + (ScrVar 's' e.Tindex) = True; + (WhVar 's' e.Tindex) = True; (Closure e.Body) = True; (ClosureBrackets e.Context) = True; @@ -2142,6 +2068,8 @@ IsSVarSubset { IsTerm { (Var 'e' e.Index) = False; + (ScrVar 'e' e.Index) = False; + (WhVar 'e' e.Index) = False; /* Рассматриваем для оптимизаций встраивания, прогонки и специализации */ (CallBrackets e.Nested) = False; @@ -2175,6 +2103,7 @@ AddContractions-Spec-Symm { == PRTC */ +*$xDRIVE AddContraction-Spec, AddContraction-Spec-Symm AddContraction-Spec { t.toAdd (s.OpenFlag e.Contrs) e.Clashes (e.Assigns) @@ -2182,62 +2111,54 @@ AddContraction-Spec { : { ((Var 'e' e._) ':' (Var 'e' e._) (Var 'e' e._)) = AfterOpen; - ((Var 'e' e._) ':' (Var 'e' e._) (Var 't' e._) (Var 'e' e._)) = AfterOpen; + ((Var 'e' e._) ':' (Var 'e' e._) (Var 't' e._) (Var 'e' e._)) + = AfterOpen; t._ = s.OpenFlag; } : s.OpenFlag^ - = - ) - - () - >; + = : t.toAdd^ + = (s.OpenFlag e.Contrs t.toAdd) + + (e.Assigns); } +gen_t__ { e.arg = } + AddContraction-Spec-Symm { t.toAdd (s.OpenFlag e.Contrs) e.SymmClashes (e.Assigns) = t.toAdd : { ((Var 'e' e._) ':' (Var 'e' e._) (Var 'e' e._)) = AfterOpen; - ((Var 'e' e._) ':' (Var 'e' e._) (Var 't' e._) (Var 'e' e._)) = AfterOpen; + ((Var 'e' e._) ':' (Var 'e' e._) (Var 't' e._) (Var 'e' e._)) + = AfterOpen; t._ = s.OpenFlag; } : s.OpenFlag^ - = - ) - - () - >; -} - -/* - Применение сужения к другому сужению - - == t.OtherContr^ -*/ - -ApplyContraction-toContraction { - t.Contr (t.Var ':' e.Right) - = (t.Var ':' ); + = : t.toAdd^ + = (s.OpenFlag e.Contrs t.toAdd) + + (e.Assigns); } /* Применение сужения к присваиванию - == e.Assigns^ */ - -ApplyContraction-toAssign { - t.Contraction (e.M ':' t.Rval) - = ( ':' t.Rval); +ApplyContractions-toAssigns { + (e.Contrs) (e.Assigns) + = : e.Expr^ + = : e.Expr^ + = (e.Expr ':' t.Var) + } + e.Assigns + > } /* @@ -2247,17 +2168,17 @@ ApplyContraction-toAssign { */ ApplyContraction-toEquation { - t.Contraction ((e.Expr) ':' (e.Lexpr)) = - (() ':' (e.Lexpr)) + t.Contraction (s.ClashType (e.Expr) ':' (e.Lexpr)) + = : e.Expr^ + = : e.Expr^ + = (s.ClashType (e.Expr) ':' (e.Lexpr)) } ApplyContraction-toSymmClash { - t.Contr (e.L '=' e.R) - = ( - - '=' - - ) + t.Contr (s.Type e.L '=' e.R) + = : e.L^ + = : e.R^ + = ; + t.Contraction e.B (ClosureBrackets e.M) e.E = + + (ClosureBrackets ) + ; - t.Other e.Rem = False + t.Contraction e.Expr = e.Expr } /* diff --git a/src/compiler/GlobalGen.ref b/src/compiler/GlobalGen.ref index 12988c0f..f91c5c35 100644 --- a/src/compiler/GlobalGen.ref +++ b/src/compiler/GlobalGen.ref @@ -278,3 +278,37 @@ CalcTermComplexity { (Brackets e.Terms) = 2>; (ADT-Brackets t.Name e.Terms) = 2>; } + + +/** + == e.Pattern^ + == s.NextId^ e.Pattern^ + + s.NextId ::= s.NUMBER + + Аналогично GlobalGen, но переменные получают последовательные числовые + индексы: s.1 e.2 t.3... +*/ +$ENTRY GlobalGen-NameVariables { + e.Pattern + = : s._ e.Pattern^ + = e.Pattern +} + +$ENTRY GlobalGen-NameVariables-Rec { + s.NextId e.Terms = +} + +NameVariables-Term { + s.NextId (Var s.Mode) = (Var s.Mode ); + + s.NextId (Brackets e.Nested) + = : s.NextId^ e.Nested^ + = s.NextId (Brackets e.Nested); + + s.NextId (ADT-Brackets (e.Name) e.Nested) + = : s.NextId^ e.Nested^ + = s.NextId (ADT-Brackets (e.Name) e.Nested); + + s.NextId t.Other = s.NextId t.Other; +} diff --git a/src/compiler/HighLevelRASL-ConjointFunc.ref b/src/compiler/HighLevelRASL-ConjointFunc.ref index 7cddb109..aed589df 100644 --- a/src/compiler/HighLevelRASL-ConjointFunc.ref +++ b/src/compiler/HighLevelRASL-ConjointFunc.ref @@ -7,12 +7,12 @@ $EXTERN GenPattern, MakeSavers, GenResult; $EXTERN GenericMatch; *$FROM GlobalGen -$EXTERN BuildImage, BuildImage-Term, Generalization, Generalization-Term, - Collapse, Collapse-Term; +$EXTERN GlobalGen-NameVariables-Rec, BuildImage, BuildImage-Term, + Generalization, Generalization-Term, Collapse, Collapse-Term; $ENTRY HighLevelRASL-Function-Conjoint { - s.FnGenSubst s.FnGenResult s.ScopeClass (e.Name) e.Sentences + s.FnGenSubst s.FnGenResult (e.Name) e.Sentences /* Функция FindDivisionAndGenerate работает с подстановками, @@ -47,7 +47,7 @@ $ENTRY HighLevelRASL-Function-Conjoint { : e.ResultCommands^ = (Function - s.ScopeClass (e.Name) + (e.Name) (CmdIssueMemory s.MaxContextSize) e.CommonMatchCommands e.ResultCommands @@ -177,34 +177,13 @@ ComposeVars { (e.MarkedPattern) () = (Junk e.MarkedPattern); } -/* Добавляет уникальные индексы */ -EnumerateVarsRec { - s.NextNumber e.Expr - = (Var s.Type 'new' ); - - s.Next (Brackets e.Nested) - = : s.Next^ e.Nested^ - = s.Next (Brackets e.Nested); - - s.Next (ADT-Brackets (e.Name) e.Nested) - = : s.Next^ e.Nested^ - = s.Next (ADT-Brackets (e.Name) e.Nested); - - s.Next t.OtherTerm = s.Next t.OtherTerm; - } - s.NextNumber e.Expr - >; -} - EnumerateVars-Subst { s.StartNumber s.Depth e.Substitute = : s.NextNumber^ e.Value^ + = + : s.NextNumber^ e.Value^ = s.NextNumber (e.Value ':' (e.Var)) } s.StartNumber e.Substitute diff --git a/src/compiler/HighLevelRASL-DisjointFunc.ref b/src/compiler/HighLevelRASL-DisjointFunc.ref index 1fa076a9..0604c9e6 100644 --- a/src/compiler/HighLevelRASL-DisjointFunc.ref +++ b/src/compiler/HighLevelRASL-DisjointFunc.ref @@ -5,8 +5,7 @@ $EXTERN GenResult, GenPattern; $ENTRY HighLevelRASL-Function-Disjoint { - s.FnGenSubst s.FnGenResult - s.ScopeClass (e.Name) e.Sentences + s.FnGenSubst s.FnGenResult (e.Name) e.Sentences = ) - (CmdComment 'RESULT:' ) + = (CmdComment { = 'TRASH:' }) + (CmdComment { = 'RESULT:' }) /* Генерируем команды аллокаций */ @@ -362,6 +362,7 @@ AddOffsets { { s.Offset (Tile e.Tile) = s.Offset + (Tile - ); + ) + ; s.Offset (Var 's' e.Index) = + (VarCopy s.Offset - ); + ) + ; s.Offset (Var 't' e.Index) = + (VarCopy s.Offset - ); + ) + ; s.Offset (Var 'e' e.Index) = + (VarCopy s.Offset - ); + ) + ; s.Offset (TkString e.String) = - (TkString e.String s.Offset); + (TkString e.String s.Offset) ; s.Offset (s.Tag e.Info) = (s.Tag e.Info s.Offset); } @@ -406,6 +414,8 @@ AddOffsets { >; } +gen_e__ { e.arg = e.arg } + GetSampleOffset { e._ (s.Mode (e.Index) e.Offsets s.SampleOffset) e._ (s.Mode e.Index) = s.Mode e.Index s.SampleOffset; diff --git a/src/compiler/HighLevelRASL-GenResult-Simple.ref b/src/compiler/HighLevelRASL-GenResult-Simple.ref index 454510bc..08db9b90 100644 --- a/src/compiler/HighLevelRASL-GenResult-Simple.ref +++ b/src/compiler/HighLevelRASL-GenResult-Simple.ref @@ -75,6 +75,8 @@ GenResult { >; } +*$NOOPT DoGenResult + DoGenResult { (e.Vars) (e.AllocCommands) (e.Commands) s.Counter (TkOpenCallCond s.Offset) e.Result = @@ -303,5 +305,5 @@ ReplicateVar { MakeVariableComment { (s.Offset s.Mode e.Index) - = (CmdComment Offset s.Offset ': ' ); + = (CmdComment { = ': ' }); } diff --git a/src/compiler/HighLevelRASL-GenSubst-Save.ref b/src/compiler/HighLevelRASL-GenSubst-Save.ref index 3aa4b2a4..288139e1 100644 --- a/src/compiler/HighLevelRASL-GenSubst-Save.ref +++ b/src/compiler/HighLevelRASL-GenSubst-Save.ref @@ -23,6 +23,8 @@ $ENTRY GenSubst-Save { >; } +*$NOOPT DoGenSubst + DoGenSubst { /* Распознавание T-подстановки */ s.ContextOffset @@ -483,7 +485,7 @@ DoGenSubst { (e.Vars ('e' (e.Index) s.Num)) (e.Commands (CmdComment - ' closed ' ' as range ' Offset s.Num + { = ' closed ' ' as range ' } ) ) >; @@ -571,7 +573,7 @@ DoGenSubst { /* Завершение разбора. */ s.ContextOffset (Junk e.MarkedPattern) (e.Vars) (e.Commands) = s.ContextOffset (e.Vars) (e.MarkedPattern) - (CmdComment ) e.Commands; + (CmdComment { = }) e.Commands; } IncVarOffset-Saved { diff --git a/src/compiler/HighLevelRASL-GenSubst-Simple.ref b/src/compiler/HighLevelRASL-GenSubst-Simple.ref index b25c6fe9..ca1c1c46 100644 --- a/src/compiler/HighLevelRASL-GenSubst-Simple.ref +++ b/src/compiler/HighLevelRASL-GenSubst-Simple.ref @@ -23,6 +23,8 @@ $ENTRY GenSubst-Simple { >; } +*$NOOPT DoGenSubst + DoGenSubst { /* Распознавание T-подстановки */ s.ContextOffset @@ -460,7 +462,7 @@ DoGenSubst { (e.Vars ('e' (e.Index) s.Num)) (e.Commands (CmdComment - ' closed ' ' as range ' Offset s.Num + { = ' closed ' ' as range ' } ) ) >; @@ -547,6 +549,6 @@ DoGenSubst { /* Завершение разбора. */ s.ContextOffset (Junk e.MarkedPattern) (e.Vars) (e.Commands) = s.ContextOffset (e.Vars) (e.MarkedPattern) - (CmdComment ) + (CmdComment { = }) e.Commands; } diff --git a/src/compiler/HighLevelRASL.ref b/src/compiler/HighLevelRASL.ref index c3e8e96e..5e9814cd 100644 --- a/src/compiler/HighLevelRASL.ref +++ b/src/compiler/HighLevelRASL.ref @@ -24,12 +24,12 @@ $EXTERN GenResult-Opt; e.RASLAST ::= t.RASLFunction* t.RASLFunction ::= - (Function s.ScopeClass (e.Name) t.HiRASLCommand*) - | (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) - | (s.SingularItem s.ScopeClass e.Name) + (Function (e.Name) t.HiRASLCommand*) + | (CmdNativeFunction (e.Name) t.SrcPos e.Code) + | (s.SingularItem e.Name) | (CmdDefineIdent e.Name) | (CmdEmitNativeCode t.SrcPos e.Code) - s.SingularItem ::= CmdEnum | CmdSwap | CmdDeclaration + s.SingularItem ::= CmdEnum | CmdSwap t.HiRASLCommand ::= (Cmd… e.Value) | (CmdSentence t.HiRASLCommand*) @@ -39,36 +39,33 @@ $ENTRY HighLevelRASL { s.Joint s.OptResult e.ProgramElements = ; - (Function s.ScopeClass (e.Name) NativeBody t.SrcPos e.Code) = - (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code); + (Function (e.Name) NativeBody t.SrcPos e.Code) + = (CmdNativeFunction (e.Name) t.SrcPos e.Code); - (Function s.ScopeClass (e.Name) Metatable e.Metatable) = - (CmdMetatable s.ScopeClass (e.Name) e.Metatable); + (Function (e.Name) Metatable e.Metatable) + = (CmdMetatable (e.Name) e.Metatable); - (Swap s.ScopeClass e.Name) = - (CmdSwap s.ScopeClass e.Name); + (Function (e.Name) Swap) = (CmdSwap e.Name); - (Declaration s.ScopeClass e.Name) = - (CmdDeclaration s.ScopeClass e.Name); + (Externs e.Names) = /* пусто */; (Ident e.Name) = (CmdDefineIdent e.Name); - (NativeBlock t.SrcPos e.Code) = - (CmdEmitNativeCode t.SrcPos e.Code); - - (Spec t.Name e.Pattern) = ; + (NativeBlock t.SrcPos e.Code) = (CmdEmitNativeCode t.SrcPos e.Code); } e.ProgramElements >; } HighLevelRASL-Function { - s.Joint s.OptResult s.ScopeClass (e.Name) e.Sentences + s.Joint s.OptResult (e.Name) e.Sentences /* Исправляем суффиксы функций-условий. @@ -114,14 +111,14 @@ HighLevelRASL-Function { = > - s.ScopeClass (e.Name) e.Sentences + (e.Name) e.Sentences >; } @@ -140,23 +137,18 @@ FixupName-Suf { } HighLevelRASL-Function-Aux { - s.FnGenFunction s.FnGenSubst s.FnGenResult - s.ScopeClass (e.Name) /* нет предложений */ - = (CmdEnum s.ScopeClass e.Name); + s.FnGenFunction s.FnGenSubst s.FnGenResult (e.Name) /* нет предложений */ + = (CmdEnum e.Name); - s.FnGenFunction s.FnGenSubst s.FnGenResult - s.ScopeClass (e.Name) t.OneSentence + s.FnGenFunction s.FnGenSubst s.FnGenResult (e.Name) t.OneSentence /* Нет смысла вызывать оптимизацию совместного сопоставления с образцом */ = ; - s.FnGenFunction s.FnGenSubst s.FnGenResult - s.ScopeClass (e.Name) e.Sentences + s.FnGenFunction s.FnGenSubst s.FnGenResult (e.Name) e.Sentences = ; } diff --git a/src/compiler/Log-AST.ref b/src/compiler/Log-AST.ref index 1be8e00d..c2dc2eef 100644 --- a/src/compiler/Log-AST.ref +++ b/src/compiler/Log-AST.ref @@ -24,28 +24,24 @@ UndoubleEmtpyLines { } Element { - (Function s.Scope (e.Name) e.Body) = ; - (ColdFunction s.ColdBy s.Scope (e.Name) e.Body) - = ; + (Entries e.Names) = ; - (Swap GN-Entry e.Name) = ('$ESWAP ' ';'); - (Swap GN-Local e.Name) = ('$SWAP ' ';'); + (Function (e.Name) e.Body) = ; + (ColdFunction s.ColdBy (e.Name) e.Body) + = ; - (Declaration GN-Entry e.Name) = ('$EXTERN ' ';'); - (Declaration GN-Local e.Name) = ('$FORWARD ' ';'); - - (Inline e.Name) = ('$INLINE ' ';'); - - (Drive e.Name) = ('$DRIVE ' ';'); - - (Intrinsic e.Name) = ('$INTRINSIC ' ';'); + (Externs e.Names) = ; + (Drives e.Names) = ; + (Intrinsics e.Names) = ; (Ident e.Name) = ('$LABEL ' ';'); (NativeBlock t.SrcPos e.Code) = ('%% native block %%'); - (Spec (e.Name) e.Pattern) - = ('$SPEC ' ' ' ';'); + (Specs e.Names) = ; + + (NoDrives e.Names) = ; + (NoSpecs e.Names) = ; (DriveInfo e.DriveInfo) = ('(DriveInfo ...)'); (SpecInfo e.SpecInfo) = ('(SpecInfo ...)'); @@ -65,14 +61,57 @@ LongLine { } +$ENTRY Log-EntryList { + e.Names = ; +} + +$ENTRY Log-ExternList { + e.Names = ; +} + +NameList { + (e.Keyword) /* нет имён */ = /* пусто */; + (e.Keyword) e.Names = (); +} + +DoNameList { + (e.OutLine) e.Names + , : True + = (e.OutLine) ; + + (e.OutLine) (e.Name) e.Names + = : s.SEP + = e.OutLine ' ' : e.NewOutLine + = + : { + True = (e.OutLine) ; + False = ; + }; + + (e.OutLine) /* пусто */ = (e.OutLine); +} + +CommaOrSemicolon { + /* empty */ = ';'; + e.Names = ','; +} + +DoNameList-Next { + (e.NextName) e.Names + = : s.SEP + = s.SEP) e.Names>; + + /* пусто */ = /* пусто */; +} + + Function { - (e.Name) s.Scope e.Body - = ) s.Scope e.Body>; + (e.Name) e.Body = ) e.Body>; } ColdFunction { - s.ColdBy (e.Name) s.Scope e.Body - = + s.ColdBy (e.Name) e.Body + = : { () e.FunctionLines = () @@ -85,38 +124,33 @@ ColdFunction { } Function-Aux { - (e.Name) s.Scope Sentences /* пусто */ - = ( e.Name ' { /* empty */ }'); + (e.Name) Sentences /* пусто */ = (e.Name ' { /* empty */ }'); - (e.Name) s.Scope Sentences e.Sentences + (e.Name) Sentences e.Sentences = () - ( e.Name ' {') + (e.Name ' {') ('}') (); - (e.Name) s.Scope NativeBody t.SrcPos e.NativeBody - = ( e.Name ' { %% native %% }'); + (e.Name) NativeBody t.SrcPos e.NativeBody = (e.Name ' { %% native %% }'); - (e.Name) s.Scope Metatable e.Metatable + (e.Name) Metatable e.Metatable = () - ( e.Name ' {') + (e.Name ' {') ('* metatable function') ' :: ' ); + ((Symbol Identifier e.Ident) (Symbol Name e.Name^)) + = (' ' ' :: ' ); } e.Metatable > ('}') (); -}; -Entry { - GN-Entry = '$ENTRY '; - GN-Local = /* пусто */; -} + (e.Name) Swap = ('$SWAP ' ';'); +}; Sentences { (e.Indent) (e.Sentence) = ; @@ -161,6 +195,10 @@ PutComment { } Tail { + (e.Indent) e.Tail = >; +} + +Tail-GEN { (e.Indent) (Condition (e.Name) (e.Result) (e.Pattern)) e.Tail = e.Indent ', ' ' : ' : e.OneLineCondition @@ -182,7 +220,7 @@ Tail { = ; } -$SPEC Expression (e.prefix) (e.indent) e.expression (e.suffix); +*$NOOPT Expression Expression { (e.Prefix) (e.Indent) /* пусто */ (e.Suffix) @@ -192,18 +230,23 @@ Expression { = ; } -$SPEC DoExpression s.POS (e.indent) (e.out-line) e.expression; - DoExpression { + s.POS (e.indent) (e.out-line) e.expression + = ) () + >; +} + +DoExpression-GEN { s.Pos (e.Indent) (e.OutLine) /* пусто */ (e.Suffix) = (e.OutLine e.Suffix); s.Pos (e.Indent) (e.OutLine) t.NextTerm e.Expr (e.Suffix) - = : e.TextualTerm - = : e.NewOutLine + = > : e.TextualTerm + = (e.TextualTerm)> : e.NewOutLine = : { True - = e.Indent e.TextualTerm : e.OutLineTerm + = : e.OutLineTerm = : { True, e.Expr : /* пусто */ @@ -239,9 +282,17 @@ InlineTerm { (ClosureBrackets e.Value) = ; } -$SPEC MultilineTerm s.pos (e.prefix) e.indent t.term (e.suffix); - MultilineTerm { + s.pos (e.prefix) e.indent t.term (e.suffix) + = ) e.indent () + >; +} + +* TODO: исправить после реализации gen_t__ +gen_t__ { e.Arg = } + +MultilineTerm-Gen { FIRST (e.Prefix) e.Indent t.Term (e.Suffix) = ; @@ -252,7 +303,7 @@ MultilineTerm { MultilineTerm-Prefix { (e.Prefix) e.Indent t.Term (e.Suffix) - = t.Term + = : { (Brackets e.Expr) = (e.Prefix '(') @@ -400,7 +451,8 @@ ClosureBrackets { } InlineSubexpr { - t.Term e.Expr = >) e.Expr>; + t.Term e.Expr + = >) >; /* пусто */ = /* пусто */; } diff --git a/src/compiler/Log.ref b/src/compiler/Log.ref index 73627b39..50049f1a 100644 --- a/src/compiler/Log.ref +++ b/src/compiler/Log.ref @@ -1,5 +1,5 @@ *$FROM Library -$EXTERN Open-Auto, Close; +$EXTERN Open-Auto; $INCLUDE "LibraryEx"; @@ -10,7 +10,7 @@ $EXTERN DisplayName; $EXTERN EscapeString; *$FROM Log-AST -$EXTERN Log-TextFromAST, Log-FormatIdentFuncMapTableLines; +$EXTERN Log-TextFromAST, Log-EntryList, Log-ExternList; /** @@ -67,6 +67,20 @@ $ENTRY Log-PutLine { } +/** + == [] +*/ +$ENTRY Log-PutLine-Lazy { + s.FnMessage + = + : { + /* none */ = /* do nothing */; + + s.FileHandle = ': ' >; + }; +} + + /** == e.AST */ @@ -78,17 +92,16 @@ $ENTRY Log-AST { s.FileHandle = - ; - (e.Line) = ; - } - - > + > e.AST; }; } +IndentedPutout { + s.FileHandle () = ; + s.FileHandle (e.Line) = ; +} + /** == e.RASL @@ -108,18 +121,26 @@ $ENTRY Log-HighLevelRASL { PutProgramElement { s.FileHandle - (Function s.ScopeClass (e.Name) e.Commands) - = ; + (Entries e.Names) + = >; + + s.FileHandle + (Externs e.Names) + = >; + + s.FileHandle + (Function (e.Name) e.Commands) + = ; s.FileHandle - (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) - = ' :: native {'> + (CmdNativeFunction (e.Name) t.SrcPos e.Code) + = ' :: native {'> ; s.FileHandle - (CmdMetatable s.ScopeClass (e.Name) e.Metatable) - = ' :: metatable {'> + (CmdMetatable (e.Name) e.Metatable) + = ' :: metatable {'> ; - s.FileHandle (CmdEnum s.ScopeClass e.Name) - = ' :: enum'>; - - s.FileHandle (CmdSwap s.ScopeClass e.Name) - = ' :: swap'>; + s.FileHandle (CmdEnum e.Name) + = ' :: enum'>; - s.FileHandle (CmdConditionFunc s.ScopeClass e.Name) - = ' :: condition'>; + s.FileHandle (CmdSwap e.Name) + = ' :: swap'>; - s.FileHandle (CmdDeclaration s.ScopeClass e.Name) - = ' :: extern'>; + s.FileHandle (CmdConditionFunc e.Name) + = ' :: condition'>; s.FileHandle (CmdDefineIdent e.Name) = >; @@ -148,24 +166,15 @@ PutProgramElement { = ; - - s.FileHandle (Spec (e.Name) e.Pattern) - = > - } PutRASLFunction { - s.FileHandle s.ScopeClass (e.Name) e.Commands - = ' {'> + s.FileHandle (e.Name) e.Commands + = ' {'> ; } -FnName { - GN-Local e.Name = ' ' ; - GN-Entry e.Name = ' $ENTRY ' ; -} - PutRASLCommands { s.FileHandle (e.Indent) e.Commands = ; - (CmdComment e.Message) - = ; + (CmdComment s.FnMessage) + = >; /* TODO: pretty print */ (s.Command e.Args) diff --git a/src/compiler/LowLevelRASL-Native.ref b/src/compiler/LowLevelRASL-Native.ref index dcafd354..5e21b3b8 100644 --- a/src/compiler/LowLevelRASL-Native.ref +++ b/src/compiler/LowLevelRASL-Native.ref @@ -15,7 +15,8 @@ $INCLUDE "LibraryEx"; */ $ENTRY LowLevelRASL-Native { s.Hash1 s.Hash2 (t.FuncTable t.IdentTable) e.Items - = + = : (e.Entries) e.Items^ + = : { /* нет нативных определений */ = /* нет нативного RASL’а */; @@ -30,6 +31,10 @@ $ENTRY LowLevelRASL-Native { }; } +GetEntries { + e.Items-B (Entries e.Entries) e.Items-E = (e.Entries) e.Items-B e.Items-E +} + PrepareTable { e.Prefix (0 /* пусто */) = /* пусто */; @@ -40,54 +45,38 @@ PrepareTable { } SetCookies { - s.Hash1 s.Hash2 (UnitName e.SrcName) = /* пропускаем */; - - s.Hash1 s.Hash2 - (Function-ToRASL s.ScopeClass (e.Name) e.Commands) = - /* пропускаем */; - - s.Hash1 s.Hash2 - (Function-ToNative s.ScopeClass (e.Name) e.Commands) = - (Function-ToNative - () - e.Commands - ); - - s.Hash1 s.Hash2 - (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) = - (CmdNativeFunction - () - t.SrcPos e.Code - ); - - s.Hash1 s.Hash2 - (CmdMetatable s.ScopeClass (e.Name) e.Metatable) = - /* пропускаем */; + e.Entries s.Hash1 s.Hash2 (UnitName e.SrcName) = /* пропускаем */; - s.Hash1 s.Hash2 (CmdEnum s.ScopeClass e.Name) = - /* пропускаем */; + e.Entries s.Hash1 s.Hash2 + (Function-ToRASL (e.Name) e.Commands) + = /* пропускаем */; - s.Hash1 s.Hash2 (CmdSwap s.ScopeClass e.Name) = - /* пропускаем */; + e.Entries s.Hash1 s.Hash2 + (Function-ToNative (e.Name) e.Commands) + = (Function-ToNative + () + e.Commands + ); - s.Hash1 s.Hash2 - (CmdConditionFunc-ToRASL s.ScopeClass e.Name) = - /* пропускаем */; - - s.Hash1 s.Hash2 - (CmdConditionFunc-ToNative s.ScopeClass e.Name) = - /* пропускаем */; - - s.Hash1 s.Hash2 (CmdDeclaration s.ScopeClass e.Name) = - /* пропускаем */; - - s.Hash1 s.Hash2 (CmdEmitNativeCode t.SrcPos e.Code) = - (CmdEmitNativeCode t.SrcPos e.Code); + e.Entries s.Hash1 s.Hash2 + (CmdNativeFunction (e.Name) t.SrcPos e.Code) + = (CmdNativeFunction + () + t.SrcPos e.Code + ); + + e.Entries s.Hash1 s.Hash2 (CmdMetatable (e.Name) e.Metatable) = /* пропускаем */; + e.Entries s.Hash1 s.Hash2 (CmdEnum e.Name) = /* пропускаем */; + e.Entries s.Hash1 s.Hash2 (CmdSwap e.Name) = /* пропускаем */; + e.Entries s.Hash1 s.Hash2 (CmdConditionFunc-ToRASL e.Name) = /* пропускаем */; + e.Entries s.Hash1 s.Hash2 (CmdConditionFunc-ToNative e.Name) = /* пропускаем */; + e.Entries s.Hash1 s.Hash2 (CmdEmitNativeCode t.SrcPos e.Code) + = (CmdEmitNativeCode t.SrcPos e.Code); } MingleName { - GN-Entry e.Name s.Hash1 s.Hash2 = e.Name Hash 0 0; - GN-Local e.Name s.Hash1 s.Hash2 = e.Name Hash s.Hash1 s.Hash2; + (e._ (e.Name) e._) e.Name s.Hash1 s.Hash2 = e.Name Hash 0 0; + (e.Entries) e.Name s.Hash1 s.Hash2 = e.Name Hash s.Hash1 s.Hash2; } PrepareFunctionsRASL { @@ -124,7 +113,7 @@ ConvertDirectCommands { ; (CmdVariableDebugTable s.Mode e.Index s.Offset) e.Tail - = (CmdComment 'DEBUG: ' s.Mode '.' e.Index ': ' ) + = (CmdComment { = 'DEBUG: ' s.Mode '.' e.Index ': ' }) ; t.Command e.Tail diff --git a/src/compiler/LowLevelRASL-RASL.ref b/src/compiler/LowLevelRASL-RASL.ref index b0e81056..26da2071 100644 --- a/src/compiler/LowLevelRASL-RASL.ref +++ b/src/compiler/LowLevelRASL-RASL.ref @@ -16,15 +16,14 @@ $INCLUDE "LibraryEx"; */ $ENTRY LowLevelRASL-RASL { s.DebugInfo s.Hash1 s.Hash2 (t.FuncTable t.IdentTable) e.Items + = : (e.Entries) e.Items^ - = - : (e.FuncScopeClass) e.Definitions + = + : (e.DefinedFunctions) e.Definitions - = + = : e.FuncScopeClass + + = : s.MaxLabel e.Definitions^ = ( @@ -35,52 +34,63 @@ $ENTRY LowLevelRASL-RASL { ); } +GetEntries { + e.Items-B (Entries e.Entries) e.Items-E = (e.Entries) e.Items-B e.Items-E +} + ClassifyItems { - (e.FuncScopeClass) (UnitName e.SrcName) = - (e.FuncScopeClass) (UnitName e.SrcName); + (e.DefinedFunctions) (UnitName e.SrcName) + = (e.DefinedFunctions) (UnitName e.SrcName); - (e.FuncScopeClass) (Function-ToRASL s.ScopeClass (e.Name) e.FunctionBody) = - (e.FuncScopeClass (s.ScopeClass e.Name)) - (Function-ToRASL s.ScopeClass (e.Name) e.FunctionBody); + (e.DefinedFunctions) (Function-ToRASL (e.Name) e.FunctionBody) + = (e.DefinedFunctions (e.Name)) + (Function-ToRASL (e.Name) e.FunctionBody); - (e.FuncScopeClass) (Function-ToNative s.ScopeClass (e.Name) e.Commands) = - (e.FuncScopeClass (s.ScopeClass e.Name)) - (CmdNativeFuncDescr s.ScopeClass e.Name); + (e.DefinedFunctions) (Function-ToNative (e.Name) e.Commands) + = (e.DefinedFunctions (e.Name)) + (CmdNativeFuncDescr e.Name); - (e.FuncScopeClass) (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) = - (e.FuncScopeClass (s.ScopeClass e.Name)) - (CmdNativeFuncDescr s.ScopeClass e.Name); + (e.DefinedFunctions) (CmdNativeFunction (e.Name) t.SrcPos e.Code) + = (e.DefinedFunctions (e.Name)) + (CmdNativeFuncDescr e.Name); - (e.FuncScopeClass) (CmdMetatable s.ScopeClass (e.Name) e.Metatable) = - (e.FuncScopeClass (s.ScopeClass e.Name)) - (CmdMetatable s.ScopeClass (e.Name) e.Metatable); + (e.DefinedFunctions) (CmdMetatable (e.Name) e.Metatable) + = (e.DefinedFunctions (e.Name)) + (CmdMetatable (e.Name) e.Metatable); - (e.FuncScopeClass) (CmdEnum s.ScopeClass e.Name) = - (e.FuncScopeClass (s.ScopeClass e.Name)) - (CmdEnumDescr s.ScopeClass e.Name); + (e.DefinedFunctions) (CmdEnum e.Name) + = (e.DefinedFunctions (e.Name)) + (CmdEnumDescr e.Name); - (e.FuncScopeClass) (CmdSwap s.ScopeClass e.Name) = - (e.FuncScopeClass (s.ScopeClass e.Name)) - (CmdSwapDescr s.ScopeClass e.Name); + (e.DefinedFunctions) (CmdSwap e.Name) + = (e.DefinedFunctions (e.Name)) + (CmdSwapDescr e.Name); - (e.FuncScopeClass) (CmdConditionFunc-ToRASL s.ScopeClass e.Name) = - (e.FuncScopeClass (s.ScopeClass e.Name)) - (CmdConditionFuncDecsrRasl s.ScopeClass e.Name); + (e.DefinedFunctions) (CmdConditionFunc-ToRASL e.Name) + = (e.DefinedFunctions (e.Name)) + (CmdConditionFuncDecsrRasl e.Name); - (e.FuncScopeClass) (CmdConditionFunc-ToNative s.ScopeClass e.Name) = - (e.FuncScopeClass (s.ScopeClass e.Name)) - (CmdConditionFuncDecsrNative s.ScopeClass e.Name); + (e.DefinedFunctions) (CmdConditionFunc-ToNative e.Name) + = (e.DefinedFunctions (e.Name)) + (CmdConditionFuncDecsrNative e.Name); - (e.FuncScopeClass) (CmdDeclaration s.ScopeClass e.Name) = - (e.FuncScopeClass (s.ScopeClass e.Name)) /* skip */; + (e.DefinedFunctions) (CmdEmitNativeCode t.SrcPos e.Code) + = (e.DefinedFunctions) /* skip */; +} - (e.FuncScopeClass) (CmdEmitNativeCode t.SrcPos e.Code) = - (e.FuncScopeClass) /* skip */; +MarkEntries { + (e.Entries) e.Names + = e.Name); + } + e.Names + > } PrepareFunctionsRASL { - s.DebugInfo s.NextLabel - (Function-ToRASL s.ScopeClass (e.Name) e.FunctionBody) + s.DebugInfo e.Entries s.NextLabel + (Function-ToRASL (e.Name) e.FunctionBody) = : e.FunctionBody^ @@ -93,6 +103,8 @@ PrepareFunctionsRASL { = : e.RASLCommands^ + = : s.ScopeClass + = s.NextLabel (CmdInterpretFuncDescr s.ScopeClass @@ -103,7 +115,12 @@ PrepareFunctionsRASL { e.RASLCommands ); - s.DebugInfo s.NextLabel t.OtherItem = s.NextLabel t.OtherItem; + s.DebugInfo e.Entries s.NextLabel (s.CmdDescr e.Name) + , CmdNativeFuncDescr CmdEnumDescr CmdSwapDescr : e._ s.CmdDescr e._ + = : s.ScopeClass + = s.NextLabel (s.CmdDescr s.ScopeClass e.Name); + + s.DebugInfo e.Entries s.NextLabel t.OtherItem = s.NextLabel t.OtherItem; } RemoveDebugInfo { @@ -140,7 +157,7 @@ ConvertInterpretCommands { } ConvertOneInterpretCommand-Simple { - (CmdComment e.Text) = /* skip comment command */; + (CmdComment s.FnText) = /* skip comment command */; (CmdUseRes) = /* пусто */; @@ -217,6 +234,11 @@ AddFunctionNameComment { >; } +Scope { + e._ (e.Name) e._ (e.Name) = GN-Entry; + e.Entries (e.Name) = GN-Local; +} + PrepareCommonRASL { (e.FuncScopeClass) (s.FunctionCount e.Functions) (s.IdentCount e.Idents) diff --git a/src/compiler/LowLevelRASL.ref b/src/compiler/LowLevelRASL.ref index 99414c96..223237f4 100644 --- a/src/compiler/LowLevelRASL.ref +++ b/src/compiler/LowLevelRASL.ref @@ -56,66 +56,69 @@ Canonize { } CalcDigest { - (s.Hash1 s.Hash2) (UnitName e.SrcName) = - () - (UnitName e.SrcName); + t.Hashes t.Element + = : t.Hashes^ t.Element^ + = t.Hashes ; +} - (s.Hash1 s.Hash2) (Function s.ScopeClass (e.Name) e.Commands) = - () - (Function s.ScopeClass (e.Name) e.Commands); +gen_t__ { e.arg = } +gen_e__ { e.arg = e.arg } - (s.Hash1 s.Hash2) - (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) = - () - (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code); +CalcDigest-Aux { + (s.Hash1 s.Hash2) (Entries e.Names) + = ) (e.Name); + } + (s.Hash1 s.Hash2) e.Names + > + : (s.Hash1^ s.Hash2^) e.Names^ + = (s.Hash1 s.Hash2) (Entries e.Names); - (s.Hash1 s.Hash2) - (CmdMetatable s.ScopeClass (e.Name) e.Metatable) = - () - (CmdMetatable s.ScopeClass (e.Name) e.Metatable); + (s.Hash1 s.Hash2) (UnitName e.SrcName) + = () + (UnitName e.SrcName); - (s.Hash1 s.Hash2) (CmdEnum s.ScopeClass e.Name) = - () - (CmdEnum s.ScopeClass e.Name); + (s.Hash1 s.Hash2) (Function (e.Name) e.Commands) + = () + (Function (e.Name) e.Commands); - (s.Hash1 s.Hash2) (CmdSwap s.ScopeClass e.Name) = - () - (CmdSwap s.ScopeClass e.Name); + (s.Hash1 s.Hash2) (CmdNativeFunction (e.Name) t.SrcPos e.Code) + = () + (CmdNativeFunction (e.Name) t.SrcPos e.Code); - (s.Hash1 s.Hash2) (CmdConditionFunc s.ScopeClass e.Name) = - () - (CmdConditionFunc s.ScopeClass e.Name); + (s.Hash1 s.Hash2) (CmdMetatable (e.Name) e.Metatable) + = () + (CmdMetatable (e.Name) e.Metatable); - (s.Hash1 s.Hash2) (CmdDeclaration s.ScopeClass e.Name) = - () - (CmdDeclaration s.ScopeClass e.Name); + (s.Hash1 s.Hash2) (CmdEnum e.Name) + = () + (CmdEnum e.Name); - (s.Hash1 s.Hash2) (CmdDefineIdent e.Name) = - (s.Hash1 s.Hash2) (CmdDefineIdent e.Name); + (s.Hash1 s.Hash2) (CmdSwap e.Name) + = () + (CmdSwap e.Name); - (s.Hash1 s.Hash2) (CmdEmitNativeCode t.SrcPos e.Code) = - (s.Hash1 s.Hash2) (CmdEmitNativeCode t.SrcPos e.Code); -} + (s.Hash1 s.Hash2) (CmdConditionFunc e.Name) + = () + (CmdConditionFunc e.Name); -HashFuncName { - s.Hash1 s.Hash2 s.ScopeClass e.Name s.Sign = - s.Sign - >; + (s.Hash1 s.Hash2) (CmdDefineIdent e.Name) + = (s.Hash1 s.Hash2) (CmdDefineIdent e.Name); + + (s.Hash1 s.Hash2) (CmdEmitNativeCode t.SrcPos e.Code) + = (s.Hash1 s.Hash2) (CmdEmitNativeCode t.SrcPos e.Code); } -CharFromScopeClass { - GN-Entry = 'E'; - GN-Local = 'L'; +HashFuncName { + s.Hash1 s.Hash2 e.Name s.Sign + = s.Sign>; } SetScopeIDs { - s.Hash1 s.Hash2 (Function s.ScopeClass (e.Name) e.Commands) - = (Function - s.ScopeClass (e.Name) - - ); + s.Hash1 s.Hash2 (Function (e.Name) e.Commands) + = (Function (e.Name) ); s.Hash1 s.Hash2 t.OtherItem = t.OtherItem; } @@ -171,36 +174,38 @@ SelectConstantsOutliner { = &OutlineConstants-WithNative e.Items-B (NativeBlock t.SrcPos e.Code) e.Items-E; - e.Items-B (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) e.Items-E + e.Items-B (CmdNativeFunction (e.Name) t.SrcPos e.Code) e.Items-E = &OutlineConstants-WithNative e.Items-B - (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) + (CmdNativeFunction (e.Name) t.SrcPos e.Code) e.Items-E; e.Items = &OutlineConstants-RASLOnly e.Items; } OutlineConstants-WithNative { + t.Tables (Entries e.Entries) = t.Tables (Entries e.Entries); + t.Tables (UnitName e.SrcName) = t.Tables (UnitName e.SrcName); - t.Tables (Function s.ScopeClass (e.Name) e.Commands) + t.Tables (Function (e.Name) e.Commands) = : t.Tables^ s.Id = : t.Tables^ e.Commands^ - = t.Tables (Function s.ScopeClass (e.Name) e.Commands); + = t.Tables (Function (e.Name) e.Commands); - t.Tables (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) + t.Tables (CmdNativeFunction (e.Name) t.SrcPos e.Code) = : t.Tables^ s.Id - = t.Tables (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code); + = t.Tables (CmdNativeFunction (e.Name) t.SrcPos e.Code); - t.Tables (CmdMetatable s.ScopeClass (e.Name) e.Metatable) + t.Tables (CmdMetatable (e.Name) e.Metatable) = : t.Tables^ e.Metatable^ = t.Tables - (CmdMetatable s.ScopeClass (e.Name) e.Metatable); + (CmdMetatable (e.Name) e.Metatable); - t.Tables (s.Definition s.ScopeClass e.Name) - , : True + t.Tables (s.Definition e.Name) + , : True = : t.Tables^ s.Id - = t.Tables (s.Definition s.ScopeClass e.Name); + = t.Tables (s.Definition e.Name); t.Tables (CmdDefineIdent e.Name) = : t.Tables^ s.Id @@ -211,16 +216,16 @@ OutlineConstants-WithNative { } OutlineConstants-RASLOnly { - t.Tables (Function s.ScopeClass (e.Name) e.Commands) + t.Tables (Function (e.Name) e.Commands) = : t.Tables^ e.Commands^ - = t.Tables (Function s.ScopeClass (e.Name) e.Commands); + = t.Tables (Function (e.Name) e.Commands); t.Tables (CmdDefineIdent e.Name) = t.Tables /* пропускаем */; - t.Tables (CmdMetatable s.ScopeClass (e.Name) e.Metatable) + t.Tables (CmdMetatable (e.Name) e.Metatable) = : t.Tables^ e.Metatable^ = t.Tables - (CmdMetatable s.ScopeClass (e.Name) e.Metatable); + (CmdMetatable (e.Name) e.Metatable); t.Tables t.OtherItem = t.Tables t.OtherItem; } @@ -308,17 +313,17 @@ UpdateTable { } MarkFunctionGenMode { - OnlyInterpret (Function s.ScopeClass (e.Name) e.Commands) = - (Function-ToRASL s.ScopeClass (e.Name) e.Commands); + OnlyInterpret (Function (e.Name) e.Commands) + = (Function-ToRASL (e.Name) e.Commands); - OnlyDirect (Function s.ScopeClass (e.Name) e.Commands) = - (Function-ToNative s.ScopeClass (e.Name) e.Commands); + OnlyDirect (Function (e.Name) e.Commands) + = (Function-ToNative (e.Name) e.Commands); - OnlyInterpret (CmdConditionFunc s.ScopeClass e.Name)= - (CmdConditionFunc-ToRASL s.ScopeClass e.Name); + OnlyInterpret (CmdConditionFunc e.Name) + = (CmdConditionFunc-ToRASL e.Name); - OnlyDirect (CmdConditionFunc s.ScopeClass e.Name) = - (CmdConditionFunc-ToNative s.ScopeClass e.Name); + OnlyDirect (CmdConditionFunc e.Name) + = (CmdConditionFunc-ToNative e.Name); s.GenMode (s.Type e.Info) = (s.Type e.Info); } diff --git a/src/compiler/ObjectMatch.ref b/src/compiler/ObjectMatch.ref deleted file mode 100644 index 27cc9614..00000000 --- a/src/compiler/ObjectMatch.ref +++ /dev/null @@ -1,659 +0,0 @@ -$INCLUDE "LibraryEx"; - -*$FROM TreeUtils -$EXTERN ExtractVariables, NewVarName; - - -/** - - == Clear (e.Val ':' t.Var)* - == Contracted ((t.Var ':' e.Val)* (e.Val ':' t.Var))* - == Failure - == Undefined - - e.Pattern, e.LPattern ::= t.PatternTerm* - t.PatternTerm — см. src/compiler/README.md - - e.Val ::= t.PatternTerm* - t.Var ::= (s.VarType e.Index) - s.VarType ::= 's' | 't' | 'e' -*/ - -$ENTRY ObjectMatch { - (e.Pattern) (e.LPattern) - = ) - ((e.Pattern) ':' (e.LPattern)) - > - : { - Success (() (e.Assigns)) = Clear ; - Success e.Solutions = Contracted e.Solutions; - Failure = Failure; - Undefined = Undefined; - } -} - -/* - - == Success t.Result* | Undefined | Failure - - t.Contr ::= (t.Var ':' e.Val) - t.Equation ::= ((e.Expr) ':' (e.LExpr)) - t.Assign ::= (e.Val ':' t.Var) - t.Result ::= ((t.Contr*) (t.Assign*)) -*/ - -Solve { - (e.UsedVars) ((e.Expr) ':' (e.Lexpr)) - = - : { - = Failure; - e.B Undefined e.A = Undefined; - e.Other = Success - }; -} - -FormatAssigns { - e.Assigns = - -} - -IsSVarSubset { - (Symbol s.Type e.Info) = True; - (Var 's' e.Tindex) = True; - (Closure e.Body) = True; - (ClosureBrackets e.Context) = True; - - t.OtherTerm = False; -} - -/* Преобразует формат результата функции Solve-Aux к формату Solve */ - -CombineResults { - (e.Solutions) Success (e.Contrs) (e.Assigns) e.Rest - = ; - (e.Solutions) /* пусто */ = e.Solutions -} - -Eq { - (e.X) (s.X) = True; - e.Other = False -} - -/* - Проверка наличия повторных переменных в присваиваниях - - == True | False -*/ - -HasRepeatedVarsAssigns { - (e.B (e.Expr ':' t.Var) e.M) (e.L t.Var e.R) = True; - (e.Lexpr) (e.RVars) = False -} - -/* Постобработка результатов решения уравнений - - - == Success (t.Contraction*) (t.Assign*) | Undefined -*/ - -Solution-PostProcess { - /* - если есть идентичные присваивания, то удалаяем их - */ - (e.Contractions) (e.Assigns) - , e.Assigns - : e.B (e.Expr ':' (Var e.HIndex)) e.M (e.Expr ':' (Var e.HIndex)) e.E - = ; - - /* - Если есть непротиворечивые присваивания вида: - (s.A <- v.B) и (s.C <- v.B) то добавляется сужение (s.C -> v.A) - и второе присваивание удаляется - */ - - (e.Contractions) (e.Assigns) - , e.Assigns - : e.B - ((Var 's' e.Index1) ':' (Var e.HIndex)) - e.M - ((Var 's' e.Index2) ':' (Var e.HIndex)) - e.E - = - >; - - /* - Если есть присваивания вида: - (s.A <- v.B) и (X <- v.B) то добавляем сужение (v.A -> X) - и удаляем первое присваивание - */ - - (e.Contractions) (e.Assigns) - , e.Assigns - : e.B - ((Var 's' e.PIndex) ':' (Var e.HIndex)) - e.M - ((Symbol s.Type e.Info) ':' (Var e.HIndex)) - e.E - = - >; - - (e.Contractions) (e.Assigns) - , e.Assigns - : e.B - ((Symbol s.Type e.Info) ':' (Var e.HIndex)) - e.M - ((Var 's' e.PIndex) ':' (Var e.HIndex)) - e.E - = - >; - - /* - Если есть непротиворечивые присваивания вида: - (X <- v.A) (X <- v.A) то удаляем одно из них - */ - - (e.Contractions) (e.Assigns) - , e.Assigns - : e.B - ((Symbol s.Type e.Info) ':' (Var e.HIndex)) - e.M - ((Symbol s.Type e.Info) ':' (Var e.HIndex)) - e.E - = ; - - /* - Если есть противоречивые присваивания вида: - (X <- s.A) и (Y <- s.A) то ничего не возвращаем - */ - - (e.Contractions) (e.Assigns) - , e.Assigns - : e.B - ((Symbol e.Info1) ':' (Var e.HIndex)) - e.M - ((Symbol e.Info2) ':' (Var e.HIndex)) - e.E - = /* пусто, т.к. противоречие */; - - /* - если есть идентичные сужения, то удаляем их - */ - - (e.Contractions) (e.Assigns) - , e.Contractions - : e.B - (e.Expr ':' (Var e.HIndex)) - e.M - (e.Expr ':' (Var e.HIndex)) - e.E - = ; - - - (e.Contractions) (e.Assigns) - , e.Assigns - : e.B - (e.Expr1 ':' (Var e.HIndex)) - e.M - (e.Expr2 ':' (Var e.HIndex)) - e.E - = Undefined; - - /* - Здесь намеренно не рассмотрены случаи вида - {{ &F\1 … }} ← var && s.X ← var, - поскольку они приводят к бессмысленным сужениям вида - s.X → {{ &F\1 … }} - */ - - - (e.Contractions) (e.Assigns) = Success (e.Contractions) (e.Assigns) -} - -/* - - == t.Result* - - t.Contr ::= (t.Var ':' e.Val) - t.Equation ::= ((e.Expr) ':' (e.LExpr)) - t.Assign ::= (e.Val ':' t.Var) - t.Result ::= Success ((t.Contr*) (t.Assign*)) | Undefined -*/ - -Solve-Aux { - /* В начале системы уравнение вида T E : Lt Le */ - (e.UsedVars) (e.Contrs) ((t.Pt e.Pe) ':' (t.Ht e.He)) e.Equations (e.Assigns) - , : True - , : True - = - : { - Success e.PRTC = ; - Failure = - }; - - /* В начале системы уравнение вида E T: Le Lt */ - (e.UsedVars) (e.Contrs) ((e.Pe t.Pt) ':' (e.He t.Ht)) e.Equations (e.Assigns) - , : True - , : True - = - : { - Success e.PRTC = ; - Failure = - }; - - /* Если уравнение имеет вид Expr: e.x, добавляем присванивание - вида Expr <- e.x */ - (e.UsedVars) (e.Contrs) ((e.Pe) ':' ((Var 'e' e.Idx))) - e.Equations (e.Assigns) - = ; - - /* Если уравнение имеет вид e.i* : empty, возвращаем результат, - предварительно добавив пустые сужения - */ - (e.UsedVars) (e.Contrs) ((e.Pt) ':' ()) e.Equations (e.Assigns) - , - : { - True - = : e.NewContrs - = - >; - - False = /* нет решений */; - }; - - /* Уравнения вида E : e.x P' e.y - Перебираем все возможные разбиения - E -> E' E'' - и решаем уравнения - E'' : P' e.Y - */ - (e.UsedVars) - (e.Contrs) - ((e.E) ':' (t.Ex e.Pe t.Ey)) e.Equations - (e.Assigns) - , : True - , : True - = - : { - Success (e.NewContrs) (e.NewAssigns) - = ; - - Undefined = Undefined; - }; - - /* Если уравнение имеет вид empty: Lt Le, ничего не возвращаем */ - (e.UsedVars) (e.Contrs) (() ':' (t.Ht e.He)) e.Equations (e.Assigns) - , : True - = /* противоречие */; - - /* Если уравнение имеет вид empty: Le Lt, ничего не возвращаем */ - (e.UsedVars) (e.Contrs) (() ':' (e.He t.Ht)) e.Equations (e.Assigns) - , : True - = /* противоречие */; - - (e.UsedVars) (e.Contrs) (e.Assigns) - = ; - - e.Other - = Undefined -} - - -/* - Перебираем все возможные разбиения - E -> E' E'' - и решаем уравнения - E'' : P' e.Y -*/ - -Solve-Iter { - (e.UsedVars) - (e.Contrs) - ((t.Ess e.Ess) ':' (e.Pe t.Ey)) - (e.Assigns) - = - : { - /* пусто */ = Undefined; - - Success (e.Contrs^) (e.Assigns^) - = Success (e.Contrs) (e.Assigns); - - Undefined - = ; - }; - - (e.UsedVars) - (e.Contrs) - (() ':' (e.Pe t.Ey)) - (e.Assigns) - = Undefined; -} - - -/* - Решает уравнение вида P:H для термов - - - == t.Result - - t.Result ::= Success t.PRTC | Failure - e.PRTC :: = (t.Contrs*) t.Equations* (t.Assigns*) - - PRTC - partially resolved term clash -*/ - -Solve-TermEquation { - /* H является символом */ - (e.UsedVars) t.Symbol t.Symbol e.PRTC - , t.Symbol : (Symbol s.Type e.Info) - = Success (e.UsedVars) e.PRTC - /* нет подстановок, нет сужений */; - - /* P - символ, H - s-переменная */ - (e.UsedVars) t.Symbol t.Svar (e.Contrs) e.Equations (e.Assigns) - , : True - , t.Svar : (Var 's' e.Hindex) - = Success - (e.UsedVars) - (e.Contrs) e.Equations - (e.Assigns (t.Symbol ':' t.Svar)); - - /* P - s-переменная, H - s-переменная */ - (e.UsedVars) t.PSvar t.HSvar (e.Contrs) e.Equations (e.Assigns) - , t.PSvar t.HSvar - : (Var 's' e.Pindex) (Var 's' e.Hindex) - = Success - (e.UsedVars) - (e.Contrs) - e.Equations - (e.Assigns (t.PSvar ':' t.HSvar)); - - - /* P - s-переменная, H - символ */ - (e.UsedVars) t.Svar t.Symbol (e.Contrs) e.Equations (e.Assigns) - , t.Svar : (Var 's' e.Pindex) - , : True - = Success - (e.UsedVars) - ; - - /* P - терм, H - t-переменная */ - (e.UsedVars) t.PVar t.HVar (e.Contrs) e.Equations (e.Assigns) - , t.HVar: (Var 't' e.Tindex) - = Success - (e.UsedVars) - (e.Contrs) - e.Equations - (e.Assigns (t.PVar':'(Var 't' e.Tindex))); - - /* P - t-переменная, H - скобочный терм */ - (e.UsedVars) t.PTvar (Brackets e.HBody) (e.Contrs) e.Equations (e.Assigns) - , t.PTvar : (Var 't' e.Pindex) - = - : t.NewVars 'e' e.NewIndex - = Success - t.NewVars - ; - - /* P - t-переменная, H - скобочный терм */ - (e.UsedVars) - t.PTvar (ADT-Brackets (e.Name) e.HBody) - (e.Contrs) e.Equations (e.Assigns) - , t.PTvar : (Var 't' e.Pindex) - = - : t.NewVars 'e' e.NewIndex - = Success - t.NewVars - ; - - /* P - t-переменная, H - символ */ - (e.UsedVars) t.PTvar t.Symbol (e.Contrs) e.Equations (e.Assigns) - , t.PTvar t.Symbol - : (Var 't' e.Pindex) (Symbol s.Type e.Info) - = Success - (e.UsedVars) - ; - - /* P - t-переменная, H - s-переменная */ - (e.UsedVars) t.PTvar t.HSvar (e.Contrs) e.Equations (e.Assigns) - , t.PTvar t.HSvar - : (Var 't' e.Pindex) (Var 's' e.Hindex) - = : (e.UsedVars^) 's' e.sIdx - = Success - (e.UsedVars) - ; - - /* H является (H′) */ - (e.UsedVars) - (Brackets e.TBody)(Brackets e.HBody) - (e.Contrs) e.Equations (e.Assigns) - = Success - (e.UsedVars) - (e.Contrs) e.Equations ((e.TBody) ':' (e.HBody)) - (e.Assigns); - - /* H является [H′] */ - (e.UsedVars) - (ADT-Brackets (e.Name) e.TBody)(ADT-Brackets (e.Name) e.HBody) - (e.Contrs) e.Equations (e.Assigns) - = Success - (e.UsedVars) - (e.Contrs) e.Equations ((e.TBody) ':' (e.HBody)) (e.Assigns); - - e.Other = Failure -} - -IsTerm { - (Var 'e' e.Index) = False; - - /* Рассматриваем для оптимизаций встраивания, прогонки и специализации */ - (CallBrackets e.Nested) = False; - (ColdCallBrackets e.Nested) = False; - - /* s-, t-переменная, скобки обоих видов, символ */ - t.OtherTerm = True; -} - -IsEVar { - (Var 'e' e._) = True; - t._ = False; -} - -/* - Добавление нескольких сужений к PRTC - - - == PRTC -*/ - -AddContractions { - (t.toAdd e.Rem) (e.Contractions) e.Equations (e.Assigns) = - - >; - - () e.PRTC = e.PRTC; -} - -/* - Добавление сужения к PRTC - - - == PRTC -*/ -AddContraction { - t.toAdd (e.Contractions) e.Equations (e.Assigns) = - (e.Contractions t.toAdd) - -} - - -/* - Применение сужения к PRTC - - - == t.Equation* (t.Assign*) -*/ - -ApplyContraction { - t.Contraction e.Equations (e.Assigns) = - - () -} - -/* - Применение сужения к присваиванию - - ':' t.Rval); -} - -/* - Применение сужения к уравнению - - == t.Equation -*/ - -ApplyContraction-toEquation { - t.Contraction ((e.Expr) ':' (e.Lexpr)) = - (() ':' (e.Lexpr)) -} - -/* - Применение сужения к выражению - - == e.Expr -*/ - -ApplyContraction-toExpr { - (t.Var ':' e.Lval) e.B t.Var e.E = - - e.Lval - ; - - t.Contraction e.B (Brackets e.M) e.E = - - (Brackets ) - ; - - t.Contraction e.B (ADT-Brackets e.M) e.E = - - (ADT-Brackets ) - ; - - t.Contraction e.Expr = e.Expr -} - -/* Проверка на последовательность свободных переменных */ - -IsFreeVariableSeq { - /* пусто */ = True; - - (Var 'e' e.Idx) e.Rem = ; - - t.Other e.Rem = False -} diff --git a/src/compiler/OptTree-AutoMarkup-Drive.ref b/src/compiler/OptTree-AutoMarkup-Drive.ref deleted file mode 100644 index bf15f4c6..00000000 --- a/src/compiler/OptTree-AutoMarkup-Drive.ref +++ /dev/null @@ -1,631 +0,0 @@ -$INCLUDE "LibraryEx"; - -*$FROM TreeUtils -$EXTERN HashName; - - -/** - == e.AST - - e.RootSet ::= (e.FuncName)* -*/ - -$ENTRY OptTree-AutoMarkup-Drive { - e.AST - = : t.MetaInfo e.AST^ - = t.MetaInfo : ((e.Forbidden) (e.Inlines) (e.UserdefDrives) (e.Entries)) - - = : (e.Indirects) e.Graph - - = : e.Roots - = - : (ToDrive e.ToDrive) (Basics e.Basics) (Unreachable e.Unreachable) - = : e.ToDrive^ - = -} - -BuldCallGraph { - e.AST (e.Inlines) - = : (e.Metatables) e.Functions - = : e.Metatables^ - = : e.Graph - - = : e.Graph^ - - = : (e.Indirects) e.Graph^ - = : e.Graph^ - - = : (e.InlinesRef) e.Graph^ - = : e.Graph^ - = (e.Indirects) e.Graph; -} - -MetaInfo { - e.AST - = ((/* forbidden list */) (/* inlines */) (/* drives */) (/* entries */)) - : t.InitMetaInfo - = (Inline e.Name); - - t.MetaInfo (Drive e.Name) - = (Drive e.Name); - - t.MetaInfo (Intrinsic e.Name) - = (Intrinsic e.Name); - - t.MetaInfo - (Function - GN-Local (e.FuncName) Sentences - (((Var 'e' e.Index)) /*=*/ ((Var 'e' e.Index))) - ) - , : True - = - (Function - GN-Local (e.FuncName) Sentences - (((Var 'e' e.Index)) /*=*/ ((Var 'e' e.Index))) - ); - - t.MetaInfo (Function s.Scope (e.FuncName) Sentences e.Body) - = : s.SentencesCount e.Body^ - = /* пусто */ - : { - /* пусто */, s.SentencesCount : 0 - = ; - - /* пусто */, : '+' - = ; - - /* пусто */ = t.MetaInfo; - } - : t.MetaInfo^ - = - (Function s.Scope (e.FuncName) Sentences e.Body); - - t.MetaInfo t.Other = t.MetaInfo t.Other; - } - t.InitMetaInfo e.AST - > -} - -MetaInfo-AddInline { - ((e.Forbidden) (e.Inlines) (e.Drives) (e.Entries)) e.Name - = ((e.Forbidden (e.Name)) (e.Inlines (e.Name)) (e.Drives) (e.Entries)); -} - -MetaInfo-AddDrive { - ((e.Forbidden) (e.Inlines) (e.Drives) (e.Entries)) e.Name - = ((e.Forbidden) (e.Inlines) (e.Drives (e.Name)) (e.Entries)); -} - -MetaInfo-AddForbidden { - ((e.Forbidden) (e.Inlines) (e.Drives) (e.Entries)) e.Name - = ((e.Forbidden (e.Name)) (e.Inlines) (e.Drives) (e.Entries)); -} - -Pseudofunction-gen_e { - 'gen_e__' = True; - 'gen-e__' = True; - 'gen_e__' SUF '~' s.N = True; - 'gen-e__' SUF '~' s.N = True; - - e._ = False; -} - -MetaInfo-AddEntry { - ((e.Forbidden) (e.Inlines) (e.Drives) (e.Entries)) GN-Entry e.Name - = ((e.Forbidden) (e.Inlines) (e.Drives) (e.Entries (e.Name))); - - ((e.Forbidden) (e.Inlines) (e.Drives) (e.Entries)) GN-Local e.Name - = ((e.Forbidden) (e.Inlines) (e.Drives) (e.Entries)); -} - -SeparateMetatables { - e.AST - = -} - -MakeGraphNode { - (Function s.ScopeClass (e.MetatableName) Metatable e.Metatable) - = - : e.Children - = (Func (e.MetatableName) Children (e.Children (INDIRECT))); - - (Function s.ScopeClass (e.Name) Sentences e.Sentences) - = (Func (e.Name) Children ()); - - t._ = /* пропускаем */; -} - -Children-Body { - e.Sentences - = - - - } - e.Conditions - > - - > - } - e.Sentences - >; -} - -Children-Expr { - e.Expression = -} - -Children-Term { - (CallBrackets (Symbol Name e.Name) e.Expr) - = (Call e.Name) ; - - (CallBrackets (ClosureBrackets (Symbol Name e.Name) e.Context) e.Expr) - = (Call e.Name) ; - - (CallBrackets e.Expr) = (INDIRECT) ; - - (Symbol Name e.Name) = (Pointer e.Name); - - (ADT-Brackets (e.Name) e.Expr) = (Pointer e.Name) ; - - (s.Brackets e.Expr) - , Brackets ClosureBrackets : e._ s.Brackets e._ - = ; - - t.AnyOtherTerm = /* ничего интересного */; -} - -InlineMetatableGraphNodes { - e.Graph (e.Metatables) - = ) - } - (e.Graph) e.Metatables - > - : (e.Graph^) - = e.Graph; -} - -InlineOneMetatable { - e.Functions-B - (Func (e.Name) Children (e.Children-B (Pointer e.MetatableName) e.Children-E)) - e.Functions-E - t.Metatable - , t.Metatable : (Func (e.MetatableName) Children (e.MetatableNodes)) - = e.Functions-B - (Func (e.Name) Children (e.Children-B e.MetatableNodes e.Children-E)) - ; - - e.Functions t.Metatable = e.Functions; -} - -SeparateInlineGraphNodes { - e.Graph (e.Inlines) - = -} - -InlineInlineReferences { - e.Graph (e.Inlines) - = : e.Inlines^ - = -} - -MakeInlineClosure { - (e.InlinesAcc) e.Inlines - = - : { - e.InlinesAcc /* same */ = e.InlinesAcc; - - e.InlinesAcc^ = ; - } -} - -ApplyInlines { - e.Graph (e.Inlines) - = - : e.Inlines^ (e.Children^) - = (e.Inlines) (Func (e.Name) Children (e.Children)); - } - (e.Inlines) e.Graph - > - : (e._) e.Graph^ - = e.Graph; -} - -ApplyInlines-Children { - e.Inlines-B (Func (e.Name) Children (e.InlineChilden)) e.Inlines-E - (e.Children-B (e.Name) e.Children-E) - = e.Children-B (e.Name) e.Children-E : e.Children - = : e.Children^ - = e.Inlines-B (Func (e.Name) Children (e.InlineChilden)) - ; - - e.Inlines (e.Children) = e.Inlines (e.Children); -} - -* == e.Set1 e.Set2\Set1 -UnionChildren { - e.Unique t.Common e.NotScanned (e.New-B t.Common e.New-E) - = e.Unique t.Common ; - - e.Unique (e.New) = e.Unique e.New; -} - -SeparateIndirects { - e.Graph - = - : (e.FunctionIndirects) e.Children^ - - = (e.Indirects e.FunctionIndirects) - (Func (e.Name) Children ()); - } - (/* indirects */) - e.Graph - > - : (e.Indirects) e.Graph^ - = () e.Graph; -} - -SeparateIndirects-Children { - e.Children - = -} - -InlineIndirects { - e.Graph-B - (Func (e.Name) Children (e.Children-B INDIRECT e.Children-E)) - e.Graph-E - (e.Indirects) - = e.Graph-B - (Func (e.Name) Children ()) - ; - - e.Graph (e.Indirects) = e.Graph; -} - -/* - - == (ToDrive e.FuncNames) (Basics e.FuncNames) (Unreachable e.FuncNames) - e.FuncNames ::= (e.Name)* -*/ -BasicVertexes { - e.Graph (e.Roots) - = : e.GraphHash - = (e.GraphHash) (/* to drive */) (/* basic */) - >; -} - -MakeGraphHash { - e.Graph - = > : s.Hash - = (s.Hash Func (e.Name) Children (e.Children)); - } - e.Graph - > - : e.Graph^ - = ; -} - -BUCKET-SIZE { = 101 } - -MakeGraphHash-Buckets { - (s.Hash Func (e.Name) Children (e.Children)) e.Graph - = - : e.Graph^ (e.Bucket) - = (e.Bucket); - - /* граф опустел */ = /* нет корзин */; -} - -MakeGraphHash-FillBucket { - e.Graph-B (s.Hash Func (e.Name) Children (e.Children)) e.Graph-E - (s.Hash e.Bucket) - = e.Graph-B - ; - - e.Graph (e.Bucket) = e.Graph (e.Bucket); -} - -MarkChildren { - e.FuncNames - = (Children - > e.Name) - } - e.FuncNames - > - ) -} - -/* - - - e.ToDrive, e.Basics ::= (e.Name)* - e.Stack ::= t.StackItem* - t.StackItem ::= (Children (s.Hash e.Name)*) | (Func s.Hash e.Name) - - Функция совершает обход графа в глубину. - - На стек кладутся потомки функции, а также имя самой функции. Когда со стека - снимается потомок, и эта функция ещё не сканирована (есть в графе), - на стек кладутся потомки потомка и имя самого потомка. Когда все потомки - функции просканированы, на верхушке остаётся имя самой функции, которое - можно снять. Для алгоритма обхода в чистом виде имена функций на стеке - не так уж и важны, они нужны для маркировки прогоняемых и базисных функций. - - Интересно получается с базисными вершинами. Базисная вершина — это вершина, - в которую ведёт стрелка от потомка. Поэтому если на стеке есть имя функции, - совпадающей с очередным потомком, эта функция базисная. Вырезаем её - из стека и запоминаем как базисную. Если на вершине стека обнаружилось - имя функции, это значит, что ссылки из потомков на неё не было, она - не является базисной и пригодна для прогонки. - - В графе находятся только функции с предложениями. Все имена функций из графа, - достижимые из корней, кладутся на стек (включая корни). Любое имя, оказавшееся - на стеке, либо переносится в карман базисных, либо прогоняемых. Функции, - оставшиеся в графе, являются недостижимыми. Таким образом, множество функций - из графа разбивается на три подмножества: базисные, прогоняемые - и недостижимые. -*/ -DoBasicVertexes { -* Базисная вершина, удаляем пометку функции со стека. - (Children (s.Hash e.BasicName) e.Siblings) - e.Stack-B (Func s.Hash e.BasicName) e.Stack-E - (e.Graph) (e.ToDrive) (e.Basics) - = ; - -* Обычная вершина. - (Children (s.Hash e.FuncName) e.Siblings) e.Stack - ( - e.Buckets-B - (s.Hash e.Graph-B (Func (e.FuncName) Children (e.Children)) e.Graph-E) - e.Buckets-E - ) - (e.ToDrive) (e.Basics) - = (Func s.Hash e.FuncName) - (Children e.Siblings) e.Stack - (e.Buckets-B e.Buckets-E) - (e.ToDrive) (e.Basics) - >; - -* Уже просканированная вершина или вызов внешней функции. - (Children (s._ e._) e.Siblings) e.Stack (e.Graph) (e.ToDrive) (e.Basics) - = ; - - (Children /* пусто */) e.Stack (e.Graph) (e.ToDrive) (e.Basics) - = ; - -* Всех детей функции просканировали. -* Если сама метка функции не удалена со стека, значит она не была базисной. - (Func s.Hash e.FuncName) e.Stack (e.Graph) (e.ToDrive) (e.Basics) - = ; - -* Все функции просканировали. - /* пустой стек */ (e.Graph) (e.ToDrive) (e.Basics) - = (ToDrive e.ToDrive) - (Basics e.Basics) - (Unreachable - - } - e.Graph - > - ); -} - -WrapBucket { - s.Hash /* пусто */ = /* пусто */; - s.Hash e.Bucket = (s.Hash e.Bucket); -} - -SetDifference { - e.Set1-B t.Common e.Set1-E (e.Set2-B t.Common e.Set2-E) - = e.Set1-B ; - - e.Set1 (e.Set2) = e.Set1; -} - -UpdateAST { - e.AST (e.FunctionsToDrive) (e.BasisVertexes) - = - : (e._) e.AST^ - = e.AST - -} - -/** - == e.AST -*/ -$ENTRY OptTree-AutoMarkup-CureDrives { - e.AST - = : t.MetaInfo e.AST^ - = t.MetaInfo : ((e.Forbidden) (e.Inlines) (e.UserdefDrives) (e.Entries)) - - = : (e.Indirects) e.Graph - - = - : (e.DrivenNodes) e.NamesCalledFromUndriven - - = - : e.Roots - = : e.Roots^ - = - : (ToDrive e.ToDrive) (Basics e.Basics) (Unreachable e.Unreachable) - - /* новых функций для прогонки не добавляем */ - = /* пусто */ : e.ToDrive^ - = -} - -SetIntersect { - (e.Set1-B t.Common e.Set1-E) (e.Set2-B t.Common t.Set2-E) - = t.Common ; - - (e.Set1) (e.Set2) = /* пусто */; -} - - -/** - == e.AST -*/ -$ENTRY OptTree-AutoMarkup-CleanupUnusedFunctions { - e.AST - = : e.Graph - = : e.Graph^ - - = : (e.Roots) e.Graph^ - = - : (ToDrive e.ToDrive) (Basics e.Basics) (Unreachable e.Unreachable) - - = - : (/* должно быть пусто */) e.AST^ - = e.AST; -} - -RemoveReferenceTagFromChildren { - (Func (e.FuncName) Children (e.Children)) - = - : e.Children^ - = (Func (e.FuncName) Children (e.Children)); -} - -UnsuffixedFunctions { - (e.Roots) t.Node - = t.Node : (Func (e.FuncName) Children (e.Children)) - = e.FuncName - : { - e._ SUF e._ = e.Roots; - e._ = e.Roots (e.FuncName); - } - : e.Roots^ - = (e.Roots) t.Node; -} - -RemoveUnused { - (e.Unused-B (e.Name) e.Unused-E) - (Function s.ScopeClass (e.Name) Sentences e._) - = (e.Unused-B e.Unused-E) /* пропускаем */; - - (e.Unused-B (e.Name) e.Unused-E) - (Function s.ScopeClass (e.Name) Metatable e._) - = (e.Unused-B e.Unused-E) /* пропускаем */; - - (e.Unused) t.OtherItem = (e.Unused) t.OtherItem; /* оставляем */ -} diff --git a/src/compiler/OptTree-AutoMarkup-Spec.ref b/src/compiler/OptTree-AutoMarkup-Spec.ref deleted file mode 100644 index 003760f8..00000000 --- a/src/compiler/OptTree-AutoMarkup-Spec.ref +++ /dev/null @@ -1,278 +0,0 @@ -$INCLUDE "LibraryEx"; - -*$FROM GlobalGen -$EXTERN GlobalGen; - -*$FROM GenericMatch -$EXTERN GenericMatch; - -*$FROM TreeUtils -$EXTERN ExtractVariables-Expr; - - -/** - == e.AST -*/ - -$ENTRY OptTree-AutoMarkup-Spec { - e.AST - = : (e.Forbidden) e.AST^ - = - : e.ExtractedPatterns - = ; - - t.Other = /* пусто */; - } - e.AST - > - : e.SpecPatterns - = e.AST - ; -} - -ForbiddenToSpecFunctions { - e.AST - = -} - -GetSpecifiedPattern { - (e.Name) e.ExtractedPatterns - = : e.IndexedGlobalGen - = - : Clear e.GenericMatch - = (e.GenericMatch); - } - e.ExtractedPatterns - > - : e.GenericMatches - = - : e.VariableMatchesDict - = : e.StaticCandidates - = - : { - /* пусто */ = /* нет статических переменных, пропускаем */; - - e.StaticParams - = : e.Pattern - = ((e.Name) e.Pattern); - }; -} - -GetIndexedGlobalGen { - e.Patterns - = : e.GlobalGen - = : e.GlobalGen^ - = : e.GlobalGen^ - = : e.GlobalGen^ - = e.GlobalGen; -} - -FillIndexes { - (e.GlobalGen) s.Type - = - : (e._) e.IndexedTypeGlobalGens - = e.IndexedTypeGlobalGens; -} - -FillIndexesRec { - (e.StartIndex) (e.GlobalGen) s.Type - = - : e.NewIndex - = (e.NewIndex) (e.IndexedVariable); - - (e.CurrentIndex) (Var e.Other) - = (e.CurrentIndex) (Var e.Other); - - (e.CurrentIndex) (Brackets e.Nested) - = - : (e.NextIndex) e.IndexedTypeGlobalGens - = (e.NextIndex) (Brackets e.IndexedTypeGlobalGens); - - (e.CurrentIndex) (ADT-Brackets (e.Name) e.Nested) - = - : (e.NextIndex) e.IndexedTypeGlobalGens - = (e.NextIndex) (ADT-Brackets (e.Name) e.IndexedTypeGlobalGens); - - (e.CurrentIndex) (Symbol e.Info) = (e.CurrentIndex) (Symbol e.Info); - } - (e.StartIndex) e.GlobalGen - > -} - -GetVariableMatches { - e.GenericMatches (e.IndexedGlobalGen) - = > : e.Variables - - = - : e.VariableBags - - = - : (e.VariableBags^) - - = e.VariableBags; -} - -GetVariableMatches-FillBag { - (e.VariableBags) (e.Subst) - = ; -} - -VarsSameIndex { - s.Mode ((Var s.Mode e._)) e.Matches = ; - s.Mode /* пусто */ = True; - s.Mode e._ = False; -} - -StaticCandidates { - e.VariableMatchesDict - = : True - = (s.Mode s.Index); - - t.VarMatches = /* пропускаем */; - } - e.VariableMatchesDict - > -} - -MarkupVarsInPattern { - (e.StaticParams) e.Pattern - = ); - - (Var s.Mode s.Index) = (Var s.Mode 'dyn' ); - - (Symbol e.Info) = (Symbol e.Info); - - (Brackets e.Expr) - = (Brackets ); - - (ADT-Brackets (e.Name) e.Expr) - = (ADT-Brackets - (e.Name) - ); - } - e.Pattern - >; -} - -FilterUnrepeatedStaticParams { - e.StaticCandidates (e.GenericMatches) - = - : e.GenericMatches^ - = ; -} - -FilterUnrepeatedStaticParams-CleanupMatch { - e.StaticCandidates (e.Substitution) - = - : e.Substitution^ - = (e.Substitution); -} - -FilterUnrepeatedStaticParams-RemoveBad { - e.StaticCandidates-B t.BadParam e.StaticCandidates-E (e.GenericMatches) - , e.GenericMatches : e._ (e.Subst) e._ - , e.Subst : e._ (t.MappedVar ':' t.BadParam) e._ (t.MappedVar ':' t._) e._ - = ; - - e.StaticCandidates (e.GenericMatches) = e.StaticCandidates; -} - -FilterSpecPatterns { - e.SpecializableDict (e.Forbidden) - = - : (e._) e.SpecDirectives - = e.SpecDirectives -} diff --git a/src/compiler/OptTree-AutoMarkup.ref b/src/compiler/OptTree-AutoMarkup.ref new file mode 100644 index 00000000..1c44482b --- /dev/null +++ b/src/compiler/OptTree-AutoMarkup.ref @@ -0,0 +1,369 @@ +$INCLUDE "LibraryEx"; + +*$FROM TreeUtils +$EXTERN HashName; + + +/** + == e.AST + + e.RootSet ::= (e.FuncName)* +*/ + +$ENTRY OptTree-AutoMarkup-Drive { + e.AST + = + : { + 0 /* пусто */ = e.Drives (e.Body); + + s.SentencesCount e.Body^, : '+' + = e.Drives (e.Body); + + s.SentencesCount e.Body^ = e.Drives (e.Name) (e.Body); + } + : e.Drives^ (e.Body^) + = (Drives e.Drives) (Function (e.Name) Sentences e.Body); + + /* пользовательскую разметку игнорируем */ + (Drives e.Drives) (Drives e._) + = (Drives e.Drives) /* игнорируем */; + + (Drives e.Drives) t.Other = (Drives e.Drives) t.Other; + } + (Drives /* пусто */) e.AST + > +} + + +/** + == e.AST +*/ +$ENTRY OptTree-AutoMarkup-DriveInstances { + e.AST + = +} + + +MakeGraphNode { + (Function (e.MetatableName) Metatable e.Metatable) + = + : e.Children + = (Func (e.MetatableName) Children (e.Children (INDIRECT))); + + (Function (e.Name) Sentences e.Sentences) + = (Func (e.Name) Children ()); + + t._ = /* пропускаем */; +} + +Children-Body { + e.Sentences + = + + + } + e.Conditions + > + + > + } + e.Sentences + >; +} + +Children-Expr { + e.Expression = +} + +Children-Term { + (CallBrackets (Symbol Name e.Name) e.Expr) + = (Call e.Name) ; + + (CallBrackets (ClosureBrackets (Symbol Name e.Name) e.Context) e.Expr) + = (Call e.Name) ; + + (CallBrackets e.Expr) = (INDIRECT) ; + + (Symbol Name e.Name) = (Pointer e.Name); + + (ADT-Brackets (e.Name) e.Expr) = (Pointer e.Name) ; + + (s.Brackets e.Expr) + , Brackets ClosureBrackets : e._ s.Brackets e._ + = ; + + t.AnyOtherTerm = /* ничего интересного */; +} + +/* + + == (ToDrive e.FuncNames) (Basics e.FuncNames) (Unreachable e.FuncNames) + e.FuncNames ::= (e.Name)* +*/ +BasicVertexes { + e.Graph (e.Roots) + = : e.GraphHash + = (e.GraphHash)> + (/* to drive */) (/* basic */) + >; +} + +gen_e__ { e.arg = e.arg } + +MakeGraphHash { + e.Graph + = > : s.Hash + = (s.Hash Func (e.Name) Children (e.Children)); + } + e.Graph + > + : e.Graph^ + = ; +} + +BUCKET-SIZE { = 101 } + +MakeGraphHash-Buckets { + (s.Hash Func (e.Name) Children (e.Children)) e.Graph + = + : e.Graph^ (e.Bucket) + = (e.Bucket); + + /* граф опустел */ = /* нет корзин */; +} + +MakeGraphHash-FillBucket { + e.Graph-B (s.Hash Func (e.Name) Children (e.Children)) e.Graph-E + (s.Hash e.Bucket) + = e.Graph-B + ; + + e.Graph (e.Bucket) = e.Graph (e.Bucket); +} + +MarkChildren { + e.FuncNames + = (Children + > e.Name) + } + e.FuncNames + > + ) +} + +/* + + + e.ToDrive, e.Basics ::= (e.Name)* + e.Stack ::= t.StackItem* + t.StackItem ::= (Children (s.Hash e.Name)*) | (Func s.Hash e.Name) + + Функция совершает обход графа в глубину. + + На стек кладутся потомки функции, а также имя самой функции. Когда со стека + снимается потомок, и эта функция ещё не сканирована (есть в графе), + на стек кладутся потомки потомка и имя самого потомка. Когда все потомки + функции просканированы, на верхушке остаётся имя самой функции, которое + можно снять. Для алгоритма обхода в чистом виде имена функций на стеке + не так уж и важны, они нужны для маркировки прогоняемых и базисных функций. + + Интересно получается с базисными вершинами. Базисная вершина — это вершина, + в которую ведёт стрелка от потомка. Поэтому если на стеке есть имя функции, + совпадающей с очередным потомком, эта функция базисная. Вырезаем её + из стека и запоминаем как базисную. Если на вершине стека обнаружилось + имя функции, это значит, что ссылки из потомков на неё не было, она + не является базисной и пригодна для прогонки. + + В графе находятся только функции с предложениями. Все имена функций из графа, + достижимые из корней, кладутся на стек (включая корни). Любое имя, оказавшееся + на стеке, либо переносится в карман базисных, либо прогоняемых. Функции, + оставшиеся в графе, являются недостижимыми. Таким образом, множество функций + из графа разбивается на три подмножества: базисные, прогоняемые + и недостижимые. +*/ +DoBasicVertexes { +* Базисная вершина, удаляем пометку функции со стека. + (Children (s.Hash e.BasicName) e.Siblings) + e.Stack-B (Func s.Hash e.BasicName) e.Stack-E + (e.Graph) (e.ToDrive) (e.Basics) + = ; + +* Обычная вершина. + (Children (s.Hash e.FuncName) e.Siblings) e.Stack + ( + e.Buckets-B + (s.Hash e.Graph-B (Func (e.FuncName) Children (e.Children)) e.Graph-E) + e.Buckets-E + ) + (e.ToDrive) (e.Basics) + = (Func s.Hash e.FuncName) + (Children e.Siblings) e.Stack + (e.Buckets-B e.Buckets-E) + (e.ToDrive) (e.Basics) + >; + +* Уже просканированная вершина или вызов внешней функции. + (Children (s._ e._) e.Siblings) e.Stack (e.Graph) (e.ToDrive) (e.Basics) + = ; + + (Children /* пусто */) e.Stack (e.Graph) (e.ToDrive) (e.Basics) + = ; + +* Всех детей функции просканировали. +* Если сама метка функции не удалена со стека, значит она не была базисной. + (Func s.Hash e.FuncName) e.Stack (e.Graph) (e.ToDrive) (e.Basics) + = ; + +* Все функции просканировали. + /* пустой стек */ (e.Graph) (e.ToDrive) (e.Basics) + = (ToDrive e.ToDrive) + (Basics e.Basics) + (Unreachable + + } + e.Graph + > + ); +} + +WrapBucket { + s.Hash /* пусто */ = /* пусто */; + s.Hash e.Bucket = (s.Hash e.Bucket); +} + +/** + == e.AST +*/ +$ENTRY OptTree-AutoMarkup-CleanupUnusedFunctions { + e.AST + = : e.Graph + = : e.Graph^ + + = : (e.Roots) e.Graph^ + = + : (ToDrive e.ToDrive) (Basics e.Basics) (Unreachable e.Unreachable) + + = + : (/* должно быть пусто */) e.AST^ + = e.AST; +} + +RemoveReferenceTagFromChildren { + (Func (e.FuncName) Children (e.Children)) + = + : e.Children^ + = (Func (e.FuncName) Children (e.Children)); +} + +UnsuffixedFunctions { + (e.Roots) t.Node + = t.Node : (Func (e.FuncName) Children (e.Children)) + = e.FuncName + : { + e._ SUF e._ = e.Roots; + e._ = e.Roots (e.FuncName); + } + : e.Roots^ + = (e.Roots) t.Node; +} + +RemoveUnused { + (e.Unused-B (e.Name) e.Unused-E) + (Function (e.Name) Sentences e._) + = (e.Unused-B e.Unused-E) /* пропускаем */; + + (e.Unused-B (e.Name) e.Unused-E) + (Function (e.Name) Metatable e._) + = (e.Unused-B e.Unused-E) /* пропускаем */; + + (e.Unused) t.OtherItem = (e.Unused) t.OtherItem; /* оставляем */ +} + +/** + == e.AST +*/ + +$ENTRY OptTree-AutoMarkup-Spec { + e.AST + = +} diff --git a/src/compiler/OptTree-Drive-Expr.ref b/src/compiler/OptTree-Drive-Expr.ref index 7f7c4551..724244ae 100644 --- a/src/compiler/OptTree-Drive-Expr.ref +++ b/src/compiler/OptTree-Drive-Expr.ref @@ -1,68 +1,33 @@ $INCLUDE "LibraryEx"; -*$FROM TreeUtils -$EXTERN HashName; -$EXTERN ExtractVariables-Expr; - -*$FROM GenericMatch -$EXTERN Solve-Drive; - *$FROM OptTree-StopRelation -$EXTERN OptTree-CanonizeExpr; -$EXTERN OptTree-CheckExprStopRelation; +$EXTERN OptTree-CanonizeExpr, OptTree-CheckExprStopRelation; -IsPassiveCall { - e.Expr - = ; - False t.Term = False; - } - True - e.Expr - > - -} +*$FROM OptTree-Drive-Intrinsic +$EXTERN OptTree-Drive-Intrinsic; -IsPassiveCall-Aux { - (Brackets e.Expr) = ; - (ADT-Brackets e.Expr) = ; +*$FROM GenericMatch +$EXTERN GenericMatch, Solve-Drive; - (CallBrackets e.Expr) = False; - (ColdCallBrackets e.Expr) = False; +*$FROM TreeUtils +$EXTERN ExpandClosures-Result, ApplyContractions, ExtractVariables-Expr, + CreateContext, MarkAllVarsAsWhole, ApplyAssigns, HashName; - t.Other = True; -} /** - - == t.OptInfo^ e.Branches (e.NewFunctions) + + == t.OptInfo^ e.FlatBranches (e.NewFunctions) - e.Branches ::= (e.Contractions (e.DrivenExpr))* + e.FlatBranches ::= (e.Contractions (e.DrivenExpr))* e.UsedVars, e.WholeVars ::= (s.Mode e.Index)* */ $ENTRY OptTree-Drive-Expr { - (e.UsedVars) (e.WholeVars) t.OptInfo e.Expr - = + (e.UsedVars) t.OptInfo e.Expr + = : e.Expr^ + = : ((s._CntNodes) t.OptInfo^ (e.NewFunctions)) e.DriveTree - = t.OptInfo >> - (e.NewFunctions); -} - -MapUnBracket { - e.Sequence = ; -} - -ColdTree { - e.Branches - = )) - } - e.Branches - >; + = t.OptInfo (e.NewFunctions); } ColdAll { @@ -77,100 +42,134 @@ ColdAll { MaxCntNodes { = 100 } -$DRIVE MaxCntNodes; +*$xDRIVE MaxCntNodes MaxTreeDepth { = 20 } -$DRIVE MaxTreeDepth; +*$xDRIVE MaxTreeDepth IncWithMax { - s.Cnt s.Max, : '+' - = ; + s.Cnt s.Max, : '+' = ; + s.Cnt s.Max = s.Max; } -CheckExprsLength { - 0 e._ = TooMany; - s.Cnt t.Expr e.Exprs = e.Exprs>; - s.Cnt = OK; -} +/* + == t.DriveTreeState t.TreeBranch* + == t.DriveTreeState t.TreeBranch* + t.DriveTreeState ::= ((s.CntNodes) t.OptInfo (e.NewFunctions)) + t.TreeBranch ::= (e.Contractions (e.DrivenRight) (t.TreeBranch*)) +*/ MakeDriveTree { - (s.CntNodes) (e.UsedVars) (e.WholeVars) t.OptInfo e.Expr (s.TreeDepth e.canoninzedExprs) + (s.CntNodes) (e.UsedVars) t.OptInfo e.Expr + (s.TreeDepth e.canoninzedExprs) = () e.canoninzedExprs : e.canoninzedExprs^ - = > > + = > + > : s.CntNodes^ s.TreeDepth^ = : { - True s.Cnt - = Generalize s.Cnt; + True s.Cnt = Generalize t.OptInfo s.Cnt; + s._ s._, : s.CntNodes - = ((s.CntNodes) t.OptInfo (/* нет функций */)) - (/* нет сужений */ (e.Expr) (/* пустое дерево */) ); + = >; + s._ s._, : s.TreeDepth - = ((s.CntNodes) t.OptInfo (/* нет функций */)) - (/* нет сужений */ (e.Expr) (/* пустое дерево */) ); + = >; + False s._Cnt = ; }; } +/* + + == t.DriveTreeState t.TreeBranch -- one branch +*/ +DriveStateWithLeaf { + s.CntNodes t.OptInfo e.Expr + = ((s.CntNodes) t.OptInfo (/* нет функций */)) + (/* нет сужений */ (e.Expr) (/* пустое дерево */)); +} + +gen_e__ { e.arg = e.arg } + GrowDriveTree { - (s.CntNodes) (e.UsedVars) (e.WholeVars) t.OptInfo e.Expr + (s.CntNodes) (e.UsedVars) t.OptInfo e.Expr (s.TreeDepth e.canoninzedExprs) - = t.OptInfo - : ((e.OptFuncNames) e.OptFuncs) + = t.OptInfo : ((e.OptFuncNames) e.OptFuncs) = : { (e.OptFuncNames^ None) e.Expr^ - = ((s.CntNodes) ((e.OptFuncNames) e.OptFuncs) (/* нет функций */)) - (/* нет сужений */ (e.Expr) (/* пустое дерево */)); + = ((e.OptFuncNames) e.OptFuncs) : t.OptInfo^ + = ; (e.OptFuncNames^ t.Call) e.Expr^ - = + = t.Call e.OptFuncs + > : (e.OptFuncs^) (e.NewFunctions) e.Branches - = e.UsedVars - : e.UsedVars^ - = - : { - ((s.CntNodes^) t.OptInfo^ (e.NewFunctions^)) e.Branches^ - = ((s.CntNodes) t.OptInfo (e.NewFunctionsAccum e.NewFunctions)) - (e.Contractions (e.DrivenRight) (e.Branches)); - Generalize s.Cnt - = (Generalize s.Cnt); - }; - (Generalize s.Cnt) (e.Contractions (e.DrivenRight)) - = (Generalize s.Cnt); - } - ((s.CntNodes) ((e.OptFuncNames) e.OptFuncs) (e.NewFunctions)) - e.Branches + + = ((e.OptFuncNames) e.OptFuncs) : t.OptInfo^ + + = : { - (Generalize 1) e._DeletedTree + Generalize t.OptInfo^ 1 = (s.TreeDepth e.canoninzedExprs) >; - (Generalize s.Cnt) e._DeletedTree - = Generalize ; - e.Tree = e.Tree; + + Generalize t.OptInfo^ s.Cnt = Generalize t.OptInfo ; + + Tree t.DriveTreeState e.Branches^ = t.DriveTreeState e.Branches; }; }; } +GrowDriveTree-DriveBranches { + (s.CntNodes) (e.UsedVars) t.OptInfo + (s.TreeDepth e.canoninzedExprs) (e.NewFunctions) e.Branches + = + : { + ((s.CntNodes^) t.OptInfo^ (e.NewFunctions^)) e.Branches^ + = ((s.CntNodes) t.OptInfo (e.NewFunctionsAcc e.NewFunctions)) + (e.Contractions (e.DrivenRight) (e.Branches)); + + Generalize t.OptInfo^ s.Cnt = (Generalize t.OptInfo s.Cnt); + }; + + (Generalize t.OptInfo^ s.Cnt) (e.Contractions (e.DrivenRight)) + = (Generalize t.OptInfo s.Cnt); + } + ((s.CntNodes) t.OptInfo (e.NewFunctions)) + e.Branches + > + : { + (Generalize t.OptInfo^ s.Cnt) e._tree = Generalize t.OptInfo s.Cnt; + + t.DriveTreeState e.Tree = Tree t.DriveTreeState e.Tree; + }; +} + RestoreDrivenCall { t.Call e.Expr - = ':' )) > + = ':' ))> } CheckExprsStopRelation { @@ -182,704 +181,283 @@ CheckExprsStopRelation { (e.currentExpr) e.historyExprs = False 0; } -BranchesVars { - e.Branches - = - } - e.Branches - >; -} - -ContractionVars { - e.Contractions - = - } - e.Contractions - >; -} - FlatDriveTree { e.Branches = ) - } - e.Branches - >; -} + /* лист */ + (e.Contractions (e.DrivenRight) (/* нет детей */)) + = (e.Contractions (e.DrivenRight)); -FlatDriveTreeAux { - (e.Contractions (e.DrivenRight) (e.Branches)) - = : e.BrachPacks - = ; -} - -FlatDriveTreeSingle { - (e.Contractions (e.DrivenRight) (/* пустое дерево */)) - = (e.Contractions (e.DrivenRight)); - - (e.Contractions (e.DrivenRight) (e.BrachPacks)) - = : e.FlatBranches = - (e.BranchDrivenRight) - ) + (e.BranchContractions (e.DrivenRight)) + = (e.Contractions e.BranchContractions (e.DrivenRight)) } - e.Branches + e.FlatBranches >; } - e.BrachPacks + e.Branches >; } -ComposeContractions { - (e.A) (e.B) - = ; - } - e.ARight - > - ); - } - e.A - > e.B; -} - -OptExpr-Aux { - (e.UsedVars) (e.WholeVars) (e.Expr) +OptOneCall { + (e.UsedVars) (e.Expr) (CallBrackets (Symbol Name e.Name) e.Args) - t.Metatables e.OptFuncs + s.Contractions-Mode t.Metatables e.OptFuncs /* Поиск информации для прогонки */ = : e.OptFuncs^ t.FunctionForDrive - = - : t.Metatables^ e.SubstitutionPacks + : t.Metatables^ (e.NewFunctions) e.Branches - = (t.Metatables e.OptFuncs) - )); - } - (/* new functions */) - e.SubstitutionPacks - >; -} - -IntrinsicCall { - t.IntrinsicFunction t.Metatables (e.Args) '__Meta_Mu' - = - : { - t.Metatables^ Ok e.Result - = t.Metatables (( ':' e.Result) (/* нет новых функций */)); - - t.Metatables^ MakeColdCall - = t.Metatables ; - }; - - t.IntrinsicFunction t.Metatables (e.Args) e.BehaviorName - = e.BehaviorName - : { - 'Add' = &Intrinsic-Add; - 'Sub' = &Intrinsic-Sub; - 'Mul' = &Intrinsic-Mul; - 'Div' = &Intrinsic-Div; - 'Mod' = &Intrinsic-Mod; - 'Divmod' = &Intrinsic-Divmod; - 'Compare' = &Intrinsic-Compare; - 'Chr' = &Intrinsic-Chr; - 'Ord' = &Intrinsic-Ord; - 'Upper' = &Intrinsic-Upper; - 'Lower' = &Intrinsic-Lower; - 'Numb' = &Intrinsic-Numb; - 'Symb' = &Intrinsic-Symb; - 'Implode' = &Intrinsic-Implode; - 'Implode_Ext' = &Intrinsic-Implode_Ext; - 'Explode' = &Intrinsic-Explode; - 'Explode_Ext' = &Intrinsic-Explode; - 'Type' = &Intrinsic-Type; - 'Lenw' = &Intrinsic-Lenw; - 'First' = &Intrinsic-First; - 'Last' = &Intrinsic-Last; - - e._ = { e._ = MakeColdCall }; - } - : s.TransformFunction - = - : { - Ok e.Result = (( ':' e.Result) (/* нет новых функций */)); - MakeColdCall = ; - } - : e.Substitutions - = t.Metatables e.Substitutions; -} + = : e.Branches^ -eDRIVEN { - = (Var 'e' DRIVEN); + = (s.Contractions-Mode t.Metatables e.OptFuncs) + (e.NewFunctions) e.Branches } -Intrinsic-Mu { - e.Args t.Metatables - , e.Args : t.Function e.MuArg (Symbol Name e.MetatableName) - = t.Function - : { - (Symbol Name e.Name) - = t.Metatables Ok (CallBrackets (Symbol Name e.Name) e.MuArg); - - (ClosureBrackets e.Body) - = t.Metatables Ok (CallBrackets (ClosureBrackets e.Body) e.MuArg); - - (Symbol Identifier s.Name) - , : True e.FunctionName - = t.Metatables Ok (CallBrackets (Symbol Name e.FunctionName) e.MuArg); - - (Symbol Char s.Name) - , : True e.FunctionName - = t.Metatables Ok (CallBrackets (Symbol Name e.FunctionName) e.MuArg); - - (Symbol Identifier e.Name) - = ; - - (Brackets e.Chars) - , : Ok e.Name - = ; - - t._ = t.Metatables MakeColdCall; - }; - - e._ t.Metatables = t.Metatables MakeColdCall; -} - -ArithmeticSymbolToFunction { - '+' = True 'Add'; - '-' = True 'Sub'; - '/' = True 'Div'; - '*' = True 'Mul'; - '%' = True 'Mod'; - '?' = True 'Residue'; - - s._ = False; -} - -AllChars { - e.Terms = ; -} - -DoAllChars { - (e.Chars) (Symbol Char s.Char) e.Rest = ; - (e.Chars) /* empty */ = Ok e.Chars; - (e.Chars) e.Rest = Fails; -} - -MakeSubstitution-FromMetatables { - t.Metatables (e.MetatableName) (e.MuArg) e.Name - = t.Metatables - : { - (Metatables - e.Tables-B ((e.MetatableName) Metatable e.Map) e.Tables-E - ) - = e.Map - : { - e._ ((Symbol Identifier e.Name) t.Pointer) e._ - = Ok (CallBrackets t.Pointer e.MuArg); - - e.Other = MakeColdCall; - } - : e.Result - = (Metatables - e.Tables-B - ((e.MetatableName) Metatable e.Map) - e.Tables-E - ) - e.Result; - - t.Metatables^ = t.Metatables MakeColdCall; - } -} +FilterScreenedBranches { + (e.Args) e.Branches + = > : e.Domain + = : e.PatTemplate -Intrinsic-Add { - e.Args - = - : { - Ok (Const e.Left) (Const e.Right) - = Ok >; - - Ok (Const 0) (ArithmResult t.ArithmCall) = Ok t.ArithmCall; - Ok (ArithmResult t.ArithmCall) (Const 0) = Ok t.ArithmCall; - - e._ = MakeColdCall; - }; -} - -ArithmArgs { - (Brackets e.Left) e.Right - , : Ok e.Left^ - , : Ok e.Right^ - = Ok (e.Left) (e.Right); - - (Symbol Char s.Sign) (Symbol Number s.Left) e.Right - , : Ok e.Right^ - = Ok (Const s.Sign s.Left) (e.Right); - - (Symbol Number s.Left) e.Right - , : Ok e.Right^ - = Ok (Const s.Left) (e.Right); - - e._ = Fails; -} - -ArithmOneArg { - (ColdCallBrackets (Symbol Name e.Name) e.Arg) - , : e._ (e.Name) e._ - = Ok ArithmResult (ColdCallBrackets (Symbol Name e.Name) e.Arg); - - e.Number, : True - = Ok Const >; - - e._ = Fails; -} - -Number-Check { - (Symbol Char '+') e.Rest = ; - (Symbol Char '-') e.Rest = ; - - e.Rest = ; -} - -Number-Check-AllNumbers { - (Symbol Number s._) = True; - (Symbol Number s._) e.Rest = ; - e._ = False; -} - -SymbolsToNumber { - e.Symbols = : e.Pattern + = ((e.Pattern) (e.UsedVars) (e.Result)); } - e.Symbols + e.Branches > -} + : e.PseudoSentenences + + = : e.PseudoSentenences^ -NumberToSymbols { - e.Number = : e.Contractions + = ((e.UsedVars) e.Contractions (e.Result)); } - e.Number + e.PseudoSentenences > } -ArithmeticFunctions { - = ('Add') ('Div') ('Divmod') ('Mod') ('Mul') ('Sub') ('Numb'); -} - -Intrinsic-Sub { - e.Args - = - : { - Ok (Const e.Left) (Const e.Right) - = Ok >; - - Ok (ArithmResult t.ArithmCall) (Const 0) = Ok t.ArithmCall; - - e._ = MakeColdCall; - }; -} - -Intrinsic-Mul { - e.Args - = - : { - Ok (Const e.Left) (Const e.Right) - = Ok >; - - Ok (Const 1) (ArithmResult t.ArithmCall) = Ok t.ArithmCall; - Ok (ArithmResult t.ArithmCall) (Const 1) = Ok t.ArithmCall; - - e._ = MakeColdCall; - }; -} - -Intrinsic-Div { - e.Args - = - : { - Ok (e._) (Const 0) = MakeColdCall; - - Ok (Const e.Left) (Const e.Right) - = Ok >; - - Ok (ArithmResult t.ArithmCall) (Const 1) = Ok t.ArithmCall; - - e._ = MakeColdCall; - }; -} - -Intrinsic-Mod { - e.Args - = - : { - Ok (e._) (Const 0) = MakeColdCall; - - Ok (Const e.Left) (Const e.Right) - = Ok >; +DoFilterScreenedBranches { + ((e.FirstPattern) (e.FirstUsedVars) (e.FirstResult)) e.PseudoSentenences + = ((e.FirstPattern) (e.FirstUsedVars) (e.FirstResult)) + : Clear e._ + = /* ветвь экранируется, стираем */; + + ((e.Pattern) (e.UsedVars) (e.Result)) + = ((e.Pattern) (e.UsedVars) (e.Result)); + } + e.PseudoSentenences + > + >; - e._ = MakeColdCall; - }; + /* пусто */ = /* пусто */; } -Intrinsic-Divmod { - e.Args - = - : { - Ok (e._) (Const 0) = MakeColdCall; - - Ok (Const e.Left) (Const e.Right) - = : (e.Q) e.R - = Ok (Brackets ) ; - - Ok (ArithmResult t.ArithmCall) (Const 1) - = Ok (Brackets t.ArithmCall) (Symbol Number 0); +RestoreContractions { + (e.Pattern) (e.PatTemplate) + = : Clear e.Assigns + = } -Intrinsic-Compare { - e.Args - , : Ok (Const e.Left) (Const e.Right) - = Ok (Symbol Char ); - - e._ = MakeColdCall; +eDRIVEN { + = (Var 'e' DRIVEN); } /* - TODO: уточнить семантику функций Chr, Ord, Upper, Lower. - - Функции не должны увеличивать число шагов рефал-машины. - - Сейчас: - 48> → '@' '@' > '@' - А должно быть: - 48> → '@' > '@' + + == t.Metatables (e.NewFunctions) (e.Branches)* + e.Branches ::= (e.UsedVars) e.Contractions (e.Expr^) - Кроме того, нужно поддерживать спуск внутрь структурных скобок - (сейчас не поддерживается). + e.Contractions включают в себя сужение e.DRIVEN для подстановки + правой части. */ -Intrinsic-Chr { - e.Args - , : True - = : e.Substitution - = Ok e.Substitution; +OptOneCall-MakeSubstitutions { + s.Contractions-Mode (e.UsedVars) (e.Expr) (e.Args) t.Function t.Metatables - e.Args = MakeColdCall; -} - -CheckArgs-Intrinsic-StaticSubstitution { - (e.Args) s.SymbolName - = e.Args - : { - (Symbol s.SymbolName e.Name) e.Rest - = ; - - (Var e.Var) e.Rest - = ; - - (ColdCallBrackets e.Body) e.Rest - = ; - - t.Other e.Rest = False; - - /* пусто */ = True; - } -} + = + : t.Metatables^ e.SubstitutionPacks -StaticSubstitution { - (e.Args) (e.FuncName) s.Func s.SymbolFrom s.SymbolTo - = ); - - (Var e.Var) - = (ColdCallBrackets (Symbol Name e.FuncName) (Var e.Var)); - - (ColdCallBrackets e.Body) - = (ColdCallBrackets - (Symbol Name e.FuncName) (ColdCallBrackets e.Body) - ); + (e.NewFunctions) ((e.UsedVars^) e.Contractions (e.NewFunction)) + = : e.DrivenRight + = : e.DrivenRight^ + = (e.NewFunctions e.NewFunction) + ((e.UsedVars) e.Contractions (e.DrivenRight)); } - e.Args + (/* new functions */) + e.SubstitutionPacks > -} - -Intrinsic-Ord { - e.Args - , : True - = : e.Substitution - = Ok e.Substitution; - - e.Args = MakeColdCall; -} + : (e.NewFunctions) e.Branches -Intrinsic-Upper { - e.Args - , : True - = : e.Substitution - = Ok e.Substitution; - - e.Args = MakeColdCall; -} - -Intrinsic-Lower { - e.Args - , : True - = : e.Substitution - = Ok e.Substitution; - - e.Args = MakeColdCall; -} - -Intrinsic-Numb { - e.Args - , : Ok e.Chars - = > : e.Result - = Ok e.Result; - - e.Args = MakeColdCall; -} - -Intrinsic-Symb { - e.Args - , : Ok Const e._ - = > : e.Numbers - = : e.Result - = Ok e.Result; - - e.Args = MakeColdCall; -} - -CharToNode { - e.Char = + = t.Metatables (e.NewFunctions) e.Branches } -Intrinsic-Implode { - e.Args - , : Ok e.Chars - = : s.Ident e.NonIdent - = s.Ident +OptOneCall-MakeSubstitutions-Aux { + s.Contractions-Mode (e.UsedVars) (e.Args) t.IntrinsicFunction t.Metatables + , t.IntrinsicFunction : ((e._) Intrinsic e.BehaviorName) + = : { - 0 = (Symbol Number 0); - e._ = (Symbol Identifier ) - } - : e.Result - = Ok e.Result ; - - e.Args = MakeColdCall; -} - -Intrinsic-Implode_Ext { - e.Args, : Ok e.Chars = Ok (Symbol Identifier e.Chars); - - e.Args = MakeColdCall; -} + t.Metatables^ Ok e.Result + = t.Metatables + ((e.UsedVars) ( ':' e.Result) (/* нет новых функций */)); -Intrinsic-Explode { - (Symbol Identifier e.Name) = Ok ; + t.Metatables^ MakeColdCall + = t.Metatables + ; + }; - e._ = MakeColdCall; -} + s.Contractions-Mode + (e.UsedVars) (e.Args) ((e.Name) Sentences e.Body) t.Metatables -Intrinsic-Type { - (CallBrackets e._) e._ = MakeColdCall; - (ColdCallBrackets e._) e._ = MakeColdCall; - (Var e._) e._ = MakeColdCall; + = : (e.Calls) (e.CallOrder) e.Args^ - t.Term e.Rest - = t.Term + = s.Contractions-Mode : { - (Symbol Number s._) = 'N0'; - (Symbol Char s.Char) = ; - (Symbol Identifier e.Name) = >; - (Symbol Name e._) = 'Fg'; - (ClosureBrackets e._) = 'Fc'; - (Brackets e._) = 'B0'; - (ADT-Brackets (e._) e._) = 'Ba'; + Contractions-Enabled = e.Args; + Contractions-Disabled = ; } - : s.Type s.SubType e._ - = Ok (Symbol Char s.Type) (Symbol Char s.SubType) t.Term e.Rest; + : e.Args^ - /* empty */ = Ok (Symbol Char '*') (Symbol Char '0'); -} - -Intrinsic-Lenw { - e.Args - , : True - = : s.Len e.Args^ - = Ok (Symbol Number s.Len) e.Args; - - e._ = MakeColdCall; -} - -FixedLength { - e._ (Var 'e' e._) e._ = False; - e._ (CallBrackets e._) e._ = False; - e._ (ColdCallBrackets e._) e._ = False; - - e._ = True; + = t.Metatables + ; } -Intrinsic-First { - (Symbol Number s.N) e.Expr - , : (e.Prefix) e.Suffix - , : True - = Ok (Brackets e.Prefix) e.Suffix; - - e._ = MakeColdCall; +ExtractCalls { + e.Arg + = + : (s.NextId (e.Calls) (e.CallOrder)) e.Arg^ + = (e.Calls) (e.CallOrder) e.Arg } -Intrinsic-Last { - (Symbol Number s.N) e.Expr - , : (e.Prefix) e.Suffix - , : True - = Ok (Brackets e.Prefix) e.Suffix; - - e._ = MakeColdCall; -} - -/* - - == t.Metatables (e.Substitutions)* - e.Substitutions ::= e.Contractions (e.NewFunctions) - - e.Contractions включают в себя сужение e.DRIVEN для подстановки - правой части. -*/ -OptExpr-MakeSubstitutions { - (e.UsedVars) (e.WholeVars) (e.Expr) (e.Args) t.IntrinsicFunction t.Metatables - , t.IntrinsicFunction : (Intrinsic (e._) Intrinsic e.BehaviorName) - = ; - - (e.UsedVars) (e.WholeVars) (e.Expr) (e.Args) t.Function t.Metatables - /* Активные вызовы игнорируем */ - , : False - - = t.Metatables ; - - (e.UsedVars) (e.WholeVars) (e.Expr) (e.Args) - (s.FuncMode (e.Name) Sentences e.Body) t.Metatables - - = s.FuncMode - : { - Drive = e.WholeVars; - Inline = e.UsedVars; - } - : e.WholeVars^ - - = t.Metatables - ; - - (e.UsedVars) (e.WholeVars) (e.Expr) (e.Args) t.Function t.Metatables - = t.Metatables ; +ExtractCallsRec { + t.State e.Expr + = + (e.Calls (t.Call ':' t.Var)) + (e.CallOrder t.Var) + ) + t.Var; + }; + + t.State^ (s.Brackets e.Content) + , Brackets ClosureBrackets : e._ s.Brackets e._ + = : t.State^ e.Content^ + = t.State (s.Brackets e.Content); + + t.State^ (ADT-Brackets (e.Name) e.Content) + = : t.State^ e.Content^ + = t.State (ADT-Brackets (e.Name) e.Content); + + t.State^ t.Other = t.State t.Other; + } + t.State e.Expr + > } MakeColdSolution { - (s.FuncMode (e.Name) s.BodyLabel e.Body) e.Args + (e.UsedVars) ((e.Name) Sentences e.Body) e.Args , e.Name : e.Prefix '*' s.Num = ( + (e.UsedVars) ( ':' (ColdCallBrackets (Symbol Name e.Name) e.Args)) - ((NewFunction GN-Local (e.Name) s.BodyLabel e.Body)) + ((NewFunction (e.Name) Sentences e.Body)) ); - (s.FuncMode (e.Name) s.BodyLabel e.Body) e.Args + (e.UsedVars) ((e.Name) s._ e.Body) e.Args = ( + (e.UsedVars) ( ':' (ColdCallBrackets (Symbol Name e.Name) e.Args)) (/* нет новых функций */) ); } -DoOptExpr-MakeSubstitutions { - (e.SentenceVars) (e.WholeVars) (e.Args) (e.Substitutions) - (Function (e.Name) Sentences ((e.LS) (e.RS)) e.Rest) +DoOptOneCall-MakeSubstitutions { + (e.SentenceVars) (e.Args) (e.Substitutions) (e.Calls) (e.CallOrder) + ((e.Name) Sentences ((e.LS) (e.RS)) e.Rest) = : e.RS^ = : { - /* - В случае решения без сужений просто применяем замены. - */ - Success (() (e.Assigns)) - = : e.CallReplacer - = e.Substitutions - (( ':' e.CallReplacer) (/* нет новых функций */)); - - /* - «Грязное» решение допускаем только в случае прогонки. - */ Success e.Solutions - , : True = : e.CallReplacer - = e.Contrs ( ':' e.CallReplacer) : e.Contrs^ - = (e.Contrs (/* нет новых функций */)); + (e.UsedVars (e.Contrs) (e.Assigns)) + = : e.RS^ + = + : { + Valid + = : e.CallReplacer + = ( ':' e.CallReplacer) e.Contrs : e.Contrs^ + = ((e.UsedVars) e.Contrs (/* нет новых функций */)); + + Invalid = Invalid; + }; } e.Solutions > - : e.NewSubstitutions - = e.Substitutions e.NewSubstitutions : e.Substitutions^ - = ) Sentences e.Rest) - >; + : { + e._ Invalid e._ + = e.Substitutions + + >; - /* - При неудаче переходим к следующему предложению, к подстановкам - ничего не добавляем. - */ - Failure - = ) Sentences e.Rest) - >; + e.NewSubstitutions + = e.Substitutions e.NewSubstitutions : e.Substitutions^ + = ) Sentences e.Rest) + >; + }; /* Здесь либо Undefined, либо грязное решение в режиме встраивания, @@ -888,13 +466,53 @@ DoOptExpr-MakeSubstitutions { e.Other = e.Substitutions >; }; - (e.SentenceVars) (e.WholeVars) (e.Args) (e.Substitutions) t.RestFunction - = e.Substitutions ; + (e.SentenceVars) (e.Args) (e.Substitutions) (e.Calls) (e.CallOrder) + t.RestFunction + = e.Substitutions + + >; +} + +CheckCallOrder { + (e.CallOrder) e.Expr + = + : { + e.CallOrder e.ClosedCalls + , '>' e.ClosedCalls : e.ClosedCalls '>' + = Valid; + + e._ = Invalid; + } +} + +ExtractCallVars { + e.Expr + = ; + + (s.CallBrackets e.Content) + , CallBrackets ColdCallBrackets : e._ s.CallBrackets e._ + = '>'; + + (ADT-Brackets (e.Name) e.Content) = ; + + t.Other = /* пропускаем */; + } + e.Expr + > } Cleanup-Step-Drop { @@ -908,16 +526,6 @@ Cleanup-Step-Drop { e.RS = e.RS; } -SafeContractions { - e.Solutions-B - ((e.Contrs-B ((Var s.Mode e.Index) ':' e._) e.Contrs-E) (e.Assigns)) - e.Solutions-E - (e.WholeVars-B (s.Mode e.Index) e.WholeVars-E) - = False; - - e.Solutions (e.WholeVars) = True; -} - DropLeft { e.List 0 = e.List; t.Head e.Tail s.N = > @@ -939,19 +547,19 @@ FindOptInfo { } FindOptInfo-Aux { - e.OptFuncs-B (Intrinsic (e.LookupName) e.Body) e.OptFuncs-E - (e.Name) (e.LookupName) s._ - = e.OptFuncs-B (Intrinsic (e.LookupName) e.Body) e.OptFuncs-E - (Intrinsic (e.Name) e.Body); + e.OptFuncs-B ((e.LookupName) Intrinsic e.Body) e.OptFuncs-E + (e.Name) (e.LookupName) 0 + = e.OptFuncs-B ((e.LookupName) Intrinsic e.Body) e.OptFuncs-E + ((e.Name) Intrinsic e.Body); - e.OptFuncs-B (s.Mode (e.LookupName) e.Body) e.OptFuncs-E + e.OptFuncs-B ((e.LookupName) e.Body) e.OptFuncs-E (e.Name) (e.LookupName) s.Drop = e.Body : Sentences e.Sentences - = e.OptFuncs-B (s.Mode (e.LookupName) e.Body) e.OptFuncs-E - (s.Mode (e.Name) Sentences ); + = e.OptFuncs-B ((e.LookupName) e.Body) e.OptFuncs-E + ((e.Name) Sentences ); } -$DRIVE CutSUF; +*$xDRIVE CutSUF CutSUF { e.Prefix SUF = e.Prefix; @@ -1025,83 +633,6 @@ FindOptimizedCall-Term { = (e.OptFuncNames t.Found) t.AnyTerm; } -/* - == e.Expr^ -*/ - -ApplyAssigns { - e.Expr (e.Assigns) - = - } - e.Expr - > -} - -ApplyAssigns-Term { - (Brackets e.Expr) (e.Assigns) = (Brackets ); - - (CallBrackets e.Args) (e.Assigns) - = (CallBrackets ); - - (ColdCallBrackets e.Args) (e.Assigns) - = (ColdCallBrackets ); - - (ClosureBrackets e.Args) (e.Assigns) - = (ClosureBrackets ); - - (ADT-Brackets (e.Name) e.Expr) (e.Assigns) - = (ADT-Brackets (e.Name) ); - - t.T (e.B (e.Asgn ':' t.T) e.E) - = e.Asgn; - - t.T (e.Assigns) = t.T; -} - -/** - - } - e.Expr - >; -} - -ApplyContractions-Term { - (Brackets e.Expr) (e.Contrs) - = (Brackets ); - - (CallBrackets e.Args) (e.Contrs) - = (CallBrackets ); - - (ColdCallBrackets e.OriginArgs) (e.Contrs) - = - : { -* Содержимое холодных скобок не изменилось, оставляем их холодными - e.OriginArgs = (ColdCallBrackets e.OriginArgs); - -* Содержимое обновилось, оттаиваем скобки - e.ChangedArgs = (CallBrackets e.ChangedArgs); - }; - - (ClosureBrackets e.Args) (e.Contrs) - = (ClosureBrackets ); - - (ADT-Brackets (e.Name) e.Expr) (e.Contrs) - = (ADT-Brackets (e.Name) ); - - t.Term (e.B (t.Term ':' e.Contr) e.E) - = ; - - t.T (e.Contrs) = t.T -} - /* == e.Name */ diff --git a/src/compiler/OptTree-Drive-Intrinsic.ref b/src/compiler/OptTree-Drive-Intrinsic.ref new file mode 100644 index 00000000..b944c4ca --- /dev/null +++ b/src/compiler/OptTree-Drive-Intrinsic.ref @@ -0,0 +1,486 @@ +$INCLUDE "LibraryEx"; + + +/** + + == t.Metatables Ok e.Result + == t.Metatables MakeColdCall + + t.Metatables ::= (t.Metatable*) + e.Args, e.Result ::= e.ReducedExpression +*/ +$ENTRY OptTree-Drive-Intrinsic { + t.Metatables (e.Args) '__Meta_Mu' + = ; + + t.Metatables (e.Args) e.BehaviorName + = e.BehaviorName + : { + 'Add' = &Intrinsic-Add; + 'Sub' = &Intrinsic-Sub; + 'Mul' = &Intrinsic-Mul; + 'Div' = &Intrinsic-Div; + 'Mod' = &Intrinsic-Mod; + 'Divmod' = &Intrinsic-Divmod; + 'Compare' = &Intrinsic-Compare; + 'Chr' = &Intrinsic-Chr; + 'Ord' = &Intrinsic-Ord; + 'Upper' = &Intrinsic-Upper; + 'Lower' = &Intrinsic-Lower; + 'Numb' = &Intrinsic-Numb; + 'Symb' = &Intrinsic-Symb; + 'Implode' = &Intrinsic-Implode; + 'Implode_Ext' = &Intrinsic-Implode_Ext; + 'Explode' = &Intrinsic-Explode; + 'Explode_Ext' = &Intrinsic-Explode; + 'Type' = &Intrinsic-Type; + 'Lenw' = &Intrinsic-Lenw; + 'First' = &Intrinsic-First; + 'Last' = &Intrinsic-Last; + + e._ = { e._ = MakeColdCall }; + } + : s.TransformFunction + = t.Metatables ; +} + +Intrinsic-Mu { + e.Args t.Metatables + , e.Args : t.Function e.MuArg (Symbol Name e.MetatableName) + = t.Function + : { + (Symbol Name e.Name) + = t.Metatables Ok (CallBrackets (Symbol Name e.Name) e.MuArg); + + (ClosureBrackets e.Body) + = t.Metatables Ok (CallBrackets (ClosureBrackets e.Body) e.MuArg); + + (Symbol Identifier s.Name) + , : True e.FunctionName + = t.Metatables Ok (CallBrackets (Symbol Name e.FunctionName) e.MuArg); + + (Symbol Char s.Name) + , : True e.FunctionName + = t.Metatables Ok (CallBrackets (Symbol Name e.FunctionName) e.MuArg); + + (Symbol Identifier e.Name) + = ; + + (Brackets e.Chars) + , : Ok e.Name + = ; + + t._ = t.Metatables MakeColdCall; + }; + + e._ t.Metatables = t.Metatables MakeColdCall; +} + +ArithmeticSymbolToFunction { + '+' = True 'Add'; + '-' = True 'Sub'; + '/' = True 'Div'; + '*' = True 'Mul'; + '%' = True 'Mod'; + '?' = True 'Residue'; + + s._ = False; +} + +AllChars { + e.Terms = ; +} + +DoAllChars { + (e.Chars) (Symbol Char s.Char) e.Rest = ; + (e.Chars) /* empty */ = Ok e.Chars; + (e.Chars) e.Rest = Fails; +} + +MakeSubstitution-FromMetatables { + t.Metatables (e.MetatableName) (e.MuArg) e.Name + = t.Metatables + : { + (Metatables + e.Tables-B ((e.MetatableName) Metatable e.Map) e.Tables-E + ) + = e.Map + : { + e._ ((Symbol Identifier e.Name) t.Pointer) e._ + = Ok (CallBrackets t.Pointer e.MuArg); + + e.Other = MakeColdCall; + } + : e.Result + = (Metatables + e.Tables-B + ((e.MetatableName) Metatable e.Map) + e.Tables-E + ) + e.Result; + + t.Metatables^ = t.Metatables MakeColdCall; + } +} + +Intrinsic-Add { + e.Args + = + : { + Ok (Const e.Left) (Const e.Right) + = Ok >; + + Ok (Const 0) (ArithmResult t.ArithmCall) = Ok t.ArithmCall; + Ok (ArithmResult t.ArithmCall) (Const 0) = Ok t.ArithmCall; + + e._ = MakeColdCall; + }; +} + +ArithmArgs { + (Brackets e.Left) e.Right + , : Ok e.Left^ + , : Ok e.Right^ + = Ok (e.Left) (e.Right); + + (Symbol Char s.Sign) (Symbol Number s.Left) e.Right + , : Ok e.Right^ + = Ok (Const s.Sign s.Left) (e.Right); + + (Symbol Number s.Left) e.Right + , : Ok e.Right^ + = Ok (Const s.Left) (e.Right); + + e._ = Fails; +} + +ArithmOneArg { + (ColdCallBrackets (Symbol Name e.Name) e.Arg) + , : e._ (e.Name) e._ + = Ok ArithmResult (ColdCallBrackets (Symbol Name e.Name) e.Arg); + + e.Number, : True + = Ok Const >; + + e._ = Fails; +} + +Number-Check { + (Symbol Char '+') e.Rest = ; + (Symbol Char '-') e.Rest = ; + + e.Rest = ; +} + +Number-Check-AllNumbers { + (Symbol Number s._) = True; + (Symbol Number s._) e.Rest = ; + e._ = False; +} + +SymbolsToNumber { + e.Symbols + = +} + +NumberToSymbols { + e.Number + = +} + +ArithmeticFunctions { + = ('Add') ('Div') ('Divmod') ('Mod') ('Mul') ('Sub') ('Numb'); +} + +Intrinsic-Sub { + e.Args + = + : { + Ok (Const e.Left) (Const e.Right) + = Ok >; + + Ok (ArithmResult t.ArithmCall) (Const 0) = Ok t.ArithmCall; + + e._ = MakeColdCall; + }; +} + +Intrinsic-Mul { + e.Args + = + : { + Ok (Const e.Left) (Const e.Right) + = Ok >; + + Ok (Const 1) (ArithmResult t.ArithmCall) = Ok t.ArithmCall; + Ok (ArithmResult t.ArithmCall) (Const 1) = Ok t.ArithmCall; + + e._ = MakeColdCall; + }; +} + +Intrinsic-Div { + e.Args + = + : { + Ok (e._) (Const 0) = MakeColdCall; + + Ok (Const e.Left) (Const e.Right) + = Ok >; + + Ok (ArithmResult t.ArithmCall) (Const 1) = Ok t.ArithmCall; + + e._ = MakeColdCall; + }; +} + +Intrinsic-Mod { + e.Args + = + : { + Ok (e._) (Const 0) = MakeColdCall; + + Ok (Const e.Left) (Const e.Right) + = Ok >; + + e._ = MakeColdCall; + }; +} + +Intrinsic-Divmod { + e.Args + = + : { + Ok (e._) (Const 0) = MakeColdCall; + + Ok (Const e.Left) (Const e.Right) + = : (e.Q) e.R + = Ok (Brackets ) ; + + Ok (ArithmResult t.ArithmCall) (Const 1) + = Ok (Brackets t.ArithmCall) (Symbol Number 0); + + e._ = MakeColdCall; + }; +} + +Intrinsic-Compare { + e.Args + , : Ok (Const e.Left) (Const e.Right) + = Ok (Symbol Char ); + + e._ = MakeColdCall; +} + +/* + TODO: уточнить семантику функций Chr, Ord, Upper, Lower. + + Функции не должны увеличивать число шагов рефал-машины. + + Сейчас: + 48> → '@' '@' > '@' + А должно быть: + 48> → '@' > '@' + + Кроме того, нужно поддерживать спуск внутрь структурных скобок + (сейчас не поддерживается). +*/ +Intrinsic-Chr { + e.Args + , : True + = : e.Substitution + = Ok e.Substitution; + + e.Args = MakeColdCall; +} + +CheckArgs-Intrinsic-StaticSubstitution { + (e.Args) s.SymbolName + = e.Args + : { + (Symbol s.SymbolName e.Name) e.Rest + = ; + + (Var e.Var) e.Rest + = ; + + (ColdCallBrackets e.Body) e.Rest + = ; + + t.Other e.Rest = False; + + /* пусто */ = True; + } +} + +StaticSubstitution { + (e.Args) (e.FuncName) s.Func s.SymbolFrom s.SymbolTo + = ); + + (Var e.Var) + = (ColdCallBrackets (Symbol Name e.FuncName) (Var e.Var)); + + (ColdCallBrackets e.Body) + = (ColdCallBrackets + (Symbol Name e.FuncName) (ColdCallBrackets e.Body) + ); + } + e.Args + > +} + +Intrinsic-Ord { + e.Args + , : True + = : e.Substitution + = Ok e.Substitution; + + e.Args = MakeColdCall; +} + +Intrinsic-Upper { + e.Args + , : True + = : e.Substitution + = Ok e.Substitution; + + e.Args = MakeColdCall; +} + +Intrinsic-Lower { + e.Args + , : True + = : e.Substitution + = Ok e.Substitution; + + e.Args = MakeColdCall; +} + +Intrinsic-Numb { + e.Args + , : Ok e.Chars + = > : e.Result + = Ok e.Result; + + e.Args = MakeColdCall; +} + +Intrinsic-Symb { + e.Args + , : Ok Const e._ + = > : e.Numbers + = : e.Result + = Ok e.Result; + + e.Args = MakeColdCall; +} + +CharToNode { + e.Char = +} + +Intrinsic-Implode { + e.Args + , : Ok e.Chars + = : s.Ident e.NonIdent + = s.Ident + : { + 0 = (Symbol Number 0); + e._ = (Symbol Identifier ) + } + : e.Result + = Ok e.Result ; + + e.Args = MakeColdCall; +} + +Intrinsic-Implode_Ext { + e.Args, : Ok e.Chars = Ok (Symbol Identifier e.Chars); + + e.Args = MakeColdCall; +} + +Intrinsic-Explode { + (Symbol Identifier e.Name) = Ok ; + + e._ = MakeColdCall; +} + +Intrinsic-Type { + (CallBrackets e._) e._ = MakeColdCall; + (ColdCallBrackets e._) e._ = MakeColdCall; + (Var e._) e._ = MakeColdCall; + (WhVar e._) e._ = MakeColdCall; + + t.Term e.Rest + = t.Term + : { + (Symbol Number s._) = 'N0'; + (Symbol Char s.Char) = ; + (Symbol Identifier e.Name) = >; + (Symbol Name e._) = 'Fg'; + (ClosureBrackets e._) = 'Fc'; + (Brackets e._) = 'B0'; + (ADT-Brackets (e._) e._) = 'Ba'; + } + : s.Type s.SubType e._ + = Ok (Symbol Char s.Type) (Symbol Char s.SubType) t.Term e.Rest; + + /* empty */ = Ok (Symbol Char '*') (Symbol Char '0'); +} + +Intrinsic-Lenw { + e.Args + , : True + = : s.Len e.Args^ + = Ok (Symbol Number s.Len) e.Args; + + e._ = MakeColdCall; +} + +FixedLength { + e._ (Var 'e' e._) e._ = False; + e._ (CallBrackets e._) e._ = False; + e._ (ColdCallBrackets e._) e._ = False; + + e._ = True; +} + +Intrinsic-First { + (Symbol Number s.N) e.Expr + , : (e.Prefix) e.Suffix + , : True + = Ok (Brackets e.Prefix) e.Suffix; + + e._ = MakeColdCall; +} + +Intrinsic-Last { + (Symbol Number s.N) e.Expr + , : (e.Prefix) e.Suffix + , : True + = Ok (Brackets e.Prefix) e.Suffix; + + e._ = MakeColdCall; +} diff --git a/src/compiler/OptTree-Drive.ref b/src/compiler/OptTree-Drive.ref index d1a64780..b63c7b79 100644 --- a/src/compiler/OptTree-Drive.ref +++ b/src/compiler/OptTree-Drive.ref @@ -1,30 +1,32 @@ $INCLUDE "LibraryEx"; -*$FROM TreeUtils -$EXTERN ExtractVariables, HashName; - *$FROM Log $EXTERN Log-PutLine; *$FROM DisplayName $EXTERN DisplayName; +*$FROM TreeUtils +$EXTERN HashName, ExtractVariables, IsLExpr, MarkAllVarsAsWhole, + ApplyContractions, UnmarkWholeVars; + *$FROM OptTree-Drive-Expr -$EXTERN OptTree-Drive-Expr, ApplyContractions; +$EXTERN OptTree-Drive-Expr; /* В дерево добавляется узел (DriveInfo e.DriveInfo). - e.DriveInfo ::= (e.OptFuncNames (e.OptFunctions)) + e.DriveInfo ::= (e.OptFuncNames) e.OptFunctions e.OptFuncNames ::= e.HashSet e.HashSet ::= s.BucketSize (e.Bucket)* e.Bucket ::= (s.Hash (s.Label e.Name)*) - e.OptFunctions ::= t.OptFunction* + e.OptFunctions ::= s.ContractMode (Metatables s.Metatable*) t.OptFunction* - t.OptFunction ::= (s.Label (e.Name) e.OptBody) - e.OptBody ::= Sentences e.Sentences + s.ContractMode ::= Contractions-Enabled | Contractions-Disabled + t.OptFunction ::= ((e.Name) Sentences e.Sentences) + t.Metatable ::= ((e.Name) e.Metatable) */ @@ -35,100 +37,61 @@ $EXTERN OptTree-Drive-Expr, ApplyContractions; s.OptIntrinsic ::= OptIntrinsic | NoOpt */ $ENTRY OptTree-Drive-Prepare { - (NoOpt NoOpt) e.AST = e.AST; - - (s.OptDrive s.OptIntrinsic) - e.AST-B (DriveInfo e.DriveInfo) e.AST-E - = ; - (s.OptDrive s.OptIntrinsic) e.AST - = ( /* no names */) /* no info */ : e.EmptyInfo - = ; -} - -/* Функция генерирует имена остаточных прогоняемых функций */ - -GenRemainderFuncNames { - s.Label e.Name s.End s.End = /* пусто — пустую функцию прогнать нельзя */; - - s.Label e.Name s.Cur s.End - = (s.Label ) - s.End>; -} - -AddStarSuffix { - e.Name 0 = e.Name; - e.Name SUF e.Suffix s.Count = e.Name SUF e.Suffix '*' s.Count; - e.Name s.Count = e.Name SUF '*' s.Count; -} -BaseName { - e.Name SUF '*' s.Count = e.Name s.Count; - e.Name '*' s.Count = e.Name s.Count; - e.Name /* нет суффикса */ = e.Name 0; -} +* Игнорируем старую разметку + = e.AST + : { + e.AST-B (DriveInfo e._) e.AST-E = e.AST-B e.AST-E; + e.AST^ = e.AST; + } + : e.AST^ -UpdateDriveInfo { - s.OptDrive s.OptIntrinsic ((e.KnownNames) e.KnownFunctions) e.AST - = : (e.Drives) e.AST^ - = : (e.Inlines) e.AST^ - = : (e.Intrinsics) e.AST^ - = : (e.Metatables) e.AST^ + = : (e.Drives) e.AST^ + = : (e.Intrinsics) e.AST^ - = : e.Drives^ - = : e.Inlines^ + = e.AST + : { + e.AST-B (NoDrives e.Names) e.AST-E + = (e.Names) e.AST-B (NoDrives e.Names) e.AST-E; - = : e.KnownNames^ + e.AST^ = (/* пусто */) e.AST; + } + : (e.NoDrives) e.AST^ - = : e.Drives^ - = : e.Inlines^ - = : e.Intrinsics^ - = : e.Metatables^ + = : e.Drives^ = > : e.Label - = >; + ((e.Label) e.Set) + = : e.Name^ + = + } + e.Set + > } - e.Drives e.Inlines e.Intrinsics e.Metatables + (('DRIVE') e.Drives) (('INTRINSIC') e.Intrinsics) > : /* пусто */ = s.OptDrive : { NoOpt = /* пусто */; - OptInline = ; - OptDrive = e.Drives; + OptInline = ; + OptDrive = ; } : e.Drives^ - = s.OptDrive - : { - NoOpt = /* пусто */; - OptInline = e.Inlines; - OptDrive = e.Inlines; - } - : e.Inlines^ + = : e.DrivesBaseNames + = : (e.DriveFuncs) e.AST^ - = : e.ExtractedNames - = - : (e.Extracted) e.AST^ + = : (e.Metatables) e.AST^ = : (e.Lengths) e.AST^ = : e.Drives^ - = : e.Inlines^ - - /* - Функция Func может быть помечена как $INLINE, рассахариватель условий - извлёк Func*k, авторазметка пометила её как $DRIVE. - Пометка $INLINE имеет приоритет. - */ - = : e.Drives^ - - = e.Drives e.Inlines e.Metatables : e.OptNames - - = : e.OptFunctions = s.OptIntrinsic : { @@ -139,42 +102,43 @@ UpdateDriveInfo { = : e.OptIntrinsicFuncs - = : e.HashSetNames + = : e.HashSetNames + + = s.OptDrive + : { + NoOpt = Contractions-Disabled; + OptInline = Contractions-Disabled; + OptDrive = Contractions-Enabled; + } + : s.ContractionsMode = (DriveInfo (e.HashSetNames) - e.KnownFunctions e.OptFunctions e.OptIntrinsicFuncs + s.ContractionsMode (e.Metatables) + e.DriveFuncs e.OptIntrinsicFuncs ) e.AST; } ExtractLabels { - s.Label e.AST - = ; -} + s.Node e.AST-B (s.Node e.Names) e.AST-E = (e.Names) e.AST-B e.AST-E; -DoExtractLabels { - s.Label (e.FoundLabels) (e.Scanned) e.AST-B (s.Label e.Name) e.AST-E - = ; - - s.Label (e.FoundLabels) (e.Scanned) e.AST = (e.FoundLabels) e.Scanned e.AST; + s.Node e.AST = (/* пусто */) e.AST; } ExtractMetatableNames { e.AST = ; + ; (e.Minuent) (e.Subtrahend) = e.Minuent; } @@ -204,17 +168,17 @@ ExtractBaseNames { = ; } -ExtractExtractableFunctions { +ExtractDriveFunctions { (e.Names) e.AST = : s.SentencesCount e.Sentences^ = (e.Lengths (e.Name s.SentencesCount)) - (Function s.ScopeClass (e.Name) Sentences e.Sentences); + (Function (e.Name) Sentences e.Sentences); (e.Lengths) t.Other = (e.Lengths) t.Other; } @@ -257,24 +221,26 @@ MultiplyRemainderNames { = e.RemainderNames; } -FormatOptFunctions { - (e.OptNames) e.Functions - = ) e.Functions - > - : (e._) e.OptFunctions - = e.OptFunctions; +/* Функция генерирует имена остаточных прогоняемых функций */ + +GenRemainderFuncNames { + s.Label e.Name s.End s.End = /* пусто — пустую функцию прогнать нельзя */; + + s.Label e.Name s.Cur s.End + = (s.Label ) + s.End>; +} + +AddStarSuffix { + e.Name 0 = e.Name; + e.Name SUF e.Suffix s.Count = e.Name SUF e.Suffix '*' s.Count; + e.Name s.Count = e.Name SUF '*' s.Count; +} + +BaseName { + e.Name SUF '*' s.Count = e.Name s.Count; + e.Name '*' s.Count = e.Name s.Count; + e.Name /* нет суффикса */ = e.Name 0; } HashSet { @@ -309,10 +275,6 @@ DoHashSet-DoFillBucket { e.Names-OtherHash (s.Hash e.Bucket) = e.Names-OtherHash (s.Hash e.Bucket); } -HashSet-AsChain { - s.BucketSize e.HashSet = -} - /** == e.AST^ @@ -325,13 +287,12 @@ $ENTRY OptTree-Drive { /* Осуществляет прогонку или оптимизацию в зависимости от ключа */ DriveInlineOptimizerTick { - ((e.OptNames) e.OptInfo) e.AST - = ((e.OptNames) ) : t.OptInfo + t.OptInfo e.AST = ; @@ -340,17 +301,17 @@ DriveInlineOptimizerTick { t.OptInfo e.AST > - : ((e.OptNames^) t.Metatables e.OptInfo^) e.AST^ + : ((e.OptNames) e.OptFunctions) e.AST^ = : (e.NewFunctions^) e.AST^ - = (DriveInfo (e.OptNames) e.OptInfo) e.AST e.NewFunctions; -} - -IsLexpr { - e.Expr - , - : { - e.Res-B OpenE e.Res-E = False; - e.Res-B (s.Mode e.Index) e.Res-M (s.Mode e.Index) e.Res-E = False; - e.Other = True; - } -} - -/* - == t.IsLexpr-Aux-Item* - - t.IsLexpr-Aux-Item ::= OpenE | ('e' e.Index) | ('t' e.Index) -*/ -IsLexpr-Aux { - e.Expr-B (Var 'e' e.Index1) e.Expr-M (Var 'e' e.Index2) e.Expr-E - = OpenE; - - e.Expr - = ; - (ADT-Brackets (e.Name) e.InBrackets) = ; - - t.Other = /* пропускаем */; - } - e.Expr - >; + = (DriveInfo (e.OptNames) e.OptFunctions) e.AST e.NewFunctions; } /* @@ -423,7 +350,7 @@ IsLexpr-Aux { */ OptFunction { - (Function s.ScopeClass (e.Name) Sentences e.Sentences) t.OptInfo + (Function (e.Name) Sentences e.Sentences) t.OptInfo = + (e.Name) Sentences ); (t.OptInfo^ (e.Sentences^) (e.NewFunctions)) = t.OptInfo - (Function s.ScopeClass (e.Name) Sentences e.Sentences) + (Function (e.Name) Sentences e.Sentences) e.NewFunctions; } } @@ -460,34 +387,40 @@ OptSentence { = : e.SentenceVars /* Если левая часть не L-выражение, сужения запрещаем */ - = + = : { - True = /* пусто */; - False = e.SentenceVars; + True = e.Right; + False = ; } - : e.WholeVars + : e.Right^ - = + = : t.OptInfo^ e.Branches (e.NewFunctions) - = t.OptInfo (e.NewFunctions) - ) (e.DrivenRight)); + = : e.Left^ + = : e.Left^ + = : e.DrivenRight^ + = ((e.Left) (e.DrivenRight)); } e.Branches - >; + > + : e.NewSentences + + = t.OptInfo (e.NewFunctions) e.NewSentences; t.Sentence t.OptInfo = t.OptInfo () t.Sentence } -WithMetatables { +ExtractMetatables { e.OptFuncs = + (e.Name) Sentences ); t.OtherItem = t.OtherItem; @@ -540,6 +473,7 @@ CleanupCold-Result { CleanupCold-Term { (Brackets e.Expr) = (Brackets ); + (ClosureBrackets e.Expr) = (ClosureBrackets ); (ADT-Brackets (e.Name) e.Expr) = (ADT-Brackets (e.Name) ); diff --git a/src/compiler/OptTree-Spec.ref b/src/compiler/OptTree-Spec.ref index 0d2ecab0..b9ecbaf4 100644 --- a/src/compiler/OptTree-Spec.ref +++ b/src/compiler/OptTree-Spec.ref @@ -1,23 +1,24 @@ $INCLUDE "LibraryEx"; -*$FROM TreeUtils -$EXTERN ExtractVariables, ExtractVariables-Expr, NewVarName, AddSuffix; - -*$FROM GenericMatch -$EXTERN GenericMatch, Solve-Spec; - *$FROM Log -$EXTERN Log-PutLine, Log-InlineExpr; +$EXTERN Log-PutLine, Log-PutLine-Lazy, Log-InlineExpr; *$FROM DisplayName $EXTERN DisplayName; -*$FROM GlobalGen -$EXTERN GlobalGen; +*$FROM TreeUtils +$EXTERN AddSuffix, ExtractVariables-Expr, NewVarName, ExtractVariables, + ApplyContractions, ApplyAssigns, IsHardExpr; + +*$FROM GenericMatch +$EXTERN Solve-Spec, GenericMatch; *$FROM OptTree-StopRelation -$EXTERN OptTree-CanonizeTuple, OptTree-CanonizeExpr; -$EXTERN OptTree-CheckTupleStopRelation, OptTree-CheckExprStopRelation; +$EXTERN OptTree-CanonizeExpr, OptTree-CheckExprStopRelation; + +*$FROM GlobalGen +$EXTERN GlobalGen-NameVariables, GlobalGen; + /** == e.AST^ @@ -29,89 +30,122 @@ $EXTERN OptTree-CheckTupleStopRelation, OptTree-CheckExprStopRelation; e.SpecInfo ::= (e.SpecFuncNames) e.SpecInfo-Specific e.SpecFuncNames ::= (e.FuncName)* e.SpecInfo-Specific ::= t.FunctionInfo* (e.Histories) - t.FunctionInfo ::= ((e.Name) (e.Pattern) (e.Body) s.NextCounter t.Signature*) + t.FunctionInfo ::= ((e.Name) (e.Body) s.NextCounter t.Signature*) t.Signature ::= ((e.InstanceName) e.Expression) e.InstanceName ::= e.Name e.Histories ::= ((e.InstanceName) e.History)* e.History ::= ((e.FuncName) e.Expression)* */ $ENTRY OptTree-Spec-Prepare { - NoOpt e.AST = e.AST; + s.OptSpec e.AST - OptSpec e.AST-B (SpecInfo e.SpecInfo) e.AST-E - = ; +* Игнорируем старую разметку + = e.AST + : { + e.AST-B (SpecInfo e._) e.AST-E = e.AST-B e.AST-E; + e.AST^ = e.AST + } + : e.AST^ - OptSpec e.AST - = (/* no names */) /* no info */ (/* no histories */) - : e.EmptyInfo - = ; -} + = e.AST + : { + e.AST-B (Specs e.Names) e.AST-E = (e.Names) e.AST-B e.AST-E; + e.AST^ = (/* пусто */) e.AST; + } + : (e.NewNames) e.AST^ -Prepare-Aux { - ((e.KnownNames) e.KnownInfo (e.KnownHistories)) e.AST - = ) - ) - ' ' - - >; - - ((e.Names) e.Info (e.Histories)) t.Other - = ((e.Names) e.Info (e.Histories)) t.Other; - } - ) - (&MapAccum - { - ((e.Names) e.Info-B (t.Name (e.Pattern)) e.Info-E (e.Histories)) - (Function s.ScopeClass t.Name Sentences e.Body) - = ( - (e.Names) - e.Info-B (t.Name (e.Pattern) (e.Body) 1) e.Info-E - (e.Histories) - ) - (Function s.ScopeClass t.Name Sentences e.Body); - - ((e.Names) e.Info) t.Other = ((e.Names) e.Info) t.Other; - } - ) - > + = s.OptSpec + : { + OptSpec = e.NewNames; + NoOpt = /* пусто */; + } + : e.NewNames^ + + = e.AST + : { + e.AST-B (NoSpecs e.Names) e.AST-E + = (e.Names) e.AST-B (NoSpecs e.Names) e.AST-E; + + e.AST^ = (/* пусто */) e.AST; + } + : (e.NoSpecs) e.AST^ + + = + : e.NewNames^ + + = > + } + e.NewNames > - : ((e.NewNames) e.NewInfo (e.NewHistories)) e.AST^ + : /* пусто */ + + = + : ((e.NewNames^) e.NewInfo) e.AST^ + + = : e.Pattern + = () e.Pattern : e.HistoryRecord + = ((e.Name) (e.HistoryRecord)); + } + e.NewInfo + > + : e.NewHistories = : e.NewInfo^ = : e.AST^ = : e.NewInfo^ - = (SpecInfo - (e.KnownNames e.NewNames) - e.KnownInfo e.NewInfo - (e.KnownHistories e.NewHistories) - ) - e.AST + = (SpecInfo (e.NewNames) e.NewInfo (e.NewHistories)) e.AST } -TrivialHistory { - e.Name (e.Pattern) - = () - e.Pattern - : e.HistoryRecord - = ((e.Name) (e.HistoryRecord)); +BottomSignature { + e.Sentences + = + : e.Patterns + = : e.GlobalGen + = } * Добавляет вызов аварийной функции Func@0 в конец каждой специализируемой @@ -121,14 +155,13 @@ AddGuardSentences { e.Info = : e.GuardName - = (e.SpecPattern) - ((CallBrackets (Symbol Name e.GuardName) e.SpecPattern)) + = ((Var 'eARG')) + ((CallBrackets (Symbol Name e.GuardName) (Var 'eARG'))) : e.GuardSentence = ( (e.Name) - (e.SpecPattern) (e.Sentences (e.GuardSentence)) e.Signatures ) @@ -141,11 +174,12 @@ AddGuardEnums { e.AST = ; + (Function (e.Name) e.Body) + = (Function (e.Name) e.Body) ; - (Declaration s.ScopeClass e.Name) - = (Declaration s.ScopeClass e.Name) ; + (Externs e.Names) + = (Externs e.Names) + } e.Names>; t.OtherItem = t.OtherItem; } @@ -158,7 +192,7 @@ GuardEnumName { } MakeGuardEnum { - e.Name = (Function GN-Local () Sentences /* пусто */) + e.Name = (Function () Sentences /* пусто */) } * Обеспечивает специализацию функций Func*n. Такие функции могут получаться @@ -170,20 +204,20 @@ CreateRemainderFunctions { } CreateRemainderFunctions-OneFunction { - s.Count ((e.Name) (e.SpecPattern) ((e.GuardSentence)) 1 /* нет сигнатур */) + s.Count ((e.Name) ((e.GuardSentence)) 1 /* нет сигнатур */) = /* пусто */; - s.Count ((e.Name) (e.SpecPattern) (e.Sentences) 1 /* нет сигнатур */) + s.Count ((e.Name) (e.Sentences) 1 /* нет сигнатур */) = s.Count : { 0 = e.Name; s._ = ; } : e.RemainderName - = ((e.RemainderName) (e.SpecPattern) (e.Sentences) 1 /* нет сигнатур */) + = ((e.RemainderName) (e.Sentences) 1 /* нет сигнатур */) - ((e.Name) (e.SpecPattern) () 1 /* нет сигнатур */) + ((e.Name) () 1 /* нет сигнатур */) >; } @@ -207,15 +241,47 @@ $ENTRY OptTree-Spec { e.AST-B e.AST-E > : (e.SpecInfo^ (e.Histories^) (e.NewFunctions)) e.AST - = (SpecInfo (e.Names) e.SpecInfo (e.Histories)) e.AST e.NewFunctions; + = : e.AST^ + = (SpecInfo (e.Names) e.SpecInfo (e.Histories)) e.AST +} + +ApplyPatches { + e.AST (e.NewFunctionsAndPatches) + = + : (e.Patches) e.NewFunctions + = + e.NewFunctions } ColdAll { e.AST = '\n' + = }> +} + +PrintHistory-Aux { + (e.Function) e.History + = 'History of ' '\n' - > } SpecUnit { (e.SpecInfo (e.Histories-B (t.Name e.History) e.Histories-E) (e.NewFunctions) ) - (Function s.ScopeClass t.Name Sentences e.Sentences) + (Function t.Name Sentences e.Sentences) = : (e.SpecInfo^ (e.Histories) (e.History^) (e.NewFunctions^)) e.Sentences^ = (e.SpecInfo (e.Histories) (e.NewFunctions)) - (ColdFunction SPEC s.ScopeClass t.Name Sentences e.Sentences); + (ColdFunction SPEC t.Name Sentences e.Sentences); (e.SpecInfo (e.Histories) (e.NewFunctions)) - (Function s.ScopeClass t.Name Sentences e.Sentences) + (Function t.Name Sentences e.Sentences) = - : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) e.Result^ - = ; -} - -SpecResult-Pass { - s.Pass (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) e.Result = ; - } + &SpecTerm (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) e.Result >; @@ -363,7 +413,14 @@ SpecResult-Pass { и пытается выполнить специализацию для него */ SpecTerm { - s.Pass (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) + (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) + (CallBrackets (ClosureBrackets e.ClosureContent) e.Argument) + = ; + + (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (CallBrackets (Symbol Name e.Name) e.Expression) , e.Name : e._ '@' 0 /* @@ -381,58 +438,56 @@ SpecTerm { = (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (CallBrackets (Symbol Name e.Name) ); - s.Pass (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) + (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (CallBrackets (Symbol Name e.Name) e.Expression) - = - : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) e.Expression^ + : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) + (CallBrackets (Symbol Name e.Name^) e.Expression^) /* SAME */ - = s.Pass - : { - Functions = &TrySpecCall; - Closures = &SkipSpecCall; - } - : s.TrySpecCall + = + : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) e.Expression^ - = ; + = (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) + (CallBrackets (Symbol Name e.Name) e.Expression); - s.Pass (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) + (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (CallBrackets e.Expression) - = : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) e.Expression^ + = (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (CallBrackets e.Expression); - s.Pass (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) + (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (ClosureBrackets e.ClosureContent) - = : e.UsedVars + = : (e._) e.eClosureArg + = : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) - e.ClosureContent^ + (CallBrackets e.ClosureContent^ (Var e.eClosureArgOut)) - = s.Pass + /* + Проверка на то, что e.eClosureArg и e.eClosureArgOut равны. Проверить + через повторную переменную нельзя, т.к. стоит режим -Werror для + сборки исходников. + TODO: исправить при реализации подавления предупреждений. + */ + = e.eClosureArgOut : { - Functions = &SkipSpecCall; - Closures = &TrySpecCall; + e.eClosureArg = /* пусто */; + e._ = <{X = e.eClosureArg e.eClosureArgOut}> } - : s.TrySpecCall - - = - : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) - (CallBrackets e.ClosureContent^ (Var 'e@')) + : /* пусто */ = e.ClosureContent : { @@ -441,32 +496,37 @@ SpecTerm { (Symbol Name e.OptName); e.ClosureContent^ + = + : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) + e.ClosureContent^ + = (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (ClosureBrackets e.ClosureContent); }; - s.Pass (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) + (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (Brackets e.Expression) - = : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) e.Expression^ = (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (Brackets e.Expression); - s.Pass (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) + (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (ADT-Brackets (e.Name) e.Expression) - = : (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^)) e.Expression^ = (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) (ADT-Brackets (e.Name) e.Expression); - s.Pass (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) t.Other + (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) t.Other = (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) t.Other; } @@ -517,17 +577,11 @@ TrySpecCall { (CallBrackets (Symbol Name e.Name) e.Expression); } -SkipSpecCall { - (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) t.CallTerm - = (e.SpecInfo (e.Histories) (e.History) (e.NewFunctions)) t.CallTerm; -} - /** - == ((e.SpecPattern) (e.Body) s.NextNumber e.Signatures t.NewSignature) + == ((e.Body) s.NextNumber e.Signatures t.NewSignature) t.NewCall t.NewFunction (e.NewHistory) Функция пытается выполнить специализацию для заданного вызова: @@ -543,76 +597,124 @@ SkipSpecCall { SpecCall { /* TODO: убрать этот хак в рамках задачи #332 */ - (e.Name) (e.SpecPattern) (e.Body) s.NextNumber e.Signatures + (e.Name) (e.Body) s.NextNumber e.Signatures (e.Argument) (e.History) - , s.NextNumber : 100 - = ((e.SpecPattern) (e.Body) s.NextNumber e.Signatures) + , : '+' + = ((e.Body) s.NextNumber e.Signatures) (CallBrackets (Symbol Name e.Name) e.Argument) /* пусто */ (/* пусто */); - (e.Name) (e.SpecPattern) (e.Body) s.NextNumber e.Signatures + (e.Name) (e.Body) s.NextNumber e.Signatures (e.Argument) (e.History) = : e.UsedVars + = : (e.ExtractedCalls (e.UsedVars^)) e.NewArgument - /* ищем динамическое обобщение для аргумента и образцов */ - = - : (e.NewArgument^) (e.Sg) (e.Solutions) - = + : e.NewArgument^ (e.UsedVars^) (e.Sg) + + = e.Sg e.ExtractedCalls : e.Sg^ + + = ; } +/* + Функция обобщает участки между двумя e-параметрами: + … e.1 … e.2 … → … e.New …, e.1 … e.2 ← e.New +*/ +GenEE { + /* пусто */ (e.UsedVars) (e.Sg) = /* пусто */ (e.UsedVars) (e.Sg); + (Var 'e' e.Index) (e.UsedVars) (e.Sg) = (Var 'e' e.Index) (e.UsedVars) (e.Sg); + + (Var 'e' e.Left) e.Expr (Var 'e' e.Right) (e.UsedVars) (e.Sg) + = : (e.UsedVars^) 'e' e.eGen + = (Var 'e' e.eGen) (e.UsedVars) + (e.Sg ((Var 'e' e.Left) e.Expr (Var 'e' e.Right) ':' (Var 'e' e.eGen))); + + (s.Brackets e.Nested) e.Expr (e.UsedVars) (e.Sg) + , Brackets ClosureBrackets : e._ s.Brackets e._ + = : e.Nested^ (e.UsedVars^) (e.Sg^) + = (s.Brackets e.Nested) ; + + (ADT-Brackets (e.Name) e.Nested) e.Expr (e.UsedVars) (e.Sg) + = : e.Nested^ (e.UsedVars^) (e.Sg^) + = (ADT-Brackets (e.Name) e.Nested) ; + + (Symbol e.Symbol) e.Expr (e.UsedVars) (e.Sg) + = (Symbol e.Symbol) ; + + (Var s.Mode e.Index) e.Expr (e.UsedVars) (e.Sg) + , 'st' : e._ s.Mode e._ + = (Var s.Mode e.Index) ; + + e.Expr (s.Brackets e.Nested) (e.UsedVars) (e.Sg) + , Brackets ClosureBrackets : e._ s.Brackets e._ + = : e.Expr^ (e.UsedVars^) (e.Sg^) + = : e.Nested^ (e.UsedVars^) (e.Sg^) + = e.Expr (s.Brackets e.Nested) (e.UsedVars) (e.Sg); + + e.Expr (ADT-Brackets (e.Name) e.Nested) (e.UsedVars) (e.Sg) + = : e.Expr^ (e.UsedVars^) (e.Sg^) + = : e.Nested^ (e.UsedVars^) (e.Sg^) + = e.Expr (ADT-Brackets (e.Name) e.Nested) (e.UsedVars) (e.Sg); + + e.Expr (Symbol e.Symbol) (e.UsedVars) (e.Sg) + = : e.Expr^ (e.UsedVars^) (e.Sg^) + = e.Expr (Symbol e.Symbol) (e.UsedVars) (e.Sg); + + e.Expr (Var s.Mode e.Index) (e.UsedVars) (e.Sg) + , 'st' : e._ s.Mode e._ + = : e.Expr^ (e.UsedVars^) (e.Sg^) + = e.Expr (Var s.Mode e.Index) (e.UsedVars) (e.Sg); +} + DynGenArg { - (e.Arg) (e.Sg) (e.Sol) (e.Begin) - ((e.Pat) e.Tail) e.Sentences - = : e.UsedVars + (e.UsedVars) (e.Arg) (e.Sg) e.Sentences + = ; +} + +*$NODRIVE DoDynGenArg + +DoDynGenArg { + (e.UsedVars) (e.Arg) (e.Sg) (e.Sol) + (e.Begin) ((e.Pat) e.Tail) e.Sentences + = e.UsedVars : e.UsedVars^ + = : e.UsedVars^ = : (e.UsedVars^) e.eNew = e.Arg (Brackets (Var e.eNew)) : e.Arg^ = : e.WrappedCondVars = e.Pat (Brackets e.WrappedCondVars) : e.Pat^ = : { - Success e.Solutions (e.SgNew) (e.ArgNew) - , e.SgNew : /* пусто */ + (e.UsedVars^) e.Solutions (/* нет обобщений */) (e.ArgNew) = e.ArgNew : e.ArgNew^ (Brackets e._) = e.Pat : e.Pat^ (Brackets e._) - = ; - Success e.Solutions (e.SgNew) (e.ArgNew) + (e.UsedVars^) e.Solutions (e.SgNew) (e.ArgNew) = e.ArgNew : e.ArgNew^ (Brackets e._) = e.Pat : e.Pat^ (Brackets e._) + = e.SgNew e.Sg : e.Sg^ + = : e.Sg^ = - > - ) - (/* пусто */) (/* пусто */) + (e.UsedVars) (e.ArgNew) (e.Sg) e.Begin ((e.Pat) e.Tail) e.Sentences >; - - Failure - = e.Arg : e.Arg^ (Brackets e._) - = e.Pat : e.Pat^ (Brackets e._) - = ; }; - (e.Arg) (e.Sg) (e.Sol) (e.Begin) /* пусто */ - = (e.Arg) (e.Sg) (e.Sol); + (e.UsedVars) (e.Arg) (e.Sg) (e.Sol) (e.Begin) /* пусто */ + = (e.UsedVars) (e.Arg) (e.Sg) (e.Sol); } WrappedCondVars { @@ -650,104 +752,250 @@ RemoveAssignByLeftPart { >; } -SpecCall-Aux { +SpecCall-BuildSignature { + (e.Name) e.SpecInfo (e.UsedVars) + (e.SourceArg) (e.NewArg) (e.Sg) (e.History) + + = e.SpecInfo : (e.Body) s.NextNumber e.Signatures + + /* ищем динамическое обобщение для аргумента и образцов */ + = + : (e.UsedVars^) (e.NewArg^) (e.Sg^) (e.Solutions) + + = + : { + (e.SpecInfo^) Trivial + = (e.SpecInfo) + (CallBrackets (Symbol Name e.Name) e.SourceArg) + /* пусто */ (/* пусто */); + + (e.SpecInfo^) Known e.InstanceName + = (e.SpecInfo) + (CallBrackets + (Symbol Name e.InstanceName) + (e.Sg)> + ) + /* пусто */ (/* пусто */); + + (e.SpecInfo^) NewSignature e.Signature + + = : e.InstanceName + = (e.Body) + e.Signatures ((e.InstanceName) e.Signature) + : e.SpecInfo^ + + = + : (e.SpecInfo^) e.NewFunctions (e.NewHistory) + + = (e.SpecInfo) + (CallBrackets + (Symbol Name e.InstanceName) + (e.Sg)> + ) + e.NewFunctions + (e.NewHistory); + } +} + +SpecCall-CheckSignature { /* тривиальная сигнатура */ - (e.Name) (e.SpecPattern) (e.Body) s.NextNumber e.Signatures - (e.OldArg) (e.NewArg) (e.Sg) (e.Solutions) (e.History) - s.NeedRelationCheck - , : True - = ((e.SpecPattern) (e.Body) s.NextNumber e.Signatures) - (CallBrackets (Symbol Name e.Name) e.OldArg) - /* пусто */ (/* пусто */); + (e.Body) s.NextNumber e.Signatures (e.NewArg) + , : True + = ((e.Body) s.NextNumber e.Signatures) + Trivial; /* проверяем, известна ли сигнатура */ - (e.Name) (e.SpecPattern) (e.Body) s.NextNumber e.Signatures - (e.OldArg) (e.NewArg) (e.Sg) (e.Solutions) (e.History) - s.NeedRelationCheck + (e.Body) s.NextNumber e.Signatures (e.NewArg) = : t._ e.Signature - = + = : { Found e.InstanceName (e.Signatures^) - = ((e.SpecPattern) (e.Body) s.NextNumber e.Signatures) - (CallBrackets - (Symbol Name e.InstanceName) - > - ) - /* пусто */ (/* пусто */); + = ((e.Body) s.NextNumber e.Signatures) + Known e.InstanceName; /* проверяем на зацикливание */ NotFound e.Signatures^ - = s.NeedRelationCheck - : { - True - = ) - e.History - >; - - False = False; - } - : { - True e.HistorySignature - /* Получает обобщённую сигнатуру для двух сигнатур */ - = : e.GenSignature - = : e.ArgVars - = - : t._ e.GenSignature^ - = : Clear e.NewSg - = - : { - /* - Если подстановка e.NewSg является тривиальной, - проверку отношения Хигмана-Крускала - в рекурсивном вызове не выполняем - */ - True = False; - - False = True; - } - : s.NeedRelationCheck^ - = ) - (/* пусто */) (/* пусто */) e.Body - > - : (e.NewArg^) (e.Sg^) (e.Solutions^) - = ; - - False - = - : e.NewSentences - = : e.InstanceName - = ( - (e.SpecPattern) (e.Body) - e.Signatures ((e.InstanceName) e.Signature) - ) - (CallBrackets - (Symbol Name e.InstanceName) - > - ) - (Function - GN-Local (e.InstanceName) - Sentences e.NewSentences - ) - ( - ( - (e.InstanceName) e.History - ((e.InstanceName) e.Signature) - ) - ); - } + = ((e.Body) s.NextNumber e.Signatures) + NewSignature e.Signature; }; } +MakeNewFunction { + (e.SpecInfo) (e.Name) e.History (e.InstanceName) + (e.Signature) (e.NewArg) (e.Solutions) + , ) e.History + > + : True e.HistoryPrefix ((e.HistoryName) e.HistorySignature) + = ; + + (e.SpecInfo) (e.Name) e.History (e.InstanceName) + (e.Signature) (e.NewArg) (e.Solutions) + = e.SpecInfo : (e.Body) s.NextNumber e.Signatures + = : e.NewSentences + = (e.SpecInfo) + (Function (e.InstanceName) Sentences e.NewSentences) + ( + ((e.InstanceName) e.History ((e.InstanceName) e.Signature)) + ); +} + +MakeNewFunction-Generalize { + /* + Зацикливание с тривиальной сигнатурой на дне. + Обобщение двух сигнатур дало бы тривиальную сигнатуру, + вызов которой соответствует вызову исходной функции. + */ + e.SpecInfo (e.Name) (e.InstanceName) (e.Signature) (e.NewArg) + (e.HistoryPrefix) ((e.HistoryName '@' 0) e.HistorySignature) (e.Solutions) + = (e.SpecInfo) + (ColdFunction LET + (e.InstanceName) + Sentences + ( + () + /* = */ + ((CallBrackets (Symbol Name e.Name) e.NewArg)) + ) + ) + ( + ((e.InstanceName) e.HistoryPrefix ((e.InstanceName) e.Signature)) + ); + + /* Простое зацикливание: текущая сигнатура есть частный случай старой. */ + e.SpecInfo (e.Name) (e.InstanceName) (e.Signature) (e.NewArg) + (e.HistoryPrefix) ((e.HistoryName) e.HistorySignature) (e.Solutions) + + , : Clear e.NewSubst + + = (e.SpecInfo) + (ColdFunction LET + (e.InstanceName) + Sentences + ( + () + /* = */ + ( + (CallBrackets + (Symbol Name e.HistoryName) + (e.NewSubst)> + ) + ) + ) + ) + ( + ((e.InstanceName) e.HistoryPrefix ((e.InstanceName) e.Signature)) + ); + + /* + Хитрое зацикливание: старая сигнатура есть частный случай текущей. + Такое возможно, если e-переменной текущей сигнатуры соответствует + пустота в старой. + + Формально тут должно строиться обобщение, которое должны оба экземпляра + вызывать (см. общий случай в последнем предложении), история обобщения + будет совпадать с историей верхнего экземпляра. + + Но обобщение будет совпадать с текущей сигнатурой, что в последнем + предложении привело бы к созданию let-экземпляра, который вызывает + себя. Поэтому тут надо разобрать частный случай — построить явным образом + экземпляр для текущей сигнатуры и патч для верхней. + */ + e.SpecInfo (e.Name) (e.InstanceName) (e.Signature) (e.NewArg) + (e.HistoryPrefix) ((e.HistoryName) e.HistorySignature) (e.Solutions) + + , : Clear e.PatchSubst + + = e.SpecInfo : (e.Body) s.NextNumber e.Signatures + = : e.NewSentences + + = (e.SpecInfo) + (PatchFunc + (e.HistoryName) + Sentences + ( + () + /* = */ + ( + (CallBrackets + (Symbol Name e.InstanceName) + (e.PatchSubst)> + ) + ) + ) + ) + (Function (e.InstanceName) Sentences e.NewSentences) + ( + ((e.InstanceName) e.HistoryPrefix ((e.InstanceName) e.Signature)) + ); + + /* Зацикливание с обобщением */ + e.SpecInfo (e.Name) (e.InstanceName) (e.Signature) (e.NewArg) + (e.HistoryPrefix) ((e.HistoryName) e.HistorySignature) (e.Solutions) + + /* Получает обобщённую сигнатуру для двух сигнатур */ + = : e.GenSignature + + = + : (e.UsedVars) e.GenSignature^ + + = : Clear e.NewSubst + = + : Clear e.PatchSubst + + = + : (e.SpecInfo^) t.GenSignatureCall e.NewFunctions (e.NewHistories) + + = (e.SpecInfo) + (PatchFunc + (e.HistoryName) + Sentences + ( + () + /* = */ + () + ) + ) + (ColdFunction LET + (e.InstanceName) + Sentences + ( + () + /* = */ + () + ) + ) + e.NewFunctions + ( + ((e.InstanceName) e.HistoryPrefix ((e.InstanceName) e.Signature)) + e.NewHistories + ); +} + +GenericMatch-Spec { + (e.Expr) (e.Pattern) + , : Clear e.Subst + = Clear + ; + + (e.Expr) (e.Pattern) = Undefined; +} + ExtractCalls-Expr { (e.Calls (e.UsedVars)) e.Expr = ; @@ -756,7 +1004,7 @@ ExtractCalls-Expr { ExtractCalls-Term { (e.Calls (e.UsedVars)) (CallBrackets e.Expr) = : (e.UsedVars^) e.NewVar - = (e.Calls ((CallBrackets e.Expr) ':' (e.NewVar)) (e.UsedVars)) + = (e.Calls ((CallBrackets e.Expr) ':' (Var e.NewVar)) (e.UsedVars)) (Var e.NewVar); (e.Calls (e.UsedVars)) (Brackets e.Expr) @@ -769,6 +1017,11 @@ ExtractCalls-Term { : (e.Calls^ (e.UsedVars^)) e.Expr^ = (e.Calls (e.UsedVars)) (ADT-Brackets (e.Name) e.Expr); + (e.Calls (e.UsedVars)) (ClosureBrackets e.Expr) + = + : (e.Calls^ (e.UsedVars^)) e.Expr^ + = (e.Calls (e.UsedVars)) (ClosureBrackets e.Expr); + (e.Calls (e.UsedVars)) t.OtherTerm = (e.Calls (e.UsedVars)) t.OtherTerm; } @@ -799,53 +1052,19 @@ RenameSignatureVars-Term { t.State t.OtherTerm = t.State t.OtherTerm; } -/* - Применяем левую подстановку к левым частям правой. - Это не совсем композиция подстановок, поскольку для композиции нужно - также объединять домены подстановок. -*/ -ApplySubst-Subst { - (e.FromSubstitution) e.ToSubstitution +ApplySequentalAssigns { + e.Expression (e.Assigns) = ':' t.Var); + (e.Expr ':' t.Var) = (t.Var ':' e.Expr) } - e.ToSubstitution - >; -} - -ApplySubst-Expr { - (e.Substitution) e.Expression - = ); - - (ADT-Brackets (e.Name) e.Nested) - = (ADT-Brackets - (e.Name) - ); - - (CallBrackets e.Nested) - = (CallBrackets ); - - (ClosureBrackets e.ClosureContent) - = (ClosureBrackets - - ); - - t.OtherTerm = t.OtherTerm; - } - e.Expression - >; + e.Assigns + > + : e.Contractions + = } -Spec-FindInSignatures { +FindInSignatures { (e.Signature) e.Signatures-B ((e.InstanceName) e.Signature) e.Signatures-E = Found e.InstanceName @@ -854,86 +1073,57 @@ Spec-FindInSignatures { (e.Signature) e.Signatures = NotFound e.Signatures; } -/** - -*/ -IsTrivialSubstitutions { - e.StaticMatches - = ; +CreateNewSentences { + (e.Arg) (e.Solutions) (e.Body) + = : e.PatternTemplate + = } -CreateNewSentences { - (e.Arg) (e.NewSentences) +DoCreateNewSentences { + (e.PatTemplate) (e.NewSentences) ((e.Sol) e.Solutions) (((e.Pat) e.Tail) e.Body) = : e.Contrs^ - = : e.Assigns^ - = ( - e.NewSentences - ( - (>) - - ) - ); - - (e.NewSentences^) Failure - = (e.NewSentences); + = : e.Pat^ + = : e.Tail^ + = (e.NewSentences ((e.Pat) e.Tail)); } (e.NewSentences) e.Sol > : (e.NewSentences^) - = ; - (e.Arg) (e.NewSentences) - (/* пусто */) (/* пусто */) - = e.NewSentences; -} - -FormatContractions { - ((Var e.ModeIndex) ':' e.Val) e.Contrs - = (e.Val ':' (e.ModeIndex)) ; - - /* пусто */ = /* пусто */; -} - -FormatAssigns { - (e.Val ':' (Var e.ModeIndex)) e.Assigns - = (e.Val ':' (e.ModeIndex)) ; - - /* пусто */ = /* пусто */; + (e.PatTemplate) (e.NewSentences) (/* пусто */) (/* пусто */) + = e.NewSentences + : { + /* + Если образец одного из предложений совпадает с шаблоном + (к нему не применилось ни одно из сужений) и условий нет, + то это предложение экранирует все последующие. + */ + e.Prefix ((e.PatTemplate) (e.Result)) e.ScreenedSentences + = e.Prefix ((e.PatTemplate) (e.Result)); + + e.NewSentences^ = e.NewSentences; + }; } ApplySubst-Tail { - (e.Substitution) (Condition (e.ConditionName) (e.Result) (e.Pattern)) e.Tail + (e.Assigns) (Condition (e.ConditionName) (e.Result) (e.Pattern)) e.Tail = ( Condition (e.ConditionName) - () - () + () + () ) - ; + ; - (e.Substitution) (e.Result) - = (); + (e.Assigns) (e.Result) = (); } WrapVars { @@ -950,7 +1140,7 @@ WrapVars { WrapVar { 'e' e.Expr = (GhostBrackets e.Expr); - s.Mode e.Expr = e.Expr + s.Mode e.Expr = e.Expr; } RemoveLastGhostBracket { @@ -971,9 +1161,18 @@ RemoveLastGhostBracket { } IsTrivialSignature { - e.Arg, e.Arg : (Var 'e' e._) = True; + e.Arg (e.Body), : False = False; + e.Arg (e.Body t.GuardSentence) = ; +} + +DoIsTrivialSignature { + e.Arg (/* кончились предложения */) = True; - e.Arg = False; + e.Arg (((e.Pattern) e.Tail) e.Sentences) + , : Clear e._ + = ; + + e.Arg (e.Sentences) = False; } OrderUniqueVars { @@ -983,36 +1182,23 @@ OrderUniqueVars { e.Variables = e.Variables; } -/* - Функции, относящиеся к проверке отношения Хигмана-Крускала -*/ - /** - - == True e.HistorySignature + + == True e.HistoryPrefix ((e.HistoryName) e.HistorySignature) == False - - Функция проверяет, выполняется ли отношение Хигмана-Крускала - для одной из сигнатур в e.History и сигнатуры e.Signature, - то есть проверяется, можно ли вложить одну сигнатуру в другую, - удалив некоторые элементы. - В случае, если в истории сигнатур удаётся найти сигнатуру, - для которой выполняется указанное отношение, - функция возвращает True и соответствующий e.HistorySignature. - В ином случае возвращается False. */ -HasHigmanKruskalRelation { +HasStopRelation { (e.Name) (e.Signature) e.History ((e.InstanceName) e.HistorySignature) , : e.Name , > : True - = True e.HistorySignature; + = True e.History ((e.InstanceName) e.HistorySignature); - (e.Name) (e.Signature) e.History ((e.InstanceName) e.HistorySignature) - = ; + (e.Name) (e.Signature) e.History t.HistoryItem + = ; (e.Name) (e.Signature) /* пустая история */ = False; } @@ -1048,3 +1234,21 @@ NameSignatureVars-Term { t.State t.OtherTerm = t.State t.OtherTerm; } + + +/** + == e.AST^ +*/ +$ENTRY OptTree-Spec-MarkLetsForDrive { + e.AST + = +} diff --git a/src/compiler/OptTree-StopRelation.ref b/src/compiler/OptTree-StopRelation.ref index 6bc3be96..76a04d5c 100644 --- a/src/compiler/OptTree-StopRelation.ref +++ b/src/compiler/OptTree-StopRelation.ref @@ -5,16 +5,16 @@ $INCLUDE "LibraryEx"; */ /** - + == True == False - Проверяет выполнение отношения Хигмана-Крускала для двух кортежей. + Проверяет выполнение отношения Хигмана-Крускала для двух выражений. Возвращает True, если отношение выполняется, и False в ином случае. - Предполагается, что оба кортежа в канонической форме. + Предполагается, что оба выражения в канонической форме. - e.CurrentTuple, e.HistoryTuple ::= (e.CanonizedExpr)* + e.CurrentExpr, e.HistoryExpr ::= e.CanonizedExpr e.CanonizedExpr ::= t.CanonizedTerm* t.CanonizedTerm ::= (Symbol s.SymType e.SymInfo) @@ -26,285 +26,85 @@ $INCLUDE "LibraryEx"; | (ClosureBrackets t.CanonizedTerm*) | (CallBrackets t.Name t.CanonizedTerm*) */ -$ENTRY OptTree-CheckTupleStopRelation { - (/* пусто */) /* пусто */ = True; - - (e.CurrentTuple) e.HistoryTuple - , e.CurrentTuple : (e.CurrentExpr) e.CurrentTuple-Rest - , e.HistoryTuple : (e.HistoryExpr) e.HistoryTuple-Rest - , - : { - True - = ; - - False = False; - }; -} - -/** - - == True - == False - - e.CurrentExpr, e.HistoryExpr ::= e.CanonizedExpr -*/ $ENTRY OptTree-CheckExprStopRelation { (e.CurrentExpr) e.HistoryExpr - /* Разделяем текущую сигнатуру на две части */ - , e.CurrentExpr : t.Term e.OtherPart - = ; - - (e.CurrentExpr) e.HistoryExpr - , e.CurrentExpr : /* пусто */ - = e.HistoryExpr - : { - /* пусто */ = True; - e._ = False; - }; -} - -/** - - == True - == False - - Одна итерация функции OptTree-CheckExprStopRelation. - - e.CurSig1 ::= t.Term* - e.CurSig2 ::= t.Term* - e.HistorySignature ::= t.Term* -*/ -DoCheckExprPairForRelation { - (e.CurSig1) (e.CurSig2) e.HistorySignature - - /* Проверяем, содержится ли полностью в e.CurSig1 */ - , : True - - = True; - - (e.CurSig1) (e.CurSig2) e.HistorySignature - - /* Проверяем, содержится ли полностью в e.CurSig2 */ - , : True - - = True; - - (e.CurSig1) (e.CurSig2) e.HistorySignature - - /* Проверяем, что часть e.HistorySignature содержится в e.CurSig1 */ - , - : True e.HistorySignature-Rest - - /* Проверяем, что оставшаяся часть содержится в e.CurSig2 */ - , + , () + > : True + = >; - = True; - - (e.CurSig1) (e.CurSig2) e.HistorySignature = False; + (e.CurrentExpr) e.HistoryExpr = ; } -/** - - == True - == False +*$xDRIVE Trace - Проверяет, что выражение содержит сигнатуру. - - e.Expr ::= t.Term* - e.Signature ::= t.Term* +Trace { +*/* + s.SubseqRes e.HKRes = e.HKRes; +/*/ + s.SubseqRes e.HKRes = e.HKRes; */ -ContainsSignature { - (e.Expr-B e.Signature e.Expr-E) e.Signature - = True; - - /* - Если выражение и сигнатура из истории начинаются на одинаковый терм, - то выражение вкладывается в сигнатуру тогда и только тогда, когда - вкладываются их хвосты. - */ - (t.Common e.Expr) t.Common e.Signature - = ; - - /* - Оптимизация частнoго случая: аналогично можно поступить и с последним - общим термом. - */ - (e.Expr t.Common) e.Signature t.Common - = ; - - /* - Если первый токен у обеих сигнатур - скобки, - пытаемся их убрать у обеих сигнатур и посмотреть, - есть ли вложение без них - */ - ((s.TermType e.Inner) e.RestExpr) (s.TermType e.OtherInner) e.OtherRestExpr - , e.Inner : t.Inner-FirstTerm e.Inner-Rest - , e.OtherInner : t.OtherInner-FirstTerm e.OtherInner-Rest - - /* - Проверяем, что первый элемент - скобки, и - в зависимости от типа скобок определяем - её внутреннее выражение - */ - , s.TermType : - { - Brackets - = True e.Inner; - - ClosureBrackets - = True e.Inner; - - ADT-Brackets - , e.Inner - : (e.Name) e.ADT-Brackets-Inner-Rest - = True e.ADT-Brackets-Inner-Rest; - - CallBrackets - = True e.Inner; - - e.OtherTermType - = False; - } - : True e.Inner^ - - , e.Inner : - { - t.Inner-FirstTerm^ e.Inner-Rest^ - = ; - - e.Expr - = ; - } - : s.InnerCheckResult - - , s.InnerCheckResult - : True - - , e.RestExpr : - { - t.RestExpr-Term e.RestExpr-Rest - = ; - - e.Expr - = ; - } - : s.RestExprCheckResult - - , s.RestExprCheckResult - : True - - = True; - - ((s.TermType e.Inner) e.RestExpr) e.Signature - , e.Inner : t.Inner-FirstTerm e.Inner-Rest - = s.TermType - : { - Brackets - = ; - - ADT-Brackets - , e.Inner - : (e.Name) t.ADT-Brackets-Inner-FirstTerm e.ADT-Brackets-Inner-Rest - = ; - - CallBrackets - = ; - - ClosureBrackets - = ; - - Var - = ; - - Symbol - = ; +} - s.OtherTermType - = False; - }; +CheckSubsequenceRelation { + e._ t.Common e.CurrentExpr (t.Common e.HistoryExpr) + = ; - (e.Expr) e.Signature = False; + e.CurrentExpr (/* пусто */) = True; + e.CurrentExpr (e.HistoryExpr) = False; } -/** - - == True e.SignaturePart - == False - - Проверяет, что выражение частично содержит сигнатуру. - Если была обнаружена часть сигнатуры, - содержащаяся в выражении, возвращает True, за которым - следует остальная часть сигнатуры. - Иначе возвращает False. +Tokenize { + e.Expression + = (')'); + (ADT-Brackets (e.Name) e.Inner) = ('[' e.Name) (']'); + (CallBrackets e.Inner) = ('<') ('>'); + (ClosureBrackets e.Inner) = ('{{') ('}}'); + + t.Other = t.Other; + } + e.Expression + > +} - e.Expr ::= t.Term* - e.Signature ::= t.Term* -*/ -PartiallyContainsSignature { - (e.Expr) e.Signature - /* Если выражение из истории пусто, возвращаем False */ - , e.Signature : /*пусто*/ - = False; +CheckHKRelation { + e.CurrentExpr (/* пусто */) = True; + /* пусто */ (e.HistoryExpr) = False; - (e.Expr) e.Signature + t.Common e.CurrentExpr (t.Common e.HistoryExpr) + = ; - /* Разделяем сигнатуру из истории на две части */ - , e.Signature : e.Signature-Part t.LastTerm + t.CurrentTerm e.CurrentExpr (t.HistoryTerm e.HistoryExpr) + , : True + = ; - /* Проверяем, что e.Signature-Part не пусто */ - , e.Signature-Part : t.FirstTerm e.OtherPart + (s.Brackets e.Inner) e.CurrentExpr (e.HistoryExpr) + , : e._ s.Brackets e._ + = ; - /* - Если текущая сигнатура содержит часть сигнатуры из истории, - возвращаем True и остальную часть, которую она не содержит. - */ - , - : True + (ADT-Brackets (e.Name) e.Inner) e.CurrentExpr (e.HistoryExpr) + = ; - = True t.LastTerm; + t.Skip e.CurrentExpr (e.HistoryExpr) + = ; +} - /* - Отщепляем последний терм от сигнатуры из истории и вызываем рекурсию, - в конце добавляем последний терм, который отщепили. - */ - (e.Expr) e.Signature-Part t.LastTerm - = - t.LastTerm; +AllBrackets { + = Brackets CallBrackets ClosureBrackets; } -/** - == (e.CanonizedExpr)* +CheckHKRelation-Term { + (s.Brackets e.CurrentExpr) (s.Brackets e.HistoryExpr) + , : e._ s.Brackets e._ + = ; - * Убирает имена переменных в сигнатуре, оставляет их типы данных. -*/ -$ENTRY OptTree-CanonizeTuple { - e.Tuple = ) } e.Tuple> + (ADT-Brackets (e.Name) e.CurrentExpr) (ADT-Brackets (e.Name) e.HistoryExpr) + = ; + + t.CurrentTerm t.HistoryTerm = False; } /** @@ -316,9 +116,15 @@ $ENTRY OptTree-CanonizeExpr { CanonizeExpr-Term { (Var s.Mode e.Index) = (Var s.Mode); + (WhVar s.Mode e.Index) = (Var s.Mode); + + /* Не различаем замороженные и обычные скобки */ + (ColdCallBrackets e.Expr) + = : e.Expr^ + = (CallBrackets e.Expr); (s.BracketsTag e.Expr) - , : True + , : e._ s.BracketsTag e._ = : e.Expr^ = (s.BracketsTag e.Expr); diff --git a/src/compiler/OptTree.ref b/src/compiler/OptTree.ref index ce79dc7a..af50057b 100644 --- a/src/compiler/OptTree.ref +++ b/src/compiler/OptTree.ref @@ -4,18 +4,18 @@ $INCLUDE "LibraryEx"; $EXTERN Config-GetTreeOptCycles, Config-GetOptDrive, Config-GetOptSpec, Config-GetOptAutoMarkup, Config-GetOptIntrinsic; -*$FROM OptTree-AutoMarkup-Spec -$EXTERN OptTree-AutoMarkup-Spec; - -*$FROM OptTree-AutoMarkup-Drive -$EXTERN OptTree-AutoMarkup-Drive, OptTree-AutoMarkup-CureDrives, - OptTree-AutoMarkup-CleanupUnusedFunctions; +*$FROM OptTree-AutoMarkup +$EXTERN OptTree-AutoMarkup-Spec, OptTree-AutoMarkup-Drive, + OptTree-AutoMarkup-DriveInstances, OptTree-AutoMarkup-CleanupUnusedFunctions; *$FROM OptTree-Drive $EXTERN OptTree-Drive-Prepare, OptTree-Drive, OptTree-Drive-CleanupColdCalls; *$FROM OptTree-Spec -$EXTERN OptTree-Spec-Prepare, OptTree-Spec; +$EXTERN OptTree-Spec-Prepare, OptTree-Spec, OptTree-Spec-MarkLetsForDrive; + +*$FROM TreeUtils +$EXTERN ExpandClosures-Result; *$FROM Log $EXTERN Log-AST; @@ -38,6 +38,7 @@ $ENTRY OptTree { = (s.OptDrive s.OptIntrinsic) : t.OptDrive = (define main (if s.OptAutoMarkup (begin @@ -48,15 +49,12 @@ $ENTRY OptTree { (DriveSpecLoop) (pass (trace 'before Driving non-recursive instances') - (call &OptTree-AutoMarkup-Drive)) + (call &OptTree-AutoMarkup-DriveInstances)) (call &OptTree-Drive-Prepare t.OptDrive) (DriveLoop)) (begin - (when (or s.OptDrive s.OptIntrinsic) - (trace 'before Curing drives') - (call &OptTree-AutoMarkup-CureDrives)) (DriveSpecLoop))) - (trace 'before Cleanup unused functions') + (trace 'before Cleanup unused functions (common)') (call &OptTree-AutoMarkup-CleanupUnusedFunctions) (call &OptTree-CleanupMarkup)) @@ -70,27 +68,39 @@ $ENTRY OptTree { (pass (trace 'before Spec') (call &OptTree-Spec s.OptSpec))) - (call &WarmColdFunctions SPEC)) + (call &OptTree-Spec-MarkLetsForDrive) + (call &WarmColdFunctions SPEC) + (pass + (trace 'before Driving let instances') + (call &OptTree-Drive-Prepare (OptInline NoOpt)) + (DriveLoop-core)) + (trace 'before Cleanup unused functions (let instances)') + (call &OptTree-AutoMarkup-CleanupUnusedFunctions)) (begin (call &OptTree-Drive-Prepare t.OptDrive) (DriveLoop)))) (define DriveLoop (if (or s.OptDrive s.OptIntrinsic) - (begin - (loop-for-warm-functions - (pass - (trace 'before Drive') - (call &ExpandClosures) - (call &OptTree-Drive))) - (call &WarmColdFunctions DRIVE) - (call &OptTree-Drive-CleanupColdCalls)) + (DriveLoop-core) (call &ExpandClosures))) + (define DriveLoop-core + (loop-for-warm-functions + (pass + (trace 'before Drive') + (call &OptTree-Drive))) + (call &WarmColdFunctions DRIVE) + (call &OptTree-Drive-CleanupColdCalls)) + + + s.Cycles (e.AST) > } +gen_e__ { e.arg = e.arg } + /** == e.OptAST @@ -101,10 +111,11 @@ $ENTRY OptTree-CleanupMarkup { e.AST = - ); + (Function (e.Name) Sentences e.Body) + = (Function (e.Name) Sentences ); t.OtherItem = t.OtherItem; } @@ -169,40 +175,10 @@ ExpandClosures-Sentence { ); } -ExpandClosures-Result { - e.Result = ; -} - -ExpandClosures-ResultTerm { - (Brackets e.Expr) = (Brackets ); - - (ADT-Brackets (e.Name) e.Expr) - = (ADT-Brackets (e.Name) ); - - (CallBrackets (ClosureBrackets e.Content) e.Expr) - = (CallBrackets ); - - (CallBrackets e.Expr) = (CallBrackets ); - - /* - Анализировать холодные вызовы (ColdCallBrackets …) не нужно, - поскольку они были проанализированы на предыдущих проходах - и с тех пор не менялись. - */ - - t.OtherTerm = t.OtherTerm; -} * Интерпретатор императивного кода оптимизаций -* TODO: удалить следующие пометки после оптимизации алгоритма оптимизации! -* Сейчас компиляция в режиме -OADiS для этого файла требует десятки минут. -$SPEC Int-Code e.arg; -$SPEC Int-Command e.arg; -$SPEC Int-LoopForWarmFunctions e.arg; - - Int { e.Defines s.Cycles (e.AST) = e.Defines : (define s.StartPoint e._) e._ @@ -278,7 +254,7 @@ Int-Cond { s.Opt = True; } -$INLINE Int-Cond; +*$xDRIVE Int-Cond Int-Cond-Or { t.Cond e.Flags @@ -306,9 +282,9 @@ Int-LoopForWarmFunctions { (e.Defines) e.Code 0 (e.AST) = 0 e.AST; (e.Defines) e.Code s.Cycles - (e.AST-B (Function s.Scope (e.Name) Sentences e.Sentences) e.AST-E) + (e.AST-B (Function (e.Name) Sentences e.Sentences) e.AST-E) - = e.AST-B (Function s.Scope (e.Name) Sentences e.Sentences) e.AST-E : e.AST + = e.AST-B (Function (e.Name) Sentences e.Sentences) e.AST-E : e.AST = : s.Cycles^ e.AST^ @@ -317,7 +293,7 @@ Int-LoopForWarmFunctions { (e.Defines) e.Code s.Cycles (e.AST) = s.Cycles e.AST; } -$INLINE Int-Lookup; +*$xDRIVE Int-Lookup Int-Lookup { s.ProcName (define s.ProcName e.Body) e._ = e.Body; diff --git a/src/compiler/ParseCmdLine.ref b/src/compiler/ParseCmdLine.ref index 1fcf609b..4515c81c 100644 --- a/src/compiler/ParseCmdLine.ref +++ b/src/compiler/ParseCmdLine.ref @@ -151,7 +151,7 @@ $ENTRY ParseCommandLine { t.Config (e.Errors) &Config-SetCompilerFlags s.Num ' -I"' e.Path '"' > - (SearchFolder s.Num e.Path); + ; (t.Config e.Errors) (TargetFileName s.Num e.FileName) = ; (t.Config e.Errors) (REF5RSL-Env s.Num) - = (t.Config e.Errors) (REF5RSL-Env s.Num); + = (t.Config e.Errors) ; (t.Config e.Errors) (OverwriteExistRasls s.Num) = ; (t.Config e.Errors) t.Option - = (t.Config e.Errors) t.Option; + = (t.Config e.Errors) ; } ) (&MapAccum { (t.Config e.Errors) (SearchFolder s.Num e.Folder) - = ( e.Errors); + = ( e.Errors>); (t.Config e.Errors) (REF5RSL-Env s.Num) - = ( e.Errors); + = ( e.Errors>); (t.Config e.Errors) (FILE s.Num e.FileName) = (t.Config e.Errors) (s.Num e.FileName); } ) { - (t.Config /* нет ошибок */) e.FileNames = - Success t.Config e.FileNames; - - (t.Config e.Errors) e.FileNames = - Fails - ; + (t.Config /* нет ошибок */) e.FileNames + = Success t.Config e.FileNames; + + (t.Config e.Errors) e.FileNames + = Fails + ; } > >; } +gen_e__ { e.arg = e.arg } + Update { t.Config (e.Errors) s.Updater s.LineNum e.Option = @@ -386,12 +390,16 @@ PrintHelp { ' screening sentences (disabled by default)\n' ' -Wnul-in-compound, -Wno-... - check/don\'t nuls in compounds\n' ' (enabled by default)\n' +' -W pseudocomment, -Wno-... - check/don\'t pseudocomment\n' +' correctness (enabled by default)\n' ' -Wpseudofunctions, -Wno-... - check/don\'t pseudofunction\n' ' correctness (enabled by default)\n' ' -Wrepeated, -Wno-... - check/don\'t suspicious repeated variables\n' ' (enabled by default)\n' ' -Wdeprecated, -Wno-... - warn/don\'t about deprecated syntax\n' ' (enabled by default)\n' +' -Wintrinsic, -Wno-... - warn/don\'t about illegal $INTRINSICs\n' +' (enabled by default)\n' ' -Werror[=...], -Wno-error[=...] - treat/don\'t all or only provided\n' ' warning(s) as error(s)\n' '-p, --prefix prefix-name\n' diff --git a/src/compiler/R5-Lexer.ref b/src/compiler/R5-Lexer.ref index 09a85c75..89077ac6 100644 --- a/src/compiler/R5-Lexer.ref +++ b/src/compiler/R5-Lexer.ref @@ -48,22 +48,6 @@ CheckClassicTokens { s.Mode (TkRefal5Mode t.Pos s.NewMode) e.Tokens = (TkRefal5Mode t.Pos s.NewMode) ; - Extended (TkPseudoComment t.Pos e.CommentTokens) e.Tokens - = - : (e.Messages) e.CommentTokens^ - = (TkPseudoComment t.Pos e.CommentTokens) - e.Messages - ; - Extended t.NextToken e.Tokens = t.NextToken ; @@ -88,13 +72,6 @@ CheckClassicTokens { = e.MaybeError (TkVariable t.Pos s.Mode e.Index) ; - Classic (TkPseudoComment t.Pos e.CommentTokens) e.Tokens - = (TkWarning - t.Pos ignored-pseudocomments - 'Pseudocomments are ignored in classic mode' - ) - ; - Classic t.NextToken e.Tokens = t.NextToken ; @@ -111,6 +88,8 @@ IncLine { (RowCol s.Line s.Col) = (RowCol 1); } +*$xDRIVE IncCol + IncCol { (RowCol s.Line s.Col) = (RowCol s.Line ); @@ -119,6 +98,8 @@ IncCol { = (RowCol s.Line <+ s.Col s.Len>); } +*$NOOPT DoScan + DoScan { t.Pos = (TkEOF t.Pos); @@ -158,17 +139,17 @@ DoScan { 1) e.Lines>; (RowCol s.Line 1) ('*$' e.Comment) e.Lines - , + = : { - True + 'Lu' e.Comment^ = : (e.CommentLines) e.Lines^ - = (' $' e.Comment) e.CommentLines : e.CommentLines^ + = (' ' e.Comment) e.CommentLines : e.CommentLines^ = : s.Count e.CommentLines^ = : e.CommentTokens = (TkPseudoComment (RowCol s.Line 1) e.CommentTokens) 1) e.Lines>; - False = 1) e.Lines>; + e._ = 1) e.Lines>; }; (RowCol s.Line 1) ('*' e.Comment) e.Lines @@ -192,7 +173,8 @@ DoScan { t.Pos ('\'' e.Line) e.Lines = (e.Line) e.Lines>; - t.Pos ('/*' e.Line) e.Lines = ; + t.Pos ('/*' e.Line) e.Lines + = ; t.Pos ('\"' e.Line) e.Lines = () (e.Line) e.Lines>; @@ -271,18 +253,22 @@ DoScan-BuildKeyword { , (TkExtern '$EXTERN') (TkExtern '$EXTRN') (TkExtern '$EXTERNAL') (TkEntry '$ENTRY') (TkEnum '$ENUM') (TkEEnum '$EENUM') (TkSwap '$SWAP') (TkESwap '$ESWAP') (TkInclude '$INCLUDE') - (TkLabel '$LABEL') + (TkLabel '$LABEL') (TkScopeId '$SCOPEID') (TkInline '$INLINE') (TkDrive '$DRIVE') (TkSpec '$SPEC') (TkMeta '$META') (TkIntrinsic '$INTRINSIC') : e.Keywords-B (s.Tag e.KeywordChars) e.Keywords-E = (s.Tag t.Pos) - (e.Line) e.Lines>; + (e.Line) e.Lines>; + e._ = /* нет предупреждения */ + } + > + (e.Line) e.Lines>; t.Pos ('$EASTEREGG') (e.Line) e.Lines = @@ -293,6 +279,8 @@ DoScan-BuildKeyword { (e.Line) e.Lines>; } +*$xDRIVE EasterEgg + EasterEgg { t.Pos s.Char e.Text = (TkChar t.Pos s.Char) ; @@ -478,6 +466,8 @@ HexDigit { }; } +*$xDRIVE DoHexDigit + DoHexDigit { s.Digit e.Samples s.Val s.Digit = s.Val; @@ -544,18 +534,6 @@ DoScan-Compound-HandleEscape { e.Lines>; } -ValidPseudocomment { - e.Keyword s.Space e._ - , : True - = ; - - e.Keyword = ; -} - -ValidPseudocomment-Keyword { - e.Keyword = ; -} - CollectPseudocommentLines { e.Lines = ; } diff --git a/src/compiler/R5-Parser.ref b/src/compiler/R5-Parser.ref index c3665404..98aef5e7 100644 --- a/src/compiler/R5-Parser.ref +++ b/src/compiler/R5-Parser.ref @@ -1,3 +1,6 @@ +$INCLUDE "LibraryEx"; + + *$FROM Error $EXTERN EL-AddErrorAt, EL-AddWarningAt; @@ -16,7 +19,7 @@ $EXTERN EL-AddErrorAt, EL-AddWarningAt; t.Include ::= (Include t.Pos e.Name) t.NativeBlock ::= (NativeBlock t.Pos e.Code) t.Ident ::= (Ident t.SrcPos e.Name) - t.SpecUnit = (Spec t.Pos (e.Name) e.Pattern) + t.SpecUnit = (LegacySpec t.Pos (e.Name) e.Pattern) t.Function ::= (Function t.SrcPos s.ScopeClass (e.Name) e.Body) e.Body ::= Sentences t.Sentence* | NativeBody t.Pos e.Code @@ -56,7 +59,106 @@ $ENTRY R5-Parse { */ Program { t.ErrorList s.Mode e.Tokens - = ; + = + : t.ErrorList^ (e.PseudocommentUnits) e.Tokens^ + = + e.PseudocommentUnits +} + +ScanPseudocomments { + t.ErrorList e.Tokens + = +} + +DoScanPseudocomments { + t.ErrorList (e.Units) (e.Scanned) + e.Tokens-B (TkPseudoComment t.Pos e.CommentTokens) e.Tokens-E + = + : t.ErrorList^ e.NewUnits + = ; + + t.ErrorList (e.Units) (e.Scanned) e.Tokens + = t.ErrorList (e.Units) e.Scanned e.Tokens; +} + +ParsePseudocomment { + t.ErrorList t.Pos (TkName t._ e.Name) e.Tokens + , Opt Drive Spec NoOpt NoDrive NoSpec Ident : e._ s.Node e._ + , > : e.Name + = ; + +/* + TODO: Стабильная версия 3.3 по-другому парсит ключевые слова и сообщает + об ошибках в них (не предупреждениях). Поэтому, чтобы можно было собрать + текущую версию и стабильной, и самой собой, для каждого ключевого слова + создаём синоним вида *$xDRIVE или *$xSPEC. Он игнорируется стабильной + версией 3.3 и работает в рабочей. + + TODO: после обновления стабильной версии нужно будет удалить поддержку + псевдокомментариев *$x..., а также почистить исходники. Для этой цели + добавлена заготовка предупреждения. +*/ + t.ErrorList t.Pos (TkName t.NamePos 'x' e.Name) e.Tokens +* = +* : t.ErrorList^ + = ; + + t.ErrorList t.Pos e._unrecognized + = t.ErrorList /* пропускаем неопознанный псевдокомментарий */; +} + +ParseNameListPseudocomment { + t.Pos s.Node (e.Scanned) t.ErrorList + (TkName t.NamePos e.Name) e.Tokens + = ; + + t.Pos s.Node (e.Scanned) t.ErrorList (s.Separator t._) e.Tokens + , TkComma TkSemicolon : e._ s.Separator e._ + = ; + + t.Pos s.Node (/* нет имён */) t.ErrorList (TkEOF t._) + = ; + + t.Pos s.Node (e.Scanned) t.ErrorList (TkEOF t._) = t.ErrorList e.Scanned; + + t.Pos s.Node (e.Scanned) t.ErrorList (TkError t.ErrPos e.Message) e.Tokens + = + e.Tokens + >; + + t.Pos s.Node (e.Scanned) t.ErrorList (TkWarning t.WarnPos s.Type e.Message) + e.Tokens + = + e.Tokens + >; + + t.Pos s.Node (e.Scanned) t.ErrorList t.Unexpected e.Tokens + = t.Unexpected : (s.Type t.TokPos e.Value) + = ', expected name, comma or semicolon' + > + e.Tokens + >; } DoProgram { @@ -88,11 +190,11 @@ UnexpectedUnitToken { UnitStartToken { = TkEntry TkName TkSemicolon TkInclude TkNativeCode TkSpec - TkPseudoComment; } NameListTags { - = TkExtern TkEnum TkEEnum TkSwap TkESwap TkLabel TkInline TkDrive TkMeta TkIntrinsic + = TkExtern TkEnum TkEEnum TkSwap TkESwap TkLabel TkInline TkDrive TkMeta + TkIntrinsic } OneOf { @@ -138,19 +240,6 @@ Unit { , : True = ; - (TkPseudoComment t.Pos e.CommentTokens) - = - : { - t.ErrorList^ (e.Units) (TkEOF t._) - = t.ErrorList (e.Units) e.Tokens; - - t.ErrorList^ (e.Units) (s.Token t.Pos^ e.Info) e._ - = - (/* no units */) e.Tokens; - }; - t.Unexpected = e.Tokens; }; } @@ -207,11 +296,11 @@ TkEntryL { } TkInline { - t.Pos e.Name = (Inline t.Pos GN-Local e.Name) + t.Pos e.Name = (LegacyInline t.Pos GN-Local e.Name) } TkDrive { - t.Pos e.Name = (Drive t.Pos GN-Local e.Name) + t.Pos e.Name = (LegacyDrive t.Pos GN-Local e.Name) } TkMeta { @@ -243,10 +332,9 @@ NameList-DoNames { t.ErrorList (e.Units) e.Tokens; t.ErrorList s.Tag (e.Units) (TkComma t.Pos) e.Tokens - = - s.Tag (e.Units) e.Tokens - >; + = + : t.ErrorList^ + = ; t.ErrorList s.Tag (e.Units) (TkName t.NamePos e.Name) (TkOpenBlock t.BracketPos) e.Tokens @@ -254,19 +342,20 @@ NameList-DoNames { t.ErrorList t.NamePos 'missed semicolon after previous ' ' declaration' > + : t.ErrorList^ + = t.ErrorList (e.Units) (TkName t.NamePos e.Name) (TkOpenBlock t.BracketPos) e.Tokens; t.ErrorList s.Tag (e.Units) (TkName t.Pos e.Name) e.Tokens - = - s.Tag (e.Units) e.Tokens - >; + = + : t.ErrorList^ + = ; t.ErrorList s.Tag (e.Units) t.NextToken e.Tokens , t.NextToken : (s.Type t.Pos e.Value) , : True - = - (e.Units) t.NextToken e.Tokens; + = : t.ErrorList^ + = t.ErrorList (e.Units) t.NextToken e.Tokens; t.ErrorList s.Tag (e.Units) t.NextToken e.Tokens = == t.ErrorList (t.SpecUnit) e.Tokens - t.SpecUnit = (Spec t.Pos (e.Name) e.Pattern) + t.SpecUnit = (LegacySpec t.Pos (e.Name) e.Pattern) */ @@ -315,7 +404,7 @@ Specialization { : t.ErrorList^ (e.Pattern) e.Tokens^ = : t.ErrorList^ e.Tokens^ - = t.ErrorList ((Spec t.Pos (e.Name) e.Pattern)) e.Tokens; + = t.ErrorList ((LegacySpec t.Pos (e.Name) e.Pattern)) e.Tokens; t.ErrorList s.Mode t.Pos t.Unexpected e.Tokens = @@ -366,7 +455,9 @@ Function { = ; t.ErrorList s.Mode (TkEntry t.Pos) e.Tokens - = + = (/* none */) e.Tokens; } @@ -524,18 +615,17 @@ SentenceTail { CheckExceedBlocks { t.ErrorList s.Mode e.ExceedBlocks - = ; + = ; } +*$NOOPT DoCheckExceedBlocks + DoCheckExceedBlocks { s.Mode t.ErrorList (e.ScannedBlocks) (t.Pos e.Body) e.RestBlocks + = + : t.ErrorList^ = - (e.ScannedBlocks (e.Body)) - e.RestBlocks + s.Mode t.ErrorList (e.ScannedBlocks (e.Body)) e.RestBlocks >; s.Mode t.ErrorList (e.ScannedBlocks) /* empty */ @@ -633,10 +723,13 @@ Pattern { Result { t.ErrorList s.Mode e.Tokens = + s.Mode (/* blocks */) + >; } +*$NOOPT Result-Blocks + Result-Blocks { s.Mode (e.Blocks) t.ErrorList t.Result (TkRefal5Mode t.ModePos s.NewMode) e.Tokens @@ -694,11 +787,15 @@ Expression { >; } +*$xDRIVE TokenChain, Expression + TokenChain { t.ErrorList s.Mode s.Kind e.Tokens = } +*$xNOOPT DoTokenChain + DoTokenChain { s.Mode s.Kind t.ErrorList (e.Collected) t.NextToken e.Tokens = t.NextToken @@ -952,6 +1049,7 @@ Expression-CheckBrackets { = t.ErrorList t.Expression e.Tokens; } +*$xDRIVE ClassicError ClassicError { t.ErrorList Classic t.Pos e.Message diff --git a/src/compiler/README.md b/src/compiler/README.md index 57f2747e..da2f67b5 100644 --- a/src/compiler/README.md +++ b/src/compiler/README.md @@ -132,14 +132,15 @@ s.Mode ::= Classic | Extended t.Unit ::= t.Function | t.Extern | t.SingleDeclaration | t.Include - | t.NativeBlock | t.Ident | t.SpecUnit + | t.NativeBlock | t.Markup | t.SpecUnit t.Extern ::= (Declaration t.Pos GN-Entry e.Name) t.SingleDeclaration ::= (s.SingleDeclarationTag t.Pos s.ScopeClass e.Name) - s.SingleDeclarationTag ::= Enum | Swap | Inline | Drive | Meta + s.SingleDeclarationTag ::= Enum | Swap | LegacyInline | LegacyDrive | Meta t.Include ::= (Include t.Pos e.Name) t.NativeBlock ::= (NativeBlock t.Pos e.Code) - t.Ident ::= (Ident t.SrcPos e.Name) - t.SpecUnit ::= (Spec t.Pos (e.Name) e.Pattern) + t.Markup ::= (s.Markup t.SrcPos e.Name) + s.Markup ::= Ident | Opt | Drive | Spec | NoOpt | NoDrive | NoSpec + t.SpecUnit ::= (LegacySpec t.Pos (e.Name) e.Pattern) t.Function ::= (Function t.SrcPos s.ScopeClass (e.Name) e.Body) e.Body ::= @@ -177,7 +178,7 @@ (`(Declaration …)`) всегда имеют область видимости `GN-Extern`. И наоборот, списки `$INLINE` и `$DRIVE` есть только в Рефале-5λ. -Для списков `Inline`, `Drive` и `Meta` тег области видимости всегда +Для списков `LegacyInline`, `LegacyDrive` и `Meta` тег области видимости всегда `GN-Local`, в дерево он добавлен для общности. Подробное описание большинства элементов дерева в проходе 2Б. @@ -319,17 +320,25 @@ e.ReducedAST ::= t.ReducedProgramElement* t.ReducedProgramElement ::= - (Function s.ScopeClass (e.Name) e.ReducedBody) - | (Swap s.ScopeClass e.Name) - | (Declaration s.ScopeClass e.Name) + (s.DeclarationListNode (e.Name)*) + | (Function (e.Name) e.ReducedBody) | (Ident e.Name) | (NativeBlock t.SrcPos e.Code) + s.DeclarationListNode ::= + Entries + | Externs + | Intrinsics + | Drives + | Specs + | NoDrives + | NoSpecs e.ReducedBody ::= Sentences t.ReducedSentence* | NativeBody t.SrcPos e.Code | Metatable e.ReducedMetatable + | Swap t.ReducedSentence ::= ((e.ReducedPattern) t.ReducedCondition* (e.ReducedResult)) t.ReducedCondition ::= @@ -402,18 +411,18 @@ e.RASLAST ::= t.RASLAST-Item* t.RASLAST-Item ::= - (Function s.ScopeClass (e.Name) e.HiCommands) - | (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) + (Entries (e.Name)*) + | (Function (e.Name) e.HiCommands) + | (CmdNativeFunction (e.Name) t.SrcPos e.Code) | t.CmdTopLevelItem t.CmdTopLevelItem ::= - (CmdEnum s.ScopeClass e.Name) - | (CmdSwap s.ScopeClass e.Name) - | (CmdDeclaration s.ScopeClass e.Name) - | (CmdConditionFunc s.ScopeClass e.Name) + (CmdEnum e.Name) + | (CmdSwap e.Name) + | (CmdConditionFunc e.Name) | (CmdDefineIdent e.Name) | (CmdEmitNativeCode t.SrcPos e.Code) - | (CmdMetatable s.ScopeClass (e.Name) e.ReducedMetatable) + | (CmdMetatable (e.Name) e.ReducedMetatable) e.HiCommands ::= t.HiCommand* t.HiCommand ::= @@ -433,7 +442,7 @@ | (CmdInitB0) | (CmdInitB0-Lite) | (CmdSave s.OldOffset s.NewOffset) - | (CmdComment e.Text) + | (CmdComment s.FnText) | (CmdVariableDebugTable s.Mode e.Index s.Depth s.Offset) | (CmdResetAllocator) | (CmdCopyVar s.Mode s.VarOffset s.SampleOffset @@ -492,6 +501,7 @@ s.VarOffset, s.SampleOffset ::= s.Offset s.OldOffset, s.NewOffset ::= s.Offset + == s.CHAR* s.LeftOffset, s.RightOffset ::= s.Offset s.SaveOffset ::= s.Offset s.R-Offset ::= ARG-BEGIN | s.Offset | RIGHT-EDGE @@ -507,7 +517,6 @@ * (`CmdNativeFunction` — функция, написанная на целевом коде), * `CmdEnum` — пустая функция, * `CmdSwap` — статический ящик, - * `CmdDeclaration` — объявление функции, * `CmdConditionFunc` — определение функции-замыкания, * `CmdDefineIdent` — определение идентификатора, * `CmdEmitNativeCode` — кусок целевого кода, выводимый как есть. @@ -522,7 +531,7 @@ * `(CmdOpenELoop s.Direction s.RangeOffset s.VarOffset e.HiCommands)` — цикл по открытой e-переменной. * `s.Direction` — текущая реализация поддерживает только направление - слева-направо, поэтому всегла `AlgLeft`, + слева-направо, поэтому всегда `AlgLeft`, * `s.RangeOffset` — смещение диапазона, внутри которого находится открытой e-переменная, * `s.VarOffset` — смещение для открытой e-переменной, @@ -566,9 +575,10 @@ сохраняют сопоставленный элемент на контексте по смещению `s.Offset`. * `(CmdSave s.OldOffset s.NewOffset)` — копирование границ диапазона `s.OldOffset` в `s.NewOffset`. - * `(CmdComment e.Text)` — соответствует однострочному комментарию - в сгенерированном коде. Содержимое `e.Text` предваряется `// ` - и выписывается в целевой файл без изменений. + * `(CmdComment s.FnText)` — соответствует однострочному комментарию + в сгенерированном коде. Вызывается функция `` без параметров, + результат вызова предваряется `// ` и выписывается в целевой файл + без изменений. * `(CmdVariableDebugTable s.Mode e.Index s.Depth s.Offset)` — формирует запись отладочной таблицы переменных (для интерактивного просмотра значений переменных в отладчике). @@ -612,8 +622,8 @@ должен быть сохранён указатель на этот символ. `CmdVarSave` и `CmdRepeatedSave` используются для сопоставления c t-переменными, при этом они сохраняют начало и конец переменной (отрезка - поля зрения) в смежных ячейках контекста. - с структурной скобкой, сохраняющее указатель на узел в context. + поля зрения) в смежных ячейках контекста со структурной скобкой, + сохраняющее указатель на узел в context. * `(CmdCallSave s.Direction s.Num s.ContextOffset s.Name)` — пропуск скобок конкретизации и имени функции в нулевом диапазоне с сохранением указателей на них в контексте (выполняется после команды `CmdInitB0-Lite`). @@ -689,9 +699,9 @@ e-переменные, распределяемые последователь | (CmdInterpretFuncDescr e.CookiedName s.LabelId) | (CmdSwapDescr e.CookiedName) | (CmdNativeFuncDescr s.ScopeClass e.Name) - | (CmdConditionFuncDescrRasl s.ScopeClass e.Name) - | (CmdConditionFuncDescrNative s.ScopeClass e.Name) - | (CmdMetatable s.ScopeClass (e.Name) e.LowMetatable) + | (CmdConditionFuncDescrRasl e.Name) + | (CmdConditionFuncDescrNative e.Name) + | (CmdMetatable (e.Name) e.LowMetatable) e.CookiedName ::= e.Name Hash s.Cookie1 s.Cookie2 s.Cookie1, s.Cookie2 ::= s.NUMBER @@ -814,7 +824,7 @@ e-переменные, распределяемые последователь * `CmdConditionFuncDescrNative` — дескриптор функции-замыкания для режима прямой кодогенерации, завершает рекурсивное вычисление поля зрения. * `t.NativeDeclarationCommand` — объявление или определение чего-то на C++ - для нативного RASL’а, сюда же входят начало и конец регулярных функций + для нативного RASL’а, сюда же входят начало и конец регулярных функций на C++: * `CmdExtern` — создаёт предобъявление для дескриптора функции, * `CmdDefineIndent` — тот же смысл, что и для высокоуровневых команд; diff --git a/src/compiler/SR-Lexer.sref b/src/compiler/SR-Lexer.sref index cd551f7d..49398aaf 100644 --- a/src/compiler/SR-Lexer.sref +++ b/src/compiler/SR-Lexer.sref @@ -429,721 +429,657 @@ $ENUM TokenError; Native . GEN:END*/ -$SPEC Root (e.acc) e.text; - Root { - (e.Accum) '%' e.Text = ; - (e.Accum) e.Text =
; + (e.Accum) '%' e.Text = ) e.Text>; + (e.Accum) e.Text =
) e.Text>; } -$SPEC StartNative-Percent (e.acc) e.text; - StartNative-Percent { - (e.Accum) '%' e.Text = ; - (e.Accum) e.Text = (TokenError 'Native inlines expects two percents')
; + (e.Accum) '%' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Native inlines expects two percents')
) e.Text>; } -$SPEC Main (e.acc) e.text; - Main { - (e.Accum) ' ' e.Text =
; - (e.Accum) '\t' e.Text =
; - (e.Accum) '\r' e.Text =
; - (e.Accum) '<' e.Text = (#TkPunctuation e.Accum '<')
; - (e.Accum) '>' e.Text = (#TkPunctuation e.Accum '>')
; - (e.Accum) '(' e.Text = (#TkPunctuation e.Accum '(')
; - (e.Accum) ')' e.Text = (#TkPunctuation e.Accum ')')
; - (e.Accum) '{' e.Text = (#TkPunctuation e.Accum '{')
; - (e.Accum) '}' e.Text = (#TkPunctuation e.Accum '}')
; - (e.Accum) '[' e.Text = (#TkPunctuation e.Accum '[')
; - (e.Accum) ']' e.Text = (#TkPunctuation e.Accum ']')
; - (e.Accum) '=' e.Text = (#TkPunctuation e.Accum '=')
; - (e.Accum) ';' e.Text = (#TkPunctuation e.Accum ';')
; - (e.Accum) ':' e.Text = (#TkPunctuation e.Accum ':')
; - (e.Accum) ',' e.Text = (#TkPunctuation e.Accum ',')
; - (e.Accum) '#' e.Text = (#TkPunctuation e.Accum '#')
; - (e.Accum) '^' e.Text = (#TkPunctuation e.Accum '^')
; - (e.Accum) 's' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '_' e.Text = ; - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) '$' e.Text = ; - (e.Accum) '\'' e.Text = ; - (e.Accum) '\"' e.Text = ; - (e.Accum) '/' e.Text = ; - (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n') ; + (e.Accum) ' ' e.Text =
) e.Text>; + (e.Accum) '\t' e.Text =
) e.Text>; + (e.Accum) '\r' e.Text =
) e.Text>; + (e.Accum) '<' e.Text = (#TkPunctuation e.Accum '<')
) e.Text>; + (e.Accum) '>' e.Text = (#TkPunctuation e.Accum '>')
) e.Text>; + (e.Accum) '(' e.Text = (#TkPunctuation e.Accum '(')
) e.Text>; + (e.Accum) ')' e.Text = (#TkPunctuation e.Accum ')')
) e.Text>; + (e.Accum) '{' e.Text = (#TkPunctuation e.Accum '{')
) e.Text>; + (e.Accum) '}' e.Text = (#TkPunctuation e.Accum '}')
) e.Text>; + (e.Accum) '[' e.Text = (#TkPunctuation e.Accum '[')
) e.Text>; + (e.Accum) ']' e.Text = (#TkPunctuation e.Accum ']')
) e.Text>; + (e.Accum) '=' e.Text = (#TkPunctuation e.Accum '=')
) e.Text>; + (e.Accum) ';' e.Text = (#TkPunctuation e.Accum ';')
) e.Text>; + (e.Accum) ':' e.Text = (#TkPunctuation e.Accum ':')
) e.Text>; + (e.Accum) ',' e.Text = (#TkPunctuation e.Accum ',')
) e.Text>; + (e.Accum) '#' e.Text = (#TkPunctuation e.Accum '#')
) e.Text>; + (e.Accum) '^' e.Text = (#TkPunctuation e.Accum '^')
) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '_' e.Text = ) e.Text>; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) '$' e.Text = ) e.Text>; + (e.Accum) '\'' e.Text = ) e.Text>; + (e.Accum) '\"' e.Text = ) e.Text>; + (e.Accum) '/' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n') ) e.Text>; (e.Accum) = (#TkEOF e.Accum); - (e.Accum) s.Any e.Text = (#TkUnexpected e.Accum s.Any)
; + (e.Accum) s.Any e.Text = (#TkUnexpected e.Accum s.Any)
) e.Text>; } -$SPEC StartNative-NewLine (e.acc) e.text; - StartNative-NewLine { - (e.Accum) '\r' e.Text = ; - (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n') ; - (e.Accum) e.Text = (TokenError 'Native inlines expects new line after two percents')
; + (e.Accum) '\r' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n') ) e.Text>; + (e.Accum) e.Text = (TokenError 'Native inlines expects new line after two percents')
) e.Text>; } -$SPEC VariableStart (e.acc) e.text; - VariableStart { - (e.Accum) '.' e.Text = ; - (e.Accum) e.Text = ; + (e.Accum) '.' e.Text = ) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC Name (e.acc) e.text; - Name { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '_' e.Text = ; - (e.Accum) '-' e.Text = ; - (e.Accum) e.Text = (#TkName e.Accum)
; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '_' e.Text = ) e.Text>; + (e.Accum) '-' e.Text = ) e.Text>; + (e.Accum) e.Text = (#TkName e.Accum)
) e.Text>; } -$SPEC Number (e.acc) e.text; - Number { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) e.Text = (#TkNumber e.Accum)
; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) e.Text = (#TkNumber e.Accum)
) e.Text>; } -$SPEC Directive (e.acc) e.text; - Directive { - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) e.Text = (TokenError 'Expected directive name')
; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Expected directive name')
) e.Text>; } -$SPEC StringLiteral-Start (e.acc) e.text; - StringLiteral-Start { - (e.Accum) '\'' e.Text = (#TkLiteral-Char e.Accum '\'')
; - (e.Accum) e.Text = ; + (e.Accum) '\'' e.Text = (#TkLiteral-Char e.Accum '\'')
) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC CompoundSymbol (e.acc) e.text; - CompoundSymbol { - (e.Accum) '\"' e.Text = (#TkCompound e.Accum '\"')
; - (e.Accum) '\\' e.Text = ; - (e.Accum) '\n' e.Text = (TokenError 'Unclosed quote')
; + (e.Accum) '\"' e.Text = (#TkCompound e.Accum '\"')
) e.Text>; + (e.Accum) '\\' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (TokenError 'Unclosed quote')
) e.Text>; (e.Accum) = (TokenError 'Unexpected EOF in compound symbol'); - (e.Accum) s.Any e.Text = ; + (e.Accum) s.Any e.Text = ) e.Text>; } -$SPEC StartComment (e.acc) e.text; - StartComment { - (e.Accum) '*' e.Text = ; - (e.Accum) '/' e.Text = ; - (e.Accum) e.Text = (#TkUnexpected e.Accum)
; + (e.Accum) '*' e.Text = ) e.Text>; + (e.Accum) '/' e.Text = ) e.Text>; + (e.Accum) e.Text = (#TkUnexpected e.Accum)
) e.Text>; } -$SPEC Native-Begin (e.acc) e.text; - Native-Begin { - (e.Accum) '%' e.Text = ; - (e.Accum) e.Text = ; + (e.Accum) '%' e.Text = ) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC VariableIndex (e.acc) e.text; - VariableIndex { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '_' e.Text = ; - (e.Accum) '-' e.Text = ; - (e.Accum) e.Text = (TokenError 'Expected variable name')
; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '_' e.Text = ) e.Text>; + (e.Accum) '-' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Expected variable name')
) e.Text>; } -$SPEC DirectiveTail (e.acc) e.text; - DirectiveTail { - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) e.Text = (#TkDirective e.Accum)
; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) e.Text = (#TkDirective e.Accum)
) e.Text>; } -$SPEC StringLiteral (e.acc) e.text; - StringLiteral { - (e.Accum) '\\' e.Text = ; - (e.Accum) '\'' e.Text = ; - (e.Accum) '\n' e.Text = (TokenError 'Unclosed quote')
; + (e.Accum) '\\' e.Text = ) e.Text>; + (e.Accum) '\'' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (TokenError 'Unclosed quote')
) e.Text>; (e.Accum) = (TokenError 'Unexpected EOF in string literal'); - (e.Accum) s.Any e.Text = (#TkLiteral-Char e.Accum s.Any) ; + (e.Accum) s.Any e.Text = (#TkLiteral-Char e.Accum s.Any) ) e.Text>; } -$SPEC Compound-Escape (e.acc) e.text; - Compound-Escape { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) '\\' e.Text = ; - (e.Accum) '\'' e.Text = ; - (e.Accum) '\"' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) '\n' e.Text = (TokenError 'Unclosed quote')
; - (e.Accum) e.Text = (TokenError 'Unexpected escape sequence') ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) '\\' e.Text = ) e.Text>; + (e.Accum) '\'' e.Text = ) e.Text>; + (e.Accum) '\"' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (TokenError 'Unclosed quote')
) e.Text>; + (e.Accum) e.Text = (TokenError 'Unexpected escape sequence') ) e.Text>; } -$SPEC CComment (e.acc) e.text; - CComment { - (e.Accum) '/' e.Text = ; - (e.Accum) '*' e.Text = ; - (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n') ; - (e.Accum) s.Any e.Text = ; - (e.Accum) e.Text = (TokenError 'Unexpected EOF: unclosed comment')
; + (e.Accum) '/' e.Text = ) e.Text>; + (e.Accum) '*' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n') ) e.Text>; + (e.Accum) s.Any e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Unexpected EOF: unclosed comment')
) e.Text>; } -$SPEC CppComment (e.acc) e.text; - CppComment { - (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n') ; + (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n') ) e.Text>; (e.Accum) = (#TkEOF e.Accum); - (e.Accum) s.Any e.Text = ; + (e.Accum) s.Any e.Text = ) e.Text>; } -$SPEC Native-CheckEnd (e.acc) e.text; - Native-CheckEnd { - (e.Accum) '%' e.Text = ; - (e.Accum) e.Text = ; + (e.Accum) '%' e.Text = ) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC Native (e.acc) e.text; - Native { - (e.Accum) '\n' e.Text = (#TkNativeLine e.Accum '\n') ; - (e.Accum) s.Any e.Text = ; - (e.Accum) e.Text = (TokenError 'Unexpected EOF: unclosed native insertion')
; + (e.Accum) '\n' e.Text = (#TkNativeLine e.Accum '\n') ) e.Text>; + (e.Accum) s.Any e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Unexpected EOF: unclosed native insertion')
) e.Text>; } -$SPEC VariableIndexTail (e.acc) e.text; - VariableIndexTail { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '_' e.Text = ; - (e.Accum) '-' e.Text = ; - (e.Accum) e.Text = (#TkVariable e.Accum)
; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '_' e.Text = ) e.Text>; + (e.Accum) '-' e.Text = ) e.Text>; + (e.Accum) e.Text = (#TkVariable e.Accum)
) e.Text>; } -$SPEC StringLiteral-Escape (e.acc) e.text; - StringLiteral-Escape { - (e.Accum) 'n' e.Text = (#TkLiteral-NewLine e.Accum 'n') ; - (e.Accum) 'r' e.Text = (#TkLiteral-CarriageReturn e.Accum 'r') ; - (e.Accum) 't' e.Text = (#TkLiteral-Tab e.Accum 't') ; - (e.Accum) 'a' e.Text = (#TkLiteral-Bell e.Accum 'a') ; - (e.Accum) 'b' e.Text = (#TkLiteral-BS e.Accum 'b') ; - (e.Accum) 'f' e.Text = (#TkLiteral-FF e.Accum 'f') ; - (e.Accum) 'v' e.Text = (#TkLiteral-VT e.Accum 'v') ; - (e.Accum) '\\' e.Text = (#TkLiteral-Char e.Accum '\\') ; - (e.Accum) '\'' e.Text = (#TkLiteral-Char e.Accum '\'') ; - (e.Accum) '\"' e.Text = (#TkLiteral-Char e.Accum '\"') ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) '\n' e.Text = (TokenError 'Unclosed quote')
; - (e.Accum) e.Text = (TokenError 'Unexpected escape sequence') ; + (e.Accum) 'n' e.Text = (#TkLiteral-NewLine e.Accum 'n') ) e.Text>; + (e.Accum) 'r' e.Text = (#TkLiteral-CarriageReturn e.Accum 'r') ) e.Text>; + (e.Accum) 't' e.Text = (#TkLiteral-Tab e.Accum 't') ) e.Text>; + (e.Accum) 'a' e.Text = (#TkLiteral-Bell e.Accum 'a') ) e.Text>; + (e.Accum) 'b' e.Text = (#TkLiteral-BS e.Accum 'b') ) e.Text>; + (e.Accum) 'f' e.Text = (#TkLiteral-FF e.Accum 'f') ) e.Text>; + (e.Accum) 'v' e.Text = (#TkLiteral-VT e.Accum 'v') ) e.Text>; + (e.Accum) '\\' e.Text = (#TkLiteral-Char e.Accum '\\') ) e.Text>; + (e.Accum) '\'' e.Text = (#TkLiteral-Char e.Accum '\'') ) e.Text>; + (e.Accum) '\"' e.Text = (#TkLiteral-Char e.Accum '\"') ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (TokenError 'Unclosed quote')
) e.Text>; + (e.Accum) e.Text = (TokenError 'Unexpected escape sequence') ) e.Text>; } -$SPEC StringLiteral-Quote (e.acc) e.text; - StringLiteral-Quote { - (e.Accum) '\'' e.Text = (#TkLiteral-Char e.Accum '\'') ; - (e.Accum) e.Text =
; + (e.Accum) '\'' e.Text = (#TkLiteral-Char e.Accum '\'') ) e.Text>; + (e.Accum) e.Text =
) e.Text>; } -$SPEC Compound-Escape-Dec (e.acc) e.text; - Compound-Escape-Dec { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) e.Text = (TokenError 'Expected decimal digit') ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Expected decimal digit') ) e.Text>; } -$SPEC Compound-Escape-Hex (e.acc) e.text; - Compound-Escape-Hex { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) e.Text = (TokenError 'Expected hexadecimal digit') ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Expected hexadecimal digit') ) e.Text>; } -$SPEC CComment-CheckNested (e.acc) e.text; - CComment-CheckNested { - (e.Accum) '*' e.Text = (TokenError 'Nested comments is disabled') ; - (e.Accum) e.Text = ; + (e.Accum) '*' e.Text = (TokenError 'Nested comments is disabled') ) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC CComment-CheckEnd (e.acc) e.text; - CComment-CheckEnd { - (e.Accum) '/' e.Text =
; - (e.Accum) e.Text = ; + (e.Accum) '/' e.Text =
) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC Native-CheckEnd2 (e.acc) e.text; - Native-CheckEnd2 { - (e.Accum) '\r' e.Text = ; - (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n')
; - (e.Accum) e.Text = ; + (e.Accum) '\r' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (#TkNewLine e.Accum '\n')
) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC StringLiteral-Escape-DCode (e.acc) e.text; - StringLiteral-Escape-DCode { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) e.Text = (TokenError 'Expected decimal digit') ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Expected decimal digit') ) e.Text>; } -$SPEC StringLiteral-Escape-OCode (e.acc) e.text; - StringLiteral-Escape-OCode { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) e.Text = (#TkLiteral-OCode e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) e.Text = (#TkLiteral-OCode e.Accum) ) e.Text>; } -$SPEC StringLiteral-Escape-XCode (e.acc) e.text; - StringLiteral-Escape-XCode { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) e.Text = (TokenError 'Expected hexadecimal digit') ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Expected hexadecimal digit') ) e.Text>; } -$SPEC StringLiteral-Escape-DNext (e.acc) e.text; - StringLiteral-Escape-DNext { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) e.Text = (#TkLiteral-Code e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) e.Text = (#TkLiteral-Code e.Accum) ) e.Text>; } -$SPEC StringLiteral-Escape-Xnext (e.acc) e.text; - StringLiteral-Escape-Xnext { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) e.Text = (#TkLiteral-XCode e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) e.Text = (#TkLiteral-XCode e.Accum) ) e.Text>; } + +gen_e__ { e.any = e.any; } diff --git a/src/compiler/SR-Parser.sref b/src/compiler/SR-Parser.sref index 7c1994d8..3297d556 100644 --- a/src/compiler/SR-Parser.sref +++ b/src/compiler/SR-Parser.sref @@ -162,7 +162,7 @@ ParseSpec { : t.ErrorList^ (e.Pattern) e.Tail^ = : t.ErrorList^ e.Tail^ - = ((#Spec s.LnNum (e.Name) e.Pattern)) t.ErrorList e.Tail; + = ((#LegacySpec s.LnNum (e.Name) e.Pattern)) t.ErrorList e.Tail; t.ErrorList t.Unexpected e.Tail = (/* ничего не генерируем */) @@ -408,11 +408,22 @@ ParseSentencePart { ParsePattern { t.ErrorList e.Tokens = ) () + e.Tokens >; } +gen_e__ { e.arg = e.arg; } + DoParsePattern { + t.ErrorList (e.MultiBracket) (e.Scanned) e.Tokens + = ) () e.Tokens + >; +} + +DoParsePattern-GEN { // Обработка литералов атомов t.ErrorList (e.MultiBrackets) (e.Scanned) (#TkChar s.LnNum s.Char) e.Tail = @@ -612,7 +623,9 @@ StrFromBracket { ParseResult { t.ErrorList e.Tokens = ) () + e.Tokens > : t.ErrorList^ (e.Result) e.Tail = : t.ErrorList^ (e.Blocks) e.Tail^ @@ -632,6 +645,13 @@ ParseBlocks { */ DoParseResult { + t.ErrorList (e.MultiBracket) (e.Scanned) e.Tokens + = ) () e.Tokens + >; +} + +DoParseResult-GEN { // Обработка литералов атомов t.ErrorList (e.MultiBracket) (e.Scanned) (#TkChar s.LnNum s.Char) e.Tail = diff --git a/src/compiler/TreeUtils.ref b/src/compiler/TreeUtils.ref index 1093a4c1..ba931707 100644 --- a/src/compiler/TreeUtils.ref +++ b/src/compiler/TreeUtils.ref @@ -35,6 +35,9 @@ $ENTRY ExtractVariables-Expr { (Var s.VarType e.Index) e.Terms = (s.VarType e.Index) ; + (WhVar s.VarType e.Index) e.Terms + = (s.VarType e.Index) ; + (Brackets e.Inner) e.Terms = ; (ADT-Brackets (e.Name) e.Inner) e.Terms = ; @@ -54,6 +57,8 @@ $ENTRY ExtractVariables-Expr { e.Variable ::= s.Mode e.Index */ $ENTRY NewVarName { + (e.Vars) s.Mode /* нет индекса */ = ; + (e.Vars-B (e.Variable) e.Vars-E) e.Variable = ; @@ -77,7 +82,7 @@ DoNewVarName { IncName { e.Name s.Digit, '0123456789' : e._B s.Digit s.Next e._E = e.Name s.Next; e.Name '9' = '0'; - e.Name = e.Name '0'; + e.Name = e.Name '1'; } @@ -114,25 +119,6 @@ $ENTRY CreateContext { >; } -/** - == e.Expression -*/ -$ENTRY CreateSpecPatternForContext { - e.Context - = - (Var 'edyn') -} - /** == e.Name @@ -169,3 +155,259 @@ HashName-Suffix { /* empty */ = /* empty */; } + +/** + == HardPattern | LPattern | Pattern | Result | ActiveResut +*/ +$ENTRY ExprType { + e.Expr + = + : { + e._ CallBrackets e._ = ActiveResut; + e._ ClosureBrackets e._ = Result; + e._ OpenE e._ = Pattern; + e._ ('e' e.Index) e._ ('e' e.Index) e._ = Pattern; + e._ ('t' e.Index) e._ ('t' e.Index) e._ = Pattern; + e._ ('s' e.Index) e._ ('s' e.Index) e._ = LPattern; + e._ = HardPattern; + } +} + +/* + == t.ExprType* + t.ExprType ::= OpenE | (s.Mode e.Index) | Forbidden +*/ +ExprType-Rec { + e.Begin (Var 'e' e._) e.Middle (Var 'e' e._) e.End + = OpenE ; + + e.Expr + = ; + (ADT-Brackets (e._) e.InBrackets) = ; + + (ClosureBrackets e._) = ClosureBrackets; + + (CallBrackets e._) = CallBrackets; + (ColdCallBrackets e._) = CallBrackets; + + t.Other = /* пропускаем */; + } + e.Expr + >; +} + +/* + == True | False + == True | False + == True | False +*/ +$ENTRY IsLExpr { + e.Expr + = + : { + HardPattern = True; + LPattern = True; + s._ = False; + } +} + +$ENTRY IsHardExpr { + e.Expr + = + : { + HardPattern = True; + s._ = False; + } +} + +$ENTRY IsPassiveExpr { + e.Expr + = + : { + ActiveResut = False; + s._ = True; + } +} + +/** + == e.Expr +*/ +$ENTRY ExpandClosures-Result { + e.Result = ; +} + +ExpandClosures-ResultTerm { + (Brackets e.Expr) = (Brackets ); + + (ADT-Brackets (e.Name) e.Expr) + = (ADT-Brackets (e.Name) ); + + (CallBrackets (ClosureBrackets e.Content) e.Expr) + = (CallBrackets ); + + (CallBrackets e.Expr) = (CallBrackets ); + + /* + Анализировать холодные вызовы (ColdCallBrackets …) не нужно, + поскольку они были проанализированы на предыдущих проходах + и с тех пор не менялись. + */ + + t.OtherTerm = t.OtherTerm; +} + +/** + : (e._) e.Expr^ + = e.Expr; +} + +ApplyContractions-Expr { + (e.Contrs) e.Expr = ; +} + +ApplyContractions-Term { + (e.Contrs) ('{'s.Coord'}') = (e.Contrs) ('{'s.Coord'}'); + + (e.Contrs) (Symbol e.Symbol) = (e.Contrs) (Symbol e.Symbol); + + (e.Contrs) (Brackets e.Expr) + = : (e.Contrs^) e.Expr^ + = (e.Contrs) (Brackets e.Expr); + + (e.B ((Var e.Var) ':' e.Contr) e.E) (Var e.Var) + = : (e.E^) e.Expr + = (e.B ((Var e.Var) ':' e.Contr) e.E) e.Expr; + + (e.Contrs) (Var e.Var) = (e.Contrs) (Var e.Var); + + (e.Contrs) (CallBrackets e.Expr) + = : (e.Contrs^) e.Expr^ + = (e.Contrs) (CallBrackets e.Expr); + + (e.Contrs) (ColdCallBrackets e.OriginArgs) + = + : { +* Содержимое холодных скобок не изменилось, оставляем их холодными + (e.Contrs^) e.OriginArgs = (e.Contrs) (ColdCallBrackets e.OriginArgs); + +* Содержимое обновилось, оттаиваем скобки + (e.Contrs^) e.ChangedArgs = (e.Contrs) (CallBrackets e.ChangedArgs); + }; + + (e.Contrs) (WhVar e.Var) = (e.Contrs) (WhVar e.Var); + (e.Contrs) (ScrVar e.Var) = (e.Contrs) (ScrVar e.Var); + + (e.Contrs) (ClosureBrackets e.Expr) + = : (e.Contrs^) e.Expr^ + = (e.Contrs) (ClosureBrackets e.Expr); + + (e.Contrs) (ADT-Brackets (e.Name) e.Expr) + = : (e.Contrs^) e.Expr^ + = (e.Contrs) (ADT-Brackets (e.Name) e.Expr); +} + +/** + == e.Expr^ +*/ +$ENTRY ApplyAssigns { + e.Expr (e.Assigns) + = + } + e.Expr + > +} + +ApplyAssigns-Term { + (Brackets e.Expr) (e.Assigns) = (Brackets ); + + (CallBrackets e.Args) (e.Assigns) + = (CallBrackets ); + + (ColdCallBrackets e.Args) (e.Assigns) + = (ColdCallBrackets ); + + (ClosureBrackets e.Args) (e.Assigns) + = (ClosureBrackets ); + + (ADT-Brackets (e.Name) e.Expr) (e.Assigns) + = (ADT-Brackets (e.Name) ); + + t.T (e.B (e.Expr ':' t.T) e.E) = e.Expr; + + t.T (e.Assigns) = t.T; +} + +/** + == e.Expr^ +*/ +$ENTRY MarkAllVarsAsWhole { + e.Expr + = ); + + (ADT-Brackets (e.Name) e.Nested) + = (ADT-Brackets (e.Name) ); + + (Var s.Mode e.Index) = (WhVar s.Mode e.Index); + + t.Other = t.Other; + } + e.Expr + > +} + +/** + == e.Expr^ +*/ +$ENTRY UnmarkWholeVars { + e.Expr + = ); + + (ADT-Brackets (e.Name) e.Nested) + = (ADT-Brackets (e.Name) ); + + (WhVar s.Mode e.Index) = (Var s.Mode e.Index); + + t.Other = t.Other; + } + e.Expr + > +} + +*$OPT IsGenFunctionName, IsGenFunctionDecoratedName + +/** + == True | False +*/ +$ENTRY IsGenFunctionName { + 'gen_e__' = True; + 'gen-e__' = True; + e._ = False; +} + +/** + == True | False +*/ +$ENTRY IsGenFunctionDecoratedName { + e.Name SUF '~' s._ = ; + e.Name = ; +} diff --git a/src/compiler/main.ref b/src/compiler/main.ref index aa0815de..ef658080 100644 --- a/src/compiler/main.ref +++ b/src/compiler/main.ref @@ -72,6 +72,8 @@ Main-SwValidCommandLine { = ; } +*$xDRIVE ReportErrors, ReportWarnings, ReportMessages + ReportErrors { t.CommandLineSource t.Config e.Errors = ; @@ -346,13 +348,15 @@ RenameLocations-Aux { = e.NewLocations; } -$INLINE AddNumSuffix; +*$xDRIVE AddNumSuffix AddNumSuffix { 0 e.Output = e.Output; - s.Num e.Output = e.Output '@' ; + s.Num e.Output = e.Output '@' >; } +gen_e__ { e.arg = e.arg } + FindFreeName { s.Num e.Output = : e.NewName @@ -663,8 +667,9 @@ Link-R { Link-WithPrefix { (e.PrefixFileName) t.Config e.Files + = : s.TargetMode = + s.TargetMode { e.IntermediateName = @@ -705,8 +710,9 @@ Link-CppCompile { e.CommandLineSuf^ = ' "' '"'; } : e.CommandLineSuf^ + = : s.TargetMode = + s.TargetMode { e.IntermediateName = >; + = : s.SrcHandle + = : s.DestHandle + = +} + +DoCopyPrefix { + s.SrcHandle s.DestHandle + = + : { + /* пусто */ = ; + e.Bytes + = + ; + } } +*$xDRIVE LinkError + LinkError { t.Config e.Message = diff --git a/src/lexgen/DFA-Lexer.ref b/src/lexgen/DFA-Lexer.ref index 1bfb33bc..76f7221d 100644 --- a/src/lexgen/DFA-Lexer.ref +++ b/src/lexgen/DFA-Lexer.ref @@ -202,438 +202,418 @@ CollectDigits { GEN:END*/ -$SPEC Root (e.acc) e.text; - Root { - (e.Accum) ' ' e.Text = ; - (e.Accum) '\t' e.Text = ; - (e.Accum) '\r' e.Text = ; - (e.Accum) '\n' e.Text = (TNewLine e.Accum '\n') ; - (e.Accum) ':' e.Text = ; - (e.Accum) '!' e.Text = ; - (e.Accum) '\'' e.Text = ; - (e.Accum) '=' e.Text = (TPunctuation e.Accum '=') ; - (e.Accum) '.' e.Text = (TPunctuation e.Accum '.') ; - (e.Accum) '|' e.Text = (TPunctuation e.Accum '|') ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) s.Any e.Text = (TUnexpectedChar e.Accum s.Any) ; + (e.Accum) ' ' e.Text = ) e.Text>; + (e.Accum) '\t' e.Text = ) e.Text>; + (e.Accum) '\r' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (TNewLine e.Accum '\n') ) e.Text>; + (e.Accum) ':' e.Text = ) e.Text>; + (e.Accum) '!' e.Text = ) e.Text>; + (e.Accum) '\'' e.Text = ) e.Text>; + (e.Accum) '=' e.Text = (TPunctuation e.Accum '=') ) e.Text>; + (e.Accum) '.' e.Text = (TPunctuation e.Accum '.') ) e.Text>; + (e.Accum) '|' e.Text = (TPunctuation e.Accum '|') ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) s.Any e.Text = (TUnexpectedChar e.Accum s.Any) ) e.Text>; (e.Accum) = (TEOF e.Accum); } -$SPEC SetName (e.acc) e.text; - SetName { - (e.Accum) ':' e.Text = (TSetName e.Accum ':') ; - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '-' e.Text = ; - (e.Accum) '_' e.Text = ; + (e.Accum) ':' e.Text = (TSetName e.Accum ':') ) e.Text>; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '-' e.Text = ) e.Text>; + (e.Accum) '_' e.Text = ) e.Text>; (e.Accum) = (TokenError 'expected end of set name, got EOF'); - (e.Accum) e.Text = (TokenError 'expected end of set name') ; + (e.Accum) e.Text = (TokenError 'expected end of set name') ) e.Text>; } -$SPEC Flush (e.acc) e.text; - Flush { - (e.Accum) '-' e.Text = (TFlush e.Accum '-') ; - (e.Accum) '\"' e.Text = ; - (e.Accum) '#' e.Text = ; - (e.Accum) e.Text = ; + (e.Accum) '-' e.Text = (TFlush e.Accum '-') ) e.Text>; + (e.Accum) '\"' e.Text = ) e.Text>; + (e.Accum) '#' e.Text = ) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC Literal (e.acc) e.text; - Literal { - (e.Accum) '\\' e.Text = ; - (e.Accum) '\'' e.Text = ; - (e.Accum) '\n' e.Text = (TokenError 'Unexpected end of line at literal') ; + (e.Accum) '\\' e.Text = ) e.Text>; + (e.Accum) '\'' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (TokenError 'Unexpected end of line at literal') ) e.Text>; (e.Accum) = (TokenError 'Unexpected end of file at literal'); - (e.Accum) s.Any e.Text = ; + (e.Accum) s.Any e.Text = ) e.Text>; } -$SPEC Name (e.acc) e.text; - Name { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '-' e.Text = ; - (e.Accum) '_' e.Text = ; - (e.Accum) e.Text = (TName e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '-' e.Text = ) e.Text>; + (e.Accum) '_' e.Text = ) e.Text>; + (e.Accum) e.Text = (TName e.Accum) ) e.Text>; } -$SPEC ErrorFlush (e.acc) e.text; - ErrorFlush { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '-' e.Text = ; - (e.Accum) '_' e.Text = ; - (e.Accum) ' ' e.Text = ; - (e.Accum) '\t' e.Text = ; - (e.Accum) ',' e.Text = ; - (e.Accum) '.' e.Text = ; - (e.Accum) ':' e.Text = ; - (e.Accum) ';' e.Text = ; - (e.Accum) '(' e.Text = ; - (e.Accum) ')' e.Text = ; - (e.Accum) '{' e.Text = ; - (e.Accum) '}' e.Text = ; - (e.Accum) '[' e.Text = ; - (e.Accum) ']' e.Text = ; - (e.Accum) '*' e.Text = ; - (e.Accum) '&' e.Text = ; - (e.Accum) '!' e.Text = ; - (e.Accum) '@' e.Text = ; - (e.Accum) '#' e.Text = ; - (e.Accum) '$' e.Text = ; - (e.Accum) '%' e.Text = ; - (e.Accum) '^' e.Text = ; - (e.Accum) '=' e.Text = ; - (e.Accum) '/' e.Text = ; - (e.Accum) '\"' e.Text = (TErrorFlush e.Accum '\"') ; - (e.Accum) e.Text = (TokenError 'Expected error text or double quote') ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '-' e.Text = ) e.Text>; + (e.Accum) '_' e.Text = ) e.Text>; + (e.Accum) ' ' e.Text = ) e.Text>; + (e.Accum) '\t' e.Text = ) e.Text>; + (e.Accum) ',' e.Text = ) e.Text>; + (e.Accum) '.' e.Text = ) e.Text>; + (e.Accum) ':' e.Text = ) e.Text>; + (e.Accum) ';' e.Text = ) e.Text>; + (e.Accum) '(' e.Text = ) e.Text>; + (e.Accum) ')' e.Text = ) e.Text>; + (e.Accum) '{' e.Text = ) e.Text>; + (e.Accum) '}' e.Text = ) e.Text>; + (e.Accum) '[' e.Text = ) e.Text>; + (e.Accum) ']' e.Text = ) e.Text>; + (e.Accum) '*' e.Text = ) e.Text>; + (e.Accum) '&' e.Text = ) e.Text>; + (e.Accum) '!' e.Text = ) e.Text>; + (e.Accum) '@' e.Text = ) e.Text>; + (e.Accum) '#' e.Text = ) e.Text>; + (e.Accum) '$' e.Text = ) e.Text>; + (e.Accum) '%' e.Text = ) e.Text>; + (e.Accum) '^' e.Text = ) e.Text>; + (e.Accum) '=' e.Text = ) e.Text>; + (e.Accum) '/' e.Text = ) e.Text>; + (e.Accum) '\"' e.Text = (TErrorFlush e.Accum '\"') ) e.Text>; + (e.Accum) e.Text = (TokenError 'Expected error text or double quote') ) e.Text>; } -$SPEC FlushName (e.acc) e.text; - FlushName { - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) e.Text = (TokenError 'Expected flush name') ; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Expected flush name') ) e.Text>; } -$SPEC Literal-Escape (e.acc) e.text; - Literal-Escape { - (e.Accum) 'n' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) '\\' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) '\'' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) e.Text = (TokenError 'Unexpected escaped character') ; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) '\\' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) '\'' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) e.Text = (TokenError 'Unexpected escaped character') ) e.Text>; } -$SPEC Literal-Quote (e.acc) e.text; - Literal-Quote { - (e.Accum) '\'' e.Text = ; - (e.Accum) e.Text = (TLiteral e.Accum) ; + (e.Accum) '\'' e.Text = ) e.Text>; + (e.Accum) e.Text = (TLiteral e.Accum) ) e.Text>; } -$SPEC FlushNameTail (e.acc) e.text; - FlushNameTail { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '-' e.Text = ; - (e.Accum) '_' e.Text = ; - (e.Accum) e.Text = (TNamedFlush e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '-' e.Text = ) e.Text>; + (e.Accum) '_' e.Text = ) e.Text>; + (e.Accum) e.Text = (TNamedFlush e.Accum) ) e.Text>; } -$SPEC Literal-DecCode (e.acc) e.text; - Literal-DecCode { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; (e.Accum) = (TokenError 'Unexpected end of file'); - (e.Accum) e.Text = (TokenError 'Expected digits') ; + (e.Accum) e.Text = (TokenError 'Expected digits') ) e.Text>; } + +gen_e__ { e.any = e.any; } diff --git a/src/lexgen/Flex-Lexer.ref b/src/lexgen/Flex-Lexer.ref index 2bd20abc..aa980bde 100644 --- a/src/lexgen/Flex-Lexer.ref +++ b/src/lexgen/Flex-Lexer.ref @@ -266,458 +266,424 @@ DigitFromChar { GEN:END*/ -$SPEC Root (e.acc) e.text; - Root { - (e.Accum) ' ' e.Text = ; - (e.Accum) '\t' e.Text = ; - (e.Accum) '\r' e.Text = ; - (e.Accum) '\n' e.Text = (TNewLine e.Accum '\n') ; - (e.Accum) '/' e.Text = (TStartRegexp e.Accum '/') ; - (e.Accum) '-' e.Text = ; - (e.Accum) '=' e.Text = (TEquals e.Accum '=') ; - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '<' e.Text = (TStateStart e.Accum '<') ; - (e.Accum) ',' e.Text = (TComma e.Accum ',') ; - (e.Accum) '>' e.Text = (TStateEnd e.Accum '>') ; - (e.Accum) '\"' e.Text = ; - (e.Accum) s.Any e.Text = (TUnexpecteChar e.Accum s.Any) ; + (e.Accum) ' ' e.Text = ) e.Text>; + (e.Accum) '\t' e.Text = ) e.Text>; + (e.Accum) '\r' e.Text = ) e.Text>; + (e.Accum) '\n' e.Text = (TNewLine e.Accum '\n') ) e.Text>; + (e.Accum) '/' e.Text = (TStartRegexp e.Accum '/') ) e.Text>; + (e.Accum) '-' e.Text = ) e.Text>; + (e.Accum) '=' e.Text = (TEquals e.Accum '=') ) e.Text>; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '<' e.Text = (TStateStart e.Accum '<') ) e.Text>; + (e.Accum) ',' e.Text = (TComma e.Accum ',') ) e.Text>; + (e.Accum) '>' e.Text = (TStateEnd e.Accum '>') ) e.Text>; + (e.Accum) '\"' e.Text = ) e.Text>; + (e.Accum) s.Any e.Text = (TUnexpecteChar e.Accum s.Any) ) e.Text>; (e.Accum) = (TEOF e.Accum); } -$SPEC ReadRegexp (e.acc) e.text; - ReadRegexp { - (e.Accum) '/' e.Text = (TEndRegexp e.Accum '/') ; - (e.Accum) '\n' e.Text = (TNewLine e.Accum '\n') ; - (e.Accum) '\\' e.Text = ; - (e.Accum) '[' e.Text = (TStartGroup e.Accum '[') ; - (e.Accum) '?' e.Text = (TQuantifier e.Accum '?') ; - (e.Accum) '*' e.Text = (TQuantifier e.Accum '*') ; - (e.Accum) '+' e.Text = (TQuantifier e.Accum '+') ; - (e.Accum) '.' e.Text = (TSpecChar e.Accum '.') ; - (e.Accum) '(' e.Text = (TSpecChar e.Accum '(') ; - (e.Accum) ')' e.Text = (TSpecChar e.Accum ')') ; - (e.Accum) '|' e.Text = (TSpecChar e.Accum '|') ; - (e.Accum) '^' e.Text = (TSpecChar e.Accum '^') ; - (e.Accum) '$' e.Text = (TSpecChar e.Accum '$') ; - (e.Accum) '{' e.Text = ; - (e.Accum) s.Any e.Text = (TChar e.Accum s.Any) ; + (e.Accum) '/' e.Text = (TEndRegexp e.Accum '/') ) e.Text>; + (e.Accum) '\n' e.Text = (TNewLine e.Accum '\n') ) e.Text>; + (e.Accum) '\\' e.Text = ) e.Text>; + (e.Accum) '[' e.Text = (TStartGroup e.Accum '[') ) e.Text>; + (e.Accum) '?' e.Text = (TQuantifier e.Accum '?') ) e.Text>; + (e.Accum) '*' e.Text = (TQuantifier e.Accum '*') ) e.Text>; + (e.Accum) '+' e.Text = (TQuantifier e.Accum '+') ) e.Text>; + (e.Accum) '.' e.Text = (TSpecChar e.Accum '.') ) e.Text>; + (e.Accum) '(' e.Text = (TSpecChar e.Accum '(') ) e.Text>; + (e.Accum) ')' e.Text = (TSpecChar e.Accum ')') ) e.Text>; + (e.Accum) '|' e.Text = (TSpecChar e.Accum '|') ) e.Text>; + (e.Accum) '^' e.Text = (TSpecChar e.Accum '^') ) e.Text>; + (e.Accum) '$' e.Text = (TSpecChar e.Accum '$') ) e.Text>; + (e.Accum) '{' e.Text = ) e.Text>; + (e.Accum) s.Any e.Text = (TChar e.Accum s.Any) ) e.Text>; (e.Accum) = (TokenError 'Unexpected EOF in Regexp'); } -$SPEC ReadArrow (e.acc) e.text; - ReadArrow { - (e.Accum) '>' e.Text = (TArrow e.Accum '>') ; - (e.Accum) e.Text = (TSkip e.Accum) ; + (e.Accum) '>' e.Text = (TArrow e.Accum '>') ) e.Text>; + (e.Accum) e.Text = (TSkip e.Accum) ) e.Text>; } -$SPEC Number (e.acc) e.text; - Number { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) e.Text = (TkNumber e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) e.Text = (TkNumber e.Accum) ) e.Text>; } -$SPEC Name (e.acc) e.text; - Name { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) e.Text = (TName e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) e.Text = (TName e.Accum) ) e.Text>; } -$SPEC ErrorMessage (e.acc) e.text; - ErrorMessage { - (e.Accum) '\"' e.Text = (TErrorMessage e.Accum '\"') ; - (e.Accum) s.Any e.Text = ; + (e.Accum) '\"' e.Text = (TErrorMessage e.Accum '\"') ) e.Text>; + (e.Accum) s.Any e.Text = ) e.Text>; (e.Accum) = (TokenError 'Unclosed error message'); } -$SPEC EscRegexp (e.acc) e.text; - EscRegexp { - (e.Accum) '\\' e.Text = (TGenericEscChar e.Accum '\\') ; - (e.Accum) 'n' e.Text = (TGenericEscChar e.Accum 'n') ; - (e.Accum) 't' e.Text = (TGenericEscChar e.Accum 't') ; - (e.Accum) 'r' e.Text = (TGenericEscChar e.Accum 'r') ; - (e.Accum) '/' e.Text = (TChar e.Accum '/') ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '.' e.Text = (TChar e.Accum '.') ; - (e.Accum) '(' e.Text = (TChar e.Accum '(') ; - (e.Accum) ')' e.Text = (TChar e.Accum ')') ; - (e.Accum) '|' e.Text = (TChar e.Accum '|') ; - (e.Accum) '^' e.Text = (TChar e.Accum '^') ; - (e.Accum) '$' e.Text = (TChar e.Accum '$') ; - (e.Accum) s.Any e.Text = (TokenError 'Bad escaped symbol') ; + (e.Accum) '\\' e.Text = (TGenericEscChar e.Accum '\\') ) e.Text>; + (e.Accum) 'n' e.Text = (TGenericEscChar e.Accum 'n') ) e.Text>; + (e.Accum) 't' e.Text = (TGenericEscChar e.Accum 't') ) e.Text>; + (e.Accum) 'r' e.Text = (TGenericEscChar e.Accum 'r') ) e.Text>; + (e.Accum) '/' e.Text = (TChar e.Accum '/') ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '.' e.Text = (TChar e.Accum '.') ) e.Text>; + (e.Accum) '(' e.Text = (TChar e.Accum '(') ) e.Text>; + (e.Accum) ')' e.Text = (TChar e.Accum ')') ) e.Text>; + (e.Accum) '|' e.Text = (TChar e.Accum '|') ) e.Text>; + (e.Accum) '^' e.Text = (TChar e.Accum '^') ) e.Text>; + (e.Accum) '$' e.Text = (TChar e.Accum '$') ) e.Text>; + (e.Accum) s.Any e.Text = (TokenError 'Bad escaped symbol') ) e.Text>; (e.Accum) = (TokenError 'Unexpected EOF in Regexp'); } -$SPEC StartGroup (e.acc) e.text; - StartGroup { - (e.Accum) '^' e.Text = (TInvertGroup e.Accum '^') ; - (e.Accum) e.Text = ; + (e.Accum) '^' e.Text = (TInvertGroup e.Accum '^') ) e.Text>; + (e.Accum) e.Text = ) e.Text>; } -$SPEC ReadInclude (e.acc) e.text; - ReadInclude { - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) s.Any e.Text = (TokenError 'Expected Name in Include') ; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) s.Any e.Text = (TokenError 'Expected Name in Include') ) e.Text>; (e.Accum) = (TokenError 'Unexpected EOF in Include'); } -$SPEC EscRegexp-XCode (e.acc) e.text; - EscRegexp-XCode { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) e.Text = (TkHexNumber e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) e.Text = (TkHexNumber e.Accum) ) e.Text>; } -$SPEC EscRegexp-OCode (e.acc) e.text; - EscRegexp-OCode { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) e.Text = (TkOctNumber e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) e.Text = (TkOctNumber e.Accum) ) e.Text>; } -$SPEC ReadGroup (e.acc) e.text; - ReadGroup { - (e.Accum) ']' e.Text = (TEndGroup e.Accum ']') ; - (e.Accum) '-' e.Text = (TGroupRange e.Accum '-') ; - (e.Accum) '\\' e.Text = ; - (e.Accum) s.Any e.Text = (TChar e.Accum s.Any) ; + (e.Accum) ']' e.Text = (TEndGroup e.Accum ']') ) e.Text>; + (e.Accum) '-' e.Text = (TGroupRange e.Accum '-') ) e.Text>; + (e.Accum) '\\' e.Text = ) e.Text>; + (e.Accum) s.Any e.Text = (TChar e.Accum s.Any) ) e.Text>; (e.Accum) = (TokenError 'Unexpected EOF in Regexp'); } -$SPEC ReadBody (e.acc) e.text; - ReadBody { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) 'g' e.Text = ; - (e.Accum) 'h' e.Text = ; - (e.Accum) 'i' e.Text = ; - (e.Accum) 'j' e.Text = ; - (e.Accum) 'k' e.Text = ; - (e.Accum) 'l' e.Text = ; - (e.Accum) 'm' e.Text = ; - (e.Accum) 'n' e.Text = ; - (e.Accum) 'o' e.Text = ; - (e.Accum) 'p' e.Text = ; - (e.Accum) 'q' e.Text = ; - (e.Accum) 'r' e.Text = ; - (e.Accum) 's' e.Text = ; - (e.Accum) 't' e.Text = ; - (e.Accum) 'u' e.Text = ; - (e.Accum) 'v' e.Text = ; - (e.Accum) 'w' e.Text = ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'y' e.Text = ; - (e.Accum) 'z' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'G' e.Text = ; - (e.Accum) 'H' e.Text = ; - (e.Accum) 'I' e.Text = ; - (e.Accum) 'J' e.Text = ; - (e.Accum) 'K' e.Text = ; - (e.Accum) 'L' e.Text = ; - (e.Accum) 'M' e.Text = ; - (e.Accum) 'N' e.Text = ; - (e.Accum) 'O' e.Text = ; - (e.Accum) 'P' e.Text = ; - (e.Accum) 'Q' e.Text = ; - (e.Accum) 'R' e.Text = ; - (e.Accum) 'S' e.Text = ; - (e.Accum) 'T' e.Text = ; - (e.Accum) 'U' e.Text = ; - (e.Accum) 'V' e.Text = ; - (e.Accum) 'W' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) 'Y' e.Text = ; - (e.Accum) 'Z' e.Text = ; - (e.Accum) '}' e.Text = (TInclude e.Accum '}') ; - (e.Accum) e.Text = (TokenError 'Unclused include') ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) 'g' e.Text = ) e.Text>; + (e.Accum) 'h' e.Text = ) e.Text>; + (e.Accum) 'i' e.Text = ) e.Text>; + (e.Accum) 'j' e.Text = ) e.Text>; + (e.Accum) 'k' e.Text = ) e.Text>; + (e.Accum) 'l' e.Text = ) e.Text>; + (e.Accum) 'm' e.Text = ) e.Text>; + (e.Accum) 'n' e.Text = ) e.Text>; + (e.Accum) 'o' e.Text = ) e.Text>; + (e.Accum) 'p' e.Text = ) e.Text>; + (e.Accum) 'q' e.Text = ) e.Text>; + (e.Accum) 'r' e.Text = ) e.Text>; + (e.Accum) 's' e.Text = ) e.Text>; + (e.Accum) 't' e.Text = ) e.Text>; + (e.Accum) 'u' e.Text = ) e.Text>; + (e.Accum) 'v' e.Text = ) e.Text>; + (e.Accum) 'w' e.Text = ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'y' e.Text = ) e.Text>; + (e.Accum) 'z' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'G' e.Text = ) e.Text>; + (e.Accum) 'H' e.Text = ) e.Text>; + (e.Accum) 'I' e.Text = ) e.Text>; + (e.Accum) 'J' e.Text = ) e.Text>; + (e.Accum) 'K' e.Text = ) e.Text>; + (e.Accum) 'L' e.Text = ) e.Text>; + (e.Accum) 'M' e.Text = ) e.Text>; + (e.Accum) 'N' e.Text = ) e.Text>; + (e.Accum) 'O' e.Text = ) e.Text>; + (e.Accum) 'P' e.Text = ) e.Text>; + (e.Accum) 'Q' e.Text = ) e.Text>; + (e.Accum) 'R' e.Text = ) e.Text>; + (e.Accum) 'S' e.Text = ) e.Text>; + (e.Accum) 'T' e.Text = ) e.Text>; + (e.Accum) 'U' e.Text = ) e.Text>; + (e.Accum) 'V' e.Text = ) e.Text>; + (e.Accum) 'W' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) 'Y' e.Text = ) e.Text>; + (e.Accum) 'Z' e.Text = ) e.Text>; + (e.Accum) '}' e.Text = (TInclude e.Accum '}') ) e.Text>; + (e.Accum) e.Text = (TokenError 'Unclused include') ) e.Text>; } -$SPEC EscRegexp-OCode-C1 (e.acc) e.text; - EscRegexp-OCode-C1 { - (e.Accum) '0' e.Text = (TkOctNumber e.Accum '0') ; - (e.Accum) '1' e.Text = (TkOctNumber e.Accum '1') ; - (e.Accum) '2' e.Text = (TkOctNumber e.Accum '2') ; - (e.Accum) '3' e.Text = (TkOctNumber e.Accum '3') ; - (e.Accum) '4' e.Text = (TkOctNumber e.Accum '4') ; - (e.Accum) '5' e.Text = (TkOctNumber e.Accum '5') ; - (e.Accum) '6' e.Text = (TkOctNumber e.Accum '6') ; - (e.Accum) '7' e.Text = (TkOctNumber e.Accum '7') ; - (e.Accum) e.Text = (TkOctNumber e.Accum) ; + (e.Accum) '0' e.Text = (TkOctNumber e.Accum '0') ) e.Text>; + (e.Accum) '1' e.Text = (TkOctNumber e.Accum '1') ) e.Text>; + (e.Accum) '2' e.Text = (TkOctNumber e.Accum '2') ) e.Text>; + (e.Accum) '3' e.Text = (TkOctNumber e.Accum '3') ) e.Text>; + (e.Accum) '4' e.Text = (TkOctNumber e.Accum '4') ) e.Text>; + (e.Accum) '5' e.Text = (TkOctNumber e.Accum '5') ) e.Text>; + (e.Accum) '6' e.Text = (TkOctNumber e.Accum '6') ) e.Text>; + (e.Accum) '7' e.Text = (TkOctNumber e.Accum '7') ) e.Text>; + (e.Accum) e.Text = (TkOctNumber e.Accum) ) e.Text>; } -$SPEC EscGroup (e.acc) e.text; - EscGroup { - (e.Accum) '\\' e.Text = (TGenericEscChar e.Accum '\\') ; - (e.Accum) 'n' e.Text = (TGenericEscChar e.Accum 'n') ; - (e.Accum) 't' e.Text = (TGenericEscChar e.Accum 't') ; - (e.Accum) 'r' e.Text = (TGenericEscChar e.Accum 'r') ; - (e.Accum) ']' e.Text = (TChar e.Accum ']') ; - (e.Accum) '-' e.Text = (TChar e.Accum '-') ; - (e.Accum) 'x' e.Text = ; - (e.Accum) 'X' e.Text = ; - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) s.Any e.Text = (TokenError 'Bad escaped symbol') ; + (e.Accum) '\\' e.Text = (TGenericEscChar e.Accum '\\') ) e.Text>; + (e.Accum) 'n' e.Text = (TGenericEscChar e.Accum 'n') ) e.Text>; + (e.Accum) 't' e.Text = (TGenericEscChar e.Accum 't') ) e.Text>; + (e.Accum) 'r' e.Text = (TGenericEscChar e.Accum 'r') ) e.Text>; + (e.Accum) ']' e.Text = (TChar e.Accum ']') ) e.Text>; + (e.Accum) '-' e.Text = (TChar e.Accum '-') ) e.Text>; + (e.Accum) 'x' e.Text = ) e.Text>; + (e.Accum) 'X' e.Text = ) e.Text>; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) s.Any e.Text = (TokenError 'Bad escaped symbol') ) e.Text>; (e.Accum) = (TokenError 'Unexpected EOF in Regexp'); } -$SPEC EscGroup-XCode (e.acc) e.text; - EscGroup-XCode { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) '8' e.Text = ; - (e.Accum) '9' e.Text = ; - (e.Accum) 'A' e.Text = ; - (e.Accum) 'B' e.Text = ; - (e.Accum) 'C' e.Text = ; - (e.Accum) 'D' e.Text = ; - (e.Accum) 'E' e.Text = ; - (e.Accum) 'F' e.Text = ; - (e.Accum) 'a' e.Text = ; - (e.Accum) 'b' e.Text = ; - (e.Accum) 'c' e.Text = ; - (e.Accum) 'd' e.Text = ; - (e.Accum) 'e' e.Text = ; - (e.Accum) 'f' e.Text = ; - (e.Accum) e.Text = (TkHexNumber e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) '8' e.Text = ) e.Text>; + (e.Accum) '9' e.Text = ) e.Text>; + (e.Accum) 'A' e.Text = ) e.Text>; + (e.Accum) 'B' e.Text = ) e.Text>; + (e.Accum) 'C' e.Text = ) e.Text>; + (e.Accum) 'D' e.Text = ) e.Text>; + (e.Accum) 'E' e.Text = ) e.Text>; + (e.Accum) 'F' e.Text = ) e.Text>; + (e.Accum) 'a' e.Text = ) e.Text>; + (e.Accum) 'b' e.Text = ) e.Text>; + (e.Accum) 'c' e.Text = ) e.Text>; + (e.Accum) 'd' e.Text = ) e.Text>; + (e.Accum) 'e' e.Text = ) e.Text>; + (e.Accum) 'f' e.Text = ) e.Text>; + (e.Accum) e.Text = (TkHexNumber e.Accum) ) e.Text>; } -$SPEC EscGroup-OCode (e.acc) e.text; - EscGroup-OCode { - (e.Accum) '0' e.Text = ; - (e.Accum) '1' e.Text = ; - (e.Accum) '2' e.Text = ; - (e.Accum) '3' e.Text = ; - (e.Accum) '4' e.Text = ; - (e.Accum) '5' e.Text = ; - (e.Accum) '6' e.Text = ; - (e.Accum) '7' e.Text = ; - (e.Accum) e.Text = (TkOctNumber e.Accum) ; + (e.Accum) '0' e.Text = ) e.Text>; + (e.Accum) '1' e.Text = ) e.Text>; + (e.Accum) '2' e.Text = ) e.Text>; + (e.Accum) '3' e.Text = ) e.Text>; + (e.Accum) '4' e.Text = ) e.Text>; + (e.Accum) '5' e.Text = ) e.Text>; + (e.Accum) '6' e.Text = ) e.Text>; + (e.Accum) '7' e.Text = ) e.Text>; + (e.Accum) e.Text = (TkOctNumber e.Accum) ) e.Text>; } -$SPEC EscGroup-OCode-C1 (e.acc) e.text; - EscGroup-OCode-C1 { - (e.Accum) '0' e.Text = (TkOctNumber e.Accum '0') ; - (e.Accum) '1' e.Text = (TkOctNumber e.Accum '1') ; - (e.Accum) '2' e.Text = (TkOctNumber e.Accum '2') ; - (e.Accum) '3' e.Text = (TkOctNumber e.Accum '3') ; - (e.Accum) '4' e.Text = (TkOctNumber e.Accum '4') ; - (e.Accum) '5' e.Text = (TkOctNumber e.Accum '5') ; - (e.Accum) '6' e.Text = (TkOctNumber e.Accum '6') ; - (e.Accum) '7' e.Text = (TkOctNumber e.Accum '7') ; - (e.Accum) e.Text = (TkOctNumber e.Accum) ; + (e.Accum) '0' e.Text = (TkOctNumber e.Accum '0') ) e.Text>; + (e.Accum) '1' e.Text = (TkOctNumber e.Accum '1') ) e.Text>; + (e.Accum) '2' e.Text = (TkOctNumber e.Accum '2') ) e.Text>; + (e.Accum) '3' e.Text = (TkOctNumber e.Accum '3') ) e.Text>; + (e.Accum) '4' e.Text = (TkOctNumber e.Accum '4') ) e.Text>; + (e.Accum) '5' e.Text = (TkOctNumber e.Accum '5') ) e.Text>; + (e.Accum) '6' e.Text = (TkOctNumber e.Accum '6') ) e.Text>; + (e.Accum) '7' e.Text = (TkOctNumber e.Accum '7') ) e.Text>; + (e.Accum) e.Text = (TkOctNumber e.Accum) ) e.Text>; } + +gen_e__ { e.any = e.any; } diff --git a/src/lexgen/Generator.ref b/src/lexgen/Generator.ref index 3eaed79e..87898a64 100644 --- a/src/lexgen/Generator.ref +++ b/src/lexgen/Generator.ref @@ -17,13 +17,13 @@ $EXTERN EscapeChar; */ $ENTRY GenerateFromDFA { e.Rules = - ; + + () + ('gen_e__ { e.any = e.any; }') } WriteFunction { ((e.NextRule) e.Alternatives) = - () - ('$SPEC ' e.NextRule ' (e.acc) e.text;') () (e.NextRule ' {') @@ -74,5 +74,5 @@ NextState-L { NextState-R { Finitive e.NextStateAccum = /* пусто */; (e.NextStateName) e.NextStateAccum = - ' <' e.NextStateName ' (' e.NextStateAccum ') e.Text>'; + ' <' e.NextStateName ' () e.Text>'; } diff --git a/src/lib/Library.ref b/src/lib/Library.ref index 4e8b36f6..24d21b4e 100644 --- a/src/lib/Library.ref +++ b/src/lib/Library.ref @@ -839,7 +839,7 @@ ZeroHandle { s.FileNo s.Default = s.FileNo; } -$LABEL stdin, stdout, stderr, stout; +*$IDENT stdin, stdout, stderr, stout %% namespace { @@ -2542,7 +2542,7 @@ $ENTRY Close { 55. == True | False e.FileName ::= s.CHAR* */ -$LABEL True, False; +*$IDENT True, False $ENTRY ExistFile { %% @@ -3585,7 +3585,7 @@ $ENTRY FTell { s.Sign ::= '+' | '-' s.Offset ::= s.MACRODIGIT */ -$LABEL CURRENT, BEGIN, END; +*$IDENT CURRENT, BEGIN, END $ENTRY FSeek { %% @@ -3706,7 +3706,7 @@ $ENTRY RenameFile { e.Errors ::= пусто TODO: поддержка сообщений об ошибках */ -$LABEL Success, Fails; +*$IDENT Success, Fails $ENTRY Module-Load { %% @@ -3799,7 +3799,7 @@ $ENTRY Module-Unload { s.FunctionName ::= s.COMPOUND e.FunctionName ::= s.CHAR+ */ -$LABEL GLOBAL, CURRENT, CURRENT-AND-GLOBAL; +*$IDENT GLOBAL, CURRENT, CURRENT-AND-GLOBAL %% namespace cookie_ns { diff --git a/src/lib/common/LibraryEx.refi b/src/lib/common/LibraryEx.refi index b931665a..0f6ccb79 100644 --- a/src/lib/common/LibraryEx.refi +++ b/src/lib/common/LibraryEx.refi @@ -15,7 +15,7 @@ Apply { = ; } -$INLINE Apply; +*$OPT Apply /** @@ -29,7 +29,7 @@ Map { t.Fn /* пусто */ = /* пусто */; } -$SPEC Map t.FUNC e.items; +*$OPT Map /** @@ -46,15 +46,14 @@ Reduce { t.Fn t.Acc /* пусто */ = t.Acc; } -$SPEC Reduce t.FUNC t.accum e.items; +*$OPT Reduce Fetch { e.Argument t.Function = ; } -$INLINE Fetch; -$SPEC Fetch e.arg t.FUNC; +*$OPT Fetch /** @@ -64,11 +63,12 @@ $SPEC Fetch e.arg t.FUNC; t.Accum′ ::= t.Accum */ MapAccum { - t.Fn t.Acc e.Tail = ; + t.Fn t.Acc e.Tail = ) e.Tail>; } -$SPEC MapAccum t.FUNC t.accum e.items; -$INLINE MapAccum; +gen-e__ { e.arg = e.arg } + +*$OPT MapAccum DoMapAccum { t.Fn t.Acc (e.Scanned) t.Next e.Tail @@ -80,14 +80,14 @@ DoMapAccum { t.Fn t.Acc (e.Scanned) /* пусто */ = t.Acc e.Scanned; } -$SPEC DoMapAccum t.FUNC t.acc (e.scanned) e.items; +*$OPT DoMapAccum UnBracket { (e.Expr) = e.Expr; } -$DRIVE UnBracket; +*$DRIVE UnBracket /** @@ -97,7 +97,7 @@ DelAccumulator { t.Acc e.Tail = e.Tail; } -$DRIVE DelAccumulator; +*$DRIVE DelAccumulator /** @@ -114,7 +114,7 @@ Dec { e.Num = ; } -$INLINE Inc, Dec; +*$DRIVE Inc, Dec /** @@ -133,7 +133,7 @@ Pipe { /* пусто */ = { e.Arg = e.Arg; }; } -$INLINE Pipe; +*$DRIVE Pipe *$FROM LibraryEx diff --git a/src/lib/common/refal5-builtins.refi b/src/lib/common/refal5-builtins.refi index b548e77a..b66008d9 100644 --- a/src/lib/common/refal5-builtins.refi +++ b/src/lib/common/refal5-builtins.refi @@ -256,7 +256,7 @@ $ENUM Ev-met; $META Residue; __Meta_Residue { e.Arg = <__Step-Drop> <__Meta_Mu e.Arg> } -$INLINE __Meta_Residue; +*$DRIVE __Meta_Residue * 51. GetEnv diff --git a/src/lib/debug/refalrts-debugger.cpp b/src/lib/debug/refalrts-debugger.cpp index 2eaadffa..9f7c68fb 100644 --- a/src/lib/debug/refalrts-debugger.cpp +++ b/src/lib/debug/refalrts-debugger.cpp @@ -659,8 +659,11 @@ std::string refalrts::debugger::RefalDebugger::ask_for_param( printf("param>"); char param[MAX_COMMAND_LEN] = {0}; - fgets(param, MAX_COMMAND_LEN - 1, m_in); - return trim(std::string(param)); + if (fgets(param, MAX_COMMAND_LEN - 1, m_in) != 0) { + return trim(std::string(param)); + } else { + return std::string(); + } } //============================================================================= @@ -1254,7 +1257,9 @@ refalrts::FnResult refalrts::debugger::RefalDebugger::debugger_loop( break; } } else { - fgets(command, MAX_COMMAND_LEN - 1, m_in); + if (fgets(command, MAX_COMMAND_LEN - 1, m_in) == 0) { + memcpy(command, s_QUIT, strlen(s_QUIT)); + } } std::pair cmdAndError = parse_input_line( std::string(command)); diff --git a/src/lib/make.bat b/src/lib/make.bat index 9d5a76b7..837724ce 100644 --- a/src/lib/make.bat +++ b/src/lib/make.bat @@ -29,7 +29,7 @@ setlocal for %%s in (%LIBS%) do ( ..\..\bin\rlc-core -C %RLC_FLAGS% %%s -d common ^ - --prelude=refal5-builtins.refi || exit /b 1 + --prelude=refal5-builtins.refi -Wno-intrinsic || exit /b 1 ..\..\bin\rlc-core --no-sources -R -o inco.bin ^ --incorporated=%%~ns || exit /b 1 find "//FROM" < %%s.ref > %TARGET%\%%s.rasl.froms @@ -103,7 +103,7 @@ setlocal pushd tmp for %%l in (%LIBRARIES%) do ( copy ..\%%l.ref . - call ..\..\..\bin\rlmake --scratch --makelib ^ + call ..\..\..\bin\rlmake --scratch --makelib -X-Wno-intrinsic ^ -o ..\..\..\lib\%%l.dll %%l.ref || exit /b 1 erase %%l.ref ) diff --git a/src/lib/make.sh b/src/lib/make.sh index 8d1336dc..c86d510a 100755 --- a/src/lib/make.sh +++ b/src/lib/make.sh @@ -12,7 +12,7 @@ compile_separated() { for s in ${LIBS}; do # shellcheck disable=SC2086 ../../bin/rlc-core -C ${RLC_FLAGS} "$s" -d common \ - --prelude=refal5-builtins.refi || exit 1 + --prelude=refal5-builtins.refi -Wno-intrinsic || exit 1 ../../bin/rlc-core --no-sources -R -o inco.bin \ --incorporated="$s" || exit 1 grep '//FROM' < "$s".ref > "$TARGET/$s".rasl.froms @@ -78,7 +78,7 @@ compile_dynamic() { ( cd tmp && for l in ${LIBRARIES}; do cp ../"$l".ref . - ../../../bin/rlmake --scratch --makelib \ + ../../../bin/rlmake --scratch --makelib -X-Wno-intrinsic \ -o ../../../lib/"$l$(platform_lib_suffix)" "$l".ref || exit 1 rm -- "$l".ref done diff --git a/src/lib/refalrts-vm.cpp b/src/lib/refalrts-vm.cpp index 27c0cd0f..a6abb4ed 100644 --- a/src/lib/refalrts-vm.cpp +++ b/src/lib/refalrts-vm.cpp @@ -225,6 +225,11 @@ void print_indent(FILE *output, int level) { putc('!', output); return; } + + if (level > 80) { + level = 80; + } + for (int i = 0; i < level; ++i) { // Каждые cPERIOD позиций вместо пробела ставим точку. bool put_marker = ((i % cPERIOD) == (cPERIOD - 1));