From edd0579ef10f0bba9c433db23464a6418f1eee0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=B7=D0=B4=D0=B0=D0=B9=D1=89=D0=B8=D0=BA?= Date: Sun, 22 Aug 2021 21:41:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=81=D0=B5=D0=B2=D0=B4=D0=BE=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D0=B8=20?= =?UTF-8?q?\*\$(NO-)=3F(OPT|DRIVE|SPEC)=20(#195,=20#314)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit После псевдокомментария может следовать любое количество имён, запятых и точек с запятой (знаки пунктуации игнорируются), имя должно быть как минимум одно. --- autotests/opt-tree-no-drive.ref | 19 ++++ autotests/opt-tree-no-opt-misplaced.ref | 15 +++ autotests/opt-tree-no-opt.ref | 15 +++ autotests/opt-tree-no-spec.ref | 16 +++ ...udocomments-error-misplaced.BAD-SYNTAX.ref | 12 --- autotests/pseudocomments-ok-multiline.ref | 2 + autotests/pseudocomments-ok.ref | 4 +- ...seudocomments-warning-classic.WARNING.ref} | 2 +- ...seudocomments-warning-conflict.WARNING.ref | 6 ++ ...seudocomments-warning-dangling.WARNING.ref | 5 + .../pseudocomments-warning-empty.WARNING.ref | 7 ++ ...pseudocomments-warning-lexer1.WARNING.ref} | 4 +- ...pseudocomments-warning-lexer2.WARNING.ref} | 4 +- ...udocomments-warning-multiunit.WARNING.ref} | 2 + ...pseudocomments-warning-syntax.WARNING.ref} | 2 + ...nts-warning-unexpected-format.WARNING.ref} | 2 + src/compiler/Checker.ref | 101 +++++++++++++++++- src/compiler/Config.ref | 3 +- src/compiler/Desugaring.ref | 17 +++ src/compiler/Engine.ref | 27 +++++ src/compiler/Log-AST.ref | 3 + src/compiler/OptTree-Drive.ref | 10 ++ src/compiler/OptTree-Spec.ref | 11 +- src/compiler/OptTree.ref | 2 + src/compiler/ParseCmdLine.ref | 3 + src/compiler/R5-Lexer.ref | 43 +------- src/compiler/R5-Parser.ref | 96 ++++++++++++++--- 27 files changed, 359 insertions(+), 74 deletions(-) create mode 100644 autotests/opt-tree-no-drive.ref create mode 100644 autotests/opt-tree-no-opt-misplaced.ref create mode 100644 autotests/opt-tree-no-opt.ref create mode 100644 autotests/opt-tree-no-spec.ref delete mode 100644 autotests/pseudocomments-error-misplaced.BAD-SYNTAX.ref rename autotests/{pseudocomments-warnings-classic.WARNING.ref => pseudocomments-warning-classic.WARNING.ref} (88%) create mode 100644 autotests/pseudocomments-warning-conflict.WARNING.ref create mode 100644 autotests/pseudocomments-warning-dangling.WARNING.ref create mode 100644 autotests/pseudocomments-warning-empty.WARNING.ref rename autotests/{pseudocomments-warning-extended.WARNING.ref => pseudocomments-warning-lexer1.WARNING.ref} (50%) rename autotests/{pseudocomments-error-lexer.BAD-SYNTAX.ref => pseudocomments-warning-lexer2.WARNING.ref} (56%) rename autotests/{pseudocomments-error-multiunit.BAD-SYNTAX.ref => pseudocomments-warning-multiunit.WARNING.ref} (75%) rename autotests/{pseudocomments-error-syntax.BAD-SYNTAX.ref => pseudocomments-warning-syntax.WARNING.ref} (78%) rename autotests/{pseudocomments-error-semantics.BAD-SYNTAX.ref => pseudocomments-warning-unexpected-format.WARNING.ref} (78%) 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/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-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-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/src/compiler/Checker.ref b/src/compiler/Checker.ref index e847be07..7868c10d 100644 --- a/src/compiler/Checker.ref +++ b/src/compiler/Checker.ref @@ -126,6 +126,15 @@ PrepareMessage { 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 { @@ -146,7 +155,9 @@ CheckPseudofunctions { = : e._ (e.Name) e._ = (Error t.SrcPos TaggedPseudofunction s.Tag e.Name); @@ -557,6 +568,15 @@ SeparateDefines { (e.Declarations) (LegacyDrive t.SrcPos s.ScopeClass e.Name) = (e.Declarations (LegacyDrive 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)); @@ -585,6 +605,9 @@ CheckDeclarations { &CheckRedefinitions &FindFinalInitEntry &CheckIntrinsics + &CheckConflictOptPseudocomments + &CleanupValidOptPseudocomments + &CheckDanglingOptPseudocomments > > } @@ -804,6 +827,82 @@ CheckIntrinsics { 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-B (Opt s._ () Yes t._ e._) e.Declarations-E + = ; + + e.Declarations = e.Declarations; +} + +CleanupValidOptPseudocomments { + 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>; diff --git a/src/compiler/Config.ref b/src/compiler/Config.ref index 6228252b..ee9b41dc 100644 --- a/src/compiler/Config.ref +++ b/src/compiler/Config.ref @@ -20,6 +20,7 @@ $ENTRY Config-Create { (Optimize /* пусто */) (WarningIds nul-in-compound pseudofunctions repeated deprecated intrinsic + pseudocomment ) (WarningIdsAsErrors /* пусто */) (ErrorFile /* пусто */) @@ -533,7 +534,7 @@ ValidWarningId { WarningForName { 'screening' = True screening; 'nul-in-compound' = True nul-in-compound; - 'ignored-pseudocomments' = True ignored-pseudocomments; + 'pseudocomment' = True pseudocomment; 'pseudofunctions' = True pseudofunctions; 'pseudofunction' = True pseudofunctions; /* синоним */ 'repeated' = True repeated; diff --git a/src/compiler/Desugaring.ref b/src/compiler/Desugaring.ref index bf7d2d9b..0087d2e5 100644 --- a/src/compiler/Desugaring.ref +++ b/src/compiler/Desugaring.ref @@ -44,6 +44,10 @@ $ENTRY Pass-RemovePos { (LegacySpec t.SrcPos (e.Name) e.Pattern) = (LegacySpec 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); } @@ -812,6 +816,12 @@ Pass-CollectDeclarations { (Intrinsic e.Name) = (GROUP Intrinsics (e.Name)); (LegacySpec e.Name) = (GROUP Specs (e.Name)); + (s.OptMarkup e.Name) + , (Opt Drives Specs) (Drive Drives) (Spec Specs) + (NoOpt NoDrives NoSpecs) (NoDrive NoDrives) (NoSpec NoSpecs) + : e._ (s.OptMarkup e.Groups) e._ + = ; + (Function (e.Name) e.Body) = (GROUP DefinedFunctions (e.Name)) (Function (e.Name) e.Body); @@ -828,6 +838,8 @@ Pass-CollectDeclarations { (GROUP Inlines) (GROUP Intrinsics) (GROUP Specs) + (GROUP NoDrives) + (GROUP NoSpecs) (GROUP DefinedFunctions) > : e.AST^ @@ -836,6 +848,8 @@ Pass-CollectDeclarations { (GROUP Inlines e.Inlines) (GROUP Intrinsics e.Intrinsics) (GROUP Specs e.Specs) + (GROUP NoDrives e.NoDrives) + (GROUP NoSpecs e.NoSpecs) (GROUP DefinedFunctions e.DefinedFunctions) = : e.Externs^ @@ -843,6 +857,8 @@ Pass-CollectDeclarations { = : e.Inlines^ = : e.Intrinsics^ = : e.Specs^ + = : e.NoDrives^ + = : e.NoSpecs^ = : e.Externs^ = : e.Inlines^ @@ -851,6 +867,7 @@ Pass-CollectDeclarations { = (Externs e.Externs) (Drives e.Drives) (Inlines e.Inlines) (Intrinsics e.Intrinsics) (Specs e.Specs) + (NoDrives e.NoDrives) (NoSpecs e.NoSpecs) e.AST } diff --git a/src/compiler/Engine.ref b/src/compiler/Engine.ref index 1974e290..13d1f0a3 100644 --- a/src/compiler/Engine.ref +++ b/src/compiler/Engine.ref @@ -444,6 +444,10 @@ PatchAST-Item { ); + 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) = ( LegacySpec () @@ -730,6 +734,8 @@ $ENTRY GlobalASTStorage-AddAST { > : ((e.NewEntries) (e.Locals)) e.AST^ + = : e.AST^ + = : e.Locals^ = e.NewEntries e.Entries : e.Entries^ @@ -766,6 +772,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/Log-AST.ref b/src/compiler/Log-AST.ref index 47279865..084353e0 100644 --- a/src/compiler/Log-AST.ref +++ b/src/compiler/Log-AST.ref @@ -41,6 +41,9 @@ Element { (Specs e.Names) = ; + (NoDrives e.Names) = ; + (NoSpecs e.Names) = ; + (DriveInfo e.DriveInfo) = ('(DriveInfo ...)'); (SpecInfo e.SpecInfo) = ('(SpecInfo ...)'); } diff --git a/src/compiler/OptTree-Drive.ref b/src/compiler/OptTree-Drive.ref index 593b5df6..d269318e 100644 --- a/src/compiler/OptTree-Drive.ref +++ b/src/compiler/OptTree-Drive.ref @@ -81,10 +81,20 @@ UpdateDriveInfo { = : (e.Drives) e.AST^ = : (e.DrivesI) e.AST^ = : (e.Intrinsics) e.AST^ + = e.AST + : { + e.AST-B (NoDrives e.Names) e.AST-E + = (e.Names) e.AST-B (NoDrives e.Names) e.AST-E; + + e.AST^ = (/* пусто */) e.AST; + } + : (e.NoDrives) e.AST^ + = : e.NoDrives^ = e.Drives e.DrivesI : e.Drives^ = : e.KnownNames^ + = : e.Drives^ = : e.Drives^ = : e.Intrinsics^ diff --git a/src/compiler/OptTree-Spec.ref b/src/compiler/OptTree-Spec.ref index a411e30c..ed940660 100644 --- a/src/compiler/OptTree-Spec.ref +++ b/src/compiler/OptTree-Spec.ref @@ -56,10 +56,19 @@ Prepare-Aux { } : (e.NewNames) e.AST^ + = 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^ + = ; - 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 ; @@ -166,17 +143,17 @@ DoScan-GEN { 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 @@ -557,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 4b610724..b3b68d7e 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; @@ -56,7 +59,84 @@ $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 : e._ s.Node e._ + , > : e.Name + = ; + + t.ErrorList t.Pos e._unrecognized + = t.ErrorList /* пропускаем неопознанный псевдокомментарий */; +} + +ParseOptPseudocomment { + 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,7 +168,6 @@ UnexpectedUnitToken { UnitStartToken { = TkEntry TkName TkSemicolon TkInclude TkNativeCode TkSpec - TkPseudoComment; } NameListTags { @@ -139,19 +218,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; }; }