Changeset 9724 for branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer
- Timestamp:
- 07/19/13 00:31:12 (12 years ago)
- Location:
- branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer
- Files:
-
- 2 added
- 5 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDef.atg
r9696 r9724 1 $namespace=SyntaxAnalyzer 2 1 3 COMPILER GPDefSyntaxAnalyzer 2 4 3 CHARACTER SETS5 CHARACTERS 4 6 letter = 'A'..'Z' + 'a'..'z'. 5 7 digit = '0'..'9'. 6 whiteSpace = CHR(9) + EOL IGNORE. /* ' ' ignored by default */ 8 9 TOKENS 10 ident = letter {letter | digit} . 7 11 8 12 COMMENTS 9 FROM '/*' TO '*/' NESTED.13 FROM "/*" TO "*/" NESTED 10 14 11 KEYWORDS 12 'PROBLEM'. 'END'. 'EPS'. 13 'LOCAL'. 'NONTERMINALS'. 'RULES'. 14 'SEM'. 'MAXIMIZE'. 'MINIMIZE'. 'TERMINALS'. 'CONSTRAINTS'. 'INIT'. 'CODE'. 15 'IN'. 'SET'. 'RANGE'. 15 IGNORE '\t' + '\r' + '\n' 16 16 17 TOKENS 18 '='. '|'. '.'. '('. ')'. '['. ']'. '{'. '}'. '>>'. '..'. 19 20 TOKEN CLASSES 21 ident = letter {letter | digit}. 22 23 PRAGMAS 24 source = '<<' SEM <<for (; ; ) { 25 switch (GPDefSyntaxAnalyzerLex.curCh) { 26 case Utils.EF: 27 Errors.SemError(GPDefSyntaxAnalyzerLex.curLine, GPDefSyntaxAnalyzerLex.curCol, "end of file in source text"); 28 return; 29 case '<': 30 GPDefSyntaxAnalyzerLex.NextCh(); 31 if (GPDefSyntaxAnalyzerLex.curCh == '<') { 32 Errors.Warning(GPDefSyntaxAnalyzerLex.curLine, GPDefSyntaxAnalyzerLex.curCol, "non closed source text before?"); 33 GPDefSyntaxAnalyzerLex.NextCh(); 34 } 35 break; 36 case '>': 37 GPDefSyntaxAnalyzerLex.NextCh(); 38 if (GPDefSyntaxAnalyzerLex.curCh == '>') { 39 GPDefSyntaxAnalyzerLex.curCh = ' '; // force GPDefSyntaxAnalyzerLex to get next character 40 return; 41 } 42 break; 43 default: 44 GPDefSyntaxAnalyzerLex.NextCh(); 45 break; 46 } 47 }>> 48 . 49 NONTERMINALS 50 GPDefSyntaxAnalyzer. 51 SemDecl. SemAction. NonterminalDecl. 52 RuleDef. SynExpr. SynTerm. SynFact. TerminalDecl. 53 ConstraintDef. ConstraintRule. SetDefinition. 54 55 RULES 17 PRODUCTIONS 56 18 GPDefSyntaxAnalyzer = 57 'PROBLEM'ident58 ['CODE' /* SourceText */]59 ['INIT' /* SourceText */]60 'NONTERMINALS'{ NonterminalDecl }61 'TERMINALS'{ TerminalDecl }62 'RULES'{ RuleDef }63 ( 'MAXIMIZE' | 'MINIMIZE') /* SourceText */64 'END'ident '.'.19 "PROBLEM" ident 20 ["CODE" "<<" {ANY} ">>" ] 21 ["INIT" "<<" {ANY} ">>" ] 22 "NONTERMINALS" { NonterminalDecl } 23 "TERMINALS" { TerminalDecl } 24 "RULES" { RuleDef } 25 ("MAXIMIZE" | "MINIMIZE") "<<" {ANY} ">>" 26 "END" ident '.'. 65 27 66 28 67 SemDecl = 'LOCAL' /* SourceText */29 SemDecl = "LOCAL" "<<" {ANY} ">>" 68 30 . 69 31 70 SemAction = 'SEM' /* SourceText */32 SemAction = "SEM" "<<" {ANY} ">>" 71 33 . 72 34 73 NonterminalDecl = ident /* FormalAttrList */'.'35 NonterminalDecl = ident "<<" {ANY} ">>" '.' 74 36 . 75 37 76 TerminalDecl = ident /* FormalAttrList */77 [ 'CONSTRAINTS'ConstraintDef ]38 TerminalDecl = ident "<<" {ANY} ">>" 39 [ "CONSTRAINTS" ConstraintDef ] 78 40 '.' 79 41 . 80 42 81 43 ConstraintDef = { ConstraintRule }. 82 ConstraintRule = ident 'IN'SetDefinition .44 ConstraintRule = ident "IN" SetDefinition . 83 45 SetDefinition = 84 'SET' /* SourceText */85 | 'RANGE' /* SourceText */ '..' /* SourceText */46 "SET" "<<" {ANY} ">>" 47 | "RANGE" "<<" {ANY} ">>" ".." "<<" {ANY} ">>" 86 48 . 87 49 88 RuleDef = ident /* FormalAttrList */'=' [SemDecl] SynExpr '.'50 RuleDef = ident "<<" {ANY} ">>" '=' [SemDecl] SynExpr '.' 89 51 . 90 52 91 SynExpr = SynTerm { '|' SynTerm}53 SynExpr = SynTerm { '|' SynTerm } 92 54 . 93 55 94 SynTerm = SynFact { SynFact}56 SynTerm = SynFact { SynFact } 95 57 . 96 58 97 59 SynFact = 98 ident /* ActualAttrList */99 | 'EPS'60 ident "<<" {ANY} ">>" 61 | "EPS" 100 62 | '(' SynExpr ')' 101 63 | '[' SynExpr ']' -
branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/SyntaxAnalyzer.csproj
r9430 r9724 42 42 </ItemGroup> 43 43 <ItemGroup> 44 <Compile Include="Coco-2\Errors.cs" /> 45 <Compile Include="Coco-2\Sets.cs" /> 46 <Compile Include="Coco-2\Utils.cs" /> 47 <Compile Include="GPDefSyntaxAnalyzer.cs"> 48 <SubType>Code</SubType> 49 </Compile> 50 <Compile Include="GPDefSyntaxAnalyzerLex.cs" /> 51 <Compile Include="GPDefSyntaxAnalyzerSem.cs" /> 52 <Compile Include="GPDefSyntaxAnalyzerSyn.cs" /> 44 <Compile Include="GPDefSyntaxAnalyzer.cs" /> 45 <Compile Include="Parser.cs" /> 53 46 <Compile Include="Properties\AssemblyInfo.cs" /> 47 <Compile Include="Scanner.cs" /> 54 48 </ItemGroup> 55 49 <ItemGroup> … … 57 51 </ItemGroup> 58 52 <ItemGroup> 59 <Content Include="GPDef.pgt.lst" /> 60 <Content Include="GPDef.sg.lst" /> 53 <Folder Include="Coco-2\" /> 61 54 </ItemGroup> 62 55 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Note: See TracChangeset
for help on using the changeset viewer.