From a7603dafe180fe1d4288a5537069802c8cfb3004 Mon Sep 17 00:00:00 2001 From: Jens Bendisposto <jens@bendisposto.de> Date: Fri, 9 Dec 2011 11:47:52 +0100 Subject: [PATCH] initial import --- .gitignore | 18 + AUTHORS | 7 + COPYING-LESSER | 504 + LICENSE | 23 + README.md | 27 + THANKS | 18 + build.gradle | 23 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 13031 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 168 + gradlew.bat | 82 + .../org/sablecc/sablecc/AcceptStates.java | 59 + .../sablecc/sablecc/AddAstProductions.java | 107 + ...ntualEmptyTransformationToProductions.java | 81 + .../AddProdTransformAndAltTransform.java | 144 + .../sablecc/sablecc/AltTransformAdapter.java | 143 + .../sablecc/AlternativeElementTypes.java | 68 + .../java/org/sablecc/sablecc/BooleanCast.java | 23 + src/main/java/org/sablecc/sablecc/Cast.java | 13 + .../java/org/sablecc/sablecc/CharSet.java | 226 + .../sablecc/ComputeCGNomenclature.java | 329 + .../org/sablecc/sablecc/ComputeInlining.java | 176 + .../sablecc/ComputeSimpleTermPosition.java | 107 + .../sablecc/sablecc/ConflictException.java | 27 + .../org/sablecc/sablecc/ConstructNFA.java | 417 + .../ConstructParserGenerationDatas.java | 86 + .../sablecc/sablecc/ConstructProdsMap.java | 27 + src/main/java/org/sablecc/sablecc/DFA.java | 403 + .../org/sablecc/sablecc/DisplayLicense.java | 68 + .../java/org/sablecc/sablecc/GenAlts.java | 420 + .../java/org/sablecc/sablecc/GenAnalyses.java | 439 + .../java/org/sablecc/sablecc/GenLexer.java | 360 + .../java/org/sablecc/sablecc/GenParser.java | 891 ++ .../java/org/sablecc/sablecc/GenProds.java | 125 + .../java/org/sablecc/sablecc/GenTokens.java | 201 + .../java/org/sablecc/sablecc/GenUtils.java | 252 + .../GenerateAlternativeCodeForParser.java | 604 ++ .../java/org/sablecc/sablecc/Grammar.java | 687 ++ .../org/sablecc/sablecc/In_Production.java | 173 + .../java/org/sablecc/sablecc/Inlining.java | 527 + src/main/java/org/sablecc/sablecc/IntSet.java | 389 + .../java/org/sablecc/sablecc/IntegerCast.java | 23 + .../sablecc/sablecc/IntegerComparator.java | 23 + .../InternalTransformationsToGrammar.java | 649 ++ .../org/sablecc/sablecc/LR0Collection.java | 147 + .../java/org/sablecc/sablecc/LR0Item.java | 98 + .../sablecc/sablecc/LR0ItemAndSetPair.java | 23 + .../java/org/sablecc/sablecc/LR0ItemSet.java | 180 + .../org/sablecc/sablecc/LR1Collection.java | 183 + .../java/org/sablecc/sablecc/LR1Item.java | 99 + .../java/org/sablecc/sablecc/LR1ItemSet.java | 233 + .../java/org/sablecc/sablecc/ListCast.java | 23 + .../org/sablecc/sablecc/MacroExpander.java | 111 + src/main/java/org/sablecc/sablecc/NFA.java | 355 + src/main/java/org/sablecc/sablecc/NoCast.java | 21 + .../java/org/sablecc/sablecc/NodeCast.java | 24 + .../org/sablecc/sablecc/PrettyPrinter.java | 300 + .../java/org/sablecc/sablecc/Production.java | 157 + .../RecursiveProductionsDetections.java | 70 + .../org/sablecc/sablecc/ResolveAltIds.java | 162 + .../org/sablecc/sablecc/ResolveAstIds.java | 349 + .../java/org/sablecc/sablecc/ResolveIds.java | 672 ++ .../sablecc/ResolveProdTransformIds.java | 357 + .../sablecc/sablecc/ResolveTransformIds.java | 1094 ++ .../java/org/sablecc/sablecc/SableCC.java | 366 + .../java/org/sablecc/sablecc/StringCast.java | 23 + .../org/sablecc/sablecc/StringComparator.java | 23 + src/main/java/org/sablecc/sablecc/Symbol.java | 151 + .../java/org/sablecc/sablecc/SymbolSet.java | 207 + .../java/org/sablecc/sablecc/Transitions.java | 84 + .../org/sablecc/sablecc/TypedHashMap.java | 175 + .../org/sablecc/sablecc/TypedLinkedList.java | 121 + .../org/sablecc/sablecc/TypedTreeMap.java | 251 + .../java/org/sablecc/sablecc/Version.java | 6 + .../sablecc/sablecc/analysis/Analysis.java | 102 + .../sablecc/analysis/AnalysisAdapter.java | 503 + .../sablecc/analysis/DepthFirstAdapter.java | 1130 ++ .../analysis/ReversedDepthFirstAdapter.java | 1129 ++ .../java/org/sablecc/sablecc/lexer/Lexer.java | 1151 ++ .../sablecc/sablecc/lexer/LexerException.java | 11 + .../java/org/sablecc/sablecc/node/AAlt.java | 189 + .../sablecc/sablecc/node/AAltTransform.java | 189 + .../java/org/sablecc/sablecc/node/AAst.java | 103 + .../org/sablecc/sablecc/node/AAstAlt.java | 146 + .../org/sablecc/sablecc/node/AAstProd.java | 146 + .../org/sablecc/sablecc/node/ACharBasic.java | 82 + .../org/sablecc/sablecc/node/ACharChar.java | 82 + .../org/sablecc/sablecc/node/AConcat.java | 103 + .../org/sablecc/sablecc/node/ADecChar.java | 82 + .../java/org/sablecc/sablecc/node/AElem.java | 211 + .../org/sablecc/sablecc/node/AGrammar.java | 361 + .../org/sablecc/sablecc/node/AHelperDef.java | 125 + .../org/sablecc/sablecc/node/AHelpers.java | 103 + .../org/sablecc/sablecc/node/AHexChar.java | 82 + .../org/sablecc/sablecc/node/AIdBasic.java | 82 + .../org/sablecc/sablecc/node/AIgnTokens.java | 103 + .../sablecc/sablecc/node/AIntervalSet.java | 125 + .../org/sablecc/sablecc/node/AListTerm.java | 146 + .../org/sablecc/sablecc/node/AMinusBinOp.java | 33 + .../sablecc/sablecc/node/ANewListTerm.java | 189 + .../org/sablecc/sablecc/node/ANewTerm.java | 189 + .../org/sablecc/sablecc/node/ANullTerm.java | 33 + .../sablecc/sablecc/node/AOperationSet.java | 168 + .../org/sablecc/sablecc/node/APlusBinOp.java | 33 + .../org/sablecc/sablecc/node/APlusUnOp.java | 82 + .../java/org/sablecc/sablecc/node/AProd.java | 253 + .../org/sablecc/sablecc/node/AProdName.java | 125 + .../sablecc/node/AProductionSpecifier.java | 33 + .../sablecc/sablecc/node/AProductions.java | 103 + .../org/sablecc/sablecc/node/AQMarkUnOp.java | 82 + .../org/sablecc/sablecc/node/ARegExp.java | 103 + .../sablecc/sablecc/node/ARegExpBasic.java | 82 + .../org/sablecc/sablecc/node/ASetBasic.java | 82 + .../sablecc/sablecc/node/ASimpleListTerm.java | 168 + .../org/sablecc/sablecc/node/ASimpleTerm.java | 168 + .../org/sablecc/sablecc/node/AStarUnOp.java | 82 + .../org/sablecc/sablecc/node/AStateList.java | 189 + .../sablecc/sablecc/node/AStateListTail.java | 125 + .../org/sablecc/sablecc/node/AStates.java | 103 + .../sablecc/sablecc/node/AStringBasic.java | 82 + .../org/sablecc/sablecc/node/ATokenDef.java | 254 + .../sablecc/sablecc/node/ATokenSpecifier.java | 33 + .../org/sablecc/sablecc/node/ATokens.java | 103 + .../org/sablecc/sablecc/node/ATransition.java | 82 + .../java/org/sablecc/sablecc/node/AUnExp.java | 125 + .../java/org/sablecc/sablecc/node/Cast.java | 8 + .../java/org/sablecc/sablecc/node/EOF.java | 30 + .../java/org/sablecc/sablecc/node/NoCast.java | 16 + .../java/org/sablecc/sablecc/node/Node.java | 78 + .../org/sablecc/sablecc/node/NodeCast.java | 16 + .../java/org/sablecc/sablecc/node/PAlt.java | 6 + .../sablecc/sablecc/node/PAltTransform.java | 6 + .../java/org/sablecc/sablecc/node/PAst.java | 6 + .../org/sablecc/sablecc/node/PAstAlt.java | 6 + .../org/sablecc/sablecc/node/PAstProd.java | 6 + .../java/org/sablecc/sablecc/node/PBasic.java | 6 + .../java/org/sablecc/sablecc/node/PBinOp.java | 6 + .../java/org/sablecc/sablecc/node/PChar.java | 6 + .../org/sablecc/sablecc/node/PConcat.java | 6 + .../java/org/sablecc/sablecc/node/PElem.java | 6 + .../org/sablecc/sablecc/node/PGrammar.java | 6 + .../org/sablecc/sablecc/node/PHelperDef.java | 6 + .../org/sablecc/sablecc/node/PHelpers.java | 6 + .../org/sablecc/sablecc/node/PIgnTokens.java | 6 + .../org/sablecc/sablecc/node/PListTerm.java | 6 + .../java/org/sablecc/sablecc/node/PProd.java | 6 + .../org/sablecc/sablecc/node/PProdName.java | 6 + .../sablecc/sablecc/node/PProductions.java | 6 + .../org/sablecc/sablecc/node/PRegExp.java | 6 + .../java/org/sablecc/sablecc/node/PSet.java | 6 + .../org/sablecc/sablecc/node/PSpecifier.java | 6 + .../org/sablecc/sablecc/node/PStateList.java | 6 + .../sablecc/sablecc/node/PStateListTail.java | 6 + .../org/sablecc/sablecc/node/PStates.java | 6 + .../java/org/sablecc/sablecc/node/PTerm.java | 6 + .../org/sablecc/sablecc/node/PTokenDef.java | 6 + .../org/sablecc/sablecc/node/PTokens.java | 6 + .../org/sablecc/sablecc/node/PTransition.java | 6 + .../java/org/sablecc/sablecc/node/PUnExp.java | 6 + .../java/org/sablecc/sablecc/node/PUnOp.java | 6 + .../java/org/sablecc/sablecc/node/Start.java | 121 + .../java/org/sablecc/sablecc/node/Switch.java | 6 + .../org/sablecc/sablecc/node/Switchable.java | 8 + .../org/sablecc/sablecc/node/TAbstract.java | 35 + .../java/org/sablecc/sablecc/node/TArrow.java | 35 + .../java/org/sablecc/sablecc/node/TBar.java | 35 + .../java/org/sablecc/sablecc/node/TBlank.java | 30 + .../java/org/sablecc/sablecc/node/TChar.java | 30 + .../java/org/sablecc/sablecc/node/TColon.java | 35 + .../java/org/sablecc/sablecc/node/TComma.java | 35 + .../org/sablecc/sablecc/node/TComment.java | 30 + .../java/org/sablecc/sablecc/node/TDDot.java | 35 + .../org/sablecc/sablecc/node/TDecChar.java | 30 + .../java/org/sablecc/sablecc/node/TDot.java | 35 + .../java/org/sablecc/sablecc/node/TEqual.java | 35 + .../org/sablecc/sablecc/node/THelpers.java | 35 + .../org/sablecc/sablecc/node/THexChar.java | 30 + .../java/org/sablecc/sablecc/node/TId.java | 30 + .../org/sablecc/sablecc/node/TIgnored.java | 35 + .../java/org/sablecc/sablecc/node/TLBkt.java | 35 + .../org/sablecc/sablecc/node/TLBrace.java | 35 + .../java/org/sablecc/sablecc/node/TLPar.java | 35 + .../java/org/sablecc/sablecc/node/TMinus.java | 35 + .../java/org/sablecc/sablecc/node/TNew.java | 35 + .../java/org/sablecc/sablecc/node/TNull.java | 35 + .../org/sablecc/sablecc/node/TPackage.java | 35 + .../java/org/sablecc/sablecc/node/TPkgId.java | 30 + .../java/org/sablecc/sablecc/node/TPlus.java | 35 + .../sablecc/node/TProductionSpecifier.java | 35 + .../sablecc/sablecc/node/TProductions.java | 35 + .../java/org/sablecc/sablecc/node/TQMark.java | 35 + .../java/org/sablecc/sablecc/node/TRBkt.java | 35 + .../org/sablecc/sablecc/node/TRBrace.java | 35 + .../java/org/sablecc/sablecc/node/TRPar.java | 35 + .../org/sablecc/sablecc/node/TSemicolon.java | 35 + .../java/org/sablecc/sablecc/node/TSlash.java | 35 + .../java/org/sablecc/sablecc/node/TStar.java | 35 + .../org/sablecc/sablecc/node/TStates.java | 35 + .../org/sablecc/sablecc/node/TString.java | 30 + .../org/sablecc/sablecc/node/TSyntax.java | 35 + .../sablecc/sablecc/node/TTokenSpecifier.java | 35 + .../org/sablecc/sablecc/node/TTokens.java | 35 + .../java/org/sablecc/sablecc/node/TTree.java | 35 + .../java/org/sablecc/sablecc/node/Token.java | 51 + .../sablecc/sablecc/node/TypedLinkedList.java | 149 + .../org/sablecc/sablecc/parser/Parser.java | 9277 +++++++++++++++++ .../sablecc/parser/ParserException.java | 21 + .../org/sablecc/sablecc/parser/State.java | 17 + .../sablecc/sablecc/parser/TokenIndex.java | 206 + .../org/sablecc/sablecc/alternatives.txt | 273 + .../org/sablecc/sablecc/analyses.txt | 287 + .../resources/org/sablecc/sablecc/lexer.txt | 454 + .../org/sablecc/sablecc/lexer/lexer.dat | Bin 0 -> 7508 bytes .../resources/org/sablecc/sablecc/parser.txt | 703 ++ .../org/sablecc/sablecc/parser/parser.dat | Bin 0 -> 20128 bytes .../org/sablecc/sablecc/productions.txt | 18 + .../resources/org/sablecc/sablecc/tokens.txt | 91 + .../resources/org/sablecc/sablecc/utils.txt | 350 + src/main/resources/patchfiles/IParser.txt | 14 + src/main/resources/patchfiles/IToken.txt | 23 + .../patchfiles/ITokenListContainer.txt | 13 + .../resources/patchfiles/PositionedNode.txt | 47 + .../resources/patchfiles/SourcePosition.txt | 27 + .../resources/patchfiles/SourcePositions.txt | 434 + .../resources/patchfiles/SourcecodeRange.txt | 30 + 225 files changed, 39106 insertions(+) create mode 100644 .gitignore create mode 100644 AUTHORS create mode 100644 COPYING-LESSER create mode 100644 LICENSE create mode 100644 README.md create mode 100644 THANKS create mode 100644 build.gradle create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 src/main/java/org/sablecc/sablecc/AcceptStates.java create mode 100644 src/main/java/org/sablecc/sablecc/AddAstProductions.java create mode 100644 src/main/java/org/sablecc/sablecc/AddEventualEmptyTransformationToProductions.java create mode 100644 src/main/java/org/sablecc/sablecc/AddProdTransformAndAltTransform.java create mode 100644 src/main/java/org/sablecc/sablecc/AltTransformAdapter.java create mode 100644 src/main/java/org/sablecc/sablecc/AlternativeElementTypes.java create mode 100644 src/main/java/org/sablecc/sablecc/BooleanCast.java create mode 100644 src/main/java/org/sablecc/sablecc/Cast.java create mode 100644 src/main/java/org/sablecc/sablecc/CharSet.java create mode 100644 src/main/java/org/sablecc/sablecc/ComputeCGNomenclature.java create mode 100644 src/main/java/org/sablecc/sablecc/ComputeInlining.java create mode 100644 src/main/java/org/sablecc/sablecc/ComputeSimpleTermPosition.java create mode 100644 src/main/java/org/sablecc/sablecc/ConflictException.java create mode 100644 src/main/java/org/sablecc/sablecc/ConstructNFA.java create mode 100644 src/main/java/org/sablecc/sablecc/ConstructParserGenerationDatas.java create mode 100644 src/main/java/org/sablecc/sablecc/ConstructProdsMap.java create mode 100644 src/main/java/org/sablecc/sablecc/DFA.java create mode 100644 src/main/java/org/sablecc/sablecc/DisplayLicense.java create mode 100644 src/main/java/org/sablecc/sablecc/GenAlts.java create mode 100644 src/main/java/org/sablecc/sablecc/GenAnalyses.java create mode 100644 src/main/java/org/sablecc/sablecc/GenLexer.java create mode 100644 src/main/java/org/sablecc/sablecc/GenParser.java create mode 100644 src/main/java/org/sablecc/sablecc/GenProds.java create mode 100644 src/main/java/org/sablecc/sablecc/GenTokens.java create mode 100644 src/main/java/org/sablecc/sablecc/GenUtils.java create mode 100644 src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java create mode 100644 src/main/java/org/sablecc/sablecc/Grammar.java create mode 100644 src/main/java/org/sablecc/sablecc/In_Production.java create mode 100644 src/main/java/org/sablecc/sablecc/Inlining.java create mode 100644 src/main/java/org/sablecc/sablecc/IntSet.java create mode 100644 src/main/java/org/sablecc/sablecc/IntegerCast.java create mode 100644 src/main/java/org/sablecc/sablecc/IntegerComparator.java create mode 100644 src/main/java/org/sablecc/sablecc/InternalTransformationsToGrammar.java create mode 100644 src/main/java/org/sablecc/sablecc/LR0Collection.java create mode 100644 src/main/java/org/sablecc/sablecc/LR0Item.java create mode 100644 src/main/java/org/sablecc/sablecc/LR0ItemAndSetPair.java create mode 100644 src/main/java/org/sablecc/sablecc/LR0ItemSet.java create mode 100644 src/main/java/org/sablecc/sablecc/LR1Collection.java create mode 100644 src/main/java/org/sablecc/sablecc/LR1Item.java create mode 100644 src/main/java/org/sablecc/sablecc/LR1ItemSet.java create mode 100644 src/main/java/org/sablecc/sablecc/ListCast.java create mode 100644 src/main/java/org/sablecc/sablecc/MacroExpander.java create mode 100644 src/main/java/org/sablecc/sablecc/NFA.java create mode 100644 src/main/java/org/sablecc/sablecc/NoCast.java create mode 100644 src/main/java/org/sablecc/sablecc/NodeCast.java create mode 100644 src/main/java/org/sablecc/sablecc/PrettyPrinter.java create mode 100644 src/main/java/org/sablecc/sablecc/Production.java create mode 100644 src/main/java/org/sablecc/sablecc/RecursiveProductionsDetections.java create mode 100644 src/main/java/org/sablecc/sablecc/ResolveAltIds.java create mode 100644 src/main/java/org/sablecc/sablecc/ResolveAstIds.java create mode 100644 src/main/java/org/sablecc/sablecc/ResolveIds.java create mode 100644 src/main/java/org/sablecc/sablecc/ResolveProdTransformIds.java create mode 100644 src/main/java/org/sablecc/sablecc/ResolveTransformIds.java create mode 100644 src/main/java/org/sablecc/sablecc/SableCC.java create mode 100644 src/main/java/org/sablecc/sablecc/StringCast.java create mode 100644 src/main/java/org/sablecc/sablecc/StringComparator.java create mode 100644 src/main/java/org/sablecc/sablecc/Symbol.java create mode 100644 src/main/java/org/sablecc/sablecc/SymbolSet.java create mode 100644 src/main/java/org/sablecc/sablecc/Transitions.java create mode 100644 src/main/java/org/sablecc/sablecc/TypedHashMap.java create mode 100644 src/main/java/org/sablecc/sablecc/TypedLinkedList.java create mode 100644 src/main/java/org/sablecc/sablecc/TypedTreeMap.java create mode 100644 src/main/java/org/sablecc/sablecc/Version.java create mode 100644 src/main/java/org/sablecc/sablecc/analysis/Analysis.java create mode 100644 src/main/java/org/sablecc/sablecc/analysis/AnalysisAdapter.java create mode 100644 src/main/java/org/sablecc/sablecc/analysis/DepthFirstAdapter.java create mode 100644 src/main/java/org/sablecc/sablecc/analysis/ReversedDepthFirstAdapter.java create mode 100644 src/main/java/org/sablecc/sablecc/lexer/Lexer.java create mode 100644 src/main/java/org/sablecc/sablecc/lexer/LexerException.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AAlt.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AAltTransform.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AAst.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AAstAlt.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AAstProd.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ACharBasic.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ACharChar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AConcat.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ADecChar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AElem.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AGrammar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AHelperDef.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AHelpers.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AHexChar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AIdBasic.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AIgnTokens.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AIntervalSet.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AListTerm.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AMinusBinOp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ANewListTerm.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ANewTerm.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ANullTerm.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AOperationSet.java create mode 100644 src/main/java/org/sablecc/sablecc/node/APlusBinOp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/APlusUnOp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AProd.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AProdName.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AProductionSpecifier.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AProductions.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AQMarkUnOp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ARegExp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ARegExpBasic.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ASetBasic.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ASimpleListTerm.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ASimpleTerm.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AStarUnOp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AStateList.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AStateListTail.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AStates.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AStringBasic.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ATokenDef.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ATokenSpecifier.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ATokens.java create mode 100644 src/main/java/org/sablecc/sablecc/node/ATransition.java create mode 100644 src/main/java/org/sablecc/sablecc/node/AUnExp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/Cast.java create mode 100644 src/main/java/org/sablecc/sablecc/node/EOF.java create mode 100644 src/main/java/org/sablecc/sablecc/node/NoCast.java create mode 100644 src/main/java/org/sablecc/sablecc/node/Node.java create mode 100644 src/main/java/org/sablecc/sablecc/node/NodeCast.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PAlt.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PAltTransform.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PAst.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PAstAlt.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PAstProd.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PBasic.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PBinOp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PChar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PConcat.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PElem.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PGrammar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PHelperDef.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PHelpers.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PIgnTokens.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PListTerm.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PProd.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PProdName.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PProductions.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PRegExp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PSet.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PSpecifier.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PStateList.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PStateListTail.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PStates.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PTerm.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PTokenDef.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PTokens.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PTransition.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PUnExp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/PUnOp.java create mode 100644 src/main/java/org/sablecc/sablecc/node/Start.java create mode 100644 src/main/java/org/sablecc/sablecc/node/Switch.java create mode 100644 src/main/java/org/sablecc/sablecc/node/Switchable.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TAbstract.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TArrow.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TBar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TBlank.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TChar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TColon.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TComma.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TComment.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TDDot.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TDecChar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TDot.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TEqual.java create mode 100644 src/main/java/org/sablecc/sablecc/node/THelpers.java create mode 100644 src/main/java/org/sablecc/sablecc/node/THexChar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TId.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TIgnored.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TLBkt.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TLBrace.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TLPar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TMinus.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TNew.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TNull.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TPackage.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TPkgId.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TPlus.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TProductionSpecifier.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TProductions.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TQMark.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TRBkt.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TRBrace.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TRPar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TSemicolon.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TSlash.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TStar.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TStates.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TString.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TSyntax.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TTokenSpecifier.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TTokens.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TTree.java create mode 100644 src/main/java/org/sablecc/sablecc/node/Token.java create mode 100644 src/main/java/org/sablecc/sablecc/node/TypedLinkedList.java create mode 100644 src/main/java/org/sablecc/sablecc/parser/Parser.java create mode 100644 src/main/java/org/sablecc/sablecc/parser/ParserException.java create mode 100644 src/main/java/org/sablecc/sablecc/parser/State.java create mode 100644 src/main/java/org/sablecc/sablecc/parser/TokenIndex.java create mode 100644 src/main/resources/org/sablecc/sablecc/alternatives.txt create mode 100644 src/main/resources/org/sablecc/sablecc/analyses.txt create mode 100644 src/main/resources/org/sablecc/sablecc/lexer.txt create mode 100644 src/main/resources/org/sablecc/sablecc/lexer/lexer.dat create mode 100644 src/main/resources/org/sablecc/sablecc/parser.txt create mode 100644 src/main/resources/org/sablecc/sablecc/parser/parser.dat create mode 100644 src/main/resources/org/sablecc/sablecc/productions.txt create mode 100644 src/main/resources/org/sablecc/sablecc/tokens.txt create mode 100644 src/main/resources/org/sablecc/sablecc/utils.txt create mode 100644 src/main/resources/patchfiles/IParser.txt create mode 100644 src/main/resources/patchfiles/IToken.txt create mode 100644 src/main/resources/patchfiles/ITokenListContainer.txt create mode 100644 src/main/resources/patchfiles/PositionedNode.txt create mode 100644 src/main/resources/patchfiles/SourcePosition.txt create mode 100644 src/main/resources/patchfiles/SourcePositions.txt create mode 100644 src/main/resources/patchfiles/SourcecodeRange.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fe3bec2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +build/ +ParserAspects/ +bin/ +.classpath +.project +.settings/org.eclipse.jdt.core.prefs +.gradle/ +logs/ +*.swp +*.log +*~ +! .gitkeep +.DS_Store +tmp/ +PROB_LOGFILE_IS_UNDEFINED +.settings/org.eclipse.jdt.ui.prefs +src/main/resources/build.properties +config.groovy \ No newline at end of file diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..37505d3 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,7 @@ +This file contains the name of all copyright holders. + +Etienne M. Gagnon <etienne.gagnon@uqam.ca> +Ben Menking <bmenking@bigfoot.com> +Mariusz Nowostawski <mariusz@marni.otago.ac.nz> +Komivi Kevin Agbakpem <agbakpem.komivi@courrier.uqam.ca> +Kis Gergely <kisg@inf.bme.hu> diff --git a/COPYING-LESSER b/COPYING-LESSER new file mode 100644 index 0000000..223ede7 --- /dev/null +++ b/COPYING-LESSER @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..283bc3c --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +SableCC, an object-oriented compiler framework. +Copyright (C) 1997-2003 Etienne M. Gagnon <etienne.gagnon@uqam.ca> and +others. All rights reserved. + +See the file "AUTHORS" for the name of all copyright holders. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this program in the file "COPYING-LESSER"; if not, +write to the Free Software Foundation, Inc., 59 Temple Place, +Suite 330, Boston, MA 02111-1307 USA + +The SableCC web site is located at: +http://www.sablecc.org/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..236e473 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +SableCC 3.2 - STUPS version +=== + +This work is based on SableCC 3.2 by Etienne Gagnon. + +Our version of SableCC enriches the abstract syntax tree with information about tokens. +Contributors to this vrsion of SableCC are: + +Fabian Fritz +Marc Büngener +Jens Bendisposto + +License +--- + +This derived work is like SableCC covered by the GNU Lesser General Public License. You can view the copyright notice and the exact terms of the license in the files LICENSE, AUTHORS and COPYING-LESSER. + +Building +--- + +* Clone the repository +* Run the deploy target using gradle. If you don't have gradle installed, you can use the gradlew wrapper scripts, e.g., under Linux use './gradlew deploy' +* The binary is located in the build/libs subdirectory. + +Documentation +--- +You can find complete and detailed documentation on the SableCC framework and syntax at the site http://sablecc.org/documentation.html \ No newline at end of file diff --git a/THANKS b/THANKS new file mode 100644 index 0000000..b903e3e --- /dev/null +++ b/THANKS @@ -0,0 +1,18 @@ +THANKS file. + +SableCC has been initially developed by Etienne M. Gagnon as his +M.Sc. research project. + +Many people have contributed to SableCC by reporting problems, +suggesting various improvements or providing other services. Here is +a list of (some of) these people and organizations. Please help us +keep it complete and exempt of errors. + +Thanks to you +------------- + +* Prof. Laurie J. Hendren <hendren@sable.mcgill.ca>: + research advisor + +* Will Hartung <willh@msoft.com> + small patch for including token in parser exception diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..17db10d --- /dev/null +++ b/build.gradle @@ -0,0 +1,23 @@ +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'maven' + + +project.version = '3.2-stups-1' +project.group = 'de.stups' + +repositories { + mavenCentral() +} + +dependencies { + testCompile 'junit:junit:4.8.2' +} + +task deploy(dependsOn: [jar,test,javadoc], group: 'Build') + +jar { + manifest { + attributes 'Main-Class': 'org.sablecc.sablecc.SableCC' + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..45bfb5c85ea4b9b0d02616718f2637b2075acb1c GIT binary patch literal 13031 zcmWIWW@h1HVBp|jSl&C+j)8%JfeAz~Ffed3FfjPKhB)ea`nl;dGoUJz^0I#A%)r3l z&A`AQf~?Tj(a+P(H8@1i*X^_KnbSVrx_TFRy>+$DojJcb$l!|cgQuT-&z!kjdd^cv zZ(Gm_eXr}@`d&UKJ+Er(d+BI+=w2#jFFvejGa)KYFHR51(%lP$Z9xu$xsHW_fg!&r z9mQejYPg|l(u)#Pa#B&0qI*^tRcU!qVnIP_5r!6z1e?bPSr{08aWXJyVb|ggwk#ZC zfNx@Eo?dcJVsUYA=<TrEZX$QNju>@$G<k9~3V0|SxxglVX_>f3P_yg;i2}pvQnz*; z3hNb$EK0R>cz>P$#r!Xu#44_4f8EIccg4DQ8+pv!_%9wlGpG33oZ5AZ>;M0LozF1& zhwDL&B(8Ugaz~6=KSu;?=-_XPm^3j!L0K(1@>my>t4#ROt4o+f<+WZMnAJ0-Y4xF| zp3;T;7A6QsbJ;mX9V-*C=BoOzF`-V$Z$8^Z!RvP1POlfNjFpUJZSG*5D7;(l$n&K0 zr*BM7^mx&wwr$bNkhEk~$+^*|j)a@3wg{cyIz8&hl{GagPp#Uf&YyO{GCf)~eDfXO zvpTPZcD?S}cy;a6BUvWTR(?D7==>t-&aY?wM43$MNH+`mxb@7TS4A<09JIA3$3*)c zyMFER%%v5xRy}{R<wYlxaa-yRf0Zq*$2l(9r9XdhaB559OYNtJ*1cPky?dFS%=XQ* zcCNH+Tk!f!S^0SlPYK@}es+_}x6E1T{!Mmm#Fe=xYI^T{T9JBogG5Gk<L;JuAI|+W zxpKi&-M{*-T@vSX)8cq*ouhARPjA^ehb1$*>6M}RnnlxU6&*X}Q@$?BHkfZT@A9N+ zr<d}1uZ#1rGW%P=JNKJ@^}4(%CFuwC4Ek0-G~~ayLHRsSuzFO1TJ|;L#Y^67ntZjj zVc-1jY^RJ>GaOuw3foL7*gfy<+N~LrTu*EX2|mUxs>WrcBWl(ql=oA+qE>m~dG+0; zHT4e{y->S6<-&XAoG1Aw+-F_6vo~Yq67h(5_oKmk^p$=)>9Fj6zt}MQcHT)<#iEHt zrpHCQRCj2ds?bc1Kg!6LTC?(zcFox?Q}tQSk7mx+n0L)Rp;mdyKGEgxBj)~^YV_K4 z<MF1IKjc_HMemL}n$6+8<Kiuw&8dgabf%P=%>2P<zv<LO&htCE=6~4SGBG?eMaf(s ztbG3K$mw&hCCvTyU}krmbkT!PyH-c*Tbd@$SNxFuXB}JrNwd=4wyTStP5Bc1Y1e$+ zKKJk+Iq}_!-R;}A|79!txWstb-zDi%i__e%@qfv=naW%K=h;p1L)kv@Gvnp27Ff;P z@a*MVTghvivS&<eYndtaedBGbf84WN4QDT$U3Pvyukyb9VBrUw!c;Dq+Ve-;NxIqF zb&|U^I>bfgu<q3l^(^es*=2lpw%@w4=gNsIinW3tqvw2PUw<XztD>O){OoF-Hpy=< zJ?=cbpFidQgYF%jzd4)_Nv!1Nm>`$G=(b0(QsutR>$89ST_SICk$H<sC;ODw(oZ^K zg}xo{SNt2d+vuceK=QYwuGOz%4><2RxtBTrp<q7e)A*m;^B>!p#~o}9h-Q5&8Z(EJ zb<g3)T2H<hHa!k4S@JtSbm4?uA+594E%+=ky}xj2*Xk#wvWiz4-YJS0w3OX(Rd4gW ze^_Vl{8fe71r^fo3*IkLe*egJ*Y(2^%PV&^NPfC~veM`JkM<SrJHxxBW~^E;dtaRO zq0)J)UI?yh$&*>Uy=gY@vIk!(=d{Hu-eN6YEs#Aya!$%Ssh2ZX{a(^hzNatia<t-X zp0D8r*_nUjR~)i3zWY5oqruZl-*oelhx~WMjt5_`3v-g-H~7u<`Tp5A{03_Ro8~sK zNBmg6^%A?Ft?nD=D1rET(dIKB177geS{%B2!C<;_&!5iQN@gop-uWAoo_(SCKXU*| zMdALc=G-+_1_nVM1_lG{1z~VyaY<@!Kv8}{YEemMYOzORUP?}C5wtiA`x!1AF7mHU zNBB_3nnybpEo$4aD_Sf!aE(THSL>ohvWF)0w0X|)VafU)wfpwnu-lLM|F+JzIWFhF zcv|q^z4ak)zpF8B%6uquuX^YAeZTkpu6=*^$^82NRa^<;bzhUE+fwFyTFl~XH|N`9 zp0=X}*ZR#3l-dIA?;VMdJoj*qytskh<3;jaH%d?T7wu8C%SbX+R8~n2YJ2D2d%{fh z*#-%vB!fRIj-|@4>yW)@<a1cZnWxY&M%01l;f55Ilp8{OV%surw5#l3>QxrH<DN8m zSIgDEZ7ccJmaCV%USlS>bm=O4u}h1TXQg(Wmt1_iPlA*4>|aCeJ7U|moLq6wEIISz zj=ZhB=T&oRe@zj6%zpcV@Nv`0d8>n+N+Y&^-YX=<^!&Ge_Vq2>R;0DvZp%GwaCmNS zX7DAmMY+sTb7seef3a*_rV!Hfe3qE6&{UhXHy3u~c?N9W7F`uFKUL`X(Tw?Nt&=bB z^5nZSE7epWT#%u}t#q>AN`I%$gRU<h*(K?9FXx`2Y~~nc7h$>X=C-_<M<>kj+AXnF zZThX9Ka}?VE)p&iJ*2%wCh5?nMCF{UvP(&Q!rBW;k9L}~Un*0+R(7W2mFts_l4_4j zbE{T9@yVGl>3=Iz{IH7B>ex@;dB2`(`?4eV2#f5^TYSDT*PP9IO(WI6PBcH;$0>OF zvA4O0jFYpT1LwbrYqHUkr>6dVXSnM7)7G^!6#f_JWVU`WnZ~PM!L&AMbrW08^njf; z=L&TNJ?}4`wz%=L`0nG)y?5K0*B*3}^kltmuy}#&W}{~!dwO4U-8;D3=w9##JG%)V z7dG{O*w`b@Wp}XjQ|Oui&QkpeE(><9d=Ol->_Ktk>RlaXLf3S~Yt=Gu9osVR>6+8& zOVl%6)Q=k9xt1MixVlbl(d@4mXP9}$|J|hXHTcM-wGX&!G~3pT)bvI(T`(8Y67m*_ z%Mgvx_#t-x<d3+6{67MZ`E%uQ>(w38=X&>GUCV=0(Snzs-`{dni|f9oe6fa^Y<WvA z=bk^FPwhY0-u&pUG|O~Nyzi?t5B*KqI~_$8BqMUN-)SD6Q)2bavTW}LQSVRJuCV=* z>i)XEt46xoE;{N)pM~U&Yhh3CltxwRs>tw&>^tn_oxJh*s+9Xia_K2@>8by;h2t$A zIeA3vesk)bh|(e9u46(<y#m2k{tEr#&W}%zs}a2O^P`>hwi6+~3pAD=RN~mAldc?= z<F=)MegE|P5r=o_o;p8m_Of#_@8(L(pO~4K6K44^(s%u;3#V>NUKDEnwdRMJ@mx*u zUz5z%ZLml?{y$)nVIudoPvXr#iXDYyyC3t_Wj)p@{Kg{h_^Y{F=*^QCr9HC+9;{fx ze4#_(d63D%nSpn7a#M`#bEk_17=7bd_fPA4as^vcv#$U5-Lb!Ix6X_D{{BVg%CB$U zeK1>nPh^kmCavWP_Yd-gmMwqq`oqdi?q`;+(r>*~t&ty8oApxoN36u&hZCR8|9|(( z0Y}}0t&4h+ZEMynpCf9zVOd&Vb)>(zqHJo2y<`6+bHDxud)JQGh<>qm-wYScGTpwZ zCr#|qx%(wX-`^k1yR~P<0fy_<l~KIEHt_#`=qB6ukRe<yP=oIh_cO_(+AkCgpIY?# zJ=1qAZ(FtHy+C-otW|ueMzyZ<P3N>P7ymt1N<AoY>fNEsUlJI(cvrKD1=zV6hVh$i zUlMTe|EWq1*}RPbch5fywBOP2Y9s3vgI(LQe7Q<}Hkz?+eJXg(c6F3LE8Fbg8y{Gt zRZDh+eizP}bR($0>uTC88(l5Q_2Nktt!g64yI++aDLAr_W2^6~J35QD85pcR`sed; zkwdOY<&(4&U3VL=R$0y*D%t23aC+lh)pv)oCPjJf3YoNh>XEl8F~TRap4K$5lup>@ zcgf7F>zL<-(k~Cx`W}e6?&^)Zqx_Ly<FNCb2%#eF&)*G>9i1yJasBkw+%?5VrtY+U z;qfYUU9HVu3D@oiD*n}Tw@faPNw-tH|F@?`t1kK5WRdha`){>QSf``-{yE3Z^H&=- zOa0+Tts^F0k-MqK%D^z0i-AE6dmRywSd!sbT%4Mllmn|7riNyQ3#W_Ju`vlB6Ey7N zzH0VJY*W~qWr3P1Ic7S(4Pr|lsZ??<KIt=OrbgD)cU%9mzkS)i;Q5x$<@2t+{~Kt# z_x+g^#TGsJXR+`1o-f{B{_oH0?e+{Y2g-%`5|{BGo*`NoyXYsgpeCp7jE9Hkh=2Z5 z(3mf#TJqR=pKtZVi5pr{?bdkw;E?Z*`1+`=W46$>51lQ|JC2^eu6n2K(D_X@Cn_gC zH~yS-xVx#vcg3Aoy87=b3d3Cj4_titrNYQ`=e{{Jeb%4XIpe!7ecGkXpD#1jth7E= zs~Q%v#Yrbwa#dId_l@}%OfLtSWV>pH&1m>{^vj{ICyxX<uil@a@lz?<Y^LGj={s7I z-L57FXHA^gc~5)QvZ(7UCG2itEEPgk^N#Q>3F$o>?iHD)qj^*5@sBD$&2<`Wr@p^i zc>Gp~FXLg&yBbGiR@`8A)|@_5Fgj$-*}}^ys*_AOUL+)_o48Mwk!`=_lCZtIdTz#< zF5TtnkCorPtN6Ss(^o^Sc>0`HhKc&qdy@|T-?gv0)LHlPtBFx%CO=OF-U&|#o5Uj1 zcDS+cg>~_xiz0g3(?qnlpX6aYF1xa8saP_b_J*}L<`j$O-<rR@)FxFrM8W8gPCwt~ zSkF~%!n;LtrhlKe=4||_7oy6?e<-TvxhpM-aX!Y;WOPnh!6DC7QMpkiG|~E!i>vOl znTm^9dUqU6iE)c*>oYPh^*<)TVJi}$Z7-)k&3vl*!V^(;Tf~+sO36rby37(+PR<VG zTF<d5?a-t`QBlF~sWu0uH7rys+O;S$tJ62{X~fN-(nG!KBEFY(>*qzD(Fkn(wfya; zkN4BtJca)8I_v+ewBt36erWaYY00Vje`_l3v=SC%Rw-7uKh+WBPqjIe{O-_lqj?Wj zcBC8GJ@%{Z(@&}CT)yPmy@^Kq4qcxTzy0cpb6QtoFYd|e_~CYJdxf9x(aU8w{eOO4 zy=?!YyH~%kKWX@X|5l61&y~}}1#Vj3-z|KY`~Ic5%8c#IvfQ6bqM6G!><>C$>%CFP zk;{CecyZOroatBW3vRFVI3XVWRCspR#KiAfKBqVGMV-BO<7mpddx3fRGruh^O?J<E zZTRBu1>Q+Q1uL1a&tCa0>cyQ?&2#@Ok@zaYvp4A3_sz0jpIi%XdJ!bQ`@CnM;o3;u z^V`JCz8Uy`s!dbPzV>&4ho<Xh-yMFt&VFxScGT<K;!PPZLSnBuGd}+pta!Ar>tAmB zi~ToxA6xVq3lvN%i<MaPcjvUfoWEW?U9i<7{mX<45{vG-&SITa-DJvPe|u4)l<F)- zdm9#kg;U>fD0WGly>nppx<<`OPc{je3-J8yTDNR!-6GaSPZgDFU0R~89(nAZ_M_|a zBNe@bD_bMo^j|VGPJa={+m`iVkIVTi-n|dCT;@-2OIXroH*58TtQ*_!I=tCh$(FNZ zLGt285ry>gJHF>%Ty;8bZ*O_W(uVT?>bv%+S5@$T`7ZTh`mGDQe;j_ZsNSFR(X7QX zk@G&kt#7PjvNMohne@P2rn<9vwcY&Z<uXxk`BLK^6!12$SDL5QXHqG%(5KPpinpPx z!v4NV&l8=pK1t<%klJb)aB|WS(b?A-rd|n+*<9IcS|PdR`7Gy!T7BnQD`om(t$zwv z9lHH+^1R!jGWo~%`y|iNdd?NOhfDru)+2t?5A893<ai#{O2;qTC3(E1*Wcbu{J-VP zk26%A_bt?l`^|Xof&PnId_Vne>}H&&bN{4x#ojjaZIu)5Ecy9o$_jz=cUD#%V~gKv z=o?U~##uT^$<$RQElSJuX2Pr`zm3b5`rZ6>xgM=m-qO2t^DGwdXbyuS_7c}6zdSD| zKQRT;46hB1Efx-ysPmh3R_*rEEmM{qX>t(s)KKN{QguBrO^j*lT3+30i+1?>9d_Cz zZ7v=4XIFt+zRWS{beVJ+Sv{FKfqJi8X9&8#-|@kH<@uX+xrWJUMc?Lpe_T2Ld-C~z zU%%(qGgPq7m-2Yn)M#$FXj<Ub7?Ta`$!y08J&&i#Rx%gH7%q6cs*!U~YJyNO+p>?_ z+8&r!Dl|%pJlc_#AXdz_?(tlUXICG#ZHf+<#42lEx@Yxc+s3|^Ggo>WC$}D2d-3$< z$>FRnaS6v)yuMO<`s4F8Ue4PzBO1R=y!r9t#+lKre|inO`bxNtoV(TccD`_icltAy zMT_%1x!%m#AZvMZg`U^@Sz99(rd)4{-lA1JEq(RpT?Vi2Z+p%3TP<e&9Np@$l}ejW z&kJ4csb76DwoGeXsFYa8^lRUleqR<YUsD}+ZDL(nnVS8cvQ2m2?1-IsxT`U5s@J?V z!rPK}YrdSGa(BDz>Fu%U!FwNSC-kfpN%hryZI#DalGk$9dfykB)rVB1<DObR;H)|( zChhHgNw`C&XF}uU73VyTmZhI9KHYU@#q9tIowuS*J9y(2c1qT*dU#!`?%?+&p{fyE zURW*Jo*pewc6g%e(OxmZ*}vxb{@){9X3mv&Sler=@a`RfM<1WMam4Y<>x%m=t**kZ zQ+zzOS~vFesS2mw5xcRw(OO7F)jP57iRikhh@}^Dx8Au}c-@6HRJM;(+*DS6#)ku| zeyPQ|H>X;xdpxf*b<K+%`H!4yR2YQilaC%ze<A+j_x#R;bS6I0)0*ka#olkwOSyYU zasShcd!KH+naXH9hx@ih_?unv{AoYgy2Gda+w#=&czkgAGUN08K5MGBr&NFCUGg<h z_(IKeU+$ebXT8FI?Kht7wOx*FDYvrl#=~np)3c>m;wtoxZ1eQoc1@sdXX`V!1?E%k zd~1A_r}%72)xnnRm#q_h>Z0AbzQ5kLrj5Pi*5<il6^e$9S+88ye+^pW_)}zBv(cNp zP=#H()!WYBd+}uAdG`193?YeqQ5zp!Q)MsW&kq&j68!gj!}Q;^d(@RHCO-eW@H69< z!t>=VuNA#E)fDM1l&xjjC^cix5mPaa-vts`Y0S)fdX#IpmP}kYwP+g4W7*Do$-XZ8 zTuY{&-=?<cdOx2`HB&CP9%pHx{DaoI3Ff~QON1;u4;*eZX^3bK-@RCZ!|B^23AWCH zIlnbjBj5Swu!!?_W(IwZ@adXkcELqQyqc@_pXQ^_J@YD<l8r>O7ukyYy3RHzj=Dba z-2KOvwuVzYGBx*h%6?w{c%poP(aaZ}^?AIilREFdSfRG>pWNO3i;Ba;g?BSel=0$O z_GR0=3gNr`|0<W2?4JF?GxNNFf2OYr`+P;?8!qpazdXMcy{dGn-`4*-y*^20RX9B2 z{}B2iM*E_Wbce!D#weaeb2Gmi-mR-MHnuo<ceO?9^&eYpdTrVYdbgkPo#V)P_=t78 z=$z+Uix}r8vcxA$Ir01hZ|eQPZxc4jYyNJHzj4@6r}@XE6Y4i#3U9G+Es@P<5&X8v zb@>kavl^VC56)h*xtDYH@z-lEAB-#KBy#`$s9N+yNcH#pf@%MvRunenge-ghpB1$! znXr6<mNOdzLnJQ)g97$~ExZUkWD6<RriMWpk#5YLk9W8_I!@dnB;=8`wY$1Gsn^Lv zc*3!z7Anj=Z9Y~rSKK)I?)Sdi_7B?YRz44Tq`Ca7vwekMeTe`3a<vx4KHF~v72B)t zSI_@_=l8uc_y7O-r`}Ne<7R(1W6Y$FTxuyEJKnTwEoPl;wCDtTfI$1Kp0hJzj!xDz z^y%I#xp2YnLe+-VNhfc=E{N>tt~>K9kn6yQ#X65eXBgcI_;`5I#m-e5>U@ut-uaNM z*D%{?+v80eK14CBXaC^Fkk3}&eJr{n`j~Y^_zQoQ5AzJ1O5S_lu$t$&<Z|=O&XTm2 z%Na!myLX)N<lu`9T)*<;qNrJY>AJ!CzVg#HJZlMD6_It)YPs0zSuK5&Prk`evotW9 zCFAMaliC);W;OjJo6t?i=>?yErc^0eTTPP8nWnRUnqSYnZ~LyPOgz0T@S2bJbuFP= zvTs7Y^^aZdEq)ZvRn@xDCn#x(%9_$IUb95yPpfFg?@oC-CGLup)Gk5s>Z~nt7rl3t z`W!k{@ZOShpRikF*6X$}lcudY=a=<tg_WirTYJx*D4XT8cHOwnUwf^`ui|zaPqCF< z?yA;BV*B$}rS9tKw>FN=;m|MF`qS}YT}I{WC3#*iGJ`(!g~d#MvE}U469=U$*XksR zZxrL*I-zW%*adH&Ez8cCy}RJJDP&#LIm7oSc$wE6=9l=s#mytn>w0_jY|pRR=38p6 zDox>j$lV_{Rb0|DF!ku7<v9lobgDv5A6~_<W|mmw=Hi93F7qTWZs%{hAUnA~vHs%1 z7T?Ko-&DWY8H#LrvSO}Tn&juKppf)RzeD#vEPhb6_k-3~uQ}c;4|$z7eSYv{<l?Mn zrpqm+R-HX^q&DxatK!1$hGf1;5wZn2EBE~U5pdA5N86&MUt()GC+E#X!#NWK^0@Ba z{AQmO@uGgs1BQ8lA8h!vez45fvQW*@cy}n_;|}@9Ga^Gi=*&z0XLD+5ZsJRmVBN@H zYn};xn`^M@sMCs+2*toF3$0dN5L$I%O6Hlis&64xNoy{uMk`N#6#Dby%%<}nTMztG z-Q6?W<2tjzqn4)iAGXTh*Z3iJCU|<Zd1}P+o~)G*+RWZHwyrXp7I5%E*nw+#6S`+K zZI)27GdE<;a?Q5#T78Y@=AM<)H&08<>T^rhUQ$=H{6Y1f2gm!l>JH^{c1{u8l&w(` zyFJY*e5)n9<I*)xziP&6w|tqTp5GmDGWz-B+t-qAxg3`$Y<<7T$~t_b$;IeB^BCs8 z*E_%N+M26b#-SU3zyJC4Tdr!BkL0s8S)LXz9-g=>J?Bof{r-;QvDZ(&=*f%`x4oNb zv*?9N4rg_l@4}52oe#Lr)t6E#joYIpetYVi<(rmv>S-rx?b);QpZbaag_mysF~0t} z<!+y2$PuqYdFSul`{LXt`^Vwt8U1CUFC655{bUq*oX7g#N}&Ah_2U0iviDE^UAyjY z-n;o_Z_5k!-`{$_c|nF_47+Ri#`H4fb9JvatSz)TbXW7o4yJ7`VhT^2wBIGC^6q2Z z@+2!`?ZNu%+sdXaJ|lU<`-`o`v8j*l94_2*Ao7OKmE2`Nma3NA&YgWRVL@AH|8|Lo z-y^PUyYcSMs%Vkbj7rlgPVvQT|119Sx5fP4D+=zv-X)f*RPlS2$Ytjx*Kc`mckR;a zT`?*<_O<bvvb;}xEL*Z%?7}qeZNL8=cy{Mh#y7idU#?&HsGt;BGkqCri-g(L#-kf% zCELp$ow35=nvrPklHHR<+&$BKt{n4xr=V%;TyXr2L5)rJanE_{L>QzK=WOkq{${Gj zNiMc?^O?^nEr`A%##pMm!1(xrZG7&(pKa{@A6u@l{K%dE5A>#n3%W^*-hQ!U?ZHI# zC`-AeUo4(-rd2jvV%c`Fu|agx!IG=R`e95>E`NP11ea&3o(v9TPXBTKUG#IybCC{t zoqyVT_nY0>daK<toN<c@SHg_W@}ys_o>_ubk3Ko)#2)w-v*EVleD|&g``a!w?>k{r z=F((6bEQYYblZ2^j@!yS-}rsPdiz@sXS<&dI=kg|Tl-6e*1RQ>FD({V++-^`P<Tth zu2V3}q9NYt*t&Hpn<P}#Iav(c{AzlCxPJO+8_>Vsi@#~7#>aJOrLFD1<rdvux9Hxq zD$%Dk-UnUezUXcg*<xJPs1kofD#l4)Z}%j@T!tQ@iv4qY=AJ0r+VuMKwyE6znNTaB ztfK27JuD0iT$~IHy4Wiqr~Leq;*z4o0^h{Uyx@|=q7vAUMsHYjxKy~vzdjxwKlkPe z&kcc@rlNZsW-Z$mn4P@l822oVEH58@W|_n@2FdLQXWX0jOa0fa>HEy|XM~1d{{FA~ z&%|xNdBg=h!V3+H&+V(be=lAB&+GU1;~6XD?X@@_tZP!#IkiJQ+0#*AzGlR+E++nW z+7U-*Rjm2FQBj4{-YhleWQWF!L(G!=qB+U#ZkPIFAMR0?`~B$SiT?AVOFl##Yn1mt z@`;;Ou}1T;HrxF@d9ThfHLDBVO`kArjZXTGNf&(gg=#I?xp(za-bpONVQ$9XOrynr zuL>yoR5ej?)`mARHtE@s&By28y!Fv=`{VCAr!}p%+`Lj^{4!(P;kTA-`GGo;$CTJR zmEXE_OV66wtu7mFUR*5NnRhh2r1|{L3KMI0$*S8D#u`(ntPX43P!eC3_F_%Ob<^1w z(seFBTz+oSLeXwc@6$y>ZCY|_<&UbZJK3fd=m}(nAGvUO!fnycD^B}Q&fPOLRU*e= z!_S2Wjs5m4Qa;^yy0yA4MmsLP_{PspR>8`jCWrfF?;3R*?OPTm^D513;nXue^KR?S zeCQE8ch*er_FcDS&u%-ealo<r-UBtw8&b~ge%z{=Q{V8!7w&a>D<v*07{Zh6a+Jp| zX~(a&ONJ|Yr9`DJ85wD9dT{7}fSaGI+^#NV8&$oMqNJ&AM|-qR-l#3tzqHyQK;gim zTSu0xOwjU);A!Ok*!)FMH2&DeuKWP@;8ef#I~Oi9u~u4Xth6|2yeP=iKGxe_c6NnR zO|Il}t$B~5U%hv2nmg&`3)Z;zf`>m%3N_l4c)92hTj{NbiR$MMi*h}TI`iSzBfkjq z>_=<-Sg&1H6;!mTTWld0{84tF_=UOziU0F2yCfGfu3?;bedD*X726v<wtQ?^e>OJn zT+~&gi%ByTPABBrWh)u>@=m>X_IAwT&G)Bj-ZV3xdu!i%u~i4V4t*8hx%o;O8@uw^ z-~d_2iR&&eC@tm4cZtex$e4Zb&6&dGX4A`W|B%`8!{vW=)%v}j?&iz$=0*6w47r=> z6KvTy{ZfeQ#W2Cc8JBgoE4~zK;_JE4eOp5)S2AO!M}Fobu{|;We)&pfOq=NMSo|U* z=*YjarL{gR{JOJyW^rs=nJnG(^-ON_`^U1sR&qPk*d#oPTbMqhtgy<ss#^Wrfw&8c zntd4OYs(zj{Ut=3P2#A;-j^v4Y&Qv=TYu7T+4pZpu1H#KJNMAjv);k0a@pw*(;j-y zbDTFd?vVVXQ!jWt9hdfOPur`QAE3H>-IV3xcTXCvJM+uQ&TW#zDPzyy^W61g<}jVu zF#Ca(s??(WiC%V15~}ekZ=IXe8P<h4gfMnpwNTP~k?UgUm{5D;fXZ4Mk;i7s40t;i z^;|OdJ0iBy$o%DeCi%S3mtiIH6W*D5s!Xc!2z;TmF08j=qUnahzJx5J8`W+5jDDFf zkJGJ4TT++#LcGW4tM_)6t43^1;iq?eGp<p5pKtH^=6ZeHeB~)zeAhVkAGw{r<6rvT zZ_HD~TugjQ=c#F#XWBYHV7<!fC9SqY{_?%<yhWAlo1a{FHY=W?-c+0NopY@U<NCNs zyxRp9UFFW3=a1g5e*Pw+cohQ!!)*oz1|{spnkVXrfotzUu0sYqZU4`_d?q5ehb!)D z(#JikxtJXTzQk=eGV`*2Rbn@rUH(A3ko8naj+4{>{QO*VSDr!aMfHm+4vxA-+N!4h z9Ft$FJr6%OMdN0ocx(JAlj!uImd(nF5qFaUr_2mX=eIpwU2C{;#rGD+Eq@}<zIHwo zF?-6=Huazlr#>taXfu^M^dVV)r`OGIQ@VGk^!!`=EV$jFAb@>mi&)I*T<_AiH@@V& zKY%_oGI>|!i!a;^4D-ct_8>g-ic1o6av(j3x#5*HAy-BJ<)u|lp6=d|D4QZV!Qq6K zf`X%f5R;pNf?>jeF!ht%Jm=0x-```HV4j_sot+&XeNgY(s!ZLrNve*Iuk}W)y_=IA zecMZX_wBRWwr!hQ_k8cnlu0}<*4Lle`}}V8JIm*F>AOGwIL&Xvldv)Cq9K3n(i^S* zCqHCLzMJ&W*sAZrW~-7KzZJV%cex)9ocaFhhe}ztUr!#}E$nN(p#QmHjm-3i|AK59 z4hqOkdD>oL)8l^XgT_9E>Uf@q-bVG2%NMP0DNt%z&-HUg+xpfIJKEGsbPioFb@{kt zO}%qle%l9K-uu@+%oUi&^>DY+gK8_SkF}EXu6<<wW6&a>S>blL|LJRWt7#9GTZuis zDd2bNkFl)%aeb3NLC3vpmOl))3VXOypicHszSEDje%<xqUH2dJFZ%aW;Gf3l`7Rgd zoBnY<&h{s?P5jgc^FOg|^%)g`$JH7$CNnI2Jpa%KeO~>{AKUx7pB^y#<NoIV`Zs&l zJf70DZi<%TQU9eMHZ7~+T9~)meCmdzyIh;iqrc7jWm~q!I`P`~TN_JmZFwDi?fJKG z%_+x)_HJaJ`PEtdiXQ9X=p6s0$+6*DJ>JLX?0sz{X?%00L2hg1(Uv^zCkr1u`1vv9 zPUPYXF*~!b&s<xPTG(Bt@niOyyx_z?&niykoK>^-{XI#-T=dZFwd*31+|Tr#F3-F8 z{!MSXNSfHyIj1Z(x-_}HirpqzeCF%Np2Zh}cUH!~c@<H6s^rz}?c3LU+9$N}%Di7@ z$NQFl`!ip=d(YAxq5Bo*8Mv;V?DM{B`O|JbiM`hQW?#GU@!T5W?LlwLk~&oLr(4X> z>D|~<{nPMQ(eI`OO=Z3|ZwtAeu6-#dCm!XgC(Y@Ye?sQ_i>lxc7iNDipP9K)X|d-1 zLtlDcn!GpPy{XS(&)F@LKl-?piK>P5?P>k7+U3K1yDj%-ynShyySaL|<m)o#Bl8z1 zpPcqCWJX{?ckZ^UscA;NH!BV$hh(;TCQGKYKVQz1nQ_x9#o+rQR`sZ$zRcS<w<MQ| zZ|eD6kg;jf$%w9n`4diV+8$7r!>>C1n6dR^&1XXIAFhr$vWFvT=Cv6OVYhPCd^)9f zpSXK+Me3&5BxT>8&)1z|c7OY1w{7O5*fR0YGuKDAux`@a<(YU+V`1_`-Wi(5?F?EB z7OMuHU;On;%H}s69^q5=-~PHx?N8xkHD7Iui*rt?`C3n7c5ynw-JF@c^x5Ifr@iDe zJeO|f^EFTQY~7U@&3&!i_uj11w(z|tJbFJwA5@geP0f6J<<at&O@8Km8Y$(<GliK} z+)GP+t9N<xofE0$b2$tytYl(~YrZbEBc|={jxz^DJ2JI04g}6x=(OWrz*47|JLVnd zZZr#-X~c0Xqx@;o<$%W_I~N{X%~|3eYn5i*HtU3_7O!-c(7NkaQkb`|(iEAkUuGja zRXNzy^lZT8P?uoijA>S<1B?rqo0IptOe-*yJEM1e6aR$zX&$x9-@JY+q>!1oAbWA2 zsOg8gng&gioG0IMPIaoET^JC4W5>nbFByrMoqB6d==79Dr>V`_G$&*F)S{%1Ay@9q zUlz65Ix9Lx*34<gYY{b`)i-bL?5}Q{wf5PGsmg4852Tp$#U;L;tI!HBlU%gi`<>t; zn~cts>-Ux%&H1u6V%wR3K>qVP+h#34ckN1zbLa}zGw;kUFI@RENyL{wd~rs9s=2_N zl}EMvotAh!sH|>_TA}57S4nb}NWzM&&~+=NoUg7bs#@-`)-Ysl&RM(Soq;Q|Hf`$6 z6Mub1TWWt%^r4ii%c>V$I<ZJ6Ad>BCW5yo!sspFos*^R{=ge2_-+aC2*`M3@oWwK3 zmgyZeN?lP^+P6$hI;%4(Yen%@qjz7cM9&7CzRKl1cX^nRaQ8ARL4o{xYotuJo(g#G zJ!?%^_NN_vE6v+>IYfx9+WKbK;)VJ?k7{h56s;-n4v0^Gp!{RSLa9)PVBfZ=^|MU3 z9t@Da+RF3ka{1>y#WDOM2hN>3J4v{9sd}4J^3&D%?|+8bEZaK$sPXI1n$BBP@0WQB z^3D3~nYQHlj5lZAF!zP8Qw!;vxNzdpY~#tFXDdg$2E3Wx78-rz$wu`y>&z1yKSh?6 zU1T$M5=i8(s?AH8CwIakZPSK^eC7WIt#XM|!j;cuTv?)&#NiaRPw0|HSL~#1XKgOe zF51!DS94ah?1I2vhZ*`CZ(QN{x$9id)Du?AzPoW52~IXFTQt@6%KJJ~^Cwr;0&;?N zQkOoeNvbSb9wzqkU!Hxs$nCzE?EzOlM5jNR;d=5}#GRW7H}j@^o*3v?s~q)tOVbOf zn`z6%^KT`cT=H=3on+niur<}2f2U~ssBPz~P;}h<g86uD@`<ypJI|&>_gE$^I=6J; z_RyJ28jqj1iTtqYQAMa7Pwd=xi{tP0zs+@C|DcKYr0elpIbUa$P5%Ao>}!oDnyZ|X zTTQ;_zqRyzvUP|4^`7S|7wPZxko%&fzedy5T%w^md8Y2PTr>4ED%s3}I^HvX&%N{f zh1Y~`OSjBVUS%0Y*TwJU9Wnk;!YCm5?b8hQs0G@IoN1H0WS)Li6*>{Jb9dl{88JRQ z+pFL12;u9^(berPOVInj;~et?_lS9kOAdW9D1Lsr*f>6Ij;V&(e7(NAe|Cwfaum!9 zG-U`ay=FKi<g5)_eCS)lAFGxAC3DC;&ExcW=r|#nwN%GJQ*6<k`seB&`^#BEUpzdw zbDqkZgK-Cz9$|VKl;qs$-C1fkU8wrco&IF`?-{+n^w(-XjfpOmXENP-^)H7Ri|2Hi zV<LY04r}zY{9Y*QWFWN1eTLFMkA|FuY-f|TyEFc3*!J9QzF^&=C*5+<u%Xat`uF6T z3a0it9~p-oiXxm}lP{gCHnco0GVhRY*KDu0I-kWJ^`$B$_RD??aCWwwI5+2CD{Fh& zhY33KpL$Mfp7?+vZP%Vu-i1upA`h*qT=VeeCqb!7zsaqZ>n0uU;8VIKI8VBQ<Fi%G z)m+)SNd0{4zRm0g{{_Q6SqmkKE|mE^i{NH1<!P(hm1Q_BiBrn*-NNcg5pCNOE$461 zE|AbJl$QFy5%!QJ?6K#XgWWqAmTw5lj9C6`ab##>^XnUOFKqUUgex^p*rEPDDadol zk)um=mK;60WS!E}V$Io8?k_c3!c_C|Y^$@TqgOR&WRR3;eB<ialY8?RwBIb3*;lq# zAhdtt?5M&?in|^N{Bb|J_3FdcFAv17T6LW2d*B>#<so;t;6j5$t}9;_FUw`v%KNWl zzkDfgqsIdIukD8G4+uXO_%h4s&F>2)9Y<xGBQ7bv@n$c0$1u&5<?!if)^DP+ytg<% zc2w^%dw%@m@xpoP3%9<%Vq81p)ykZVw~HUge)@Cmmay`o)UO#w?{KewSTkk&ye9t# zWmRs^cE6N7zkavD)W@zzvV<qzIJ6{N^|)D5g`w?^x&LyLwYCZ$l|Aw{NXCWze7vLQ z^oM?G4+Srk8#DGB@v@(=Ji+wA#QVVJDf7O+zq;bs>km~)f74t(vQ>F6{v&d)!~CK; z@0TB2?{Egh30!}u8)N+{i2dk(3(F~A)MNi|+I4Y#zN%_@Ra2n4V4zZcd{Jw<`2IUh z0{b3VT)Wp@`ZwcFjBMVk<G&`|7W^RpQC70+^@i2S`j4&rRK6uzJ?*+1T&#NZa_$C& zz0FlOwm!KZ<9A+mOVFuHU0LS&uPsdTKdzk_`uRidjOeFrL1)*f_Nc18Df%z+Kar)z zo$pu3{gvq_tuk+PROShA>4XPPJsWb`;GoR4eL7h`_O^U@x;lY%=RMa0e@!y&?)6Gn zRyK!zwyjv7{i#cFN7#c}y%?{5=~bZu`WIw_GS@ohyjUT3z)gRWUe4OR@;RLC7u+5x zwYqOS$^G_hyMb?Bkg|Mq#q_!@@7`E{4VfBpye>!fh}p5PM`e{O*f!KM<o?~U<o%Uc zrG2$KE?i&O^SIRHv4Yx#a=~A@b{p3!u3O#tCMs@4dwA#NA0oWdv)3;?`B}14{)n&M zy=xalb!$%ST@)Z+rkup|_(R&g!|uFl+81?MwC4ZT{`ok5ij0VPf$x$~pD&LO24tIl z&T~Ir^j}wF{mQSt3$N~Z_W8@@rDs<3U7Y($t<OAJN%ZWJ6B@1Ojvwc;3OzcZQ#9uP zj_f4Xywq1yK0J|`cHIBcks_aDrMniVj#$UUmjB}q@MdHZVaB~0o&gL57~VR981S|6 z=-SZN#)A}t@RCMN94qCKP1ucPp*u)70|Ut7dC*Q8J{_QC?+6`-pgPjQ>(cd+HDX%? zkI?uQRU>RkJh}nsOX490Ffc4>RA7WG(TCa$Gr%3}5a@IbXsis<;X*eTeT6B)TunBt z=Hgv%if%gk+9ZVOzC2h>$Ffoh-Awe^cZ8Yy1+kim+OtMC4t>rGVcZNctj0lu6nk)@ z4`3opla$438t&mtbcdo3A|Q<ZporCIv>^p_^U%BM2=i_!VK)!C;~wD6$_CQG%fQQU Ml$n8nM<2uk00{J=h5!Hn literal 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..de72702 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Jun 08 11:31:31 CEST 2011 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://repo.gradle.org/gradle/distributions/gradle-1.0-milestone-3-bin.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..d8809f1 --- /dev/null +++ b/gradlew @@ -0,0 +1,168 @@ +#!/bin/bash + +############################################################################## +## ## +## Gradle wrapper script for UN*X ## +## ## +############################################################################## + +# Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together. +# GRADLE_OPTS="$GRADLE_OPTS -Xmx512m" +# JAVA_OPTS="$JAVA_OPTS -Xmx512m" + +GRADLE_APP_NAME=Gradle + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set JAVA_HOME if it's not already set. +if [ -z "$JAVA_HOME" ] ; then + if $darwin ; then + [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home" + [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" + else + javaExecutable="`which javac`" + [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME." + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME." + javaExecutable="`readlink -f \"$javaExecutable\"`" + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + export JAVA_HOME="$javaHome" + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"` + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain +CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar +WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties +# Determine the Java command to use to start the JVM. +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="java" + fi +fi +if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +if [ -z "$JAVA_HOME" ] ; then + warn "JAVA_HOME environment variable is not set" +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name +if $darwin; then + JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME" +# we may also want to set -Xdock:image +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +GRADLE_APP_BASE_NAME=`basename "$0"` + +exec "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \ + -classpath "$CLASSPATH" \ + -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \ + -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \ + $STARTER_MAIN_CLASS \ + "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..4855abb --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,82 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem ## +@rem Gradle startup script for Windows ## +@rem ## +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together. +@rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512m +@rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512m + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=.\ + +@rem Find java.exe +set JAVA_EXE=java.exe +if not defined JAVA_HOME goto init + +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. +echo. +goto end + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain +set CLASSPATH=%DIRNAME%\gradle\wrapper\gradle-wrapper.jar +set WRAPPER_PROPERTIES=%DIRNAME%\gradle\wrapper\gradle-wrapper.properties + +set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%" + +@rem Execute Gradle +"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1 + +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit "%ERRORLEVEL%" +exit /b "%ERRORLEVEL%" + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega \ No newline at end of file diff --git a/src/main/java/org/sablecc/sablecc/AcceptStates.java b/src/main/java/org/sablecc/sablecc/AcceptStates.java new file mode 100644 index 0000000..7bdfe11 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/AcceptStates.java @@ -0,0 +1,59 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; + +public class AcceptStates extends DepthFirstAdapter +{ + public DFA dfa; + public String stateName; + private ResolveIds ids; + + public AcceptStates(DFA dfa, ResolveIds ids, String stateName) + { + this.dfa = dfa; + this.ids = ids; + this.stateName = stateName; + } + + public void caseStart(Start node) + { + for(int i = 0; i < dfa.states.size(); i++) + { + DFA.State state = (DFA.State) dfa.states.elementAt(i); + state.accept = -1; + + int accept = -1; + + for(int k = 0; k < state.nfaStates.size(); k++) + { + if(state.nfaStates.get(k)) + { + if(dfa.nfa.states[k].accept != null) + { + if(accept == -1) + { + accept = ids.tokenList.indexOf(dfa.nfa.states[k].accept); + } + else + { + accept = Math.min( + ids.tokenList.indexOf(dfa.nfa.states[k].accept), + accept); + } + } + } + } + + state.accept = accept; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/AddAstProductions.java b/src/main/java/org/sablecc/sablecc/AddAstProductions.java new file mode 100644 index 0000000..3238138 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/AddAstProductions.java @@ -0,0 +1,107 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +/* + * AddAstProductions + * + * This class provide a part of the support of SableCC2.x.x grammars by + * SableCC3.x.x. + * Its role is to add the section Abstract Syntax Tree and its productions + * to the Grammar based on the Production Section. + * It's the same result if a copy-paste of Productions section was added + * to the SableCC2.x.x original grammar and renammed Abstract Syntax Tree. + */ + +public class AddAstProductions extends DepthFirstAdapter +{ + + LinkedList listAstProd = new TypedLinkedList(); + private boolean firstAlt; + + public AddAstProductions() + {} + + public void caseAProd(AProd node) + { + firstAlt = true; + listOfAstAlts = new TypedLinkedList(); + + /* + * Here, we assume that if there is no Abstract Syntax Tree Section specified + * in the grammar, no transformations syntax is allowed in Productions section + */ + if(node.getArrow() != null) + { + error(node.getArrow()); + } + + Object []list_alt = (Object[]) node.getAlts().toArray(); + for(int i=0; i<list_alt.length; i++) + { + ((PAlt)list_alt[i]).apply(this); + } + + AAstProd astProd = new AAstProd(new TId(node.getId().getText()), listOfAstAlts); + listAstProd.add(astProd); + } + + public void outAGrammar(AGrammar node) + { + node.setAst(new AAst(listAstProd)); + } + + public void inAAlt(AAlt node) + { + listElems = new TypedLinkedList(); + processingParsedAlt = true; + } + + public void inAAltTransform(AAltTransform node) + { + if(node.getLBrace() != null) + { + error(node.getLBrace()); + } + } + + public void outAAlt(AAlt node) + { + TId aAltname = node.getAltName() == null ? null : (TId)node.getAltName().clone(); + AAstAlt astAlt = new AAstAlt(aAltname, listElems); + + listOfAstAlts.add(astAlt); + processingParsedAlt = false; + } + + boolean processingParsedAlt; + + public void inAElem(AElem node) + { + if(processingParsedAlt) + { + AElem tmp = (AElem)node.clone(); + listElems.add(tmp); + } + } + + LinkedList listElems; + LinkedList listOfAstAlts; + + public void error(Token token) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "AST transformations are not allowed because there are no section Abstract Syntax Tree"); + } +} diff --git a/src/main/java/org/sablecc/sablecc/AddEventualEmptyTransformationToProductions.java b/src/main/java/org/sablecc/sablecc/AddEventualEmptyTransformationToProductions.java new file mode 100644 index 0000000..3c0d404 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/AddEventualEmptyTransformationToProductions.java @@ -0,0 +1,81 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +/* + * AddEventualEmptyTransformationToProductions + * + * This class provide the second part of the support by SableCC3.x.x + * for SableCC2.x.x grammars. + * Its role is to add Productions and Alternatives transformations within + * Productions section. + * Assuming this is run after the eventual AddAstProductions it also add + * default transformations to productions and alternatives which have not + * not specified them. + */ + +public class AddEventualEmptyTransformationToProductions extends DepthFirstAdapter +{ + private String currentProd; + private String currentAlt; + + private ResolveIds ids; + private ResolveAstIds ast_ids; + + public AddEventualEmptyTransformationToProductions(ResolveIds ids, ResolveAstIds ast_ids) + { + this.ids = ids; + this.ast_ids = ast_ids; + } + + public void inAProd(AProd node) + { + currentProd = (String)ids.names.get(node); + + /* If there is no transformation specified for the production + * and there is no AST production which has the same name as the current + * CST production, this production is transformed into an empty + */ + if(node.getArrow() == null && ast_ids.ast_prods.get(currentProd) == null ) + { + node.setArrow(new TArrow(node.getId().getLine(), node.getId().getPos()+node.getId().getText().length() )); + node.setProdTransform(new LinkedList()); + + AAlt []alts = (AAlt[]) node.getAlts().toArray(new AAlt[0]); + + for(int i=0; i<alts.length; i++) + { + alts[i].apply( new DepthFirstAdapter() + { + public void inAAlt(AAlt node) + { + if(node.getAltTransform() != null && ((AAltTransform)node.getAltTransform()).getTerms().size() > 0) + { + error(((AAltTransform)node.getAltTransform()).getLBrace()); + } + node.setAltTransform( new AAltTransform(new TLBrace(), new LinkedList(), new TRBrace()) ); + } + } + ); + } + } + } + + private static void error(Token token) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "This alternative transformation should be transformed to {-> } " ); + } + +} diff --git a/src/main/java/org/sablecc/sablecc/AddProdTransformAndAltTransform.java b/src/main/java/org/sablecc/sablecc/AddProdTransformAndAltTransform.java new file mode 100644 index 0000000..336a94e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/AddProdTransformAndAltTransform.java @@ -0,0 +1,144 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +/* + * AddProdTransformAndAltTransform + * + * This class provide the second part of the support by SableCC3.x.x + * for SableCC2.x.x grammars. + * Its role is to add Productions and Alternatives transformations within + * Productions section. + * Assuming this is run after the eventual AddAstProductions it also add + * default transformations to productions and alternatives which have not + * not specified them. + */ + +public class AddProdTransformAndAltTransform extends DepthFirstAdapter +{ + + private String currentProdId; + private String currentAlt; + + public void inAProd(final AProd production) + { + currentProdId = production.getId().getText(); + + if(production.getArrow() == null) + { + AElem elem = new AElem(null, new AProductionSpecifier(), new TId(currentProdId), null); + LinkedList listOfProdTransformElem = new LinkedList(); + listOfProdTransformElem.add(elem); + production.setProdTransform(listOfProdTransformElem); + production.setArrow(new TArrow()); + } + } + + private int i; + private LinkedList list; + + public void inAAlt(AAlt alt) + { + if(alt.getAltTransform() == null) + { + currentAlt = currentProdId; + list = new LinkedList(); + AProdName aProdName = new AProdName(new TId(currentProdId), null); + + if(alt.getAltName() != null) + { + aProdName.setProdNameTail( new TId(alt.getAltName().getText()) ); + } + + if( alt.getElems().size() > 0 ) + { + Object temp[] = alt.getElems().toArray(); + + for(i = 0; i < temp.length; i++) + { + ((PElem) temp[i]).apply(new DepthFirstAdapter() + { + public void caseAElem(AElem elem) + { + PTerm term; + String termId; + boolean elemNameExplicitelySpecified = false; + + if(elem.getElemName() != null) + { + termId = elem.getElemName().getText(); + elemNameExplicitelySpecified = true; + } + else + { + termId = elem.getId().getText(); + } + + if( (elem.getUnOp() != null) && + ( (elem.getUnOp() instanceof AStarUnOp) || (elem.getUnOp() instanceof APlusUnOp) ) ) + { + LinkedList listP = new LinkedList(); + if( !elemNameExplicitelySpecified && (elem.getSpecifier()!= null) ) + { + if(elem.getSpecifier() instanceof ATokenSpecifier) + { + listP.add( new ASimpleListTerm(new ATokenSpecifier(), new TId(termId), null ) ); + term = new AListTerm(new TLBkt(), listP); + } + else + { + listP.add( new ASimpleListTerm(new AProductionSpecifier(), new TId(termId), null ) ); + term = new AListTerm(new TLBkt(), listP); + } + } + else + { + listP.add( new ASimpleListTerm(null, new TId(termId), null) ); + term = new AListTerm(new TLBkt(), listP); + } + } + else + { + if( !elemNameExplicitelySpecified && (elem.getSpecifier()!= null) ) + { + + if(elem.getSpecifier() instanceof ATokenSpecifier) + { + term = new ASimpleTerm( new ATokenSpecifier(), new TId(termId), null); + } + else + { + term = new ASimpleTerm( new AProductionSpecifier(), new TId(termId), null); + } + } + else + { + term = new ASimpleTerm( null, new TId(termId), null); + } + } + + list.add(term); + } + } + ); + } + } + + ANewTerm newTerm = new ANewTerm(aProdName, new TLPar(), list); + LinkedList lst = new LinkedList(); + lst.add(newTerm); + + alt.setAltTransform(new AAltTransform(new TLBrace(), lst, new TRBrace())); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/AltTransformAdapter.java b/src/main/java/org/sablecc/sablecc/AltTransformAdapter.java new file mode 100644 index 0000000..fc12732 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/AltTransformAdapter.java @@ -0,0 +1,143 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.io.*; + +public class AltTransformAdapter extends DepthFirstAdapter +{ + ResolveAltIds altIds; + String currentNewAltName; + + private Map isElementIsAlist; + + private LinkedList listSimpleTermTransform; + private Map simpleTermTransform; + private Map simpleTermOrsimpleListTermTypes; + + AltTransformAdapter(Map simpleTermTransform, + LinkedList listSimpleTermTransform, + String currentNewAltName, + ResolveAltIds altIds, Map isElementIsAlist, + Map simpleTermOrsimpleListTermTypes) + { + this.currentNewAltName = currentNewAltName; + this.altIds = altIds; + this.isElementIsAlist = isElementIsAlist; + this.listSimpleTermTransform = listSimpleTermTransform; + this.simpleTermTransform = simpleTermTransform; + this.simpleTermOrsimpleListTermTypes = simpleTermOrsimpleListTermTypes; + } + + public void inASimpleTerm(ASimpleTerm node) + { + String name = node.getId().getText(); + + if( !((LinkedList)altIds.alts_elems.get(currentNewAltName)).contains(name) && + !((LinkedList)altIds.alts_elems.get(currentNewAltName)).contains("$"+name) ) + { + node.replaceBy( new ANullTerm() ); + } + + if( isElementIsAlist.get(currentNewAltName+name) != null ) + { + TId simpleTermTail; + if(node.getSimpleTermTail() != null) + { + simpleTermTail = node.getSimpleTermTail(); + } + else + { + simpleTermTail = new TId( (String)isElementIsAlist.get(currentNewAltName+name) ); + } + + ASimpleTerm asimpleTerm = new ASimpleTerm( node.getSpecifier(), node.getId(), simpleTermTail); + + if(simpleTermOrsimpleListTermTypes.get(node) != null) + { + simpleTermOrsimpleListTermTypes.put(asimpleTerm, (String)simpleTermOrsimpleListTermTypes.get(node)); + } + + node.replaceBy(asimpleTerm); + simpleTermTransform.put(asimpleTerm, "L"+ResolveIds.name((String)isElementIsAlist.get(currentNewAltName+name)) ); + + //Terms are added here only if they were implicitely transformed + listSimpleTermTransform.add( asimpleTerm ); + } + } + + public void inASimpleListTerm(ASimpleListTerm node) + { + String name = node.getId().getText(); + + if( !((LinkedList)altIds.alts_elems.get(currentNewAltName)).contains(name) && + !((LinkedList)altIds.alts_elems.get(currentNewAltName)).contains("$"+name) ) + { + node.replaceBy( null ); + } + + if( isElementIsAlist.get(currentNewAltName+name) != null) + { + TId simpleTermTail; + if(node.getSimpleTermTail() != null) + { + simpleTermTail = node.getSimpleTermTail(); + } + else + { + simpleTermTail = new TId((String)isElementIsAlist.get(currentNewAltName+name)); + } + + TId tid; + tid = ( ((LinkedList)altIds.alts_elems_list_elemName.get(currentNewAltName)).contains(name) ? + node.getId() : new TId( "$" + node.getId().getText() ) ); + + ASimpleListTerm asimpleListTerm = new ASimpleListTerm( node.getSpecifier(), tid, simpleTermTail); + + if(simpleTermOrsimpleListTermTypes.get(node) != null) + { + simpleTermOrsimpleListTermTypes.put(asimpleListTerm, (String)simpleTermOrsimpleListTermTypes.get(node)); + } + + node.replaceBy(asimpleListTerm); + simpleTermTransform.put(asimpleListTerm, "L"+ResolveIds.name((String)isElementIsAlist.get(currentNewAltName+name) )); + + //Terms are added here only if they were implicitely transformed + listSimpleTermTransform.add( asimpleListTerm ); + } + } + + public void outAListTerm(AListTerm node) + { + if( (node.getListTerms() != null) && (node.getListTerms().size() > 0) ) + { + Object[] temp = node.getListTerms().toArray(); + + if(simpleTermTransform.get(temp[0]) != null) + { + String firstTermType = (String)simpleTermTransform.get(temp[0]); + + if(firstTermType != null) + { + if(!firstTermType.startsWith("L")) + { + simpleTermTransform.put(node, "L" + firstTermType); + } + else + { + simpleTermTransform.put(node, firstTermType); + } + } + } + } + } + +} diff --git a/src/main/java/org/sablecc/sablecc/AlternativeElementTypes.java b/src/main/java/org/sablecc/sablecc/AlternativeElementTypes.java new file mode 100644 index 0000000..1c74f44 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/AlternativeElementTypes.java @@ -0,0 +1,68 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +public class AlternativeElementTypes extends DepthFirstAdapter +{ + private Map altElemTypes = new TypedHashMap(StringCast.instance, + StringCast.instance); + + private ResolveIds ids; + private String currentAlt; + + public AlternativeElementTypes(ResolveIds ids) + { + this.ids = ids; + } + + public Map getMapOfAltElemType() + { + return altElemTypes; + } + + public void caseAAst(AAst node) + {} + + public void caseAProd(final AProd production) + { + Object []temp = production.getAlts().toArray(); + for(int i = 0; i<temp.length; i++) + { + ((PAlt)temp[i]).apply(this); + } + } + + public void caseAAlt(AAlt node) + { + currentAlt = (String)ids.names.get(node); + Object []temp = node.getElems().toArray(); + for(int i = 0; i<temp.length; i++) + { + ((PElem)temp[i]).apply(this); + } + } + + public void inAElem(AElem node) + { + String elemType = (String)ids.elemTypes.get(node); + + if(node.getElemName() != null) + { + altElemTypes.put(currentAlt+"."+node.getElemName().getText(), elemType ); + } + else + { + altElemTypes.put(currentAlt+"."+node.getId().getText(), elemType ); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/BooleanCast.java b/src/main/java/org/sablecc/sablecc/BooleanCast.java new file mode 100644 index 0000000..b14570e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/BooleanCast.java @@ -0,0 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class BooleanCast implements Cast +{ + public final static BooleanCast instance = new BooleanCast(); + + private BooleanCast() + {} + + public Object cast(Object o) + { + return (Boolean) o; + } +} diff --git a/src/main/java/org/sablecc/sablecc/Cast.java b/src/main/java/org/sablecc/sablecc/Cast.java new file mode 100644 index 0000000..3c17b13 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/Cast.java @@ -0,0 +1,13 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +public interface Cast +{ + Object cast(Object o); +} diff --git a/src/main/java/org/sablecc/sablecc/CharSet.java b/src/main/java/org/sablecc/sablecc/CharSet.java new file mode 100644 index 0000000..b43bd7b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/CharSet.java @@ -0,0 +1,226 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import java.util.Enumeration; +import java.util.Vector; + +public class CharSet implements Cloneable +{ + private final Vector intervals = new Vector(0); + + public CharSet(char c) + { + intervals.addElement(new Interval(c, c)); + } + + public CharSet(char start, char end) + { + intervals.addElement(new Interval(start, end)); + } + + private CharSet(Vector intervals) + { + for(Enumeration e = intervals.elements(); e.hasMoreElements();) + { + this.intervals.addElement(((Interval) e.nextElement()).clone()); + } + } + + public Object clone() + { + return new CharSet(intervals); + } + + public Interval findOverlap(Interval interval1) + { + int low = 0; + int high = intervals.size() - 1; + Interval interval2; + Interval result = null; + + while(high >= low) + { + int middle = (high + low) / 2; + + interval2 = (Interval) intervals.elementAt(middle); + + if(interval1.start <= interval2.end) + { + if(interval1.end >= interval2.start) + { + result = interval2; + // we continue, to find the lowest matching interval! + } + + high = middle - 1; + } + else + { + low = middle + 1; + } + } + + return result; + } + + private void remove + (Interval interval) + { + intervals.removeElement(interval); + } + + private void add + (Interval interval) + { + for(int i = 0; i < intervals.size(); i++) + { + Interval iv = (Interval) intervals.elementAt(i); + + if(iv.start > interval.start) + { + intervals.insertElementAt(interval, i); + return; + } + } + + intervals.addElement(interval); + } + + public CharSet union(CharSet chars) + { + CharSet result = (CharSet) clone(); + + Interval interval; + Interval largeInterval; + Interval overlap; + + for(Enumeration e = chars.intervals.elements(); e.hasMoreElements();) + { + interval = (Interval) ((Interval) e.nextElement()).clone(); + + do + { + largeInterval = new Interval( + (interval.start == 0) ? (char) 0 : (char) (interval.start - 1), + (interval.end == 0xffff) ? (char) 0xffff : (char) (interval.end + 1)); + + overlap = result.findOverlap(largeInterval); + if(overlap != null) + { + result.remove(overlap); + interval.start = (char) Math.min(interval.start, overlap.start); + interval.end = (char) Math.max(interval.end, overlap.end); + } + } + while(overlap != null); + + result.add(interval); + } + + return result; + } + + public CharSet diff(CharSet chars) + { + CharSet result = (CharSet) clone(); + + Interval interval; + Interval overlap; + + for(Enumeration e = chars.intervals.elements(); e.hasMoreElements();) + { + interval = (Interval) ((Interval) e.nextElement()).clone(); + + do + { + overlap = result.findOverlap(interval); + if(overlap != null) + { + result.remove(overlap); + if(overlap.start < interval.start) + { + result.add(new Interval(overlap.start, (char) (interval.start - 1))); + } + if(overlap.end > interval.end) + { + result.add(new Interval((char) (interval.end + 1), overlap.end)); + } + } + } + while(overlap != null); + } + + return result; + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + + for(Enumeration e = intervals.elements(); e.hasMoreElements();) + { + result.append("[" + e.nextElement() + "] "); + } + + return "" + result; + } + + public static class Interval implements Cloneable + { + public Interval(char start, char end) + { + this.start = start; + this.end = end; + } + + public Object clone() + { + return new Interval(start, end); + } + + private String c(char c) + { + if((c >= 32) && (c < 127)) + { + return "" + c; + } + + return "" + ((int) c); + } + + public String toString() + { + if(start < end) + { + return c(start) + " .. " + c(end); + } + else + { + return c(start); + } + } + + public char start; + public char end; + } + + public static class IntervalCast implements Cast + { + public final static IntervalCast instance = new IntervalCast(); + + private IntervalCast() + {} + + public Object cast(Object o) + { + return (Interval) o; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/ComputeCGNomenclature.java b/src/main/java/org/sablecc/sablecc/ComputeCGNomenclature.java new file mode 100644 index 0000000..4452150 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ComputeCGNomenclature.java @@ -0,0 +1,329 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Last Modification date :: 04-February-2004 + * Add termtail to simple term and simple listterm + * in order to support scripting generation for parser by + * the new scripting engine. + * + * Fix bug related to code generation. + * Method #public void caseASimpleTerm(ASimpleTerm node)# + * and #public void caseASimpleTerm(ASimpleTerm node)# + * were rewrite. The type of simpleTerm was the problem. +*/ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +public class ComputeCGNomenclature extends DepthFirstAdapter +{ + private String currentProd; + private String currentAlt; + private int counter; + private ResolveIds ids; + private ResolveProdTransformIds prodTransformIds; + private Map altElemTypes; + + private final Map altTransformElemTypes = new TypedHashMap( + NodeCast.instance, + StringCast.instance); + + private final Map termNumbers = new TypedHashMap(NodeCast.instance, + IntegerCast.instance); + + public ComputeCGNomenclature(ResolveIds ids, ResolveProdTransformIds prodTransformIds) + { + this.ids = ids; + this.prodTransformIds = prodTransformIds; + } + + public void setAltElemTypes(Map aMap) + { + this.altElemTypes = aMap; + } + + public Map getAltTransformElemTypes() + { + return altTransformElemTypes; + } + + public Map getTermNumbers() + { + return termNumbers; + } + + public void caseAProd(final AProd production) + { + currentProd = "P" + ids.name(production.getId().getText()); + Object []temp = production.getAlts().toArray(); + for(int i = 0; i<temp.length; i++) + { + ((PAlt)temp[i]).apply(this); + } + } + + public void inAAlt(AAlt nodeAlt) + { + counter = 0; + + if(nodeAlt.getAltName() != null) + { + currentAlt = "A"+ + ids.name( nodeAlt.getAltName().getText() )+ + currentProd.substring(1); + } + else + { + currentAlt = "A" + currentProd.substring(1); + } + + counter = 0; + } + + public void caseAAst(AAst node) + {} + + public void inAElem(AElem node) + { + String elemType = (String)ids.elemTypes.get(node); + + if(node.getElemName() != null) + { + ids.altsElemNameTypes.put(currentAlt+"."+node.getElemName().getText(), elemType ); + } + } + + public void inANewTerm(ANewTerm node) + { + AProdName aProdName = (AProdName)node.getProdName(); + String type = "P" + ids.name(aProdName.getId().getText()); + + altTransformElemTypes.put(node, type); + termNumbers.put(node, new Integer(++counter)); + } + + public void inANewListTerm(ANewListTerm node) + { + AProdName aProdName = (AProdName)node.getProdName(); + String type = "P" + ids.name(aProdName.getId().getText()); + + altTransformElemTypes.put(node, type); + termNumbers.put(node, new Integer(++counter)); + } + + public void outAListTerm(AListTerm node) + { + if( node.getListTerms().size() > 0 ) + { + Object[] temp = node.getListTerms().toArray(); + + String firstTermType = (String)altTransformElemTypes.get(temp[0]); + + if(firstTermType != null) + { + if(!firstTermType.startsWith("L")) + { + altTransformElemTypes.put(node, "L" + firstTermType); + } + else + { + altTransformElemTypes.put(node, firstTermType); + } + } + } + else + { + altTransformElemTypes.put(node, "Lnull"); + } + termNumbers.put(node, new Integer(++counter)); + } + + public void caseASimpleTerm(ASimpleTerm node) + { + String name; + String elemType = (String) this.altElemTypes.get( currentAlt+"."+node.getId().getText() ); + + if(node.getSimpleTermTail() == null) + { + name = elemType; + if(name.startsWith("P") ) + { + //add termtail to the simpleterm + node.setSimpleTermTail( (TId)node.getId().clone() ); + } + } + else + { + String termTail = node.getSimpleTermTail().getText(); + name = (String)prodTransformIds.prodTransformElemTypesString.get(elemType+"."+termTail); + } + + if(name.endsWith("?")) + { + name = name.substring(0, name.length()-1); + } + + altTransformElemTypes.put(node, name); + termNumbers.put(node, new Integer(++counter)); + } + + /* + public void caseASimpleTerm(ASimpleTerm node) + { + String name; + String elemType = (String)altElemTypes.get( currentAlt+"."+node.getId().getText() ); + + if( ( (elemType != null) && elemType.startsWith("T") ) || + ( (elemType == null) && ids.tokens.get("T" + ids.name(node.getId().getText())) != null ) ) + { + if(elemType != null) + { + name = elemType; + } + else + { + name = "T" + ids.name(node.getId().getText()); + } + } + else + { + if(node.getSimpleTermTail() == null) + { + if(elemType != null) + { + name = elemType; + } + else + { + name = "P" + ids.name(node.getId().getText()); + } + + //add termtail to the simpleterm + node.setSimpleTermTail( (TId)node.getId().clone() ); + } + else + { + String prodType; + if(elemType != null) + { + prodType = elemType; + } + else + { + prodType = "P" + ids.name(node.getId().getText()); + } + + String termTail = node.getSimpleTermTail().getText(); + name = (String)prodTransformIds.prodTransformElemTypesString.get(prodType+"."+termTail); + } + } + + if(name.endsWith("?")) + { + name = name.substring(0, name.length()-1); + } + altTransformElemTypes.put(node, name); + termNumbers.put(node, new Integer(++counter)); + } + */ + public void caseANullTerm(ANullTerm node) + { + altTransformElemTypes.put(node, "null"); + termNumbers.put(node, new Integer(++counter)); + } + + public void caseASimpleListTerm(ASimpleListTerm node) + { + String name; + String elemType = (String)altElemTypes.get( currentAlt+"."+node.getId().getText() ); + + if(node.getSimpleTermTail() == null) + { + name = elemType; + if( name.startsWith("P") ) + { + //add termtail to the simpleterm + node.setSimpleTermTail( (TId)node.getId().clone() ); + } + } + else + { + String termTail = node.getSimpleTermTail().getText(); + name = (String)prodTransformIds.prodTransformElemTypesString.get(elemType+"."+termTail); + } + + if(name.endsWith("?")) + { + name = name.substring(0, name.length()-1); + } + altTransformElemTypes.put(node, name); + termNumbers.put(node, new Integer(++counter)); + } + /* + public void caseASimpleListTerm(ASimpleListTerm node) + { + String name; + String elemType = (String)altElemTypes.get( currentAlt+"."+node.getId().getText() ); + + if( ( (elemType != null) && elemType.startsWith("T") ) || + ( (elemType == null) && ids.tokens.get("T" + ids.name(node.getId().getText())) != null ) ) + { + if(elemType != null) + { + name = elemType; + } + else + { + name = "T" + ids.name(node.getId().getText()); + } + } + //it seems to be a production without a specifier + else + { + if(node.getSimpleTermTail() == null) + { + if(elemType != null) + { + name = elemType; + } + else + { + name = "P" + ids.name(node.getId().getText()); + } + + //add termtail to the simpleterm + node.setSimpleTermTail( (TId)node.getId().clone() ); + } + else + { + String prodType; + if(elemType != null) + { + prodType = elemType; + } + else + { + prodType = "P" + ids.name(node.getId().getText()); + } + String termTail = node.getSimpleTermTail().getText(); + name = (String)prodTransformIds.prodTransformElemTypesString.get(prodType+"."+termTail); + } + } + if(name.endsWith("?")) + { + name = name.substring(0, name.length()-1); + } + altTransformElemTypes.put(node, name); + termNumbers.put(node, new Integer(++counter)); + } + */ +} diff --git a/src/main/java/org/sablecc/sablecc/ComputeInlining.java b/src/main/java/org/sablecc/sablecc/ComputeInlining.java new file mode 100644 index 0000000..7926289 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ComputeInlining.java @@ -0,0 +1,176 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; + +/* + * Last Modification date : 23 07 2004 + * fix bug : when an inlining of a production does not resolve a conflict + * the associated alternatives transformation should not be transformed. + * The bug was about transforming this instead. +*/ + +/* + * ComputeInlining + * This class takes SableCC grammar represented by the tree + * and a list of production to inline within this grammar and + * try to inline those productions. + */ + +public class ComputeInlining +{ + //Productions implied in a conflict + private Set setOfProdToBeInline; + + //Map of all productions in the grammar + private Map productionsMap; + private Start tree; + + public ComputeInlining(Set set + , + Map productionsMap, + Start tree) + { + this.setOfProdToBeInline = set + ; + this.productionsMap = productionsMap; + this.tree = tree; + } + + /** + * This method compute the inline of a all productions implied in a conflict + * in the grammar. + * It returns : + * -- true if at least one production is inlined with success + * -- and false otherwise. + */ + public boolean computeInlining() + { + final BooleanEx atLeastOneProductionInlined = new BooleanEx(false); + String []nameOfProds = (String[])setOfProdToBeInline.toArray(new String[0]); + + for(int i=0; i<nameOfProds.length; i++) + { + final AProd prod = (AProd)productionsMap.get(nameOfProds[i]); + + //We proceed inlining only if the production to inline is not recursive + //and if it doesn't have more than SableCC.inliningMaxAlts alternatives. + if( prod.getAlts().size() <= SableCC.inliningMaxAlts && !isProductionRecursive(prod) ) + { + //This class construct a special data structure for the production to inline. + final In_Production in_production = new In_Production((AProd)prod.clone()); + + tree.apply(new DepthFirstAdapter() + { + public void caseAProd(AProd node) + { + //We do not inline the production itself. + if(node.getId().getText().equals(prod.getId().getText())) + { + return; + } + + Inlining inliningClass = new Inlining(node, in_production); + + //The proper inlining is done here(method inlineProduction) + if( inliningClass.inlineProduction() && !atLeastOneProductionInlined.getValue()) + { + atLeastOneProductionInlined.setValue(true); + } + } + } + ); + } + } + + LinkedList listOfGrammarProds = ((AProductions)((AGrammar)tree.getPGrammar()).getProductions()).getProds(); + + //Once the production is inlined, we do not need it anymore, so we remove it from the grammar. + String[] inlinedProductionsToRemove = (String[])Inlining.productionsToBeRemoved.toArray(new String[0]); + for(int i=0; i<inlinedProductionsToRemove.length; i++) + { + listOfGrammarProds.remove(productionsMap.get(inlinedProductionsToRemove[i]) ); + } + + Inlining.productionsToBeRemoved.clear(); + return atLeastOneProductionInlined.getValue(); + } + + /* + * A production is recursive if one of its alternatives contains an occurrence + * of itself. + */ + public boolean isProductionRecursive(final AProd production) + { + final BooleanEx recursive = new BooleanEx(false); + final String currentProdName = production.getId().getText(); + + production.apply(new DepthFirstAdapter() + { + public void caseAProd(AProd node) + { + Object temp[] = node.getAlts().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PAlt) temp[i]).apply(this); + } + } + + public void caseAAlt(AAlt node) + { + Object temp[] = node.getElems().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PElem) temp[i]).apply(this); + } + } + + public void caseAElem(AElem node) + { + if(node.getId().getText().equals(currentProdName)) + { + if(node.getSpecifier() != null && node.getSpecifier() instanceof ATokenSpecifier) + { + return; + } + recursive.setValue(true); + } + } + } + ); + return recursive.getValue(); + } + + /* This class is used to simulate final Boolean. + * Since final variable cannot be assigned value more than + * one time, we need another class which boolean value field + * can be changed so often as necessary. + */ + class BooleanEx + { + boolean value; + + BooleanEx(boolean value) + { + this.value = value; + } + + void setValue(boolean value) + { + this.value = value; + } + + boolean getValue() + { + return value; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/ComputeSimpleTermPosition.java b/src/main/java/org/sablecc/sablecc/ComputeSimpleTermPosition.java new file mode 100644 index 0000000..792f9c4 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ComputeSimpleTermPosition.java @@ -0,0 +1,107 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +public class ComputeSimpleTermPosition extends DepthFirstAdapter +{ + String currentAlt; + String currentProd; + boolean processingParsedAlt; + private ResolveIds ids; + private int counter; + + public final Map positionsMap = new TypedHashMap( + StringCast.instance, + StringCast.instance); + + public final Map elems_position = new TypedHashMap( + StringCast.instance, + IntegerCast.instance); + + public ComputeSimpleTermPosition(ResolveIds ids) + { + this.ids = ids; + } + + public void inAProd(AProd node) + { + currentProd = ids.name(node.getId().getText()); + ids.names.put(node, currentProd); + } + + public void inAAlt(AAlt node) + { + counter = 0; + processingParsedAlt = true; + + if(node.getAltName() != null) + { + currentAlt = "A" + + ids.name( node.getAltName().getText() ) + + currentProd; + } + else + { + currentAlt = "A" + currentProd; + } + + ids.names.put(node, currentAlt); + } + + public void inAElem(AElem node) + { + if(processingParsedAlt) + { + String currentElemName; + if(node.getElemName() != null) + { + currentElemName = currentAlt + "." + node.getElemName().getText(); + } + else + { + currentElemName = currentAlt + "." + node.getId().getText(); + } + + elems_position.put(currentElemName, new Integer(++counter)); + } + + if(node.getSpecifier() != null && + node.getSpecifier() instanceof ATokenSpecifier) + { + return; + } + + String name = ids.name( node.getId().getText() ); + + String elemType = (String)ids.elemTypes.get(node); + if(processingParsedAlt && elemType.startsWith("P")) + { + String elemName; + if(node.getElemName() != null) + { + elemName = node.getElemName().getText(); + } + else + { + elemName = node.getId().getText(); + } + + positionsMap.put(currentAlt+"."+elemName, elemType); + } + } + + public void outAAlt(AAlt node) + { + processingParsedAlt = false; + } +} diff --git a/src/main/java/org/sablecc/sablecc/ConflictException.java b/src/main/java/org/sablecc/sablecc/ConflictException.java new file mode 100644 index 0000000..9dc3a37 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ConflictException.java @@ -0,0 +1,27 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.node.*; +import java.util.Set; + +public class ConflictException extends Exception +{ + private Set conflictualProductions; + + public ConflictException(Set conflictualProductions, String message) + { + super(message); + this.conflictualProductions = conflictualProductions; + } + + public Set getConflictualProductions() + { + return conflictualProductions; + } +} diff --git a/src/main/java/org/sablecc/sablecc/ConstructNFA.java b/src/main/java/org/sablecc/sablecc/ConstructNFA.java new file mode 100644 index 0000000..33c65ec --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ConstructNFA.java @@ -0,0 +1,417 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; + +public class ConstructNFA extends DepthFirstAdapter +{ + private ResolveIds ids; + private String stateName; + + private int i; + + ConstructNFA(ResolveIds ids, String stateName) + { + this.ids = ids; + this.stateName = stateName; + } + + public void outStart(Start node) + { + setOut(node, getOut(node.getPGrammar())); + + // free memory + if(getOut(node.getPGrammar()) != null) + setOut(node.getPGrammar(), null); + } + + public void outAGrammar(AGrammar node) + { + setOut(node, getOut(node.getTokens())); + + // free memory + if(getOut(node.getTokens()) != null) + setOut(node.getTokens(), null); + } + + public void outAHelperDef(AHelperDef node) + { + setOut(node, getOut(node.getRegExp())); + + // free memory + if(getOut(node.getRegExp()) != null) + setOut(node.getRegExp(), null); + } + + public void outATokens(ATokens node) + { + ATokenDef[] tokenDefs = (ATokenDef[]) node.getTokenDefs().toArray(new ATokenDef[0]); + NFA result = null; + + for(int i = tokenDefs.length - 1; i >= 0 ; i--) + { + NFA nfa = (NFA) getOut(tokenDefs[i]); + if(nfa != null) + { + if(result == null) + { + result = nfa; + } + else + { + result = nfa.merge(result); + } + + // free memory + if(getOut(tokenDefs[i]) != null) + setOut(tokenDefs[i], null); + } + } + + if(result != null) + setOut(node, result); + } + + public void outATokenDef(ATokenDef node) + { + Set set + = (Set) getOut(node.getStateList()); + Object o1 = getOut(node.getRegExp()); + + if((set + == null) || (set.size() == 0) || set.contains(stateName)) + { + //System.out.print("*"); + + NFA n1 = (o1 instanceof NFA) ? (NFA) o1 : new NFA((CharSet) o1); + String name = (String) ids.names.get(node); + + n1.states[n1.states.length - 1].accept = name; + setOut(node, n1); + } + else + { + //System.out.print("-"); + } + + // free memory + if(getOut(node.getStateList()) != null) + setOut(node.getStateList(), null); + if(getOut(node.getRegExp()) != null) + setOut(node.getRegExp(), null); + } + + public void outAStateList(AStateList node) + { + Set set + = new TreeSet(); + AStateListTail[] stateListTails = (AStateListTail[]) node.getStateLists().toArray(new AStateListTail[0]); + + for(int i = stateListTails.length - 1; i >= 0 ; i--) + { + String str = stateListTails[i].getId().getText().toUpperCase(); + set.add(str); + } + + set.add(node.getId().getText().toUpperCase()); + setOut(node, set + ); + } + + public void outARegExp(ARegExp node) + { + AConcat[] concats = (AConcat[]) node.getConcats().toArray(new AConcat[0]); + NFA result = null; + + if(concats.length > 1) + { + for(int i = concats.length - 1; i >= 0 ; i--) + { + Object o = getOut(concats[i]); + NFA nfa = (o instanceof NFA) ? (NFA) o : new NFA((CharSet) o); + + if(result == null) + { + result = nfa; + } + else + { + result = nfa.alternate(result); + } + + // free memory + if(getOut(concats[i]) != null) + setOut(concats[i], null); + } + setOut(node, result); + } + else if(concats.length == 1) + { + setOut(node, getOut(concats[0])); + + // free memory + if(getOut(concats[0]) != null) + setOut(concats[0], null); + } + } + + public void outAConcat(AConcat node) + { + AUnExp[] unExps = (AUnExp[]) node.getUnExps().toArray(new AUnExp[0]); + + if(unExps.length == 0) + { + setOut(node, new NFA()); + } + else if(unExps.length == 1) + { + setOut(node, getOut(unExps[0])); + + // free memory + if(getOut(unExps[0]) != null) + setOut(unExps[0], null); + } + else + { + NFA result = null; + + for(int i = unExps.length - 1; i >= 0 ; i--) + { + Object o = getOut(unExps[i]); + NFA nfa = (o instanceof NFA) ? (NFA) o : new NFA((CharSet) o); + + if(result == null) + { + result = nfa; + } + else + { + result = nfa.concatenate(result); + } + + // free memory + if(getOut(unExps[i]) != null) + setOut(unExps[i], null); + } + + setOut(node, result); + } + } + + public void outAUnExp(AUnExp node) + { + Object o = getOut(node.getBasic()); + + char c = ' '; + if(node.getUnOp() != null) + c = ((Character) getOut(node.getUnOp())).charValue(); + + switch(c) + { + case '*': + { + NFA n = (o instanceof NFA) ? (NFA) o : new NFA((CharSet) o); + setOut(node, n.zeroOrMore()); + } + break; + case '?': + { + NFA n = (o instanceof NFA) ? (NFA) o : new NFA((CharSet) o); + setOut(node, n.zeroOrOne()); + } + break; + case '+': + { + NFA n = (o instanceof NFA) ? (NFA) o : new NFA((CharSet) o); + setOut(node, n.oneOrMore()); + } + break; + default: + { + setOut(node, o); + } + break; + } + + // free memory + if(getOut(node.getBasic()) != null) + setOut(node.getBasic(), null); + if(getOut(node.getUnOp()) != null) + setOut(node.getUnOp(), null); + } + + public void outACharBasic(ACharBasic node) + { + char c = ((Character) getOut(node.getChar())).charValue(); + setOut(node, new CharSet(c)); + + // free memory + if(getOut(node.getChar()) != null) + setOut(node.getChar(), null); + } + + public void outASetBasic(ASetBasic node) + { + setOut(node, getOut(node.getSet())); + + // free memory + if(getOut(node.getSet()) != null) + setOut(node.getSet(), null); + } + + public void outAStringBasic(AStringBasic node) + { + String s = node.getString().getText(); + s = s.substring(1, s.length() -1); + + setOut(node, new NFA(s)); + } + + public void outAIdBasic(AIdBasic node) + { + Object o = getOut((Node) ids.helpers.get(node.getId().getText())); + + if(o instanceof NFA) + { + setOut(node, ((NFA) o).clone()); + } + else + { + setOut(node, ((CharSet) o).clone()); + } + } + + public void outARegExpBasic(ARegExpBasic node) + { + setOut(node, getOut(node.getRegExp())); + + // free memory + if(getOut(node.getRegExp()) != null) + setOut(node.getRegExp(), null); + } + + public void outACharChar(ACharChar node) + { + setOut(node, new Character(node.getChar().getText().charAt(1))); + } + + public void outADecChar(ADecChar node) + { + setOut(node, new Character((char) Integer.parseInt(node.getDecChar().getText()))); + } + + public void outAHexChar(AHexChar node) + { + setOut(node, new Character((char) + Integer.parseInt(node.getHexChar().getText().substring(2), 16))); + } + + public void outAOperationSet(AOperationSet node) + { + try + { + CharSet cs1 = (CharSet) getOut(node.getLeft()); + CharSet cs2 = (CharSet) getOut(node.getRight()); + char binop = ((Character) getOut(node.getBinOp())).charValue(); + + switch(binop) + { + case '+': + { + setOut(node, cs1.union(cs2)); + } + break; + case '-': + { + setOut(node, cs1.diff(cs2)); + } + break; + } + } + catch(Exception e) + { + throw new RuntimeException(node + " is invalid."); + } + + // free memory + if(getOut(node.getLeft()) != null) + setOut(node.getLeft(), null); + if(getOut(node.getBinOp()) != null) + setOut(node.getBinOp(), null); + if(getOut(node.getRight()) != null) + setOut(node.getRight(), null); + } + + public void outAIntervalSet(AIntervalSet node) + { + char c1 = ((Character) getOut(node.getLeft())).charValue(); + char c2 = ((Character) getOut(node.getRight())).charValue(); + + if(c1 > c2) + { + throw new RuntimeException(node + " is invalid."); + } + + setOut(node, new CharSet(c1, c2)); + + // free memory + if(getOut(node.getLeft()) != null) + setOut(node.getLeft(), null); + if(getOut(node.getRight()) != null) + setOut(node.getRight(), null); + } + + public void outAStarUnOp(AStarUnOp node) + { + setOut(node, new Character('*')); + } + + public void outAQMarkUnOp(AQMarkUnOp node) + { + setOut(node, new Character('?')); + } + + public void outAPlusUnOp(APlusUnOp node) + { + setOut(node, new Character('+')); + } + + public void outAPlusBinOp(APlusBinOp node) + { + setOut(node, new Character('+')); + } + + public void outAMinusBinOp(AMinusBinOp node) + { + setOut(node, new Character('-')); + } + + public Object getOut(Node node) + { + if(node == null) + { + return null; + } + + return super.getOut(node); + } + + public void setOut(Node node, Object out) + { + if(node == null) + { + throw new NullPointerException(); + } + + super.setOut(node, out); + } +} + diff --git a/src/main/java/org/sablecc/sablecc/ConstructParserGenerationDatas.java b/src/main/java/org/sablecc/sablecc/ConstructParserGenerationDatas.java new file mode 100644 index 0000000..c14f56a --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ConstructParserGenerationDatas.java @@ -0,0 +1,86 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; + +public class ConstructParserGenerationDatas extends DepthFirstAdapter +{ + private ResolveIds ids; + private int currentAlt; + private boolean processingAst; + private String currentProd; + + private Map alts; + + public ConstructParserGenerationDatas(ResolveIds ids, Map alts) + { + this.ids = ids; + this.alts = alts; + } + + public void caseAAst(AAst node) + {} + + public void caseAProd(AProd node) + { + currentProd = (String) ids.names.get(node); + AAlt[] alts = (AAlt[])node.getAlts().toArray(new AAlt[0]); + for(int i=0; i<alts.length; i++) + { + alts[i].apply(this); + } + } + + public void caseAAlt(AAlt node) + { + currentAlt = Grammar.addProduction(currentProd, (String) ids.names.get(node)); + alts.put(ids.names.get(node), node); + + AElem[] temp = (AElem[])node.getElems().toArray(new AElem[0]); + for(int i = 0; i < temp.length; i++) + { + temp[i].apply(this); + } + } + + public void caseAElem(AElem node) + { + String name = ids.name(node.getId().getText()); + + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + ids.elemTypes.put(node, "T" + name); + } + else + { + ids.elemTypes.put(node, "P" + name); + } + } + else + { + Object token = ids.tokens.get("T" + name); + Object production = ids.prods.get("P" + name); + + if(token != null) + { + ids.elemTypes.put(node, "T" + name); + } + else + { + ids.elemTypes.put(node, "P" + name); + } + } + name = (String) ids.elemTypes.get(node); + Grammar.addSymbolToProduction(name, currentAlt); + } +} diff --git a/src/main/java/org/sablecc/sablecc/ConstructProdsMap.java b/src/main/java/org/sablecc/sablecc/ConstructProdsMap.java new file mode 100644 index 0000000..cd02575 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ConstructProdsMap.java @@ -0,0 +1,27 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; + +public class ConstructProdsMap extends DepthFirstAdapter +{ + public Map productionsMap = + new TypedTreeMap(StringCast.instance, + NodeCast.instance); + + private String currentProd; + + public void caseAProd(AProd node) + { + currentProd = ResolveIds.name(node.getId().getText()); + productionsMap.put("P" + currentProd, node); + } +} diff --git a/src/main/java/org/sablecc/sablecc/DFA.java b/src/main/java/org/sablecc/sablecc/DFA.java new file mode 100644 index 0000000..3747676 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/DFA.java @@ -0,0 +1,403 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.Vector; +import java.util.Hashtable; + +public class DFA +{ + public DFA(NFA nfa) + { + this.nfa = nfa; + construct(); + optimize(); + } + + public NFA nfa; + public final Vector states = new Vector(0); + public final Hashtable finder = new Hashtable(1); + + private void optimize() + { + Vector transitions = new Vector(0); + + for(int i = 0; i < states.size(); i++) + { + DFA.State state = (DFA.State) states.elementAt(i); + transitions.addElement(new Vector(0)); + + for(int j = 0; j < state.transitions.size(); j++) + { + int max = 0; + int st = -1; + + for(int k = 0; k < i; k++) + { + int match = match(i,j,k); + + if(match > max) + { + max = match; + st = k; + } + } + + if(max < 2) + { + ((Vector) transitions.elementAt(i)).addElement( + state.transitions.elementAt(j)); + } + else + { + DFA.Transition transition1 = + (DFA.Transition) state.transitions.elementAt(j); + DFA.Transition transition2 = + (DFA.Transition) state.transitions.elementAt(j + max - 1); + + DFA.Transition transition = + new DFA.Transition( + new CharSet.Interval( + transition1.interval().start, + transition2.interval().end), + -2 - st); + + ((Vector) transitions.elementAt(i)).addElement(transition); + j += max - 1; + } + } + } + + for(int i = 0; i < states.size(); i++) + { + DFA.State state = (DFA.State) states.elementAt(i); + state.transitions = (Vector) transitions.elementAt(i); + } + } + + private int match(int st1, int tr, int st2) + { + DFA.State state1 = (DFA.State) states.elementAt(st1); + DFA.State state2 = (DFA.State) states.elementAt(st2); + + DFA.Transition first = + (DFA.Transition) state1.transitions.elementAt(tr); + + int j = -1; + + for(int i = 0; i < state2.transitions.size(); i++) + { + DFA.Transition transition = + (DFA.Transition) state2.transitions.elementAt(i); + + if(transition.match(first)) + { + j = i; + break; + } + } + + if(j == -1) + { + return 0; + } + + int max = 0; + int i = tr; + + while((i < state1.transitions.size()) && + (j < state2.transitions.size())) + { + DFA.Transition transition1 = + (DFA.Transition) state1.transitions.elementAt(i); + + DFA.Transition transition2 = + (DFA.Transition) state2.transitions.elementAt(j); + + if(!transition1.match(transition2)) + { + return max; + } + + max++; + i++; + j++; + } + + return max; + } + + private void construct() + { + computeEClosures(); + + IntSet initial = new IntSet(); + initial.or(eclosure(0)); + + State state = new State(initial); + states.addElement(state); + finder.put(state.nfaStates, new Integer(0)); + + int i = -1; + while(++i < states.size()) + { + System.out.print("."); + + state = (State) states.elementAt(i); + + CharSet.Interval interval = new CharSet.Interval((char) 0, (char) 0xffff); + + do + { + IntSet destination = new IntSet(); + interval.end = (char) 0xffff; + boolean modified = false; + + int[] elements = state.nfaStates.elements(); + + for(int k = 0; k < elements.length; k++) + { + int j = elements[k]; + + if((nfa.states[j].transitions[0] != null) && + (nfa.states[j].transitions[0].chars != null)) + { + CharSet.Interval overlap = + nfa.states[j].transitions[0].chars.findOverlap(interval); + + if(overlap != null) + { + if(overlap.start > interval.start) + { + interval.end = (char) (overlap.start - 1); + } + else + { + destination.set(nfa.states[j].transitions[0].destination); + modified = true; + + if(overlap.end < interval.end) + { + interval.end = overlap.end; + } + } + } + } + + if((nfa.states[j].transitions[1] != null) && + (nfa.states[j].transitions[1].chars != null)) + { + CharSet.Interval overlap = + nfa.states[j].transitions[1].chars.findOverlap(interval); + + if(overlap != null) + { + if(overlap.start > interval.start) + { + interval.end = (char) (overlap.start - 1); + } + else + { + destination.set(nfa.states[j].transitions[1].destination); + + if(overlap.end < interval.end) + { + interval.end = overlap.end; + } + } + } + } + } + + if(modified) + { + destination = eclosure(destination); + Integer dest = (Integer) finder.get(destination); + + if(dest != null) + { + state.transitions.addElement( + new Transition((CharSet.Interval) interval.clone(), dest.intValue())); + } + else + { + State s = new State(destination); + states.addElement(s); + finder.put(s.nfaStates, new Integer(states.size() - 1)); + + state.transitions.addElement( + new Transition((CharSet.Interval) interval.clone(), states.size() - 1)); + } + } + + interval.start = (char) (interval.end + 1); + } + while(interval.end != (char) 0xffff); + + // System.out.println(state); + } + + // System.out.println(this); + } + + private IntSet[] eclosures; + + private void computeEClosures() + { + eclosures = new IntSet[nfa.states.length]; + + for(int i = 0; i < nfa.states.length; i++) + { + System.out.print("."); + + IntSet set + = new IntSet(); + eclosure(i, set + ); + eclosures[i] = set + ; + } + + System.out.println(); + } + + private IntSet eclosure(int state) + { + return eclosures[state]; + } + + private void eclosure(int state, IntSet nfaStates) + { + if(eclosures[state] != null) + { + nfaStates.or(eclosures[state]); + return; + } + + nfaStates.set(state); + + if((nfa.states[state].transitions[0] != null) && + (nfa.states[state].transitions[0].chars == null) && + (!nfaStates.get(nfa.states[state].transitions[0].destination))) + + { + eclosure(nfa.states[state].transitions[0].destination, nfaStates); + } + + if((nfa.states[state].transitions[1] != null) && + (nfa.states[state].transitions[1].chars == null) && + (!nfaStates.get(nfa.states[state].transitions[1].destination))) + + { + eclosure(nfa.states[state].transitions[1].destination, nfaStates); + } + } + + private IntSet eclosure(IntSet nfaStates) + { + IntSet result = new IntSet(); + + int[] elements = nfaStates.elements(); + + for(int j = 0; j < elements.length; j++) + { + int i = elements[j]; + + result.or(eclosure(i)); + } + + return result; + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + + for(int i = 0; i < states.size(); i++) + { + result.append(i + ": " + states.elementAt(i) + + System.getProperty("line.separator")); + } + + return result.toString(); + } + + public static class State + { + public State(IntSet nfaStates) + { + this.nfaStates = nfaStates; + } + + public IntSet nfaStates = new IntSet(); + public Vector transitions = new Vector(0); + public int accept; + + public String toString() + { + StringBuffer result = new StringBuffer(); + + /* for(int i = 0; i < nfaStates.size(); i++) + { + if(nfaStates.get(i)) + { + if(nfa.states[i].accept != null) + { + result.append("(" + nfa.states[i].accept + ")"); + } + } + }*/ + + for(int i = 0; i < transitions.size(); i++) + { + result.append(transitions.elementAt(i) + ","); + } + + return result /*+ " " + nfaStates*/ + ""; + } + } + + public static class Transition + { + private char start; + private char end; + + public int destination; + + public Transition(CharSet.Interval interval, int destination) + { + this.start = interval.start; + this.end = interval.end; + this.destination = destination; + } + + public CharSet.Interval interval() + { + return new CharSet.Interval(start, end); + } + + public Transition(Transition transition) + { + start = transition.start; + end = transition.end; + destination = transition.destination; + } + + public String toString() + { + return destination + ":[" + interval() + "]"; + } + + public boolean match(Transition transition) + { + return (start == transition.start) && + (end == transition.end) && + (destination == transition.destination); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/DisplayLicense.java b/src/main/java/org/sablecc/sablecc/DisplayLicense.java new file mode 100644 index 0000000..7fae95d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/DisplayLicense.java @@ -0,0 +1,68 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.io.*; + +class DisplayLicense +{ + DisplayLicense() + { + try + { + BufferedReader in = + new BufferedReader( + new InputStreamReader( + getClass().getResourceAsStream("LICENSE"))); + System.out.println("---- FILE: LICENSE ----"); + + String s; + while((s = in.readLine()) != null) + { + System.out.println(s); + } + in.close(); + + System.out.println("---- END OF FILE: SableCC-LICENSE ----"); + System.out.println(); + + System.out.println("---- FILE: AUTHORS ----"); + in = + new BufferedReader( + new InputStreamReader( + getClass().getResourceAsStream("AUTHORS"))); + + while((s = in.readLine()) != null) + { + System.out.println(s); + } + in.close(); + System.out.println("---- END OF FILE: AUTHORS ----"); + System.out.println(); + + System.out.println("---- FILE: COPYING-LESSER ----"); + + in = + new BufferedReader( + new InputStreamReader( + getClass().getResourceAsStream("COPYING-LESSER"))); + + while((s = in.readLine()) != null) + { + System.out.println(s); + } + in.close(); + System.out.println("---- END OF FILE: COPYING-LESSER ----"); + } + catch(Exception e) + { + System.out.println(e); + System.exit(1); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/GenAlts.java b/src/main/java/org/sablecc/sablecc/GenAlts.java new file mode 100644 index 0000000..db62b6d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/GenAlts.java @@ -0,0 +1,420 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +public class GenAlts extends DepthFirstAdapter +{ + private MacroExpander macros; + private ResolveAstIds ast_ids; + private File pkgDir; + private String pkgName; + private List elemList; + + private String currentProd; + ElemInfo info; + // final GenAlts instance = this; + + public GenAlts(ResolveAstIds ast_ids) + { + this.ast_ids = ast_ids; + try + { + macros = new MacroExpander( + new InputStreamReader( + getClass().getResourceAsStream("alternatives.txt"))); + } + catch(IOException e) + { + throw new RuntimeException("unable to open alternatives.txt."); + } + + pkgDir = new File(ast_ids.astIds.pkgDir, "node"); + pkgName = ast_ids.astIds.pkgName.equals("") ? "node" : ast_ids.astIds.pkgName + ".node"; + + if(!pkgDir.exists()) + { + if(!pkgDir.mkdir()) + { + throw new RuntimeException("Unable to create " + pkgDir.getAbsolutePath()); + } + } + } + + public void inAAstProd(AAstProd node) + { + currentProd = (String) ast_ids.ast_names.get(node); + } + + public void inAAstAlt(AAstAlt node) + { + elemList = new TypedLinkedList(ElemInfoCast.instance); + } + + public void caseAProductions(AProductions node) + {} + + public void inAElem(AElem node) + { + info = new ElemInfo(); + info.name = (String) ast_ids.ast_names.get(node); + info.type = (String) ast_ids.ast_elemTypes.get(node); + info.operator = ElemInfo.NONE; + + if(node.getUnOp() != null) + { + node.getUnOp().apply(new DepthFirstAdapter() + { + public void caseAStarUnOp(AStarUnOp node) + { + info.operator = ElemInfo.STAR; + } + + public void caseAQMarkUnOp(AQMarkUnOp node) + { + info.operator = ElemInfo.QMARK; + } + + public void caseAPlusUnOp(APlusUnOp node) + { + info.operator = ElemInfo.PLUS; + } + } + ); + } + elemList.add(info); + info = null; + } + + public void outAAstAlt(AAstAlt node) + { + String name = (String) ast_ids.ast_names.get(node); + + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, name + ".java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, name + ".java").getAbsolutePath()); + } + + try + { + boolean hasOperator = false; + boolean hasList = false; + + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + if(info != null) + switch(info.operator) + { + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + hasList = true; + } + break; + } + } + + macros.apply(file, "AlternativeHeader1", new String[] {pkgName}); + + if(hasList) + { + macros.apply(file, "AlternativeHeaderList", new String[] {}); + } + + macros.apply(file, "AlternativeHeader2", new String[] { + ast_ids.astIds.pkgName.equals("") ? "analysis" : ast_ids.astIds.pkgName + ".analysis", + name, currentProd}); + + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + if(info != null) + switch(info.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "NodeElement", + new String[] {info.type, + nodeName(info.name)}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + hasOperator = true; + macros.apply(file, "ListElement", + new String[] {info.type, nodeName(info.name)}); + } + break; + } + } + + macros.apply(file, "ConstructorHeader", + new String[] {name}); + macros.apply(file, "ConstructorBodyHeader", null); + macros.apply(file, "ConstructorBodyTail", null); + + if(elemList.size() > 0) + { + macros.apply(file, "ConstructorHeader", + new String[] {name}); + + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + if(info != null) + switch(info.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "ConstructorHeaderDeclNode", + new String[] {info.type, nodeName(info.name), i.hasNext() ? "," : ""}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "ConstructorHeaderDeclList", + new String[] {info.type, nodeName(info.name), i.hasNext() ? "," : ""}); + } + break; + } + } + + macros.apply(file, "ConstructorBodyHeader", null); + + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + + if(info != null ) + switch(info.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "ConstructorBodyNode", + new String[] {info.name, nodeName(info.name)}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "ConstructorBodyList", + new String[] {info.name, nodeName(info.name)}); + } + break; + } + } + + macros.apply(file, "ConstructorBodyTail", null); + } + + //**************** + macros.apply(file, "CloneHeader", + new String[] {name}); + + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + if(info != null) + switch(info.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "CloneBodyNode", + new String[] {info.type, nodeName(info.name), i.hasNext() ? "," : ""}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "CloneBodyList", + new String[] {nodeName(info.name), i.hasNext() ? "," : ""}); + } + break; + } + } + + macros.apply(file, "CloneTail", null); + + macros.apply(file, "Apply", new String[] {name}); + + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + + if(info != null) + switch(info.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "GetSetNode", + new String[] {info.type, info.name, nodeName(info.name)}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "GetSetList", + new String[] {info.name, nodeName(info.name), info.type}); + } + break; + } + } + + macros.apply(file, "ToStringHeader", null); + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + + if(info != null) + switch(info.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "ToStringBodyNode", + new String[] {nodeName(info.name)}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "ToStringBodyList", + new String[] {nodeName(info.name)}); + } + break; + } + } + macros.apply(file, "ToStringTail", null); + + macros.apply(file, "RemoveChildHeader", null); + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + + if(info != null) + switch(info.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "RemoveChildNode", + new String[] {nodeName(info.name)}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "RemoveChildList", + new String[] {nodeName(info.name)}); + } + break; + } + } + macros.apply(file, "RemoveChildTail", null); + + macros.apply(file, "ReplaceChildHeader", null); + for(Iterator i = elemList.iterator(); i.hasNext();) + { + ElemInfo info = (ElemInfo) i.next(); + + if(info != null) + switch(info.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "ReplaceChildNode", + new String[] {nodeName(info.name), info.name, info.type}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "ReplaceChildList", + new String[] {nodeName(info.name), info.type}); + } + break; + } + } + macros.apply(file, "ReplaceChildTail", null); + + macros.apply(file, "AlternativeTail", null); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, name + ".java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + + elemList = null; + } + + public static String nodeName(String s) + { + StringBuffer result = new StringBuffer(s); + + if(result.length() > 0) + { + result.setCharAt(0, Character.toLowerCase(result.charAt(0))); + } + + return result.toString(); + } + + private static class ElemInfo + { + final static int NONE = 0; + final static int STAR = 1; + final static int QMARK = 2; + final static int PLUS = 3; + + String name; + String type; + int operator; + } + + private static class ElemInfoCast implements Cast + { + public final static ElemInfoCast instance = new ElemInfoCast(); + + private ElemInfoCast() + {} + + public Object cast(Object o) + { + return (ElemInfo) o; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/GenAnalyses.java b/src/main/java/org/sablecc/sablecc/GenAnalyses.java new file mode 100644 index 0000000..2e7eb94 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/GenAnalyses.java @@ -0,0 +1,439 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +public class GenAnalyses extends DepthFirstAdapter +{ + private MacroExpander macros; + private ResolveAstIds ast_ids; + private File pkgDir; + private String pkgName; + private List elemList; + private List altList = new TypedLinkedList(AltInfoCast.instance); + private List tokenList = new TypedLinkedList(StringCast.instance); + private String mainProduction; + + ElemInfo info; + // final GenAnalyses instance = this; + + public GenAnalyses(ResolveAstIds ast_ids) + { + this.ast_ids = ast_ids; + try + { + macros = new MacroExpander( + new InputStreamReader( + getClass().getResourceAsStream("analyses.txt"))); + } + catch(IOException e) + { + throw new RuntimeException("unable to open analyses.txt."); + } + + pkgDir = new File(ast_ids.astIds.pkgDir, "analysis"); + pkgName = ast_ids.astIds.pkgName.equals("") ? "analysis" : ast_ids.astIds.pkgName + ".analysis"; + + if(!pkgDir.exists()) + { + if(!pkgDir.mkdir()) + { + throw new RuntimeException("Unable to create " + pkgDir.getAbsolutePath()); + } + } + } + + public void inAAstProd(AAstProd node) + { + if(mainProduction == null) + { + mainProduction = (String) ast_ids.ast_names.get(node); + } + } + + public void inATokenDef(ATokenDef node) + { + tokenList.add(ast_ids.astIds.names.get(node)); + } + + public void inAAstAlt(AAstAlt node) + { + elemList = new TypedLinkedList(ElemInfoCast.instance); + } + + public void caseAProductions(AProductions node) + {} + + public void inAElem(AElem node) + { + info = new ElemInfo(); + + info.name = (String) ast_ids.ast_names.get(node); + info.type = (String) ast_ids.ast_elemTypes.get(node); + info.operator = ElemInfo.NONE; + + if(node.getUnOp() != null) + { + node.getUnOp().apply(new DepthFirstAdapter() + { + + public void caseAStarUnOp(AStarUnOp node) + { + info.operator = ElemInfo.STAR; + } + + public void caseAQMarkUnOp(AQMarkUnOp node) + { + info.operator = ElemInfo.QMARK; + } + + public void caseAPlusUnOp(APlusUnOp node) + { + info.operator = ElemInfo.PLUS; + } + } + ); + } + + elemList.add(info); + info = null; + } + + public void outAAstAlt(AAstAlt node) + { + AltInfo info = new AltInfo(); + + info.name = (String) ast_ids.ast_names.get(node); + info.elems.addAll(elemList); + elemList = null; + + altList.add(info); + } + + public void outStart(Start node) + { + createAnalysis(); + createAnalysisAdapter(); + + if(mainProduction != null) + { + createDepthFirstAdapter(); + createReversedDepthFirstAdapter(); + } + } + + public void createAnalysis() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "Analysis.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "Analysis.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "AnalysisHeader", new String[] {pkgName, + ast_ids.astIds.pkgName.equals("") ? "node" : ast_ids.astIds.pkgName + ".node"}); + + if(mainProduction != null) + { + macros.apply(file, "AnalysisStart", null); + + for(Iterator i = altList.iterator(); i.hasNext();) + { + AltInfo info = (AltInfo) i.next(); + + macros.apply(file, "AnalysisBody", + new String[] {info.name}); + } + + file.newLine(); + } + + for(Iterator i = tokenList.iterator(); i.hasNext();) + { + macros.apply(file, "AnalysisBody", + new String[] {(String) i.next()}); + } + + macros.apply(file, "AnalysisTail", null); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Analysis.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + public void createAnalysisAdapter() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "AnalysisAdapter.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "AnalysisAdapter.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "AnalysisAdapterHeader", new String[] {pkgName, + ast_ids.astIds.pkgName.equals("") ? "node" : ast_ids.astIds.pkgName + ".node"}); + + if(mainProduction != null) + { + macros.apply(file, "AnalysisAdapterStart", null); + + for(Iterator i = altList.iterator(); i.hasNext();) + { + AltInfo info = (AltInfo) i.next(); + + macros.apply(file, "AnalysisAdapterBody", + new String[] {info.name}); + } + } + + for(Iterator i = tokenList.iterator(); i.hasNext();) + { + macros.apply(file, "AnalysisAdapterBody", + new String[] {(String) i.next()}); + } + + macros.apply(file, "AnalysisAdapterTail", null); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "AnalysisAdapter.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + public void createDepthFirstAdapter() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "DepthFirstAdapter.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "DepthFirstAdapter.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "DepthFirstAdapterHeader", new String[] {pkgName, + ast_ids.astIds.pkgName.equals("") ? "node" : ast_ids.astIds.pkgName + ".node", + mainProduction}); + + for(Iterator i = altList.iterator(); i.hasNext();) + { + AltInfo info = (AltInfo) i.next(); + + macros.apply(file, "DepthFirstAdapterInOut", + new String[] {info.name}); + + macros.apply(file, "DepthFirstAdapterCaseHeader", + new String[] {info.name}); + + for(Iterator j = info.elems.iterator(); j.hasNext();) + { + ElemInfo eInfo = (ElemInfo) j.next(); + + switch(eInfo.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "DepthFirstAdapterCaseBodyNode", + new String[] {eInfo.name}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "DepthFirstAdapterCaseBodyList", + new String[] {eInfo.name, eInfo.type}); + } + break; + } + } + + macros.apply(file, "DepthFirstAdapterCaseTail", + new String[] {info.name}); + + } + + macros.apply(file, "DepthFirstAdapterTail", null); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "DepthFirstAdapter.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + public void createReversedDepthFirstAdapter() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "ReversedDepthFirstAdapter.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "ReversedDepthFirstAdapter.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "ReversedDepthFirstAdapterHeader", new String[] {pkgName, + ast_ids.astIds.pkgName.equals("") ? "node" : ast_ids.astIds.pkgName + ".node", + mainProduction}); + + for(Iterator i = altList.iterator(); i.hasNext();) + { + AltInfo info = (AltInfo) i.next(); + + macros.apply(file, "DepthFirstAdapterInOut", + new String[] {info.name}); + + macros.apply(file, "DepthFirstAdapterCaseHeader", + new String[] {info.name}); + + for(ListIterator j = info.elems.listIterator(info.elems.size()); j.hasPrevious();) + { + ElemInfo eInfo = (ElemInfo) j.previous(); + + switch(eInfo.operator) + { + case ElemInfo.QMARK: + case ElemInfo.NONE: + { + macros.apply(file, "DepthFirstAdapterCaseBodyNode", + new String[] {eInfo.name}); + } + break; + case ElemInfo.STAR: + case ElemInfo.PLUS: + { + macros.apply(file, "ReversedDepthFirstAdapterCaseBodyList", + new String[] {eInfo.name, eInfo.type}); + } + break; + } + } + + macros.apply(file, "DepthFirstAdapterCaseTail", + new String[] {info.name}); + + } + + macros.apply(file, "DepthFirstAdapterTail", null); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "ReversedDepthFirstAdapter.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + private static class ElemInfo + { + final static int NONE = 0; + final static int STAR = 1; + final static int QMARK = 2; + final static int PLUS = 3; + + String name; + String type; + int operator; + } + + private static class ElemInfoCast implements Cast + { + final static ElemInfoCast instance = new ElemInfoCast(); + + private ElemInfoCast() + {} + + public Object cast(Object o) + { + return (ElemInfo) o; + } + } + + private static class AltInfo + { + String name; + final List elems = new TypedLinkedList(ElemInfoCast.instance); + } + + private static class AltInfoCast implements Cast + { + final static AltInfoCast instance = new AltInfoCast(); + + private AltInfoCast() + {} + + public Object cast(Object o) + { + return (AltInfo) o; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/GenLexer.java b/src/main/java/org/sablecc/sablecc/GenLexer.java new file mode 100644 index 0000000..05ea799 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/GenLexer.java @@ -0,0 +1,360 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.io.*; +import java.util.Vector; +import java.util.Enumeration; + +public class GenLexer extends AnalysisAdapter +{ + private MacroExpander macros; + private ResolveIds ids; + private File pkgDir; + private String pkgName; + private AcceptStates[] acceptStatesArray; + private Transitions transitions; + + public GenLexer(ResolveIds ids) + { + this.ids = ids; + + try + { + macros = new MacroExpander( + new InputStreamReader( + getClass().getResourceAsStream("lexer.txt"))); + } + catch(IOException e) + { + throw new RuntimeException("unable to open lexer.txt."); + } + + pkgDir = new File(ids.pkgDir, "lexer"); + pkgName = ids.pkgName.equals("") ? "lexer" : ids.pkgName + ".lexer"; + + if(!pkgDir.exists()) + { + if(!pkgDir.mkdir()) + { + throw new RuntimeException("Unable to create " + pkgDir.getAbsolutePath()); + } + } + } + + public void caseStart(Start tree) + { + String[] names; + int numStates = Math.max(1, ids.stateList.size()); + + acceptStatesArray = new AcceptStates[numStates]; + names = new String[numStates]; + + if(ids.stateList.size() == 0) + { + names[0] = "INITIAL"; + } + else + { + Iterator iter = ids.stateList.iterator(); + for(int i = 0; i < numStates; i++) + { + names[i] = (String) iter.next(); + } + } + + for(int i = 0; i < numStates; i++) + { + System.out.println(" State: " + names[i]); + + System.out.println(" - Constructing NFA."); + ConstructNFA nfaConstructor = new ConstructNFA(ids, names[i]); + tree.apply(nfaConstructor); + System.out.println(); + + NFA nfa = (NFA) nfaConstructor.getOut(tree); + nfaConstructor = null; + + System.out.println(" - Constructing DFA."); + DFA dfa = new DFA(nfa); + System.out.println(); + + System.out.println(" - resolving ACCEPT states."); + acceptStatesArray[i] = new AcceptStates(dfa, ids, names[i]); + tree.apply(acceptStatesArray[i]); + } + + transitions = new Transitions(); + tree.apply(transitions); + + createLexerException(); + createLexer(); + } + + private void createLexerException() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "LexerException.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "LexerException.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "LexerException", new String[] {pkgName}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "LexerException.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + private void createLexer() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "Lexer.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "Lexer.java").getAbsolutePath()); + } + + try + { + String startState = "INITIAL"; + if(ids.stateList.size() > 0) + { + startState = (String) ids.stateList.getFirst(); + } + + macros.apply(file, "LexerHeader", new String[] {pkgName, + ids.pkgName.equals("") ? "node" : ids.pkgName + ".node", + startState}); + + for(ListIterator i = ids.tokenList.listIterator(); i.hasNext();) + { + String name = (String) i.next(); + Node node = (Node) ids.tokens.get(name); + boolean fixed = ((Boolean) ids.fixedTokens.get(node)) + .booleanValue(); + + if(fixed) + { + macros.apply(file, "LexerFixedToken", + new String[] {"" + i.previousIndex(), name}); + } + else + { + macros.apply(file, "LexerVariableToken", + new String[] {"" + i.previousIndex(), name}); + } + + Map map = (Map) transitions.tokenStates.get(node); + if(map.size() > 0) + { + macros.apply(file, "TokenSwitchHeader", null); + + for(Iterator j = map.entrySet().iterator(); j.hasNext();) + { + Map.Entry entry = (Map.Entry) j.next(); + + macros.apply(file, "TokenCase", + new String[] {ids.stateList.indexOf((String) entry.getKey()) + "", + (String) entry.getValue()}); + } + + macros.apply(file, "TokenSwitchTail", null); + } + + macros.apply(file, "LexerTokenTail", null); + } + + macros.apply(file, "LexerBody1"); + + for(ListIterator i = ids.tokenList.listIterator(); i.hasNext();) + { + String name = (String) i.next(); + Node node = (Node) ids.tokens.get(name); + boolean fixed = ((Boolean) ids.fixedTokens.get(node)) + .booleanValue(); + + if(fixed) + { + macros.apply(file, "LexerNewFixedToken", + new String[] {"" + i.previousIndex(), name}); + } + else + { + macros.apply(file, "LexerNewVariableToken", + new String[] {"" + i.previousIndex(), name}); + } + } + + macros.apply(file, "LexerBody2"); + + DataOutputStream out = new DataOutputStream( + new BufferedOutputStream( + new FileOutputStream( + new File(pkgDir, "lexer.dat")))); + + out.writeInt(acceptStatesArray.length); + for(int accSt = 0; accSt < acceptStatesArray.length; accSt++) + { + DFA dfa = acceptStatesArray[accSt].dfa; + + file.write(" { // " + acceptStatesArray[accSt].stateName + System.getProperty("line.separator")); + Vector outerArray = new Vector(); + + for(int i = 0; i < dfa.states.size(); i++) + { + Vector innerArray = new Vector(); + + DFA.State state = (DFA.State) dfa.states.elementAt(i); + file.write(" {"); + + for(int j = 0; j < state.transitions.size(); j++) + { + DFA.Transition transition = + (DFA.Transition) state.transitions.elementAt(j); + + file.write("{" + ((int) transition.interval().start) + ", " + + ((int) transition.interval().end) + ", " + + transition.destination + "}, "); + + innerArray.addElement(new int[] { + ((int) transition.interval().start), + ((int) transition.interval().end), + transition.destination}); + } + + file.write("}," + System.getProperty("line.separator")); + + outerArray.addElement(innerArray); + } + file.write(" }" + System.getProperty("line.separator")); + + out.writeInt(outerArray.size()); + for(Enumeration e = outerArray.elements(); e.hasMoreElements();) + { + Vector innerArray = (Vector) e.nextElement(); + out.writeInt(innerArray.size()); + for(Enumeration n = innerArray.elements(); n.hasMoreElements();) + { + int[] array = (int[]) n.nextElement(); + + for(int i = 0; i < 3; i++) + { + out.writeInt(array[i]); + } + } + } + } + + macros.apply(file, "LexerAcceptHeader"); + + final int stateNumber = acceptStatesArray.length; + + Vector outerArray = new Vector(); + + for(int i = 0; i < stateNumber; i++) + { + DFA dfa = acceptStatesArray[i].dfa; + Vector innerArray = new Vector(); + + file.write(" // " + acceptStatesArray[i].stateName + System.getProperty("line.separator")); + file.write(" {"); + + for(int j = 0; j < dfa.states.size(); j++) + { + DFA.State state = (DFA.State) dfa.states.elementAt(j); + + file.write(state.accept + ", "); + innerArray.addElement(new Integer(state.accept)); + } + + file.write("}," + System.getProperty("line.separator")); + + outerArray.addElement(innerArray); + } + + out.writeInt(outerArray.size()); + for(Enumeration e = outerArray.elements(); e.hasMoreElements();) + { + Vector innerArray = (Vector) e.nextElement(); + out.writeInt(innerArray.size()); + for(Enumeration n = innerArray.elements(); n.hasMoreElements();) + { + Integer i = (Integer) n.nextElement(); + out.writeInt(i.intValue()); + } + } + out.close(); + + file.write(System.getProperty("line.separator")); + + macros.apply(file, "LexerAcceptTail"); + + macros.apply(file, "LexerStateHeader"); + + if(ids.stateList.size() > 0) + { + for(ListIterator i = ids.stateList.listIterator(); i.hasNext();) + { + String s = (String) i.next(); + + macros.apply(file, "LexerStateBody", + new String[] {s, "" + i.previousIndex()}); + } + } + else + { + macros.apply(file, "LexerStateBody", + new String[] {"INITIAL", "" + 0}); + } + + macros.apply(file, "LexerStateTail"); + + macros.apply(file, "LexerTail"); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Lexer.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } +} diff --git a/src/main/java/org/sablecc/sablecc/GenParser.java b/src/main/java/org/sablecc/sablecc/GenParser.java new file mode 100644 index 0000000..84230dd --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/GenParser.java @@ -0,0 +1,891 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.io.*; +import org.sablecc.sablecc.Grammar; +import java.util.Vector; +import java.util.Enumeration; + +/* + * GenParser + * + * This class is the responsible of generation of the parser. + * It calls another classes which will do internal transformations + * to the grammar in order to made it support by BNF parser generator + * algorithm whereas SableCC3.x.x grammars can be written with some + * operators of the EBNF form. + * It can also call an appropriate Tree-Walker which in case of conflict + * will try to inline productions involved in the conflict with the aim of + * resolving it. + */ + +public class GenParser extends DepthFirstAdapter +{ + //This is the tree-walker field which made internal transformations("EBNF"->BNF) to the grammar + InternalTransformationsToGrammar bnf_and_CST_AST_Transformations; + + //tree-walker field which construct data structures for generating of parsing tables. + ConstructParserGenerationDatas genParserAdapter; + + private MacroExpander macros; + private ResolveIds ids; + private ResolveAltIds altIds; + private ResolveTransformIds transformIds; + + // This class reference variable fills the map "altsElemTypes" from class AlternativeElementTypes. It associates + // the name of elements with its types + private AlternativeElementTypes AET; + + //This computes variables declarations position and type for parser generation. + //In fact it helps to determine how many elements are needed to pop from the stack + private ComputeCGNomenclature CG; + + //This helps to compute alternative transformations code generation. + private ComputeSimpleTermPosition CTP; + + private File pkgDir; + private String pkgName; + private boolean hasProductions; + private String firstProductionName; + private boolean processInlining; + private boolean prettyPrinting; + private boolean grammarHasTransformations; + + // This boolean is used to check weither the filter() method in class Parser.java + // should be present or not. + private boolean activateFilter = true; + + //This tree-walker field generate the code of parsing and construction of the AST. + GenerateAlternativeCodeForParser aParsedAltAdapter; + + private LinkedList listSimpleTermTransform = new LinkedList(); + + public final Map simpleTermTransform = + new TypedHashMap(NodeCast.instance, + StringCast.instance); + + //This map contains Productions which were explicitely transformed in the grammar + //Those transformations was specified by the grammar-writer. + private final Map mapProductionTransformations = + new TypedHashMap(StringCast.instance, + ListCast.instance); + + private Map alts; + + public GenParser(ResolveIds ids, ResolveAltIds altIds, ResolveTransformIds transformIds, + String firstProductionName, boolean processInlining, boolean prettyPrinting, + boolean grammarHasTransformations) + { + this.ids = ids; + this.altIds = altIds; + this.transformIds = transformIds; + this.processInlining = processInlining; + this.prettyPrinting = prettyPrinting; + this.grammarHasTransformations = grammarHasTransformations; + + AET = new AlternativeElementTypes(ids); + CG = new ComputeCGNomenclature(ids, transformIds.getProdTransformIds()); + CTP = new ComputeSimpleTermPosition(ids); + this.firstProductionName = firstProductionName; + + try + { + macros = new MacroExpander( + new InputStreamReader( + getClass().getResourceAsStream("parser.txt"))); + } + catch(IOException e) + { + throw new RuntimeException("unable to open parser.txt."); + } + + pkgDir = new File(ids.pkgDir, "parser"); + pkgName = ids.pkgName.equals("") ? "parser" : ids.pkgName + ".parser"; + + if(!pkgDir.exists()) + { + if(!pkgDir.mkdir()) + { + throw new RuntimeException("Unable to create " + pkgDir.getAbsolutePath()); + } + } + } + + public void caseStart(Start tree) + { + tree.getPGrammar().apply(new DepthFirstAdapter() + { + public void caseAProd(AProd node) + { + hasProductions = true; + if(node.getProdTransform() != null) + { + mapProductionTransformations.put("P"+ResolveIds.name(node.getId().getText()), + node.getProdTransform().clone() ); + } + } + } + ); + + if(!hasProductions) + { + return; + } + + //Performing internal transformations + bnf_and_CST_AST_Transformations = + new InternalTransformationsToGrammar(ids, altIds, transformIds, + listSimpleTermTransform, + simpleTermTransform, + mapProductionTransformations, + transformIds.simpleTermOrsimpleListTermTypes); + + //apply internal transformations to the grammar. + tree.getPGrammar().apply(bnf_and_CST_AST_Transformations); + + if(prettyPrinting) + { + tree.apply(new PrettyPrinter()); + return; + } + + ConstructProdsMap mapOfProds = new ConstructProdsMap(); + tree.apply(mapOfProds); + + boolean computeLALR = false; + + //This do-while loop is managing the inlining process. + do + { + //Initialization of parsing tables and some symbol tables + //names and elemTypes from ResolveIds. + reinit(); + reConstructSymbolTables(tree); + + tree.apply(new DepthFirstAdapter() + { + private boolean hasAlternative; + + public void caseATokenDef(ATokenDef node) + { + String name = (String) ids.names.get(node); + String errorName = (String) ids.errorNames.get(node); + + if(!ids.ignTokens.containsKey(name)) + { + Grammar.addTerminal(name, errorName); + } + } + + public void inAProd(AProd node) + { + hasAlternative = false; + } + + public void inAAlt(AAlt node) + { + hasAlternative = true; + } + + public void outAProd(AProd node) + { + if(hasAlternative) + { + Grammar.addNonterminal((String) ids.names.get(node)); + } + } + } + ); + + //Construct all necessary informations for generation of the parser. + //This map contains all the alternatives of the transformed final grammar + alts = new TypedHashMap(StringCast.instance, NodeCast.instance); + + tree.getPGrammar().apply(new ConstructParserGenerationDatas(ids, alts)); + + try + { + //Generation of parsing symbol tables + Grammar.computeLALR(); + computeLALR = true; + } + catch(ConflictException ce) + { + if(activateFilter) + { + activateFilter = false; + } + + //Here, we are trying to inline the grammar with production imply in the conflict. + if(processInlining) + { + ComputeInlining grammarToBeInlinedWithConflictualProductions = new ComputeInlining(ce.getConflictualProductions(), + mapOfProds.productionsMap, + tree); + if(!grammarToBeInlinedWithConflictualProductions.computeInlining()) + { + System.out.println("\nA previous conflict that we've tried to solve by inline some productions inside the grammars cannot be solved that way. The transformed grammar is : "); + tree.apply(new PrettyPrinter()); + throw new RuntimeException(ce.getMessage()); + } + + System.out.println(); + System.out.println("Inlining."); + } + else + { + throw new RuntimeException(ce.getMessage()); + } + } + } + while(!computeLALR); + + tree.getPGrammar().apply(AET); + CG.setAltElemTypes(AET.getMapOfAltElemType()); + tree.getPGrammar().apply(CG); + tree.getPGrammar().apply(CTP); + + createParser(); + createParserException(); + createState(); + createTokenIndex(); + } + + public void reinit() + { + // re-initialize all static structures in the engine + LR0Collection.reinit(); + Symbol.reinit(); + Production.reinit(); + Grammar.reinit(); + ids.reinit(); + } + + private String currentProd; + private String currentAlt; + + //reconstruction of map names of class ResolveIds + public void reConstructSymbolTables(Start tree) + { + tree.apply(new DepthFirstAdapter() + { + public void caseAProd(AProd node) + { + currentProd = ids.name(node.getId().getText()); + String name = "P" + currentProd; + + ids.names.put(node, name); + + //list of inAAlt code. + Object []list_alt = (Object [])node.getAlts().toArray(); + for(int i = 0; i< list_alt.length; i++) + { + ((PAlt)list_alt[i]).apply(this); + } + } + + public void outAHelperDef(AHelperDef node) + { + String name = node.getId().getText(); + ids.names.put(node, name); + } + + public void outATokenDef(ATokenDef node) + { + String name = "T" + ids.name(node.getId().getText()); + + ids.names.put(node, name); + } + + public void caseAAlt(final AAlt alt) + { + if(alt.getAltName() != null) + { + currentAlt = + "A" + + ids.name(alt.getAltName().getText()) + + currentProd; + + ids.names.put(alt, currentAlt); + } + else + { + currentAlt = "A" + currentProd; + ids.names.put(alt, currentAlt); + } + + AElem list_elem[] = (AElem[]) alt.getElems().toArray(new AElem[0]); + for(int i=0; i<list_elem.length;i++) + { + list_elem[i].apply(this); + } + } + + public void caseAAst(AAst node) + {} + + public void caseAElem(final AElem elem) + { + if(elem.getElemName() != null) + { + ids.names.put(elem, ids.name(elem.getElemName().getText()) ); + } + else + { + ids.names.put(elem, ids.name(elem.getId().getText())); + } + } + } + ); + } + + //Parser.java Generation + private void createParser() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "Parser.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + + try + { + Symbol[] terminals = Symbol.terminals(); + Symbol[] nonterminals = Symbol.nonterminals(); + Production[] productions = Production.productions(); + + macros.apply(file, "ParserHeader", new String[] {pkgName, + ids.pkgName.equals("") ? "lexer" : ids.pkgName + ".lexer", + ids.pkgName.equals("") ? "node" : ids.pkgName + ".node", + ids.pkgName.equals("") ? "analysis" : ids.pkgName + ".analysis"}); + + if(activateFilter && !grammarHasTransformations) + { + macros.apply(file, "ParserNoInliningPushHeader"); + macros.apply(file, "ParserCommon", new String[] {", true", ", false"}); + } + else + { + macros.apply(file, "ParserInliningPushHeader"); + macros.apply(file, "ParserCommon", new String[] {"", ""}); + } + + //this loop generates the code for all possible reductions and the type of + //the node needed to be created at a local point. + for(int i = 0; i < (productions.length - 1); i++) + { + Node node = (Node) alts.get(productions[i].name); + + if(activateFilter && !grammarHasTransformations) + { + macros.apply(file, "ParserNoInliningReduce", new String[] { + "" + productions[i].index, + "" + productions[i].leftside, + "" + (productions[i].name.startsWith("ANonTerminal$") || + productions[i].name.startsWith("ATerminal$")), + productions[i].name}); + } + else + { + macros.apply(file, "ParserInliningReduce", new String[] { + "" + productions[i].index, + "" + productions[i].leftside, + productions[i].name}); + } + } + + macros.apply(file, "ParserParseTail", new String[] {firstProductionName}); + + //the node creation code. Reduce methods definitions are done here + for(int i = 0; i < (productions.length - 1); i++) + { + macros.apply(file, "ParserNewHeader", new String[] { + "" + productions[i].index, + productions[i].name}); + + final Node node = (Node) alts.get(productions[i].name); + + final BufferedWriter finalFile = file; + final LinkedList stack = new LinkedList(); + + node.apply(new DepthFirstAdapter() + { + private int current; + + public void caseAElem(AElem elem) + { + current++; + + stack.addFirst(new Element("ParserNewBodyDecl", + new String[] {"" + current})); + } + } + ); + + try + { + for(Iterator it = stack.iterator(); it.hasNext();) + { + Element e = (Element) it.next(); + macros.apply(file, e.macro, e.arguments); + } + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + + String nodeName = (String)ids.names.get(node); + String realnodeName = (String)ids.names.get(node); + aParsedAltAdapter = + new GenerateAlternativeCodeForParser(pkgDir, nodeName, realnodeName, + file, transformIds, CG, CTP, + simpleTermTransform, macros, + listSimpleTermTransform, + transformIds.simpleTermOrsimpleListTermTypes); + node.apply(aParsedAltAdapter); + } + + macros.apply(file, "ParserActionHeader"); + + StringBuffer table = new StringBuffer(); + + DataOutputStream out = new DataOutputStream( + new BufferedOutputStream( + new FileOutputStream( + new File(pkgDir, "parser.dat")))); + + Vector outerArray = new Vector(); + //Generating of paring tables + for(int i = 0; i < Grammar.action_.length; i++) + { + Vector innerArray = new Vector(); + + String mostFrequentAction = "ERROR"; + int mostFrequentDestination = i; + int frequence = 0; + Map map = new TreeMap(IntegerComparator.instance); + + for(int j = 0; j < Grammar.action_[i].length; j++) + { + if(Grammar.action_[i][j] != null) + { + if(Grammar.action_[i][j][0] == 1) + { + Integer index = new Integer(Grammar.action_[i][j][1]); + Integer count = (Integer) map.get(index); + int freq = count == null ? 0 : count.intValue(); + map.put(index, new Integer(++freq)); + if(freq > frequence) + { + frequence = freq; + mostFrequentAction = "REDUCE"; + mostFrequentDestination = Grammar.action_[i][j][1]; + } + } + } + } + table.append("\t\t\t{"); + + table.append("{" + -1 + ", " + + mostFrequentAction + ", " + + mostFrequentDestination + "}, "); + innerArray.addElement( + new int[] {-1, + mostFrequentAction.equals("ERROR") ? 3 : 1, + mostFrequentDestination}); + + for(int j = 0; j < Grammar.action_[i].length; j++) + { + if(Grammar.action_[i][j] != null) + { + switch(Grammar.action_[i][j][0]) + { + case 0: + table.append("{" + j + ", SHIFT, " + Grammar.action_[i][j][1] + "}, "); + innerArray.addElement(new int[] {j, 0, Grammar.action_[i][j][1]}); + break; + case 1: + if(Grammar.action_[i][j][1] != mostFrequentDestination) + { + table.append("{" + j + ", REDUCE, " + Grammar.action_[i][j][1] + "}, "); + innerArray.addElement(new int[] {j, 1, Grammar.action_[i][j][1]}); + } + break; + case 2: + table.append("{" + j + ", ACCEPT, -1}, "); + innerArray.addElement(new int[] {j, 2, -1}); + break; + } + } + } + + table.append("}," + System.getProperty("line.separator")); + outerArray.addElement(innerArray); + } + + file.write("" + table); + + out.writeInt(outerArray.size()); + for(Enumeration e = outerArray.elements(); e.hasMoreElements();) + { + Vector innerArray = (Vector) e.nextElement(); + out.writeInt(innerArray.size()); + for(Enumeration n = innerArray.elements(); n.hasMoreElements();) + { + int[] array = (int[]) n.nextElement(); + + for(int i = 0; i < 3; i++) + { + out.writeInt(array[i]); + } + } + } + + macros.apply(file, "ParserActionTail"); + + macros.apply(file, "ParserGotoHeader"); + + table = new StringBuffer(); + outerArray = new Vector(); + + for(int j = 0; j < nonterminals.length - 1; j++) + { + Vector innerArray = new Vector(); + + int mostFrequent = -1; + int frequence = 0; + Map map = new TreeMap(IntegerComparator.instance); + + for(int i = 0; i < Grammar.goto_.length; i++) + { + if(Grammar.goto_[i][j] != -1) + { + Integer index = new Integer(Grammar.goto_[i][j]); + Integer count = (Integer) map.get(index); + int freq = count == null ? 0 : count.intValue(); + map.put(index, new Integer(++freq)); + if(freq > frequence) + { + frequence = freq; + mostFrequent = Grammar.goto_[i][j]; + } + } + } + + table.append("\t\t\t{"); + + table.append("{" + (-1) + ", " + mostFrequent + "}, "); + innerArray.addElement(new int[] {-1, mostFrequent}); + + for(int i = 0; i < Grammar.goto_.length; i++) + { + if((Grammar.goto_[i][j] != -1) && + (Grammar.goto_[i][j] != mostFrequent)) + { + table.append("{" + i + ", " + Grammar.goto_[i][j] + "}, "); + innerArray.addElement(new int[] {i, Grammar.goto_[i][j]}); + } + } + + table.append("}," + System.getProperty("line.separator")); + + outerArray.addElement(innerArray); + } + + file.write("" + table); + + out.writeInt(outerArray.size()); + for(Enumeration e = outerArray.elements(); e.hasMoreElements();) + { + Vector innerArray = (Vector) e.nextElement(); + out.writeInt(innerArray.size()); + for(Enumeration n = innerArray.elements(); n.hasMoreElements();) + { + int[] array = (int[]) n.nextElement(); + + for(int i = 0; i < 2; i++) + { + out.writeInt(array[i]); + } + } + } + + macros.apply(file, "ParserGotoTail"); + + macros.apply(file, "ParserErrorsHeader"); + + table = new StringBuffer(); + StringBuffer index = new StringBuffer(); + int nextIndex = 0; + + Map errorIndex = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + IntegerCast.instance); + + outerArray = new Vector(); + Vector indexArray = new Vector(); + + index.append("\t\t\t"); + for(int i = 0; i < Grammar.action_.length; i++) + { + StringBuffer s = new StringBuffer(); + s.append("expecting: "); + + boolean comma = false; + for(int j = 0; j < Grammar.action_[i].length; j++) + { + if(Grammar.action_[i][j] != null) + { + if(comma) + { + s.append(", "); + } + else + { + comma = true; + } + + s.append(Symbol.symbol(j, true).errorName); + } + } + + if(errorIndex.containsKey(s.toString())) + { + index.append(errorIndex.get(s.toString()) + ", "); + indexArray.addElement(errorIndex.get(s.toString())); + } + else + { + table.append("\t\t\t\"" + s + "\"," + System.getProperty("line.separator")); + outerArray.addElement(s.toString()); + errorIndex.put(s.toString(), new Integer(nextIndex)); + indexArray.addElement(new Integer(nextIndex)); + index.append(nextIndex++ + ", "); + } + } + + file.write("" + table); + + out.writeInt(outerArray.size()); + for(Enumeration e = outerArray.elements(); e.hasMoreElements();) + { + String s = (String) e.nextElement(); + out.writeInt(s.length()); + int length = s.length(); + for(int i = 0; i < length; i++) + { + out.writeChar(s.charAt(i)); + } + } + + out.writeInt(indexArray.size()); + for(Enumeration e = indexArray.elements(); e.hasMoreElements();) + { + Integer n = (Integer) e.nextElement(); + out.writeInt(n.intValue()); + } + + out.close(); + + macros.apply(file, "ParserErrorsTail"); + + macros.apply(file, "ParserErrorIndexHeader"); + file.write("" + index); + macros.apply(file, "ParserErrorIndexTail"); + + macros.apply(file, "ParserTail"); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + private void createTokenIndex() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "TokenIndex.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "TokenIndex.java").getAbsolutePath()); + } + + try + { + Symbol[] terminals = Symbol.terminals(); + + macros.apply(file, "TokenIndexHeader", new String[] {pkgName, + ids.pkgName.equals("") ? "node" : ids.pkgName + ".node", + ids.pkgName.equals("") ? "analysis" : ids.pkgName + ".analysis"}); + + for(int i = 0; i < (terminals.length - 2); i++) + { + macros.apply(file, "TokenIndexBody", new String[] {terminals[i].name, "" + i}); + } + + macros.apply(file, "TokenIndexTail", new String[] {"" + (terminals.length - 2)}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "TokenIndex.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + private void createParserException() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "ParserException.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "ParserException.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "ParserException", new String[] {pkgName, + ids.pkgName.equals("") ? "node" : ids.pkgName + ".node"}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "ParserException.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + private void createState() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "State.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "State.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "State", new String[] {pkgName}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "State.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + private int count(String name) + { + if(name.charAt(0) != 'X') + { + return 0; + } + + StringBuffer s = new StringBuffer(); + int i = 1; + + while((i < name.length()) && + (name.charAt(i) >= '0') && + (name.charAt(i) <= '9')) + { + s.append(name.charAt(i++)); + } + + return Integer.parseInt(s.toString()); + } + + private String name(String name) + { + if(name.charAt(0) != 'X') + { + return name; + } + + int i = 1; + while((i < name.length()) && + (name.charAt(i) >= '0') && + (name.charAt(i) <= '9')) + { + i++; + } + + return name.substring(i); + } + + static class Element + { + String macro; + String[] arguments; + + Element(String macro, String[] arguments) + { + this.macro = macro; + this.arguments = arguments; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/GenProds.java b/src/main/java/org/sablecc/sablecc/GenProds.java new file mode 100644 index 0000000..5e47012 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/GenProds.java @@ -0,0 +1,125 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +public class GenProds extends DepthFirstAdapter +{ + private MacroExpander macros; + private ResolveAstIds ast_ids; + private File pkgDir; + private String pkgName; + private Map hiddenProds = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + + public GenProds(ResolveAstIds ast_ids) + { + this.ast_ids = ast_ids; + + try + { + macros = new MacroExpander( + new InputStreamReader( + getClass().getResourceAsStream("productions.txt"))); + } + catch(IOException e) + { + throw new RuntimeException("unable to open productions.txt."); + } + + pkgDir = new File(ast_ids.astIds.pkgDir, "node"); + pkgName = ast_ids.astIds.pkgName.equals("") ? "node" : ast_ids.astIds.pkgName + ".node"; + + if(!pkgDir.exists()) + { + if(!pkgDir.mkdir()) + { + throw new RuntimeException("Unable to create " + pkgDir.getAbsolutePath()); + } + } + } + + public void inAAstProd(AAstProd node) + { + String name = (String) ast_ids.ast_names.get(node); + + createProduction(name); + } + + private void createProduction(String name) + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, name + ".java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, name + ".java").getAbsolutePath()); + } + + try + { + macros.apply(file, "Production", new String[] {pkgName, name}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, name + ".java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + private void createAlternative(String name, String macro, String[] arg) + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, name + ".java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, name + ".java").getAbsolutePath()); + } + + try + { + macros.apply(file, macro, arg); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, name + ".java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } +} diff --git a/src/main/java/org/sablecc/sablecc/GenTokens.java b/src/main/java/org/sablecc/sablecc/GenTokens.java new file mode 100644 index 0000000..dac7d0c --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/GenTokens.java @@ -0,0 +1,201 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.io.*; +import java.util.LinkedList; + +public class GenTokens extends DepthFirstAdapter +{ + private MacroExpander macros; + private ResolveIds ids; + private File pkgDir; + private String pkgName; + + // final GenTokens instance = this; + String text; + + public GenTokens(ResolveIds ids) + { + this.ids = ids; + + try + { + macros = new MacroExpander( + new InputStreamReader( + getClass().getResourceAsStream("tokens.txt"))); + } + catch(IOException e) + { + throw new RuntimeException("unable to open tokens.txt."); + } + + pkgDir = new File(ids.pkgDir, "node"); + pkgName = ids.pkgName.equals("") ? "node" : ids.pkgName + ".node"; + + if(!pkgDir.exists()) + { + if(!pkgDir.mkdir()) + { + throw new RuntimeException("Unable to create " + pkgDir.getAbsolutePath()); + } + } + } + + public void inATokenDef(ATokenDef node) + { + String name = (String) ids.names.get(node); + + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, name + ".java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, name + ".java").getAbsolutePath()); + } + + text = null; + + ARegExp regExp = (ARegExp) node.getRegExp(); + + LinkedList concats = regExp.getConcats(); + + if(concats.size() == 1) + { + AConcat concat = (AConcat)concats.getFirst(); + LinkedList unExps = concat.getUnExps(); + + if(unExps.size() == 1) + { + AUnExp unExp = (AUnExp) unExps.getFirst(); + + PBasic basic = unExp.getBasic(); + + if((basic instanceof AStringBasic) && + (unExp.getUnOp() == null)) + { + text = ((AStringBasic) basic).getString().getText(); + text = text.substring(1, text.length() - 1); + } + else if((basic instanceof ACharBasic) && + (unExp.getUnOp() == null)) + { + PChar pChar = ((ACharBasic) basic).getChar(); + + if(pChar instanceof ACharChar) + { + text = ((ACharChar) pChar).getChar().getText(); + text = text.substring(1, text.length() - 1); + } + } + } + } + + try + { + if(text == null) + { + ids.fixedTokens.put(node, new Boolean(false)); + + macros.apply(file, "VariableTextToken", new String[] { pkgName, + ids.pkgName.equals("") ? "analysis" : ids.pkgName + ".analysis", + name}); + } + else + { + ids.fixedTokens.put(node, new Boolean(true)); + + macros.apply(file, "FixedTextToken", new String[] { pkgName, + ids.pkgName.equals("") ? "analysis" : ids.pkgName + ".analysis", + name, processText(text)}); + + ids.errorNames.put(node, "'" + text + "'"); + } + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, name + ".java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + private String processText(String s) + { + StringBuffer result = new StringBuffer(); + + for(int i = 0; i < s.length(); i++) + { + char c = s.charAt(i); + + switch(c) + { + case '\b': + { + result.append("\\t"); + break; + } + case '\t': + { + result.append("\\t"); + break; + } + case '\n': + { + result.append("\\n"); + break; + } + case '\f': + { + result.append("\\f"); + break; + } + case '\r': + { + result.append("\\r"); + break; + } + case '\"': + { + result.append("\\\""); + break; + } + case '\'': + { + result.append("\\\'"); + break; + } + case '\\': + { + result.append("\\\\"); + break; + } + default: + { + result.append(c); + } + } + } + + return result.toString(); + } +} + diff --git a/src/main/java/org/sablecc/sablecc/GenUtils.java b/src/main/java/org/sablecc/sablecc/GenUtils.java new file mode 100644 index 0000000..06ea736 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/GenUtils.java @@ -0,0 +1,252 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +public class GenUtils extends DepthFirstAdapter +{ + private MacroExpander macros; + private ResolveAstIds ast_ids; + private File pkgDir; + private String pkgName; + private String mainProduction; + + public GenUtils(ResolveAstIds ast_ids) + { + this.ast_ids = ast_ids; + + try + { + macros = new MacroExpander( + new InputStreamReader( + getClass().getResourceAsStream("utils.txt"))); + } + catch(IOException e) + { + throw new RuntimeException("unable to open utils.txt."); + } + + pkgDir = new File(ast_ids.astIds.pkgDir, "node"); + pkgName = ast_ids.astIds.pkgName.equals("") ? "node" : ast_ids.astIds.pkgName + ".node"; + + if(!pkgDir.exists()) + { + if(!pkgDir.mkdir()) + { + throw new RuntimeException("Unable to create " + pkgDir.getAbsolutePath()); + } + } + } + + /* + public void caseAGrammar(AGrammar node) + { + AAstProd []temp = (AAstProd[])node.getAst().toArray(new AAstProd[0]); + + for(int i=0; i<temp.length; i++) + { + temp[i].apply(this); + } + } + */ + + public void caseAAstProd(AAstProd node) + { + if(mainProduction == null) + { + mainProduction = (String) ast_ids.ast_names.get(node); + } + } + + public void outStart(Start node) + { + if(mainProduction != null) + { + createStart(); + } + + createEOF(); + createNode(); + createToken(); + create("Switch"); + create("Switchable"); + } + + public void createStart() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "Start.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "Start.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "Start", new String[] {pkgName, + ast_ids.astIds.pkgName.equals("") ? "analysis" : ast_ids.astIds.pkgName + ".analysis", + mainProduction, GenAlts.nodeName(mainProduction)}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Start.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + public void createEOF() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "EOF.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "EOF.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "EOF", new String[] {pkgName, + ast_ids.astIds.pkgName.equals("") ? "analysis" : ast_ids.astIds.pkgName + ".analysis"}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "EOF.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + public void createNode() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "Node.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "Node.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "Node", new String[] {pkgName, + ast_ids.astIds.pkgName.equals("") ? "analysis" : ast_ids.astIds.pkgName + ".analysis"}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Node.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + public void createToken() + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, "Token.java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, "Token.java").getAbsolutePath()); + } + + try + { + macros.apply(file, "Token", new String[] {pkgName}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Token.java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } + + public void create(String cls) + { + BufferedWriter file; + + try + { + file = new BufferedWriter( + new FileWriter( + new File(pkgDir, cls + ".java"))); + } + catch(IOException e) + { + throw new RuntimeException("Unable to create " + new File(pkgDir, cls + ".java").getAbsolutePath()); + } + + try + { + macros.apply(file, cls, new String[] {pkgName}); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, cls + ".java").getAbsolutePath()); + } + + try + { + file.close(); + } + catch(IOException e) + {} + } +} diff --git a/src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java b/src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java new file mode 100644 index 0000000..8a532a4 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java @@ -0,0 +1,604 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.io.*; +import org.sablecc.sablecc.Grammar; +import java.util.Vector; +import java.util.Enumeration; + +public class GenerateAlternativeCodeForParser extends DepthFirstAdapter +{ + String currentAlt; + String realcurrentAlt; + BufferedWriter file; + private File pkgDir; + + private ResolveTransformIds transformIds; + private ComputeCGNomenclature CG; + private ComputeSimpleTermPosition CTP; + private MacroExpander macros; + private Map simpleTermTransformMap; + private LinkedList listSimpleTermTransform; + private Map simpleTermOrsimpleListTermTypes; + + GenerateAlternativeCodeForParser(File pkgDir, String aParsedAltName, + String raParsedAltName, + BufferedWriter file, + ResolveTransformIds transformIds, + ComputeCGNomenclature CG, + ComputeSimpleTermPosition CTP, + Map simpleTermTransformMap, + MacroExpander macros, + LinkedList listSimpleTermTransform, + Map simpleTermOrsimpleListTermTypes) + { + this.pkgDir = pkgDir; + this.file = file; + currentAlt = aParsedAltName; + realcurrentAlt = raParsedAltName; + this.transformIds = transformIds; + this.CG = CG; + this.CTP = CTP; + this.simpleTermTransformMap = simpleTermTransformMap; + this.macros = macros; + this.listSimpleTermTransform = listSimpleTermTransform; + this.simpleTermOrsimpleListTermTypes = simpleTermOrsimpleListTermTypes; + } + + public void inAAltTransform(AAltTransform node) + { + Object temp[] = node.getTerms().toArray(); + String type_name; + int position; + + for(int i = 0; i < temp.length; i++) + { + if(simpleTermTransformMap.get(temp[i]) != null) + { + type_name = (String)simpleTermTransformMap.get(temp[i]); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(temp[i]); + } + + position = ((Integer)CG.getTermNumbers().get(temp[i])).intValue(); + + try + { + if(type_name.startsWith("L")) + { + macros.apply(file, "ParserListVariableDeclaration", new String[] {"" + position}); + } + else if(type_name.equals("null")) + { + macros.apply(file, "ParserNullVariableDeclaration", new String[] {"" + position}); + } + else + { + macros.apply(file, "ParserSimpleVariableDeclaration", new String[] {type_name, type_name.toLowerCase(), "" + position}); + } + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + } + } + + public void outAAltTransform(AAltTransform node) + { + Object temp[] = node.getTerms().toArray(); + String type_name; + int position; + + try + { + for(int i = 0; i < temp.length; i++) + { + if(simpleTermTransformMap.get(temp[i]) != null) + { + type_name = (String)simpleTermTransformMap.get(temp[i]); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(temp[i]); + } + + position = ((Integer)CG.getTermNumbers().get(temp[i])).intValue(); + + if(type_name.startsWith("L")) + { + type_name = "list"; + } + else if(type_name.equals("null")) + { + type_name = "null"; + } + else + { + type_name = type_name.toLowerCase(); + } + macros.apply(file, "ParserNewBodyListAdd", new String[] {type_name, "" + position}); + + } + macros.apply(file, "ParserNewTail"); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + } + + public void inAParams(LinkedList list_param) + { + String type_name; + int position; + + Object temp[] = list_param.toArray(); + + for(int i = 0; i < temp.length; i++) + { + if(simpleTermTransformMap.get(temp[i]) != null) + { + type_name = (String)simpleTermTransformMap.get(temp[i]); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(temp[i]); + } + position = ((Integer)CG.getTermNumbers().get(temp[i])).intValue(); + + try + { + if(type_name.startsWith("L")) + { + macros.apply(file, "ParserListVariableDeclaration", new String[] {"" + position}); + } + else if(type_name.equals("null")) + { + macros.apply(file, "ParserNullVariableDeclaration", new String[] {"" + position}); + } + else + { + macros.apply(file, "ParserSimpleVariableDeclaration", new String[] {type_name, type_name.toLowerCase(), "" + position}); + } + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + } + } + + public void inASimpleTerm(ASimpleTerm node) + { + try + { + String type_name; + if(simpleTermTransformMap.get(node) != null) + { + type_name = (String)simpleTermTransformMap.get(node); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(node); + } + int position = ((Integer)CG.getTermNumbers().get(node)).intValue(); + String termKey = currentAlt+"."+node.getId().getText(); + int elemPosition = ((Integer)CTP.elems_position.get(termKey)).intValue(); + int positionMap = 0; + + if(node.getSimpleTermTail() != null ) + { + if( !listSimpleTermTransform.contains(node.getId().getText() ) ) + { + String type = (String)CTP.positionsMap.get( realcurrentAlt+"."+node.getId().getText() ); + LinkedList list = (LinkedList)transformIds.getProdTransformIds().prod_transforms.get(type); + if( list.indexOf( node.getSimpleTermTail().getText() ) >= 0 ) + { + positionMap = list.indexOf( node.getSimpleTermTail().getText() ); + } + } + + if(simpleTermOrsimpleListTermTypes.get(node) != null) + { + String type = (String)simpleTermOrsimpleListTermTypes.get(node); + LinkedList list = (LinkedList)transformIds.getProdTransformIds().prod_transforms.get(type); + if( list.indexOf( node.getSimpleTermTail().getText() ) >= 0 ) + { + positionMap = list.indexOf( node.getSimpleTermTail().getText() ); + } + } + } + + String type; + if(type_name.startsWith("L")) + { + type_name = "list"; + type = "LinkedList"; + } + else if(type_name.equals("null")) + { + type_name = "null"; + type = "Object"; + } + else + { + type = type_name; + } + + macros.apply(file, "ParserSimpleTerm", new String[] + { + type_name.toLowerCase(), ""+position, + type, ""+elemPosition, ""+positionMap + } + ); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + } + + public void inASimpleListTerm(ASimpleListTerm node) + { + try + { + String type_name; + if(simpleTermTransformMap.get(node) != null) + { + type_name = (String)simpleTermTransformMap.get(node); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(node); + } + + String termKey = currentAlt+"."+node.getId().getText(); + int position = ((Integer)CG.getTermNumbers().get(node)).intValue(); + + int elemPosition = ((Integer)CTP.elems_position.get(termKey)).intValue(); + + int positionMap = 0; + + if(node.getSimpleTermTail() != null ) + { + if( !listSimpleTermTransform.contains(node.getId().getText()) ) + { + String type = (String)CTP.positionsMap.get( realcurrentAlt+"."+node.getId().getText() ); + LinkedList list = (LinkedList)transformIds.getProdTransformIds().prod_transforms.get(type); + if( list.indexOf( node.getSimpleTermTail().getText() ) >= 0 ) + { + positionMap = list.indexOf( node.getSimpleTermTail().getText() ); + } + } + + if(simpleTermOrsimpleListTermTypes.get(node) != null) + { + String type = (String)simpleTermOrsimpleListTermTypes.get(node); + LinkedList list = (LinkedList)transformIds.getProdTransformIds().prod_transforms.get(type); + if( list.indexOf( node.getSimpleTermTail().getText() ) >= 0 ) + { + positionMap = list.indexOf( node.getSimpleTermTail().getText() ); + } + } + } + + String type; + if(type_name.startsWith("L")) + { + type_name = "list"; + type = "LinkedList"; + } + else if(type_name.equals("null")) + { + type_name = "null"; + type = "Object"; + } + else + { + type = type_name; + } + + macros.apply(file, "ParserSimpleTerm", new String[] + { + type_name.toLowerCase(), ""+position, + type, ""+elemPosition, ""+positionMap + } + ); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + } + + public void inANewTerm(ANewTerm node) + { + try + { + macros.apply(file, "ParserBraceOpening"); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + inAParams(node.getParams()); + } + + public void inANewListTerm(ANewListTerm node) + { + try + { + macros.apply(file, "ParserBraceOpening"); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + inAParams(node.getParams()); + } + + public void inAListTerm(AListTerm node) + { + try + { + macros.apply(file, "ParserBraceOpening"); + Object temp[] = node.getListTerms().toArray(); + + for(int i = 0; i < temp.length; i++) + { + String type_name; + if(simpleTermTransformMap.get(temp[i]) != null) + { + type_name = (String)simpleTermTransformMap.get(temp[i]); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(temp[i]); + } + int position = ((Integer)CG.getTermNumbers().get(temp[i])).intValue(); + + if(type_name.startsWith("L")) + { + macros.apply(file, "ParserListVariableDeclaration", new String[] {"" + position}); + } + else if(type_name.equals("null")) + { + macros.apply(file, "ParserNullVariableDeclaration", new String[] {"" + position}); + } + else + { + macros.apply(file, "ParserSimpleVariableDeclaration", new String[] {type_name, type_name.toLowerCase(), "" + position}); + } + } + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + } + + public void outAListTerm(AListTerm node) + { + try + { + Object temp[] = node.getListTerms().toArray(); + int listPosition = ((Integer)CG.getTermNumbers().get(node)).intValue(); + + for(int i = 0; i < temp.length; i++) + { + String type_name; + if(simpleTermTransformMap.get(temp[i]) != null) + { + type_name = (String)simpleTermTransformMap.get(temp[i]); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(temp[i]); + } + int position = ((Integer)CG.getTermNumbers().get(temp[i])).intValue(); + + if(!type_name.equals("null")) + { + if(type_name.startsWith("L")) + { + macros.apply(file, "ParserTypedLinkedListAddAll", new String[] {"list", ""+listPosition, "list", ""+ position}); + } + else + { + macros.apply(file, "ParserTypedLinkedListAdd", new String[] {"list", ""+listPosition, type_name.toLowerCase(), ""+ position}); + } + } + } + macros.apply(file, "ParserBraceClosing"); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "Parser.java").getAbsolutePath()); + } + } + + public void outANewTerm(ANewTerm node) + { + String type_name = (String)CG.getAltTransformElemTypes().get(node); + if(simpleTermTransformMap.get(node) != null) + { + type_name = (String)simpleTermTransformMap.get(node); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(node); + } + int position = ((Integer)CG.getTermNumbers().get(node)).intValue(); + String newAltName = name((AProdName)node.getProdName()); + + try + { + if(type_name.startsWith("L")) + { + type_name = "list"; + } + else + { + type_name = type_name.toLowerCase(); + } + macros.apply(file, "ParserNewBodyNew", new String[] {type_name, ""+position, newAltName}); + + if(node.getParams().size() > 0) + { + Object temp[] = node.getParams().toArray(); + String isNotTheFirstParam = ""; + + for(int i = 0; i < temp.length; i++) + { + if(simpleTermTransformMap.get(temp[i]) != null) + { + type_name = (String)simpleTermTransformMap.get(temp[i]); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(temp[i]); + } + position = ((Integer)CG.getTermNumbers().get(temp[i])).intValue(); + + if(i != 0) + { + isNotTheFirstParam = ", "; + } + + if(type_name.equals("null")) + { + macros.apply(file, "ParserNew&ListBodyParamsNull", new String[] {isNotTheFirstParam+"null"}); + } + else + { + if(type_name.startsWith("L")) + { + type_name = "list"; + } + else + { + type_name = type_name.toLowerCase(); + } + macros.apply(file, "ParserNew&ListBodyParams", new String[] {isNotTheFirstParam+type_name, ""+position}); + } + + } + } + macros.apply(file, "ParserNewBodyNewTail"); + macros.apply(file, "ParserBraceClosing"); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "TokenIndex.java").getAbsolutePath()); + } + } + + public void outANewListTerm(ANewListTerm node) + { + String type_name; + if(simpleTermTransformMap.get(node) != null) + { + type_name = (String)simpleTermTransformMap.get(node); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(node); + } + int position = ((Integer)CG.getTermNumbers().get(node)).intValue(); + String newAltName = name((AProdName)node.getProdName()); + try + { + if(type_name.startsWith("L")) + { + type_name = "list"; + } + else + { + type_name = type_name.toLowerCase(); + } + macros.apply(file, "ParserNewBodyNew", new String[] {type_name, ""+position, newAltName}); + + if(node.getParams().size() > 0) + { + Object temp[] = node.getParams().toArray(); + String isNotTheFirstParam = ""; + + for(int i = 0; i < temp.length; i++) + { + if(simpleTermTransformMap.get(temp[i]) != null) + { + type_name = (String)simpleTermTransformMap.get(temp[i]); + } + else + { + type_name = (String)CG.getAltTransformElemTypes().get(temp[i]); + } + position = ((Integer)CG.getTermNumbers().get(temp[i])).intValue(); + + if(i != 0) + { + isNotTheFirstParam = ", "; + } + + if(type_name.equals("null")) + { + macros.apply(file, "ParserNew&ListBodyParamsNull", new String[] {isNotTheFirstParam+"null"}); + } + else + { + if(type_name.startsWith("L")) + { + type_name = "list"; + } + else + { + type_name = type_name.toLowerCase(); + } + macros.apply(file, "ParserNew&ListBodyParams", new String[] {isNotTheFirstParam+type_name, ""+position}); + } + } + } + macros.apply(file, "ParserNewBodyNewTail"); + macros.apply(file, "ParserBraceClosing"); + } + catch(IOException e) + { + throw new RuntimeException("An error occured while writing to " + + new File(pkgDir, "TokenIndex.java").getAbsolutePath()); + } + } + + public String name(AProdName node) + { + if(node.getProdNameTail() != null) + { + return "A" + + ResolveIds.name(node.getProdNameTail().getText()) + + ResolveIds.name(node.getId().getText()); + } + return "A" + ResolveIds.name(node.getId().getText()); + } + +} diff --git a/src/main/java/org/sablecc/sablecc/Grammar.java b/src/main/java/org/sablecc/sablecc/Grammar.java new file mode 100644 index 0000000..77d121b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/Grammar.java @@ -0,0 +1,687 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.Vector; +import java.util.*; + +public final class Grammar +{ + private static TreeMap fastLr0Closure = new TreeMap(); + private static TreeMap fastLr1Closure = new TreeMap(); + + static int startSymbol; + static int startProduction; + static int eof ; + static int dummy ; + + static int[][][] action_; + static int[][] goto_; + + static + { + reinit(); + } + + private Grammar() + {} + + public static int addTerminal(String name, String errorName) + { + return new Symbol(name, errorName, true).index; + } + + public static int addNonterminal(String name) + { + return new Symbol(name, null, false).index; + } + + public static int addProduction(String nonterminal, String name) + { + Symbol symbol = Symbol.symbol(nonterminal); + + if(symbol.terminal) + { + throw new IllegalArgumentException("The symbol " + nonterminal + + " is a terminal."); + } + + return new Production(symbol.index, name).index; + } + + public static void addSymbolToProduction(String symbol, int production) + { + Production.production(production).addSymbol(Symbol.symbol(symbol)); + } + + public static void reinit() + { + fastLr0Closure = new TreeMap(); + fastLr1Closure = new TreeMap(); + startSymbol = 0; + startProduction = -1; + eof = -1; + dummy = -1; + action_ = null; + goto_ = null; + } + + public static void computeLALR() throws ConflictException + { + // Add EOF to terminals + eof = addTerminal("EOF", "EOF"); + // Add dummy to terminals + dummy = addTerminal("#", null); + + // Add the production S'->S + startSymbol = addNonterminal("Start"); + Production start = new Production(startSymbol, "Start"); + start.addSymbol(Symbol.symbol(0, false)); + startProduction = start.index; + + computeFirst(); + + LR0ItemSet set + = new LR0ItemSet(); + set.set(new LR0Item(startProduction, 0)); + LR1Collection collection = new LR1Collection(set + ); + + LR0ItemSet[] sets = collection.collection.sets(); + Symbol[] terminals = Symbol.terminals(); + Symbol[] nonterminals = Symbol.nonterminals(); + + action_ = new int[sets.length][terminals.length - 1][]; + goto_ = new int[sets.length][nonterminals.length - 1]; + + Set listOfConflictualProds = new HashSet(); + StringBuffer conflictMessage = new StringBuffer(); + + for(int i = 0; i < sets.length; i++) + { + System.out.print("."); + + LR1ItemSet state = new LR1ItemSet(); + + { + LR0Item[] items = sets[i].items(); + for(int j = 0; j < items.length; j++) + { + Symbol[] lookaheads = ((SymbolSet) collection.lookaheads[i]. + get + (items[j])).getSymbols(); + + for(int k = 0; k < lookaheads.length; k++) + { + state.set(new LR1Item(items[j], lookaheads[k].index)); + } + } + } + + state = CLOSURE(state); + + LR1Item[] items = state.items(); + + for(int j = 0; j < terminals.length; j++) + { + Integer destination = collection.collection.GOTO(i, terminals[j]); + if(destination != null) + { + //Shift action is taken + action_[i][j] = new int[] {0, destination.intValue()}; + } + + for(int k = 0; k < items.length; k++) + { + Production production = Production. + production(items[k].lr0Item.production); + + //A conflict occurs only if one is on the end of an alternative + try + { + production.rightside(items[k].lr0Item.position); + } + catch(Exception e) + { + if(production.leftside != startSymbol) + { + if(items[k].terminal == terminals[j].index) + { + int[] action = action_[i][j]; + if(action != null) + { + /* The current alternative is conflictual (reduce in a XXX/reduce conflict) */ + listOfConflictualProds.add(Symbol.symbol(production.leftside, false).toString()); + + /* */ + switch(action[0]) + { + case 0: + conflictMessage.append( + "\n\nshift/reduce conflict in state [stack:" + + collection.collection.names.elementAt(i) + "*] on " + + terminals[j] + " in " + state.toString(terminals[j])); + + /* nothing else to do */ + break; + + case 1: + conflictMessage.append( + "\n\nreduce/reduce conflict in state [stack:" + + collection.collection.names.elementAt(i) + "*] on " + + terminals[j] + " in " + state.toString(terminals[j])); + + listOfConflictualProds.add(Symbol.symbol(Production.production(action[1]).leftside, false).toString()); + break; + + case 2: + conflictMessage.append( + "\n\nreduce/accept conflict in state [stack:" + + collection.collection.names.elementAt(i) + "*] on " + + terminals[j] + " in " + state.toString(terminals[j])); + + listOfConflictualProds.add(Symbol.symbol(Production.production(action[1]).leftside, false).toString()); + break; + } + } + else + { + //it's a reduction action + action_[i][j] = new int[] {1, + items[k].lr0Item.production}; + } + } + } + else + { + if(terminals[j].index == eof) + { + int[] action = action_[i][j]; + if(action != null) + { + /* The current alternative is conflictual (accept in a XXX/accept conflict) */ + listOfConflictualProds.add(Symbol.symbol(production.leftside, false).toString()); + + /* */ + switch(action[0]) + { + case 0: + conflictMessage.append( + "shift/accept conflict in state [stack:" + + collection.collection.names.elementAt(i) + "*] on " + + terminals[j] + " in " + state); + + /* nothing else to do */ + break; + + case 1: + conflictMessage.append( + "reduce/accept conflict in state [stack:" + + collection.collection.names.elementAt(i) + "*] on " + + terminals[j] + " in " + state); + + listOfConflictualProds.add(Symbol.symbol(Production.production(action[1]).leftside, false).toString()); + + break; + } + } + else + { + //accept action is taken + action_[i][j] = new int[] {2}; + } + } + } + }//End of catch + } + + } + + if (listOfConflictualProds.size() > 0) + { + throw new ConflictException(listOfConflictualProds, conflictMessage.toString()); + } + + for(int j = 0; j < nonterminals.length - 1; j++) + { + Integer destination = collection.collection.GOTO(i, nonterminals[j]); + + if(destination != null) + { + goto_[i][j] = destination.intValue(); + } + else + { + goto_[i][j] = -1; + } + } + + } + System.out.println(); + } + + static SymbolSet[] FIRST_Terminal; + static SymbolSet[] FIRST_Nonterminal; + + static void computeFirst() + { + // Get terminals, nonterminals and productions + Symbol[] terminals = Symbol.terminals(); + Symbol[] nonterminals = Symbol.nonterminals(); + Production[] productions = Production.productions(); + + // Initialize FIRST(X) to {} + FIRST_Terminal = new SymbolSet[terminals.length]; + for(int i = 0; i < terminals.length; i++) + { + FIRST_Terminal[i] = new SymbolSet(); + } + + FIRST_Nonterminal = new SymbolSet[nonterminals.length]; + for(int i = 0; i < nonterminals.length; i++) + { + FIRST_Nonterminal[i] = new SymbolSet(); + } + + // if X is terminal, then FIRST(X) is {X} + for(int i = 0; i < terminals.length; i++) + { + FIRST_Terminal[i].setTerminal(terminals[i].index); + } + + // if X -> empty is a production, then add empty to FIRST(X) + for(int i = 0; i < productions.length; i++) + { + if(productions[i].rightside().length == 0) + { + FIRST_Nonterminal[productions[i].leftside]. + setEmpty(); + } + } + + // if X is nonterminal and X -> Y(1) Y(2) ... Y(k) is a production, + // then place t in FIRST(X) if for some i, t is in FIRST(Y(i)), and + // empty is in all of FIRST(Y(1)), ... , FIRST(Y(i-1)). + boolean changed; + do + { + changed = false; + + for(int i = 0; i < productions.length; i++) + { + SymbolSet before = + (SymbolSet) FIRST_Nonterminal[productions[i].leftside].clone(); + + FIRST_Nonterminal[productions[i].leftside]. + or(FIRST(productions[i].rightside())); + + if(!before.equals(FIRST_Nonterminal[productions[i].leftside])) + { + changed = true; + } + } + } + while(changed); + } + + static SymbolSet FIRST(Symbol[] symbols) + { + return FIRST(symbols, 0, symbols.length); + } + + static SymbolSet FIRST(Symbol[] symbols, int begin) + { + return FIRST(symbols, begin, symbols.length); + } + + static SymbolSet FIRST(Symbol[] symbols, int begin, int end) + { + SymbolSet result = new SymbolSet(); + + boolean previousContainsEmpty = true; + + for(int i = begin; i < end; i++) + { + if(!previousContainsEmpty) + { + break; + } + + if(symbols[i].terminal) + { + result.or(FIRST_Terminal[symbols[i].index]); + previousContainsEmpty = FIRST_Terminal[symbols[i].index].getEmpty(); + } + else + { + result.or(FIRST_Nonterminal[symbols[i].index]); + previousContainsEmpty = FIRST_Nonterminal[symbols[i].index].getEmpty(); + } + } + + if(previousContainsEmpty) + { + result.setEmpty(); + } + else + { + result.clearEmpty(); + } + + return result; + } + + static SymbolSet[] FOLLOW; + + static void computeFollow() + { + // Get terminals, nonterminals and productions + Symbol[] terminals = Symbol.terminals(); + Symbol[] nonterminals = Symbol.nonterminals(); + Production[] productions = Production.productions(); + + // Initialize FOLLOW(A) to {} + FOLLOW = new SymbolSet[nonterminals.length]; + for(int i = 0; i < nonterminals.length; i++) + { + FOLLOW[i] = new SymbolSet(); + } + + // Place eof in FOLLOW(S) where S is the start symbol. + FOLLOW[startSymbol].setTerminal(eof); + + // If there is a production A->xBy, then everything in FIRST(y) except + // for empty is placed in FOLLOW(B). + for(int i = 0; i < productions.length; i++) + { + Symbol[] rightside = productions[i].rightside(); + + for(int j = 0; j < rightside.length; j++) + { + if(!rightside[j].terminal) + { + SymbolSet set + = FIRST(rightside, j + 1); + set.clearEmpty(); + FOLLOW[rightside[j].index].or(set + ); + } + } + } + + // If there is a production A->xB, or a production A->xBy where FIRST(y) + // contains empty, then everything in FOLLOW(A) is in FOLLOW(B). + boolean changed; + do + { + changed = false; + + for(int i = 0; i < productions.length; i++) + { + Symbol[] rightside = productions[i].rightside(); + + for(int j = 0; j < rightside.length; j++) + { + if(!rightside[j].terminal) + { + SymbolSet before = + (SymbolSet) FOLLOW[rightside[j].index].clone(); + + if(FIRST(rightside, j + 1).getEmpty()) + { + FOLLOW[rightside[j].index]. + or(FOLLOW[productions[i].leftside]); + } + + if(!before.equals(FOLLOW[rightside[j].index])) + { + changed = true; + } + } + } + } + } + while(changed); + } + + static SymbolSet FOLLOW(int nonterminal) + { + return FOLLOW[nonterminal]; + } + + static LR0ItemSet CLOSURE(LR0Item item) + { + LR0ItemSet result = (LR0ItemSet) fastLr0Closure.get(item); + + if(result != null) + { + return result; + } + + result = new LR0ItemSet(); + result.set(item); + + LR0ItemSet newItems = result; + boolean modified; + do + { + modified = false; + LR0Item[] items = newItems.items(); + newItems = new LR0ItemSet(); + + for(int i = 0; i < items.length; i++) + { + Production production = Production.production(items[i].production); + Symbol[] rightside = production.rightside(); + if(items[i].position < rightside.length) + { + Symbol symbol = rightside[items[i].position]; + + if(!symbol.terminal) + { + Production[] alternatives = + Production.alternatives(symbol.index); + + for(int j = 0; j < alternatives.length; j++) + { + LR0Item newItem = new LR0Item(alternatives[j].index, 0); + + if(!result.get(newItem)) + { + result.set(newItem); + newItems.set(newItem); + modified = true; + } + } + } + } + } + } + while(modified); + + fastLr0Closure.put(item, result); + + return result; + } + + // private static final SplayTreeMap fastLr0SetClosure = new SplayTreeMap(); + + static LR0ItemSet CLOSURE(LR0ItemSet set + ) + { + LR0ItemSet result = + /* + (LR0ItemSet) fastLr0SetClosure.get(set); + + if(result != null) + { + return result; + } + + result =*/ + new LR0ItemSet(); + + LR0Item[] setItems = set.items(); + + for(int i = 0; i < setItems.length; i++) + { + LR0Item[] items = CLOSURE(setItems[i]).items(); + + for(int j = 0; j < items.length; j++) + { + result.set(items[j]); + } + } + + // fastLr0SetClosure.put(set, result); + + return result; + } + + static LR1ItemSet CLOSURE(LR1Item item) + { + LR1ItemSet result = (LR1ItemSet) fastLr1Closure.get(item); + + if(result != null) + { + return result; + } + + result = new LR1ItemSet(); + result.set(item); + + LR1ItemSet newItems = result; + boolean modified; + do + { + modified = false; + LR1Item[] items = newItems.items(); + newItems = new LR1ItemSet(); + + for(int i = 0; i < items.length; i++) + { + Production production = Production.production(items[i].lr0Item.production); + Symbol[] rightside = production.rightside(); + if(items[i].lr0Item.position < rightside.length) + { + Symbol symbol = rightside[items[i].lr0Item.position]; + + if(!symbol.terminal) + { + Vector tailVector = new Vector(0); + + for(int k = items[i].lr0Item.position + 1; k < rightside.length; k++) + { + tailVector.addElement(rightside[k]); + } + + tailVector.addElement(Symbol.symbol(items[i].terminal, true)); + + Symbol[] tail = new Symbol[tailVector.size()]; + tailVector.copyInto(tail); + + Symbol[] symbols = FIRST(tail).getSymbols(); + + Production[] alternatives = + Production.alternatives(symbol.index); + + for(int k = 0; k < symbols.length; k++) + { + if(symbols[k].terminal) + { + for(int j = 0; j < alternatives.length; j++) + { + LR1Item newItem = new LR1Item( + new LR0Item(alternatives[j].index, 0), + symbols[k].index); + + if(!result.get(newItem)) + { + result.set(newItem); + newItems.set(newItem); + modified = true; + } + } + } + } + } + } + } + } + while(modified); + + fastLr1Closure.put(item, result); + + return result; + } + + // private static final SplayTreeMap fastLr1SetClosure = new SplayTreeMap(); + + static LR1ItemSet CLOSURE(LR1ItemSet set + ) + { + LR1ItemSet result = + /* + (LR1ItemSet) fastLr1SetClosure.get(set); + + if(result != null) + { + return result; + } + + result =*/ + new LR1ItemSet(); + + LR1Item[] setItems = set.items(); + + for(int i = 0; i < setItems.length; i++) + { + LR1Item[] items = CLOSURE(new LR1Item(setItems[i].lr0Item, dummy)).items(); + + for(int j = 0; j < items.length; j++) + { + result.set(new LR1Item(items[j].lr0Item, + items[j].terminal == dummy ? setItems[i].terminal : items[j].terminal)); + } + } + + // fastLr1SetClosure.put(set, result); + + return result; + } + + static LR0ItemSet GOTO(LR0ItemSet set + , Symbol symbol) + { + LR0ItemSet initialset = set + ; + set + = CLOSURE(set + ); + LR0ItemSet result = new LR0ItemSet(); + + // return all items A->xS.y such that A->x.Sy is in set. (S=symbol) + LR0Item[] items = set.items(); + for(int i = 0; i < items.length; i++) + { + Production production = Production.production(items[i].production); + Symbol[] rightside = production.rightside(); + if(items[i].position < rightside.length) + { + if(symbol.equals(rightside[items[i].position])) + { + result.set(new LR0Item(items[i].production, + items[i].position + 1)); + } + } + } + + return result; + } + +} diff --git a/src/main/java/org/sablecc/sablecc/In_Production.java b/src/main/java/org/sablecc/sablecc/In_Production.java new file mode 100644 index 0000000..79aedb3 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/In_Production.java @@ -0,0 +1,173 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; + +public class In_Production +{ + private String name; + private String[] prodTransformElems; + private int nbAlts; + private In_Alternative[] alternatives; + + public In_Production(AProd prod) + { + setName(prod.getId().getText()); + + AElem[] prodTransforms = (AElem [])prod.getProdTransform().toArray(new AElem[0]); + prodTransformElems = new String[prodTransforms.length]; + + for(int i=0; i<prodTransforms.length; i++) + { + if(prodTransforms[i].getElemName() != null) + { + prodTransformElems[i] = prodTransforms[i].getElemName().getText(); + } + else + { + prodTransformElems[i] = prodTransforms[i].getId().getText(); + } + } + + if(prodTransforms.length == 0) + { + prodTransformElems = new String[1]; + prodTransformElems[0] = new String(" "); + } + + AAlt[] alts = (AAlt[])prod.getAlts().toArray(new AAlt[0]); + alternatives = new In_Alternative[alts.length]; + + for(int i=0; i<alts.length; i++) + { + addAlternative(i, new In_Alternative(alts[i], prodTransformElems, name)); + } + + nbAlts = alts.length; + } + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public int getNbAlts() + { + return nbAlts; + } + + public void addAlternative(int position, In_Alternative alt) + { + alternatives[position] = alt; + } + + public In_Alternative getAlternative(int position) + { + return alternatives[position]; + } + + class In_Alternative + { + String name; + int nbElems; + AElem[] elements; + Map prodTransform_altTransform; + + In_Alternative(AAlt alt, String[] prodTransformElems, String prodName) + { + setName(alt.getAltName() != null ? alt.getAltName().getText() : ""); + + elements = new AElem[alt.getElems().size()]; + AElem[] listOfElems = (AElem[]) alt.getElems().toArray(new AElem[0]); + + final String newElemName = (name.equals("") ? prodName : prodName + "#" + name ); + + for(int i=0; i<listOfElems.length; i++) + { + AElem tmpElem = (AElem)listOfElems[i].clone(); + + if(tmpElem.getElemName() != null) + { + tmpElem.setElemName(new TId(newElemName + "#" + tmpElem.getElemName().getText() ) ); + } + else + { + tmpElem.setElemName(new TId(newElemName + "#" + tmpElem.getId().getText() )); + } + + addElem(i, tmpElem ); + } + + nbElems = listOfElems.length; + + prodTransform_altTransform = + new TypedHashMap(prodTransformElems.length, + StringCast.instance, + NodeCast.instance); + + LinkedList list = ((AAltTransform)alt.getAltTransform()).getTerms(); + for(int i=0; i<list.size(); i++) + { + PTerm tmpTerm = (PTerm)list.get(i); + tmpTerm.apply(new DepthFirstAdapter() + { + public void caseASimpleListTerm(ASimpleListTerm node) + { + node.setId( new TId(newElemName + "#" + node.getId().getText(), node.getId().getLine(), node.getId().getPos()) ); + } + + public void caseASimpleTerm(ASimpleTerm node) + { + node.setId( new TId(newElemName + "#" + node.getId().getText(), node.getId().getLine(), node.getId().getPos()) ); + } + + } + ); + prodTransform_altTransform.put(prodTransformElems[i], tmpTerm); + } + } + + void setName(String name) + { + this.name = name; + } + + String getName() + { + return name; + } + + int getNbElems() + { + return nbElems; + } + + Map getProdTransform_AlTransformMap() + { + return prodTransform_altTransform; + } + + void addElem(int position, AElem elem) + { + elements[position] = elem; + } + + AElem[] getElems() + { + return elements; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/Inlining.java b/src/main/java/org/sablecc/sablecc/Inlining.java new file mode 100644 index 0000000..ae8979d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/Inlining.java @@ -0,0 +1,527 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Last Modification date : 17-11-2003 + * Fix simpleTerm and simpleListTerm bug related to + * name confusion. + * Now, elem_name is automatically added to an elem to avoid that. + * The name has the form (production_name#alternative_name#elemId) + * or (production_name#alternative_name#elemName) + */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; + +public class Inlining +{ + public static HashSet productionsToBeRemoved = + new HashSet(); + + private AProd current_production; + + //The production to inline within current_production + private In_Production prod_to_inline; + + public Inlining(AProd curr_prod, In_Production prod_to_inline) + { + this.current_production = curr_prod; + this.prod_to_inline = prod_to_inline; + } + + /* + * The core of inlining is done here. + * returns true if it succeeds and false otherwise + */ + public boolean inlineProduction() + { + AAlt[] alts = (AAlt[])current_production.getAlts().toArray(new AAlt[0]); + final BooleanEx prodMustBeInlined = new BooleanEx(false); + + /* + We're trying to detect if the current production must be inlined. + ie one of its alternatives contains production to inline + */ + for(int i=0; i<alts.length; i++) + { + ((PAlt)alts[i]).apply( new DepthFirstAdapter() + { + public void caseAElem(AElem node) + { + String elem_name = node.getId().getText(); + + if(elem_name.equals(prod_to_inline.getName()) && + !(node.getSpecifier() instanceof ATokenSpecifier) ) + { + prodMustBeInlined.setValue(true); + } + } + } + ); + //We only need to know if one element within one of the production alternatives matches. + if(prodMustBeInlined.getValue()) + { + break; + } + } + + //If the production must be inlined + if(prodMustBeInlined.getValue()) + { + /* + Once we detect that the production can be inline, + we try to inline each of its alternatives. + */ + LinkedList listOfAlts = new TypedLinkedList(NodeCast.instance); + for(int i=0; i<alts.length; i++) + { + listOfAlts.addAll( inlineAlternative(alts[i]) ); + } + /************************************************************************** + if( !containsDoubloons(listOfAlts) ) + { + //list of productions whose inlining was a success. + productionsToBeRemoved.add("P" + ResolveIds.name(prod_to_inline.getName())); + + current_production.setAlts(listOfAlts); + return true; + } + return false; + /**************************************************************************/ + listOfAlts = (LinkedList)removeAlternativeDoubloonsFromInlinedProduction(listOfAlts); + + //list of productions whose inlining was a success. + productionsToBeRemoved.add("P" + ResolveIds.name(prod_to_inline.getName())); + + current_production.setAlts(listOfAlts); + return true; + } + + return false; + } + + List removeAlternativeDoubloonsFromInlinedProduction(List inlinedAlternatives) + { + AAlt[] alts = (AAlt [])inlinedAlternatives.toArray(new AAlt[0]); + LinkedList[] theWhole = new LinkedList[alts.length]; + + TreeSet indexOfDoublonsAlternatives = new TreeSet(); + + for(int i=0; i<alts.length; i++) + { + LinkedList elems = alts[i].getElems(); + AElem[] arrayOfElems = (AElem []) elems.toArray(new AElem[0]); + LinkedList listOfElems = new TypedLinkedList(StringCast.instance); + for(int j=0; j<arrayOfElems.length; j++) + { + listOfElems.add(arrayOfElems[j].getId().getText()); + } + theWhole[i] = listOfElems; + + LinkedList currentList = listOfElems; + + for(int k=0; k<i; k++) + { + if( currentList.equals(theWhole[k]) ) + { + //theWhole[k] = null; + indexOfDoublonsAlternatives.add(new Integer(k)); + } + } + } + + { + int i = 0; + + for(Iterator iter = indexOfDoublonsAlternatives.iterator(); iter.hasNext();) + { + int index = ((Integer)iter.next()).intValue(); + //System.out.println("(" + index + "," + i + ")"); + inlinedAlternatives.remove( index - i++ ); + } + } + return inlinedAlternatives; + } + + /***************************************************************** + boolean containsDoubloons(List aList) + { + AAlt[] alts = (AAlt [])aList.toArray(new AAlt[0]); + LinkedList[] theWhole = new LinkedList[alts.length]; + + for(int i=0; i<alts.length; i++) + { + LinkedList elems = alts[i].getElems(); + AElem[] arrayOfElems = (AElem []) elems.toArray(new AElem[0]); + LinkedList listOfElems = new TypedLinkedList(StringCast.instance); + for(int j=0; j<arrayOfElems.length; j++) + { + listOfElems.add(arrayOfElems[j].getId().getText()); + } + theWhole[i] = listOfElems; + + LinkedList currentList = listOfElems; + for(int k=0; k<i; k++) + { + if( currentList.equals(theWhole[k]) ) + { + return true; + } + } + } + return false; + } + /*****************************************************************/ + + /* + * Inlining of an alternative + * + */ + public LinkedList inlineAlternative(AAlt alt) + { + AElem[] elems = (AElem[])alt.getElems().toArray(new AElem[0]); + String elem_name ; + + // This list contains the names of elements to inline within an alternative + // The elem name can be either a production name or name given to it by user + //LinkedList eventualProdIdOrNames = new LinkedList(); + int occurenceOfProductionToInlineWithinTheAlternative = 0; + + for(int i=0; i<elems.length; i++) + { + elem_name = elems[i].getId().getText(); + + /* + Element to inline within an alternative is added to + a list of occurrences of the production to inline + */ + if(elem_name.equals(prod_to_inline.getName()) && + !(elems[i].getSpecifier() instanceof ATokenSpecifier) ) + { + occurenceOfProductionToInlineWithinTheAlternative++; + /* + if(elems[i].getElemName() != null) + { + eventualProdIdOrNames.add( elems[i].getElemName().getText() ); + } + else + { + eventualProdIdOrNames.add( elems[i].getId().getText() ); + } + */ + } + } + + LinkedList resultingListOfAlts = new TypedLinkedList(); + resultingListOfAlts.add(alt); + for(int i=0; i<occurenceOfProductionToInlineWithinTheAlternative; i++) + { + resultingListOfAlts = inline(resultingListOfAlts, i+1); + } + + return resultingListOfAlts; + } + + String alt_elem_info = null; + /* + * whichOccurence is used to number an element within the alternative + */ + public LinkedList inline(LinkedList altsList, int whichOccurence) + { + LinkedList resultList = new LinkedList(); + AAlt[] alts = (AAlt[])altsList.toArray(new AAlt[0]); + AAlt aParsed_alt; + Map mapOfNewTermNames; + + for(int i=0; i<alts.length; i++) + { + aParsed_alt = alts[i]; + + for(int j=0; j<prod_to_inline.getNbAlts(); j++) + { + mapOfNewTermNames = new TypedHashMap(StringCast.instance, + StringCast.instance); + + LinkedList listElems = inlineList(aParsed_alt.getElems(), + prod_to_inline.getAlternative(j).getElems(), + mapOfNewTermNames); + AAltTransform aAltTransform = + (AAltTransform)((AAltTransform)aParsed_alt.getAltTransform()).clone(); + final Map currentMap = prod_to_inline.getAlternative(j).getProdTransform_AlTransformMap(); + + aAltTransform.apply(new DepthFirstAdapter() + { + public void caseASimpleTerm(ASimpleTerm node) + { + if(node.getId().getText().equals(alt_elem_info) && + !(node.getSpecifier() instanceof ATokenSpecifier) ) + { + String termTail; + if(node.getSimpleTermTail() != null) + { + termTail = node.getSimpleTermTail().getText(); + } + else + { + termTail = prod_to_inline.getName(); + } + + PTerm term = (PTerm)((PTerm)currentMap.get(termTail)).clone(); + + if(currentMap.get(termTail) != null) + { + node.replaceBy(term); + } + } + } + + public void caseASimpleListTerm(final ASimpleListTerm node_) + { + if(node_.getId().getText().equals(alt_elem_info) && + !(node_.getSpecifier() instanceof ATokenSpecifier) ) + { + String termTail; + if(node_.getSimpleTermTail() != null) + { + termTail = node_.getSimpleTermTail().getText(); + } + else + { + termTail = prod_to_inline.getName(); + } + + if(currentMap.get(termTail) != null) + { + PTerm term = (PTerm)currentMap.get(termTail); + + if( !(currentMap.get(termTail) instanceof ANewListTerm) && + !(currentMap.get(termTail) instanceof ASimpleListTerm) + ) + { + term.apply(new DepthFirstAdapter() + { + public void caseANewTerm(ANewTerm node) + { + node_.replaceBy( new ANewListTerm( (AProdName)node.getProdName().clone(), + (TLPar)node.getLPar().clone(), + (LinkedList)cloneList(node.getParams()) + ) + ); + } + + public void caseASimpleTerm(ASimpleTerm node) + { + PSpecifier specifier = null; + TId simpleTermTail = null; + if(node.getSpecifier() != null) + { + specifier = (PSpecifier)node.getSpecifier().clone(); + } + if(node.getSimpleTermTail() != null) + { + simpleTermTail = (TId)node.getSimpleTermTail().clone(); + } + node_.replaceBy( new ASimpleListTerm( specifier, + (TId)node.getId().clone(), + simpleTermTail + ) + ); + } + + public void caseNullTerm(ANullTerm node) + { + node_.replaceBy( null ); + } + + public void caseAListTerm(AListTerm node) + { + AListTerm parent = (AListTerm)node_.parent(); + LinkedList oldlistTerms = parent.getListTerms(); + LinkedList newlistTerms = new LinkedList(); + + Object[] oldListTermsArray = (Object[]) oldlistTerms.toArray(); + for(int i=0; i<oldListTermsArray.length; i++) + { + if(oldListTermsArray[i] != node_) + { + if(oldListTermsArray[i] instanceof PTerm) + { + newlistTerms.add( ((PTerm)oldListTermsArray[i]).clone() ); + } + else + { + newlistTerms.add( ((PListTerm)oldListTermsArray[i]).clone() ); + } + } + else + { + newlistTerms.addAll(cloneList(node.getListTerms())); + } + } + parent.setListTerms(newlistTerms); + } + } + ); + } + else + { + node_.replaceBy(term); + } + } + } + } + } + ); + + AAltTransform tmpaAltTransform = (AAltTransform)aAltTransform.clone(); + fixSimpleTermOrSimpleListTermNames(tmpaAltTransform, mapOfNewTermNames); + String newAltName; + if(aParsed_alt.getAltName() != null) + { + newAltName = aParsed_alt.getAltName().getText()+ "$" + + prod_to_inline.getAlternative(j).getName() + whichOccurence; + } + else + { + newAltName = prod_to_inline.getAlternative(j).getName() + whichOccurence; + } + + resultList.add( new AAlt(new TId(newAltName), + listElems, + tmpaAltTransform) + ); + } + } + return resultList; + } + + public LinkedList inlineList(LinkedList oldElemsList, + AElem[] inliningProductionsElems, + Map mapOfNewTermNames) + { + int position = 0; + AElem[] listElems = (AElem[]) oldElemsList.toArray(new AElem[0]); + for(int i=0; i<listElems.length; i++) + { + //We are looking for the position of the element inside the alternative. + if( listElems[i].getId().getText().equals(prod_to_inline.getName()) && + !(listElems[i].getSpecifier() instanceof ATokenSpecifier) ) + { + position = i; + if(listElems[i].getElemName() != null) + { + alt_elem_info = listElems[i].getElemName().getText(); + } + else + { + alt_elem_info = listElems[i].getId().getText(); + } + break; + } + } + + LinkedList list = new LinkedList(); + int elemPosition = 1; + + //Before the inlined element (old alternative elements) + for(int i=0; i<position; i++) + { + list.add(((AElem)oldElemsList.get(i)).clone() ); + } + + // The inline element (new element added to the alternative) + for(int i=0; i<inliningProductionsElems.length; i++) + { + list.add(inliningProductionsElems[i].clone()); + } + + // After the inlined element (old alternative elements) + for(int i=position+1; i<listElems.length; i++) + { + list.add(((AElem)oldElemsList.get(i)).clone()); + } + + AElem[] listOfAltElems = (AElem[]) list.toArray(new AElem[0]); + for(int i=0; i<listOfAltElems.length; i++) + { + String old_name = listOfAltElems[i].getId().getText(); + TId elemName = (TId)listOfAltElems[i].getElemName(); + if(elemName != null) + { + elemName = (TId)elemName; + old_name = elemName.getText(); + } + + String elemNameString = (elemName != null ? elemName.getText() : "@elem@" ); + elemNameString += (i+1); + listOfAltElems[i].setElemName(new TId(elemNameString)); + mapOfNewTermNames.put(old_name, elemNameString); + } + + return list; + } + + private void fixSimpleTermOrSimpleListTermNames(AAltTransform tmpaAltTransform, + final Map mapOldNameNewNames) + { + tmpaAltTransform.apply(new DepthFirstAdapter() + { + public void caseASimpleTerm(ASimpleTerm node) + { + if(mapOldNameNewNames.get(node.getId().getText()) != null) + { + node.setId(new TId( (String)mapOldNameNewNames.get(node.getId().getText()) )); + } + } + + public void caseASimpleListTerm(ASimpleListTerm node) + { + if(mapOldNameNewNames.get(node.getId().getText()) != null) + { + node.setId(new TId( (String)mapOldNameNewNames.get(node.getId().getText()) )); + } + } + } + ); + } + + private List cloneList(List list) + { + List clone = new LinkedList(); + + for(Iterator i = list.iterator(); i.hasNext();) + { + clone.add(((Node) i.next()).clone()); + } + + return clone; + } + + class BooleanEx + { + boolean value; + + BooleanEx(boolean value) + { + this.value = value; + } + + void setValue(boolean value) + { + this.value = value; + } + + boolean getValue() + { + return value; + } + } + +} diff --git a/src/main/java/org/sablecc/sablecc/IntSet.java b/src/main/java/org/sablecc/sablecc/IntSet.java new file mode 100644 index 0000000..2c44fd3 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/IntSet.java @@ -0,0 +1,389 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +public class IntSet +{ + // public static boolean DEBUG = false; + private int[] elements = new int[0]; + + public IntSet() + {} + + private IntSet(IntSet set + ) + { + elements = (int[]) set.elements.clone(); + } + + public void and(IntSet set + ) + { + if(set + == this) + { + return; + } + + int length = 0; + + int l = 0; + int r = 0; + while((l < elements.length) && (r < set.elements.length)) + { + if(elements[l] < set.elements[r]) + { + l++; + } + else if(elements[l] == set.elements[r]) + { + length++; + l++; + r++; + } + else + { + r++; + } + } + + int[] old = elements; + elements = new int[length]; + + length = l = r = 0; + while((l < old.length) && (r < set.elements.length)) + { + if(old[l] < set.elements[r]) + { + l++; + } + else if(old[l] == set.elements[r]) + { + elements[length++] = old[l]; + l++; + r++; + } + else + { + r++; + } + } + + } + + public void clear(int bit) + { + elements = new int[0]; + } + + public Object clone() + { + return new IntSet(this); + } + + public boolean equals(Object obj) + { + if(obj == null) + { + return false; + } + + if(!(obj instanceof IntSet)) + { + return false; + } + + IntSet set + = (IntSet) obj; + + if(elements.length != set.elements.length) + { + return false; + } + + for(int i = 0; i < elements.length; i++) + { + if(elements[i] != set.elements[i]) + { + return false; + } + } + + return true; + } + + public boolean get + (int bit) + { + int low = 0; + int high = elements.length - 1; + + while(low <= high) + { + int middle = (low + high) / 2; + + if(bit < elements[middle]) + { + high = middle - 1; + } + else if(bit == elements[middle]) + { + return true; + } + else + { + low = middle + 1; + } + } + + return false; + } + + public int hashCode() + { + int result = 0; + + for(int i = 0; i < elements.length; i++) + { + result += elements[i]; + } + + return result; + } + + public void or(IntSet set + ) + { + if(set + == this) + { + return; + } + + // if(DEBUG) + // { + // System.out.println( + // " elements.length:" + elements.length + + // " set.elements.length:" + set.elements.length); + // } + + int length = 0; + + int l = 0; + int r = 0; + while((l < elements.length) || (r < set.elements.length)) + { + // if(DEBUG) + // { + // System.out.println( + // " l:" + l + + // " r:" + r + + // " length:" + length); + // } + + if((r == set.elements.length) || + ((l != elements.length) && (elements[l] < set.elements[r]))) + { + length++; + l++; + } + else if((l == elements.length) || + (elements[l] > set.elements[r])) + { + length++; + r++; + } + else + { + length++; + l++; + r++; + } + } + + int[] old = elements; + elements = new int[length]; + + length = l = r = 0; + while((l < old.length) || (r < set.elements.length)) + { + // if(DEBUG) + // { + // System.out.println( + // " l:" + l + + // " r:" + r + + // " length:" + length); + // } + + if((r == set.elements.length) || + ((l != old.length) && (old[l] < set.elements[r]))) + { + elements[length++] = old[l]; + l++; + } + else if((l == old.length) || + (old[l] > set.elements[r])) + { + elements[length++] = set.elements[r]; + r++; + } + else + { + elements[length++] = old[l]; + l++; + r++; + } + } + + } + + public void set + (int bit) + { + if(!get + (bit)) + { + int[] old = elements; + elements = new int[old.length + 1]; + + int old_pos = 0; + boolean bit_inserted = false; + int pos = 0; + + while(pos < elements.length) + { + if(!bit_inserted) + { + if(old_pos < old.length) + { + if(bit < old[old_pos]) + { + elements[pos++] = bit; + bit_inserted = true; + } + else + { + elements[pos++] = old[old_pos++]; + } + } + else + { + elements[pos++] = bit; + bit_inserted = true; + } + } + else + { + elements[pos++] = old[old_pos++]; + } + } + } + } + + public int size() + { + if(elements.length == 0) + { + return 0; + } + + return elements[elements.length - 1] + 1; + } + + public String toString() + { + StringBuffer s = new StringBuffer(); + + s.append("{"); + + boolean comma = false; + + for(int i = 0; i < elements.length; i++) + { + if(comma) + { + s.append(", "); + } + else + { + comma = true; + } + + s.append(elements[i]); + } + s.append("}"); + + return s.toString(); + } + + public void xor(IntSet set + ) + { + if(set + == this) + { + set + = (IntSet) set.clone(); + } + + int length = 0; + int l = 0; + int r = 0; + + while((l < elements.length) || (r < set.elements.length)) + { + if((r == set.elements.length) || + ((l != elements.length) && (elements[l] < set.elements[r]))) + { + length++; + l++; + } + else if((l == elements.length) || + (elements[l] > set.elements[r])) + { + length++; + r++; + } + else + { + l++; + r++; + } + } + + int[] old = elements; + elements = new int[length]; + + length = l = r = 0; + while((l < old.length) || (r < set.elements.length)) + { + if((r == set.elements.length) || + ((l != old.length) && (old[l] < set.elements[r]))) + { + elements[length++] = old[l]; + l++; + } + else if((l == old.length) || + (old[l] > set.elements[r])) + { + elements[length++] = set.elements[r]; + r++; + } + else + { + l++; + r++; + } + } + } + + public int[] elements() + { + return (int[]) elements/*.clone()*/; + } +} diff --git a/src/main/java/org/sablecc/sablecc/IntegerCast.java b/src/main/java/org/sablecc/sablecc/IntegerCast.java new file mode 100644 index 0000000..a05df2d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/IntegerCast.java @@ -0,0 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class IntegerCast implements Cast +{ + public final static IntegerCast instance = new IntegerCast(); + + private IntegerCast() + {} + + public Object cast(Object o) + { + return (Integer) o; + } +} diff --git a/src/main/java/org/sablecc/sablecc/IntegerComparator.java b/src/main/java/org/sablecc/sablecc/IntegerComparator.java new file mode 100644 index 0000000..ca5e9a2 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/IntegerComparator.java @@ -0,0 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class IntegerComparator implements Comparator +{ + public final static IntegerComparator instance = new IntegerComparator(); + + private IntegerComparator() + {} + + public int compare(Object o1, Object o2) + { + return ((Integer) o1).intValue() - ((Integer) o2).intValue(); + } +} diff --git a/src/main/java/org/sablecc/sablecc/InternalTransformationsToGrammar.java b/src/main/java/org/sablecc/sablecc/InternalTransformationsToGrammar.java new file mode 100644 index 0000000..2cd0a92 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/InternalTransformationsToGrammar.java @@ -0,0 +1,649 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* +* Last Modification date : October, the 11th 2003 +* Goal of the modification : addition of specifier to +* the generated production($prod) to handle list of element. +* +* +*/ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.io.*; + +public class InternalTransformationsToGrammar extends DepthFirstAdapter +{ + + private ResolveIds ids; + private ResolveAltIds altIds; + private ResolveTransformIds transformIds; + private String currentProd; + private int currentAlt; + private String currentAltName; + private boolean processingAst; + private boolean processingProdTransform; + + static final int NONE = 0; + static final int STAR = 1; + static final int QMARK = 2; + static final int PLUS = 3; + + int count; + int elem; + + private LinkedList listSimpleTermTransform; + + public final Map simpleTermTransform; + Map mapProductionTransformations; + Map simpleTermOrsimpleListTermTypes; + + private Map isElementIsAlist = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + StringCast.instance); + + private LinkedList listProd; + + public InternalTransformationsToGrammar(ResolveIds ids, ResolveAltIds altIds, + ResolveTransformIds transformIds, + LinkedList listSimpleTermTransform, + Map simpleTermTransform, + Map mapProductionTransformations, + Map simpleTermOrsimpleListTermTypes) + { + this.ids = ids; + this.altIds = altIds; + this.transformIds = transformIds; + this.listSimpleTermTransform = listSimpleTermTransform; + this.simpleTermTransform = simpleTermTransform; + this.mapProductionTransformations = mapProductionTransformations; + this.simpleTermOrsimpleListTermTypes = simpleTermOrsimpleListTermTypes; + } + + public void inAProductions(AProductions node) + { + listProd = node.getProds(); + } + + private LinkedList listOfAlts; + + public void inAAst(AAst node) + { + processingAst = true; + } + + public void outAAst(AAst node) + { + processingAst = false; + } + + public void caseAProd(AProd node) + { + currentProd = (String) ids.names.get(node); + listOfAlts = new LinkedList(); + + Object[] list_alt = (Object[])node.getAlts().toArray(); + for(int i=0; i<list_alt.length; i++) + { + ((PAlt) list_alt[i]).apply(this); + } + + node.setAlts(listOfAlts); + } + + private LinkedList listElems; + private AAlt aParsedAlt; + private LinkedList listElemsAltTransform; + private String currentNewAltName; + + boolean countElementNecessary; + + LinkedList listOfAlternativeElemsWHaveName; + + public void caseAAlt(AAlt node) + { + count = 1; + currentAltName = (String) ids.names.get(node); + + AAltTransform currentAltTransform = (AAltTransform)node.getAltTransform(); + + listOfAlternativeElemsWHaveName = new LinkedList(); + + node.apply(new DepthFirstAdapter() + { + public void inAElem(AElem node) + { + InternalTransformationsToGrammar.this.setOut(node, new Integer(NONE)); + } + + public void caseAStarUnOp(AStarUnOp node) + { + count *= 2; + InternalTransformationsToGrammar.this.setOut(node.parent(), new Integer(STAR)); + } + + public void caseAQMarkUnOp(AQMarkUnOp node) + { + count *= 2; + InternalTransformationsToGrammar.this.setOut(node.parent(), new Integer(QMARK)); + } + + public void caseAPlusUnOp(APlusUnOp node) + { + InternalTransformationsToGrammar.this.setOut(node.parent(), new Integer(PLUS)); + } + } + ); + + if(count == 1) + { + listElems = new LinkedList(); + listElemsAltTransform = new LinkedList(); + + countElementNecessary = false; + + Object temp[] = node.getElems().toArray(); + for(int i = 0; i < temp.length; i++) + { + Object obj = temp[i]; + + if( ((AElem)obj).getUnOp() != null && + ( ((AElem)obj).getUnOp() instanceof AQMarkUnOp || + ((AElem)obj).getUnOp() instanceof AStarUnOp ) + ) + { + if(!countElementNecessary) + { + countElementNecessary = true; + } + } + } + + for(int i = 0; i < temp.length; i++) + { + ((PElem)temp[i]).apply(this); + } + + TId nameOfAlt = null; + + if(node.getAltName() != null) + { + nameOfAlt = (TId)node.getAltName().clone(); + } + + currentNewAltName = currentProd + "." + currentAltName.toLowerCase(); + altIds.alts_elems.put(currentNewAltName, listElemsAltTransform); + altIds.alts_elems_list_elemName.put(currentNewAltName, listOfAlternativeElemsWHaveName); + + AAltTransform altTransform = (AAltTransform)currentAltTransform.clone(); + + AltTransformAdapter altTransformAdapter = + new AltTransformAdapter(simpleTermTransform, listSimpleTermTransform, + currentNewAltName, altIds, + isElementIsAlist, + simpleTermOrsimpleListTermTypes); + + altTransform.apply(altTransformAdapter); + + aParsedAlt = new AAlt(nameOfAlt, listElems, altTransform); + + ids.names.put(aParsedAlt, ids.names.get(node)); + + listOfAlts.add(aParsedAlt); + } + else + { + int max = count; + AAltTransform altTransform; + + for(count = 0; count < max; count++) + { + listElems = new LinkedList(); + listElemsAltTransform = new LinkedList(); + + elem = 0; + + currentNewAltName = currentProd + "." + currentAltName.toLowerCase()+(count + 1); + + countElementNecessary = false; + + Object temp[] = node.getElems().toArray(); + for(int i = 0; i < temp.length; i++) + { + Object obj = temp[i]; + + if( ((AElem)obj).getUnOp() != null && + ( ((AElem)obj).getUnOp() instanceof AQMarkUnOp || + ((AElem)obj).getUnOp() instanceof AStarUnOp ) + ) + { + if(!countElementNecessary) + { + countElementNecessary = true; + } + } + } + + for(int i = 0; i < temp.length; i++) + { + ((PElem)temp[i]).apply(this); + } + + altIds.alts_elems.put(currentNewAltName, listElemsAltTransform); + altIds.alts_elems_list_elemName.put(currentNewAltName, listOfAlternativeElemsWHaveName); + + altTransform = (AAltTransform)currentAltTransform.clone(); + + AltTransformAdapter altTransformAdapter = + new AltTransformAdapter(simpleTermTransform, listSimpleTermTransform, + currentNewAltName, altIds, + isElementIsAlist, + simpleTermOrsimpleListTermTypes); + + altTransform.apply(altTransformAdapter); + aParsedAlt = new AAlt(new TId(currentAltName.toLowerCase()+(count + 1)), listElems, altTransform); + + String currentAltInlining; + currentAltInlining = "A" + ids.name(aParsedAlt.getAltName().getText()) + currentProd; + ids.names.put(aParsedAlt, currentAltInlining); + + listOfAlts.add(aParsedAlt); + } + } + } + + LinkedList checkCreationOfXElem = new TypedLinkedList(StringCast.instance); + + //It's also available for Ignored alternatives + public void caseAElem(AElem node) + { + if(!processingAst) + { + int op = ((Integer) getOut(node)).intValue(); + String name = (String) ids.elemTypes.get(node); + String numero = (countElementNecessary == true ? ""+(count+1) : "" ); + String qMarkOrPlusElemType; + String elemNameOfElem = null; + + TId aElemName = null; + PSpecifier specifier = null; + + if(node.getElemName() != null) + { + elemNameOfElem = node.getElemName().getText(); + aElemName = new TId(elemNameOfElem); + } + + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + specifier = new ATokenSpecifier(); + } + else + { + specifier = new AProductionSpecifier(); + } + } + + AElem aElem = null; + String elemName = node.getId().getText(); + boolean ok = false; + boolean oklist = false; + + switch(op) + { + case NONE: + { + aElem = new AElem(aElemName, specifier, new TId(elemName), null); + if(elemNameOfElem != null) + { + ids.names.put(aElem, ids.name(elemNameOfElem)); + } + else + { + ids.names.put(aElem, ids.name(elemName)); + } + ok = true; + } + break; + case STAR: + { + + if((count & (1 << elem)) != 0) + { + qMarkOrPlusElemType = (String)ids.elemTypes.get(node); + LinkedList tmpProdTransform = (LinkedList)mapProductionTransformations.get(qMarkOrPlusElemType); + + if(!checkCreationOfXElem.contains("$" + elemName)) + { + checkCreationOfXElem.add("$" + elemName); + listProd.add( createXelemProduction("$" + elemName, qMarkOrPlusElemType, + name, tmpProdTransform) ); + } + + elemName = "$" + elemName; + aElem = new AElem(aElemName, new AProductionSpecifier(), new TId(elemName), null); + + if(elemNameOfElem != null) + { + ids.names.put(aElem, ids.name(elemNameOfElem)); + } + else + { + ids.names.put(aElem, ids.name(elemName)); + } + + ok = true; + oklist = true; + } + + elem++; + } + break; + case QMARK: + { + if((count & (1 << elem)) != 0) + { + aElem = new AElem(aElemName, specifier, new TId(elemName), null); + + if(elemNameOfElem != null) + { + ids.names.put(aElem, ids.name(elemNameOfElem)); + } + else + { + ids.names.put(aElem, ids.name(elemName)); + } + + ok = true; + } + + elem++; + } + break; + case PLUS: + { + qMarkOrPlusElemType = (String)ids.elemTypes.get(node); + LinkedList tmpProdTransform = (LinkedList)mapProductionTransformations.get(qMarkOrPlusElemType); + + if(!checkCreationOfXElem.contains("$" + elemName)) + { + checkCreationOfXElem.add("$" + elemName); + listProd.add( createXelemProduction("$" + elemName, qMarkOrPlusElemType, + name, tmpProdTransform) ); + } + + elemName = "$" + elemName; + aElem = new AElem(aElemName, new AProductionSpecifier(), new TId(elemName), null); + + if(elemNameOfElem != null) + { + ids.names.put(aElem, ids.name(elemNameOfElem)); + } + else + { + ids.names.put(aElem, ids.name(elemName)); + } + + ok = true; + oklist = true; + } + break; + } + + if(ok) + { + if(aElemName != null) + { + listElemsAltTransform.add(aElemName.getText()); + if(oklist) + { + if(elemNameOfElem != null) + { + listOfAlternativeElemsWHaveName.add(elemNameOfElem); + } + isElementIsAlist.put(currentProd+"."+currentAltName.toLowerCase()+numero+aElemName.getText(), + node.getId().getText()); + } + } + else + { + listElemsAltTransform.add(elemName); + if(oklist) + { + if(elemNameOfElem != null) + { + listOfAlternativeElemsWHaveName.add(elemNameOfElem); + } + isElementIsAlist.put(currentProd+"."+currentAltName.toLowerCase()+numero+node.getId().getText(), + node.getId().getText()); + } + } + } + + if(aElem != null) + { + listElems.add(aElem); + } + } + } + + /* + This method creates the production for star(*) and plus(+) substitution in the grammar + elem* -> $elem | + elem + This creates the production :: + $elem {-> elem* } + + = {nonTerminal} $elem elem {-> [$elem.elem elem] } + | {terminal} elem {-> [elem] } + ; + */ + public AProd createXelemProduction(final String name, final String elemTypeName, + String XproductionName, + LinkedList nodeProdTransform) + { + final String rname = name.substring(1); + LinkedList listOfAltsXelem = new LinkedList(); + + if(nodeProdTransform != null) + { + nodeProdTransform = (LinkedList)cloneList(nodeProdTransform); + + //Creation of the production transformation for Xelem + //if the production transformation is introduced by the software + if(nodeProdTransform.size() == 1) + { + AElem elem = (AElem)nodeProdTransform.get(0); + if(elem.getUnOp() == null && elem.getId().getText().equals(rname)) + { + LinkedList elemsProdTransform = new LinkedList(); + elemsProdTransform.add( new AElem( null, new AProductionSpecifier(), new TId(rname), new AStarUnOp() ) ); + nodeProdTransform = elemsProdTransform; + } + } + + } + //That means elem is token type + else + { + String name_resolved = ids.name(name); + + LinkedList elemsProdTransform = new LinkedList(); + elemsProdTransform.add( new AElem( null, new ATokenSpecifier(), new TId(rname), new AStarUnOp() ) ); + nodeProdTransform = elemsProdTransform; + } + + final LinkedList listProdTransformationOfXelem = new LinkedList(); + + AElem []temp_listProdTransform = (AElem[])nodeProdTransform.toArray(new AElem[0]); + for(int i=0; i<temp_listProdTransform.length; i++) + { + temp_listProdTransform[i].apply( new DepthFirstAdapter() + { + public void caseAElem(AElem node) + { + //The production transformation needs to have a star operator. + node.setUnOp(new AStarUnOp(new TStar())); + if(node.getElemName() != null) + { + listProdTransformationOfXelem.add( node.getElemName().getText() ); + } + else + { + listProdTransformationOfXelem.add( node.getId().getText() ); + } + } + } + ); + } + + //creation of the first AltTransform node + AElem[] prodTransformElems = (AElem[]) nodeProdTransform.toArray(new AElem[0]); + + final LinkedList listTerms_first = new LinkedList(); + + for(int i = 0; i < prodTransformElems.length; i++) + { + prodTransformElems[i].apply(new AnalysisAdapter() + { + public void caseAElem(AElem node) + { + String tmpNodeName = ( (node.getElemName() == null) ? node.getId().getText() : + node.getElemName().getText() ); + LinkedList listAListTerm_first = new LinkedList(); + + if(elemTypeName.startsWith("T")) + { + listAListTerm_first.add(new ASimpleListTerm(new ATokenSpecifier(), + new TId(rname), null )); + } + else + { + listAListTerm_first.add(new ASimpleListTerm(new AProductionSpecifier(), + new TId(rname),new TId(tmpNodeName) ) ); + } + listTerms_first.add( new AListTerm(new TLBkt(), listAListTerm_first) ); + } + } + ); + } + + AAltTransform aAltTransform = new AAltTransform(new TLBrace(), listTerms_first, new TRBrace()); + + //create the first list of elems of an alternative + LinkedList elems = new LinkedList(); + AElem aElemFirstTobeAdded; + //the elem is a token + if(elemTypeName.startsWith("T")) + { + aElemFirstTobeAdded = new AElem(null, new ATokenSpecifier(), new TId(rname), null); + } + else + { + aElemFirstTobeAdded = new AElem(null, new AProductionSpecifier(), new TId(rname), null); + } + elems.add(aElemFirstTobeAdded); + + //creation of the first alternative + AAlt aParsedAlt = new AAlt(new TId("terminal"), elems, aAltTransform); + String terminal_altName = "ATerminal" + ids.name(name); + + listOfAltsXelem.add(aParsedAlt); + + //create the second AltTransform node + prodTransformElems = (AElem[]) nodeProdTransform.toArray(new AElem[0]); + + final LinkedList listTerms_second = new LinkedList(); + + for(int i = 0; i < prodTransformElems.length; i++) + { + prodTransformElems[i].apply(new AnalysisAdapter() + { + public void caseAElem(AElem node) + { + String tmpNodeName = ( (node.getElemName() == null) ? node.getId().getText() : + node.getElemName().getText() ); + + LinkedList listAListTerm_second = new LinkedList(); + + listAListTerm_second.add(new ASimpleListTerm(null, new TId(name), + new TId(tmpNodeName)) ); + + if(elemTypeName.startsWith("T")) + { + listAListTerm_second.add(new ASimpleListTerm(new ATokenSpecifier(), + new TId(rname), null )); + } + else + { + listAListTerm_second.add(new ASimpleListTerm(new AProductionSpecifier(), + new TId(rname), + new TId(tmpNodeName) ) ); + } + listTerms_second.add(new AListTerm(new TLBkt(), listAListTerm_second)); + } + } + ); + } + + aAltTransform = new AAltTransform(new TLBrace(), listTerms_second, new TRBrace()); + + //creation of the second list of elems of an alternative :: two elems + elems = new LinkedList(); + + //first elem + AElem aElemSecondTobeAdded = new AElem(null, new AProductionSpecifier(), new TId(name), null); + elems.add(aElemSecondTobeAdded); + + //second elem + if(elemTypeName.startsWith("T")) + { + aElemSecondTobeAdded = new AElem(null, new ATokenSpecifier(), new TId(rname), null); + } + else + { + aElemSecondTobeAdded = new AElem(null, new AProductionSpecifier(), new TId(rname), null); + } + elems.add(aElemSecondTobeAdded); + + aParsedAlt = new AAlt(new TId("non_terminal"), elems, aAltTransform); + + String nonTerminal_altName = "ANonTerminal" + ids.name(name); + + listOfAltsXelem.add(aParsedAlt); + + AProd prodToReturn = new AProd(new TId(name), new TArrow(), nodeProdTransform, listOfAltsXelem); + prodToReturn.apply(ids); + prodToReturn.apply(transformIds.getProdTransformIds()); + + return prodToReturn; + } + + private List cloneList(List list) + { + List clone = new LinkedList(); + + for(Iterator i = list.iterator(); i.hasNext();) + { + clone.add(((Node) i.next()).clone()); + } + return clone; + } + + private String xproductionType(String name) + { + return "P$" + name.substring(1).toLowerCase(); + } + +} diff --git a/src/main/java/org/sablecc/sablecc/LR0Collection.java b/src/main/java/org/sablecc/sablecc/LR0Collection.java new file mode 100644 index 0000000..2dca7cd --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/LR0Collection.java @@ -0,0 +1,147 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import java.util.Vector; + +final class LR0Collection +{ + private final Vector sets = new Vector(0); + private final TreeMap setIndices = new TreeMap(); + private final Vector GOTO = new Vector(0); + final Vector names = new Vector(0); + + LR0Collection(LR0ItemSet set + ) + { + add + (set + , -1, null); + + for(int i = 0; i < sets.size(); i++) + { + System.out.print("."); + Symbol[] symbols = Symbol.symbols(); + + for(int j = 0; j < symbols.length; j++) + { + addGoto(i, symbols[j], Grammar.GOTO(set + (i), symbols[j])); + } + } + System.out.println(); + } + + private int add + (LR0ItemSet set + , int from, Symbol symbol) + { + Integer result = set + (set + ); + + if(result == null) + { + result = new Integer(sets.size()); + + setIndices.put(set + , result); + sets.addElement(set + ); + GOTO.addElement(new TreeMap()); + if(from == -1) + { + names.addElement(" "); + } + else + { + names.addElement(names.elementAt(from) + "" + symbol + " "); + } + } + + return result.intValue(); + } + + private static LR0ItemSet empty = new LR0ItemSet(); + + public static void reinit() + { + empty = new LR0ItemSet(); + } + + private void addGoto(int from, Symbol symbol, LR0ItemSet to) + { + if(!to.equals(empty)) + { + ((TreeMap) GOTO.elementAt(from)).put(symbol, new Integer(add + (to, from, symbol))); + } + } + + private Integer set + (LR0ItemSet set + ) + { + return (Integer) setIndices.get(set + ); + } + + private LR0ItemSet set + (int index) + { + return (LR0ItemSet) sets.elementAt(index); + } + + LR0ItemSet[] sets() + { + LR0ItemSet[] result = new LR0ItemSet[sets.size()]; + sets.copyInto(result); + + return result; + } + + Integer GOTO(int set + , Symbol symbol) + { + return (Integer) ((TreeMap) GOTO.elementAt(set + )).get(symbol); + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + + result.append("{[LR0ItemCollection]" + System.getProperty("line.separator")); + LR0ItemSet[] sets = sets(); + Symbol[] symbols = Symbol.symbols(); + + for(int i = 0; i < sets.length; i++) + { + result.append(i + ":" + Grammar.CLOSURE(sets[i])); + result.append(System.getProperty("line.separator")); + + for(int j = 0; j < symbols.length; j++) + { + if(GOTO(i, symbols[j]) != null) + { + result.append("["); + result.append(symbols[j]); + result.append(":"); + result.append(GOTO(i, symbols[j])); + result.append("]"); + } + } + + result.append(System.getProperty("line.separator")); + } + + result.append("}"); + return result.toString(); + } +} diff --git a/src/main/java/org/sablecc/sablecc/LR0Item.java b/src/main/java/org/sablecc/sablecc/LR0Item.java new file mode 100644 index 0000000..a6f973b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/LR0Item.java @@ -0,0 +1,98 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +final class LR0Item implements Cloneable, Comparable +{ + final int production; + final int position; + + LR0Item(int production, int position) + { + this.production = production; + this.position = position; + } + + public int compareTo(Object object) + { + LR0Item item = (LR0Item) object; + + int result = production - item.production; + + if(result == 0) + { + result = position - item.position; + } + + return result; + } + + public Object clone() + { + return new LR0Item(production, position); + } + + public boolean equals(Object obj) + { + if((obj == null) || + (obj.getClass() != this.getClass())) + { + return false; + } + + LR0Item item = (LR0Item) obj; + + return (item.production == production) && + (item.position == position); + } + + public int hashCode() + { + return (production * 13) ^ (position * 17); + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + String prodStr = (Production.production(production)).toString(); + int pos = 0; + + StringTokenizer list = new StringTokenizer(prodStr, "= "); + + // we know that there is at least one token (lhs) + result.append(list.nextToken()); + result.append(" ="); + + while(list.hasMoreElements()) + { + String tmp = list.nextToken(); + + if(pos == position) + { + result.append(" * "); + result.append(tmp); + } + else + { + result.append(" "); + result.append(tmp); + } + + pos++; + } + + if(pos == position) + { + result.append(" *"); + } + + return "[ " + result + " ]"; + } +} diff --git a/src/main/java/org/sablecc/sablecc/LR0ItemAndSetPair.java b/src/main/java/org/sablecc/sablecc/LR0ItemAndSetPair.java new file mode 100644 index 0000000..a411e58 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/LR0ItemAndSetPair.java @@ -0,0 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +final class LR0ItemAndSetPair +{ + public final LR0Item item; + public final int set + ; + + LR0ItemAndSetPair(LR0Item item, int set + ) + { + this.item = item; + this.set = set + ; + } +} diff --git a/src/main/java/org/sablecc/sablecc/LR0ItemSet.java b/src/main/java/org/sablecc/sablecc/LR0ItemSet.java new file mode 100644 index 0000000..d2ca512 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/LR0ItemSet.java @@ -0,0 +1,180 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +import java.util.Vector; + +final class LR0ItemSet implements Cloneable, Comparable +{ + private final TreeMap items; + private int hashCode; + + LR0ItemSet() + { + items = new TreeMap(); + } + + private LR0ItemSet(LR0ItemSet set + ) + { + items = (TreeMap) set.items.clone(); + } + + void set + (LR0Item item) + { + if(items.put(item, item) == null) + { + hashCode += item.hashCode(); + modified_ = true; + } + } + + boolean get + (LR0Item item) + { + return items.get(item) != null; + } + + LR0Item[] items_; + boolean modified_ = true; + + private void computeArray() + { + Vector itemVector = new Vector(0); + + for(Iterator e = items.keySet().iterator(); e.hasNext();) + { + itemVector.addElement(e.next()); + } + + items_ = new LR0Item[itemVector.size()]; + itemVector.copyInto(items_); + modified_ = false; + } + + LR0Item[] items() + { + if(modified_) + { + computeArray(); + } + + return items_; + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + result.append("{"); + + Production[] productions = Production.productions(); + boolean space = false; + for(int i = 0; i < productions.length; i++) + { + int rightsideLength = productions[i].rightside().length; + + for(int j = 0; j <= rightsideLength; j++) + { + LR0Item item = new LR0Item(productions[i].index, j); + if(get + (item)) + { + if(space) + { + result.append(","); + } + else + { + space = true; + } + + result.append(item); + } + } + + } + + result.append("}"); + return result.toString(); + } + + public Object clone() + { + return new LR0ItemSet(this); + } + + public boolean equals(Object obj) + { + if((obj == null) || + (obj.getClass() != this.getClass())) + { + return false; + } + + LR0ItemSet set + = (LR0ItemSet) obj; + + if(set.items.size() != items.size()) + { + return false; + } + + for(Iterator e = items.keySet().iterator(); e.hasNext();) + { + if(!set.get((LR0Item) e.next())) + { + return false; + } + } + + return true; + } + + public int hashCode() + { + return hashCode; + } + + public int compareTo(Object object) + { + LR0ItemSet set + = (LR0ItemSet) object; + + int result = items.size() - set.items.size(); + + if(result == 0) + { + Iterator e = items.keySet().iterator(); + Iterator f = set.items.keySet().iterator(); + + while(e.hasNext() && f.hasNext() && (result == 0)) + { + result = ((LR0Item) e.next()).compareTo(f.next()); + } + + if(result == 0) + { + if(e.hasNext()) + { + return 1; + } + + if(f.hasNext()) + { + return -1; + } + } + } + + return result; + } + +} diff --git a/src/main/java/org/sablecc/sablecc/LR1Collection.java b/src/main/java/org/sablecc/sablecc/LR1Collection.java new file mode 100644 index 0000000..cca9246 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/LR1Collection.java @@ -0,0 +1,183 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.Vector; +import java.util.Enumeration; +import java.util.*; + +final class LR1Collection +{ + final LR0Collection collection; + final TreeMap[] lookaheads; + private final TreeMap[] propagation; + + LR1Collection(LR0ItemSet set + ) + { + collection = new LR0Collection(set + ); + + // Initialize lookaheads to nothing, propagation to nothing + LR0ItemSet[] sets = collection.sets(); + lookaheads = new TreeMap[sets.length]; + propagation = new TreeMap[sets.length]; + + for(int i = 0; i < sets.length; i++) + { + System.out.print("."); + lookaheads[i] = new TreeMap(); + propagation[i] = new TreeMap(); + + LR0Item[] items = sets[i].items(); + for(int j = 0; j < items.length; j++) + { + lookaheads[i].put(items[j], new SymbolSet()); + propagation[i].put(items[j], new Vector(0)); + } + } + System.out.println(); + + ((SymbolSet) lookaheads[0].get(set.items()[0])).setTerminal(Grammar.eof); + + for(int i = 0; i < sets.length; i++) + { + System.out.print("."); + LR0Item[] items = sets[i].items(); + + for(int j = 0; j < items.length; j++) + { + LR1ItemSet lr1Set = new LR1ItemSet(); + lr1Set.set(new LR1Item(items[j], Grammar.dummy)); + + LR1Item[] closure = Grammar.CLOSURE(lr1Set).items(); + + for(int k = 0; k < closure.length; k++) + { + if(closure[k].terminal != Grammar.dummy) + { + Symbol[] rightside = Production. + production(closure[k].lr0Item.production). + rightside(); + + if(closure[k].lr0Item.position < rightside.length) + { + Integer destination = collection.GOTO(i, + rightside[closure[k].lr0Item.position]); + + if(destination != null) + { + + ((SymbolSet) lookaheads[destination.intValue()]. + get + (new LR0Item(closure[k].lr0Item.production, + closure[k].lr0Item.position + 1))). + setTerminal(closure[k].terminal); + + /*((SymbolSet) lookaheads[collection.GOTO(i, + Production.production(closure[k].lr0Item.production). + rightside(closure[k].lr0Item.position)).intValue()]. + get(new LR0Item(closure[k].lr0Item.production, + closure[k].lr0Item.position + 1))). + setTerminal(closure[k].terminal);*/ + } + } + } + else + { + Symbol[] rightside = Production. + production(closure[k].lr0Item.production). + rightside(); + + if(closure[k].lr0Item.position < rightside.length) + { + Integer destination = collection.GOTO(i, + rightside[closure[k].lr0Item.position]); + + if(destination != null) + { + ((Vector) propagation[i].get(items[j])). + addElement(new LR0ItemAndSetPair( + new LR0Item(closure[k].lr0Item.production, + closure[k].lr0Item.position + 1), + destination.intValue())); + + /*((Vector) propagation[i].get(items[j])). + addElement(new LR0ItemAndSetPair( + new LR0Item(closure[k].lr0Item.production, + closure[k].lr0Item.position + 1), + collection.GOTO(i, + Production.production(closure[k].lr0Item.production). + rightside(closure[k].lr0Item.position)).intValue()));*/ + } + } + } + } + } + } + System.out.println(); + + boolean changed; + do + { + System.out.print("."); + changed = false; + for(int i = 0; i < sets.length; i++) + { + LR0Item[] items = sets[i].items(); + + for(int j = 0; j < items.length; j++) + { + for(Enumeration e = ((Vector) propagation[i].get(items[j])). + elements(); e.hasMoreElements();) + { + LR0ItemAndSetPair pair = (LR0ItemAndSetPair) e.nextElement(); + + SymbolSet before = (SymbolSet) + ((SymbolSet) lookaheads[pair.set].get(pair.item)).clone(); + + ((SymbolSet) lookaheads[pair.set].get(pair.item)). + or((SymbolSet) lookaheads[i].get(items[j])); + + if(!before.equals(lookaheads[pair.set].get(pair.item))) + { + changed = true; + } + } + } + } + } + while(changed); + System.out.println(); + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + + result.append(collection); + result.append(System.getProperty("line.separator")); + + result.append("Lookaheads" + System.getProperty("line.separator")); + LR0ItemSet[] sets = collection.sets(); + + for(int i = 0; i < sets.length; i++) + { + result.append(i + ":" + System.getProperty("line.separator")); + LR0Item[] items = sets[i].items(); + + for(int j = 0; j < items.length; j++) + { + result.append(items[j] + ":" + lookaheads[i].get(items[j]) + + System.getProperty("line.separator")); + } + } + + return result.toString(); + } +} diff --git a/src/main/java/org/sablecc/sablecc/LR1Item.java b/src/main/java/org/sablecc/sablecc/LR1Item.java new file mode 100644 index 0000000..9aadae7 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/LR1Item.java @@ -0,0 +1,99 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +final class LR1Item implements Cloneable, Comparable +{ + final LR0Item lr0Item; + final int terminal; + + LR1Item(LR0Item lr0Item, int terminal) + { + this.lr0Item = lr0Item; + this.terminal = terminal; + } + + public Object clone() + { + return new LR1Item(lr0Item, terminal); + } + + public boolean equals(Object obj) + { + if((obj == null) || + (obj.getClass() != this.getClass())) + { + return false; + } + + LR1Item item = (LR1Item) obj; + + return (item.lr0Item.equals(lr0Item)) && + (item.terminal == terminal); + } + + public int hashCode() + { + return lr0Item.hashCode() * (terminal + 1) * 37; + } + + public String toString() + { + return lr0Item + ":" + Symbol.symbol(terminal, true); + } + + public String toString(Symbol lookahead) + { + // two cases: + // (1) we are facing a reduction, and the lookahed + // should match + // (2) we are in the middle of a production. The + // next element should match. + + Symbol[] rightside = Production.production(lr0Item.production).rightside(); + + if(lr0Item.position == rightside.length) + { + Symbol term = Symbol.symbol(terminal, true); + + if(term == lookahead) + { + return lr0Item + " followed by " + term + " (reduce)"; + } + else + { + return null; + } + } + + if(rightside[lr0Item.position] == lookahead) + { + return lr0Item + " (shift)"; + } + else + { + return null; + } + } + + public int compareTo(Object object) + { + LR1Item item = (LR1Item) object; + + int result = lr0Item.compareTo(item.lr0Item); + + if(result == 0) + { + result = terminal - item.terminal; + } + + return result; + } +} diff --git a/src/main/java/org/sablecc/sablecc/LR1ItemSet.java b/src/main/java/org/sablecc/sablecc/LR1ItemSet.java new file mode 100644 index 0000000..ba7114d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/LR1ItemSet.java @@ -0,0 +1,233 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import java.util.Vector; + +final class LR1ItemSet implements Cloneable, Comparable +{ + private final TreeMap items; + private int hashCode = 0; + + LR1ItemSet() + { + this.items = new TreeMap(); + } + + private LR1ItemSet(LR1ItemSet set + ) + { + this.items = (TreeMap) set.items.clone(); + this.hashCode = set.hashCode; + } + + void set + (LR1Item item) + { + if(items.put(item, item) == null) + { + hashCode += item.hashCode(); + modified_ = true; + } + } + + boolean get + (LR1Item item) + { + return items.get(item) != null; + } + + LR1Item[] items_; + boolean modified_ = true; + + private void computeArray() + { + Vector itemVector = new Vector(0); + + for(Iterator e = items.keySet().iterator(); e.hasNext();) + { + itemVector.addElement(e.next()); + } + + items_ = new LR1Item[itemVector.size()]; + itemVector.copyInto(items_); + modified_ = false; + } + + LR1Item[] items() + { + if(modified_) + { + computeArray(); + } + + return items_; + } + + public String toString() + { + String nl = System.getProperty("line.separator"); + + StringBuffer result = new StringBuffer(); + result.append("{" + nl + "\t"); + + Production[] productions = Production.productions(); + Symbol[] terminals = Symbol.terminals(); + boolean comma = false; + for(int i = 0; i < productions.length; i++) + { + int rightsideLength = productions[i].rightside().length; + + for(int j = 0; j <= rightsideLength; j++) + { + LR0Item lr0Item = new LR0Item(productions[i].index, j); + + for(int k = 0; k < terminals.length; k++) + { + LR1Item item = new LR1Item(lr0Item, terminals[k].index); + if(get + (item)) + { + if(comma) + { + result.append("," + nl + "\t"); + } + else + { + comma = true; + } + + result.append(item); + } + } + } + } + + result.append(nl + "}"); + return result.toString(); + } + + public String toString(Symbol lookahead) + { + String nl = System.getProperty("line.separator"); + + LR1Item[] items = items(); + int length = items.length; + + TreeSet strings = new TreeSet(); + + for(int i = 0; i < length; i++) + { + + String s = items[i].toString(lookahead); + //System.out.println("s = " + s + " " + " items[i] : " + items[i] + " lookahead : " + lookahead); + if(s != null) + { + strings.add(s); + } + } + + StringBuffer result = new StringBuffer(); + result.append("{"); + + boolean colon = false; + for(Iterator i = strings.iterator(); i.hasNext(); ) + { + if(colon) + { + result.append(","); + result.append(nl); + } + else + { + colon = true; + result.append(nl); + } + + result.append("\t"); + result.append(i.next()); + } + + result.append(nl); + result.append("}"); + + return result.toString(); + } + + public Object clone() + { + return new LR1ItemSet(this); + } + + public boolean equals(Object obj) + { + if((obj == null) || + (obj.getClass() != this.getClass())) + { + return false; + } + + LR1ItemSet set + = (LR1ItemSet) obj; + + if(set.items.size() != items.size()) + { + return false; + } + + for(Iterator e = items.keySet().iterator(); e.hasNext();) + { + if(!set.get((LR1Item) e.next())) + { + return false; + } + } + + return true; + } + + public int hashCode() + { + return hashCode; + } + + public int compareTo(Object object) + { + LR1ItemSet set + = (LR1ItemSet) object; + + int result = items.size() - set.items.size(); + + if(result == 0) + { + Iterator e = items.keySet().iterator(); + Iterator f = set.items.keySet().iterator(); + + while(e.hasNext() && f.hasNext() && (result == 0)) + { + result = ((LR1Item) e.next()).compareTo(f.next()); + } + + if(result == 0) + { + if(e.hasNext()) + { + return 1; + } + + if(f.hasNext()) + { + return -1; + } + } + } + + return result; + } +} diff --git a/src/main/java/org/sablecc/sablecc/ListCast.java b/src/main/java/org/sablecc/sablecc/ListCast.java new file mode 100644 index 0000000..f66bd6d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ListCast.java @@ -0,0 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class ListCast implements Cast +{ + public final static ListCast instance = new ListCast(); + + private ListCast() + {} + + public Object cast(Object o) + { + return (List) o; + } +} diff --git a/src/main/java/org/sablecc/sablecc/MacroExpander.java b/src/main/java/org/sablecc/sablecc/MacroExpander.java new file mode 100644 index 0000000..1cc8b66 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/MacroExpander.java @@ -0,0 +1,111 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.io.*; +import java.util.*; + +public class MacroExpander +{ + private static final String MACRO = "Macro:"; + private static final String lineSeparator = System.getProperty("line.separator"); + + private Map macros = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + ListCast.instance); + + public MacroExpander(Reader in) throws IOException + { + BufferedReader br = new BufferedReader(in); + while(readInMacro(br)) + ; + in.close(); + } + + private boolean readInMacro(BufferedReader in) throws IOException + { + String line; + while((line = in.readLine()) != null) + { + if(line.startsWith(MACRO)) + { + String name = line.substring(MACRO.length()); + List macro = new TypedLinkedList(StringCast.instance); + + while((line = in.readLine()) != null) + { + if(line.equals("$")) + { + macros.put(name, macro); + return true; + } + + macro.add(line); + } + + macros.put(name, macro); + return false; + } + } + + return false; + } + + public String toString() + { + return this.getClass().getName() + macros; + } + + public void apply(BufferedWriter out, String macroName) throws IOException + { + apply(out, macroName, null); + } + + public void apply(BufferedWriter out, String macroName, String[] arguments) throws IOException + { + List macro = (List) macros.get(macroName); + + for(ListIterator li = macro.listIterator(); li.hasNext();) + { + if(li.nextIndex() != 0) + { + out.newLine(); + } + + String line = (String) li.next(); + char c; + + for(int i = 0; i < line.length(); i++) + { + if((c = line.charAt(i)) == '$') + { + StringBuffer index = new StringBuffer(); + + while((c = line.charAt(++i)) != '$') + { + index.append(c); + } + + if(index.length() == 0) + { + out.write('$'); + } + else + { + out.write(arguments[Integer.parseInt(index.toString())]); + } + } + else + { + out.write(c); + } + } + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/NFA.java b/src/main/java/org/sablecc/sablecc/NFA.java new file mode 100644 index 0000000..8de83cf --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/NFA.java @@ -0,0 +1,355 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class NFA implements Cloneable +{ + public State[] states; + + private NFA(int size) + { + System.out.print("."); + states = new State[size]; + } + + public NFA() + { + this(2); + states[0] = new State(); + states[0].transitions[0] = new Transition(null, 1); + states[1] = new State(); + } + + public NFA(CharSet chars) + { + this(2); + states[0] = new State(); + states[0].transitions[0] = new Transition(chars, 1); + states[1] = new State(); + } + + public NFA(String string) + { + this(string.length() + 1); + + for(int i = 0; i < string.length(); i++) + { + states[i] = new State(); + states[i].transitions[0] = new Transition(new CharSet(string.charAt(i)), i + 1); + } + + states[string.length()] = new State(); + } + + private NFA(NFA nfa) + { + this(nfa.states.length); + + for(int i = 0; i < nfa.states.length; i++) + { + states[i] = new State(nfa.states[i]); + } + } + + public NFA zeroOrMore() + { + NFA nfa = new NFA(states.length + 2); + nfa.states[0] = new State(); + nfa.states[0].transitions[0] = new Transition(null, 1); + nfa.states[0].transitions[1] = new Transition(null, states.length + 1); + + for(int i = 0; i < states.length; i++) + { + nfa.states[i + 1] = new State(states[i]); + + if(nfa.states[i + 1].transitions[0] != null) + { + nfa.states[i + 1].transitions[0].destination += 1; + } + + if(nfa.states[i + 1].transitions[1] != null) + { + nfa.states[i + 1].transitions[1].destination += 1; + } + } + + nfa.states[states.length].transitions[0] = new Transition(null, 1); + nfa.states[states.length].transitions[1] = new Transition(null, states.length + 1); + + nfa.states[states.length + 1] = new State(); + + return nfa; + } + + public NFA zeroOrOne() + { + NFA nfa = new NFA(states.length + 2); + nfa.states[0] = new State(); + nfa.states[0].transitions[0] = new Transition(null, 1); + nfa.states[0].transitions[1] = new Transition(null, states.length + 1); + + for(int i = 0; i < states.length; i++) + { + nfa.states[i + 1] = new State(states[i]); + + if(nfa.states[i + 1].transitions[0] != null) + { + nfa.states[i + 1].transitions[0].destination += 1; + } + + if(nfa.states[i + 1].transitions[1] != null) + { + nfa.states[i + 1].transitions[1].destination += 1; + } + } + + nfa.states[states.length].transitions[1] = new Transition(null, states.length + 1); + + nfa.states[states.length + 1] = new State(); + + return nfa; + } + + public NFA oneOrMore() + { + NFA nfa = new NFA(states.length + 2); + nfa.states[0] = new State(); + nfa.states[0].transitions[0] = new Transition(null, 1); + + for(int i = 0; i < states.length; i++) + { + nfa.states[i + 1] = new State(states[i]); + + if(nfa.states[i + 1].transitions[0] != null) + { + nfa.states[i + 1].transitions[0].destination += 1; + } + + if(nfa.states[i + 1].transitions[1] != null) + { + nfa.states[i + 1].transitions[1].destination += 1; + } + } + + nfa.states[states.length].transitions[0] = new Transition(null, 1); + nfa.states[states.length].transitions[1] = new Transition(null, states.length + 1); + + nfa.states[states.length + 1] = new State(); + + return nfa; + } + + public NFA concatenate(NFA next) + { + NFA nfa = new NFA(states.length + next.states.length - 1); + + for(int i = 0; i < states.length - 1; i++) + { + nfa.states[i] = new State(states[i]); + } + + for(int i = 0; i < next.states.length; i++) + { + nfa.states[states.length + i - 1] = new State(next.states[i]); + + if(nfa.states[states.length + i - 1].transitions[0] != null) + { + nfa.states[states.length + i - 1].transitions[0].destination += + states.length - 1; + } + + if(nfa.states[states.length + i - 1].transitions[1] != null) + { + nfa.states[states.length + i - 1].transitions[1].destination += + states.length - 1; + } + } + + return nfa; + } + + public NFA alternate(NFA next) + { + NFA nfa = new NFA(states.length + next.states.length + 2); + + nfa.states[0] = new State(); + nfa.states[0].transitions[0] = new Transition(null, 1); + nfa.states[0].transitions[1] = new Transition(null, states.length + 1); + + for(int i = 0; i < states.length; i++) + { + nfa.states[i + 1] = new State(states[i]); + + if(nfa.states[i + 1].transitions[0] != null) + { + nfa.states[i + 1].transitions[0].destination += 1; + } + + if(nfa.states[i + 1].transitions[1] != null) + { + nfa.states[i + 1].transitions[1].destination += 1; + } + } + + nfa.states[states.length].transitions[0] = + new Transition(null, states.length + next.states.length + 1); + + for(int i = 0; i < next.states.length; i++) + { + nfa.states[states.length + i + 1] = new State(next.states[i]); + + if(nfa.states[states.length + i + 1].transitions[0] != null) + { + nfa.states[states.length + i + 1].transitions[0].destination += + states.length + 1; + } + + if(nfa.states[states.length + i + 1].transitions[1] != null) + { + nfa.states[states.length + i + 1].transitions[1].destination += + states.length + 1; + } + } + + nfa.states[states.length + next.states.length].transitions[0] = + new Transition(null, states.length + next.states.length + 1); + + nfa.states[states.length + next.states.length + 1] = new State(); + + return nfa; + } + + public NFA merge(NFA next) + { + NFA nfa = new NFA(states.length + next.states.length + 1); + + nfa.states[0] = new State(); + nfa.states[0].transitions[0] = new Transition(null, 1); + nfa.states[0].transitions[1] = new Transition(null, states.length + 1); + + for(int i = 0; i < states.length; i++) + { + nfa.states[i + 1] = new State(states[i]); + + if(nfa.states[i + 1].transitions[0] != null) + { + nfa.states[i + 1].transitions[0].destination += 1; + } + + if(nfa.states[i + 1].transitions[1] != null) + { + nfa.states[i + 1].transitions[1].destination += 1; + } + } + + for(int i = 0; i < next.states.length; i++) + { + nfa.states[states.length + i + 1] = new State(next.states[i]); + + if(nfa.states[states.length + i + 1].transitions[0] != null) + { + nfa.states[states.length + i + 1].transitions[0].destination += + states.length + 1; + } + + if(nfa.states[states.length + i + 1].transitions[1] != null) + { + nfa.states[states.length + i + 1].transitions[1].destination += + states.length + 1; + } + } + + return nfa; + } + + public Object clone() + { + return new NFA(this); + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + for(int i = 0; i < states.length; i++) + { + result.append(i + ":" + states[i] + System.getProperty("line.separator")); + } + return result.toString(); + } + + public static class State + { + public String accept; + + public Transition[] transitions = new Transition[2]; + + public State() + {} + + public State(State state) + { + if(state.accept != null) + { + accept = state.accept; + } + + if(state.transitions[0] != null) + { + transitions[0] = new Transition(state.transitions[0]); + } + + if(state.transitions[1] != null) + { + transitions[1] = new Transition(state.transitions[1]); + } + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + if(accept != null) + { + result.append("(" + accept + ") "); + } + if(transitions[0] != null) + { + result.append(" " + transitions[0]); + } + if(transitions[1] != null) + { + result.append(" " + transitions[1]); + } + return result.toString(); + } + } + + public static class Transition + { + public CharSet chars; + public int destination; + + public Transition(CharSet chars, int destination) + { + this.chars = chars; + this.destination = destination; + } + + public Transition(Transition transition) + { + chars = transition.chars; + destination = transition.destination; + } + + public String toString() + { + return destination + ":{" + chars + "}"; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/NoCast.java b/src/main/java/org/sablecc/sablecc/NoCast.java new file mode 100644 index 0000000..0198130 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/NoCast.java @@ -0,0 +1,21 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +public class NoCast implements Cast +{ + public final static NoCast instance = new NoCast(); + + private NoCast() + {} + + public Object cast(Object o) + { + return o; + } +} diff --git a/src/main/java/org/sablecc/sablecc/NodeCast.java b/src/main/java/org/sablecc/sablecc/NodeCast.java new file mode 100644 index 0000000..202c84b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/NodeCast.java @@ -0,0 +1,24 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.node.*; + +public class NodeCast implements Cast +{ + public final static NodeCast instance = new NodeCast(); + + private NodeCast() + {} + + public Object cast(Object o) + { + return (Node) o; + } +} diff --git a/src/main/java/org/sablecc/sablecc/PrettyPrinter.java b/src/main/java/org/sablecc/sablecc/PrettyPrinter.java new file mode 100644 index 0000000..43eb5cf --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/PrettyPrinter.java @@ -0,0 +1,300 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; + +public class PrettyPrinter extends DepthFirstAdapter +{ + public static String production_INDENT = " " ; + public static String prod_transform_INDENT = " "; + public static String alternative_INDENT = " " ; + public static String alt_transform_INDENT = " " ; + + public void caseAProductions(AProductions node) + { + System.err.println("Productions \n"); + AProd [] prods = + (AProd [])node.getProds().toArray(new AProd[0]); + for(int i = 0; i < prods.length; i++) + { + prods[i].apply(this); + } + } + + public void caseAProd(AProd node) + { + System.err.print(production_INDENT + node.getId().getText()); + String hasProdTransform = "="; + if(node.getArrow() == null) + { + hasProdTransform = ""; + System.err.println(" = "); + } + System.err.println(); + + AElem[] elems = (AElem [])node.getProdTransform().toArray(new AElem[0]); + + //if(node.getArrow() != null) + if(elems.length > 0) + { + System.err.print(prod_transform_INDENT + "{-> "); + + for(int i=0; i<elems.length; i++) + { + //System.err.print(elems[i] + " "); + elems[i].apply(this); + System.err.print(" "); + } + System.err.println(" } " + hasProdTransform); + } + + Object[] alts = (Object[])node.getAlts().toArray(); + for(int i=0; i<alts.length-1; i++) + { + ((PAlt)alts[i]).apply(this); + System.err.println( " |"); + } + ((PAlt)alts[alts.length-1]).apply(this); + + System.err.println("\n" + alternative_INDENT + ";\n"); + } + + public void caseAAlt(AAlt node) + { + System.err.print("\n" + alternative_INDENT); + + if(node.getAltName() != null) + { + System.err.print("{" + node.getAltName().getText()+"} "); + } + + AElem[] listElems = (AElem[])node.getElems().toArray(new AElem[0]); + for(int i=0; i<listElems.length; i++) + { + //System.err.print(listElems[i]); + listElems[i].apply(this); + System.err.print(" "); + } + + if(node.getAltTransform() != null) + { + node.getAltTransform().apply(this); + } + } + + public void caseAAltTransform(AAltTransform node) + { + System.err.print("\n" + alt_transform_INDENT + "{-> "); + + Object []terms = (Object[]) node.getTerms().toArray(); + for(int i=0; i<terms.length; i++) + { + ((PTerm)terms[i]).apply(this); + System.err.print(" "); + } + + System.err.print(" } "); + } + + public void caseAProdName(AProdName node) + { + System.err.print(node.getId().getText()); + if(node.getProdNameTail() != null) + { + System.err.print("." + node.getProdNameTail().getText()); + } + } + + public void caseANewTerm(ANewTerm node) + { + System.err.print("New "); + node.getProdName().apply(this); + System.err.print(" (" ); + + Object []params = node.getParams().toArray(); + if(params.length > 0) + { + for(int i=0; i<params.length-1; i++) + { + ((PTerm)params[i]).apply(this); + System.err.print(", "); + } + ((PTerm)params[params.length-1]).apply(this); + } + System.err.print(" )"); + } + + public void caseAListTerm(AListTerm node) + { + System.err.print("[ "); + Object []list_terms = node.getListTerms().toArray(); + + for(int i=0; i<list_terms.length; i++) + { + ((PListTerm)list_terms[i]).apply(this); + } + System.err.print(" ]"); + } + + public void caseASimpleTerm(ASimpleTerm node) + { + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + System.err.print("T."); + } + else + { + System.err.print("P."); + } + } + System.err.print(node.getId().getText() ); + if(node.getSimpleTermTail() != null) + { + System.err.print("." + node.getSimpleTermTail().getText()); + } + System.err.print(" "); + } + + public void caseANullTerm(ANullTerm node) + { + System.err.print("Null "); + } + + public void caseANewListTerm(ANewListTerm node) + { + System.err.print("New "); + node.getProdName().apply(this); + System.err.print(" (" ); + + Object []params = node.getParams().toArray(); + if(params.length > 0) + { + for(int i=0; i<params.length-1; i++) + { + ((PTerm)params[i]).apply(this); + System.err.print(", "); + } + ((PTerm)params[params.length-1]).apply(this); + } + System.err.print(" )"); + } + + public void caseASimpleListTerm(ASimpleListTerm node) + { + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + System.err.print("T."); + } + else + { + System.err.print("P."); + } + } + System.err.print(node.getId().getText() ); + if(node.getSimpleTermTail() != null) + { + System.err.print("." + node.getSimpleTermTail().getText()); + } + System.err.print(" "); + } + + public void caseAAst(AAst node) + { + System.err.print("Abstract Syntax Tree\n"); + + AAstProd [] prods = + (AAstProd [])node.getProds().toArray(new AAstProd[0]); + for(int i = 0; i < prods.length; i++) + { + prods[i].apply(this); + } + } + + public void caseAAstProd(AAstProd node) + { + System.err.println(production_INDENT + node.getId().getText() + " ="); + + AAstAlt[] alts = (AAstAlt[])node.getAlts().toArray(new AAstAlt[0]); + for(int i=0; i<alts.length-1; i++) + { + alts[i].apply(this); + System.err.println( "| "); + } + alts[alts.length-1].apply(this); + + System.err.println("\n" + alternative_INDENT + ";\n"); + } + + public void caseAAstAlt(AAstAlt node) + { + System.err.print(alternative_INDENT); + + if(node.getAltName() != null) + { + System.err.print("{" + node.getAltName().getText()+"} "); + } + + AElem[] listElems = (AElem[])node.getElems().toArray(new AElem[0]); + for(int i=0; i<listElems.length; i++) + { + //System.err.print(listElems[i]); + listElems[i].apply(this); + System.err.print(" "); + } + } + + public void caseAElem(AElem node) + { + if(node.getElemName() != null) + { + System.err.print("[" + node.getElemName().getText() + "]: "); + } + + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + System.err.print("T."); + } + else + { + System.err.print("P."); + } + } + + System.err.print(node.getId().getText()); + if(node.getUnOp() != null) + { + node.getUnOp().apply(new DepthFirstAdapter() + { + public void caseAStarUnOp(AStarUnOp node) + { + System.err.print("*"); + } + + public void caseAQMarkUnOp(AQMarkUnOp node) + { + System.err.print("?"); + } + + public void caseAPlusUnOp(APlusUnOp node) + { + System.err.print("+"); + } + } + ); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/Production.java b/src/main/java/org/sablecc/sablecc/Production.java new file mode 100644 index 0000000..9fb1cc1 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/Production.java @@ -0,0 +1,157 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import java.util.Vector; +import java.util.Enumeration; + +final class Production +{ + final int leftside; + final int index; + final String name; + + private final Vector rightside = new Vector(); + private static final Vector productions = new Vector(0); + private static TreeMap alternatives_ = new TreeMap(IntegerComparator.instance); + private static boolean modified_ = true; + private static Production[] productions_; + + public static void reinit() + { + productions.removeAllElements(); + alternatives_ = new TreeMap(IntegerComparator.instance); + productions_ = null; + modified_ = true; + productions_ = null; + } + + private static void computeArray_() + { + productions_ = new Production[productions.size()]; + productions.copyInto(productions_); + modified_ = false; + } + + private boolean modified = true; + private Symbol[] rightside_; + + private void computeArray() + { + rightside_ = new Symbol[rightside.size()]; + rightside.copyInto(rightside_); + modified = false; + } + + Production(int leftside, String name) + { + productions.addElement(this); + + this.name = name; + this.leftside = leftside; + this.index = productions.indexOf(this); + modified_ = true; + } + + Symbol[] rightside() + { + if(modified) + { + computeArray(); + } + + return rightside_; + } + + void addSymbol(Symbol s) + { + rightside.addElement(s); + modified = true; + modified_ = true; + } + + Symbol rightside(int index) + { + return (Symbol) rightside.elementAt(index); + } + + static Production production(int index) + { + return (Production) productions.elementAt(index); + } + + static Production[] alternatives(int nonterminal) + { + if(modified_) + { + alternatives_ = new TreeMap(IntegerComparator.instance); + } + + Production[] result = (Production[]) alternatives_.get(new Integer(nonterminal)); + + if(result == null) + { + Vector alternatives = new Vector(0); + + for(Enumeration e = productions.elements(); e.hasMoreElements();) + { + Production production = (Production) e.nextElement(); + + if(production.leftside == nonterminal) + { + alternatives.addElement(production); + } + } + + result = new Production[alternatives.size()]; + alternatives.copyInto(result); + + alternatives_.put(new Integer(nonterminal), result); + } + + return result; + } + + static Production[] productions() + { + if(modified_) + { + computeArray_(); + } + + return productions_; + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + + result.append(Symbol.symbol(leftside, false)); + + result.append(" = "); + + Symbol[] symbols = rightside(); + boolean space = false; + for(int i = 0; i < symbols.length; i++) + { + if(space) + { + result.append(" "); + } + else + { + space = true; + } + + result.append(symbols[i]); + } + + return result.toString(); + } +} diff --git a/src/main/java/org/sablecc/sablecc/RecursiveProductionsDetections.java b/src/main/java/org/sablecc/sablecc/RecursiveProductionsDetections.java new file mode 100644 index 0000000..c29276e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/RecursiveProductionsDetections.java @@ -0,0 +1,70 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; + +public class RecursiveProductionsDetections extends DepthFirstAdapter +{ + public LinkedList listOfRecursiveProds = new TypedLinkedList(StringCast.instance); + private String currentProd; + + public void caseAProd(AProd node) + { + currentProd = node.getId().getText(); + if(!node.getId().getText().startsWith("$")) + { + Object []alts = node.getAlts().toArray(); + + for(int i=0; i<alts.length; i++) + { + ((PAlt)alts[i]).apply(this); + } + } + else + { + listOfRecursiveProds.add( ResolveIds.name(currentProd) ); + } + } + + public void caseAAlt(AAlt node) + { + Object temp[] = node.getElems().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PElem) temp[i]).apply(this); + } + } + /* + public void caseAIgnoredAlt(AIgnoredAlt node) + { + Object temp[] = node.getElems().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PElem) temp[i]).apply(this); + } + } + */ + + public void caseAElem(AElem node) + { + if(node.getId().getText().equals(currentProd)) + { + if(node.getSpecifier() != null && node.getSpecifier() instanceof ATokenSpecifier) + { + return; + } + if( !listOfRecursiveProds.contains(ResolveIds.name(currentProd)) ) + { + listOfRecursiveProds.add( ResolveIds.name(currentProd) ); + } + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/ResolveAltIds.java b/src/main/java/org/sablecc/sablecc/ResolveAltIds.java new file mode 100644 index 0000000..e6f42f0 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ResolveAltIds.java @@ -0,0 +1,162 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** + * Last Modification date : 03-11-2003 + * Remove the checking of question mark and + operator + * for production tranformations + * I've commented out the method + * public void caseAProd(AProd node) { ... } + * Date : 15-01-2003 : + * The method is now removed because it is not used anymore + */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +/* + * ResolveAltIds + * + * This class computes semantic verifications for AST alternatives + * section. The same thing is done by ResolveIds class for Productions + * section. + */ + +public class ResolveAltIds extends DepthFirstAdapter +{ + public ResolveIds ids; + + //Map of alternatives elements which are not list : + // ie not followed by * or + operator. + public Map alts_elems = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + ListCast.instance); + + //Map of only alternatives elements which are list : + //followed by * or + operator. + public Map alts_elems_list = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + ListCast.instance); + + //Map of all alternatives elements. Elements name are stored + //if it is specified otherwise, it is its id. + //(elem = elem_name? specifier? id un_op?) + public Map alts_elemsGlobal = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + ListCast.instance); + + //Map of all alternatives elements which have explicit name. + public Map alts_elems_list_elemName = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + ListCast.instance); + + private LinkedList listElemsGlobal; + private LinkedList listElems; + private LinkedList listElemslist; + + String currentAlt; + + //This is true if the current elem is a list and false otherwise + private boolean blist; + + public ResolveAltIds(ResolveIds ids) + { + this.ids = ids; + } + + /* + * This method is checking if there is QMark or Plus Operator in in the + * list of productions transformations elements + */ + + public void caseAProd(AProd node) + { + AElem []temp = (AElem[]) node.getProdTransform().toArray(new AElem[0]); + + Object []list_alts = node.getAlts().toArray(); + for(int j=0; j<list_alts.length; j++) + { + ((PAlt)list_alts[j]).apply(this); + } + } + + /* + * Here, a map which associate the current alternative with the list of elems + * is created. + */ + public void caseAAlt(AAlt alt) + { + //contains all the elements in the alternative, no matter if they are list or not + listElemsGlobal = new LinkedList(); + + //contains only single (without operator * or +) element of the alternative. + listElems = new LinkedList(); + + //contains only element of the alternative which are list(operator * or +). + listElemslist = new LinkedList(); + + currentAlt = (String)ids.names.get(alt); + + AElem[] list_elems = (AElem[])alt.getElems().toArray(new AElem[0]); + for(int i=0; i<list_elems.length; i++) + { + list_elems[i].apply(this); + } + + alts_elemsGlobal.put(currentAlt, listElemsGlobal); + alts_elems.put(currentAlt, listElems); + alts_elems_list.put(currentAlt, listElemslist); + } + + public void caseAElem(final AElem elem) + { + blist = false; + if( (elem.getUnOp() != null) && + ((elem.getUnOp() instanceof AStarUnOp) || (elem.getUnOp() instanceof APlusUnOp)) ) + { + blist = true; + } + + String elem_name = (elem.getElemName() != null ? elem.getElemName().getText() : elem.getId().getText() ); + if(!blist) + { + listElems.add(elem_name); + } + else + { + listElemslist.add(elem_name); + } + + listElemsGlobal.add(elem_name); + } + + //This method is overriding in order to not allow ASt traversal to visit + //AST elements. + public void caseAAst(AAst node) + {} + + public String toString() + { + StringBuffer s = new StringBuffer(); + String nl = System.getProperty("line.separator"); + + s.append("Alternative elements : "); + s.append(nl); + s.append(alts_elems); + s.append(nl); + + return s.toString(); + } +} diff --git a/src/main/java/org/sablecc/sablecc/ResolveAstIds.java b/src/main/java/org/sablecc/sablecc/ResolveAstIds.java new file mode 100644 index 0000000..a0613df --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ResolveAstIds.java @@ -0,0 +1,349 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +/* + * ResolveAstIds + * + * This class computes basic semantic verifications for AST alternatives + * section. The same thing is done by ResolveIds class for Productions + * section. It makes sure that there is no conflictual names and it also + * constructs few symbol tables necessary in the rest of the code. + */ + +/** + * Last Modification date : 18-10-2004 + * correct AST alternative element error bug (error2()) + * Now only tokens and AST section's productions can be used in + * AST alternatives + * + * 15-01-2004 + * Remove comment method error1(...) + * + */ + +public class ResolveAstIds extends DepthFirstAdapter +{ + //Map of AST productions. The AST production node can be obtained + //by giving the name of this production + // Example :: PAstProd is the name of the declared the following productions + // ast_prod = id equal [alts]:ast_alt* semicolon; + public final Map ast_prods = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + //Same thing that above for AST alternatives. + public final Map ast_alts = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + //Same thing that above for AST alternatives elements. + public final Map ast_elems = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + //Map of all names of AST productions. + //They are essentially used to generate AST node classes. + public final Map ast_names = new TypedHashMap( + NodeCast.instance, + StringCast.instance); + public final Map ast_elemTypes = new TypedHashMap( + NodeCast.instance, + StringCast.instance); + public ResolveIds astIds; + + private String firstAstProduction; + private String currentProd; + private String currentAlt; + private int lastLine; + private int lastPos; + + public ResolveAstIds(ResolveIds ids) + { + astIds = ids; + } + + public String getFirstAstProduction() + { + return firstAstProduction; + } + + public void inAAst(AAst node) + { + LinkedList listProds = node.getProds(); + if(listProds.size() > 0) + { + AAstProd firstAstProd = (AAstProd)listProds.getFirst(); + firstAstProduction = "P" + astIds.name(firstAstProd.getId().getText()); + } + } + + public void inAAstProd(AAstProd node) + { + currentProd = astIds.name(node.getId().getText()); + + String name = "P" + currentProd; + + if(ast_prods.put(name, node) != null) + { + error(node.getId(), name); + } + ast_names.put(node, name); + } + + public void inAAstAlt(final AAstAlt alt) + { + if(alt.getAltName() != null) + { + currentAlt = + "A" + + astIds.name(alt.getAltName().getText()) + + currentProd; + + if(ast_alts.put(currentAlt, alt) != null) + { + error(alt.getAltName(), currentAlt); + } + ast_names.put(alt, currentAlt); + } + else + { + currentAlt = "A" + currentProd; + + if(ast_alts.put(currentAlt, alt) != null) + { + error(currentAlt); + } + ast_names.put(alt, currentAlt); + } + } + + //Only Abstract Syntax Tree section is concerned by the visitor here. + public void caseAProductions(AProductions node) + {} + + public void caseAElem(final AElem elem) + { + String name; + String elem_name; + TId tid; + if(elem.getElemName() != null) + { + tid = elem.getElemName(); + } + else + { + tid = elem.getId(); + } + + elem_name = tid.getText(); + name = currentAlt + "." + astIds.name(elem_name); + + if(ast_elems.put(name, elem) != null) + { + error(tid, name); + } + + if(elem_name.equals("class")) + { + error5(tid); + } + + ast_names.put(elem, astIds.name(elem_name)); + } + + public void outAAstProd(AAstProd prod) + { + prod.apply(new DepthFirstAdapter() + { + public void caseAElem(AElem node) + { + String name = astIds.name(node.getId().getText()); + + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + ast_elemTypes.put(node, "T" + name); + } + else + { + ast_elemTypes.put(node, "P" + name); + } + } + else + { + Object token = astIds.tokens.get("T" + name); + + if(token != null) + { + ast_elemTypes.put(node, "T" + name); + } + else + { + ast_elemTypes.put(node, "P" + name); + } + } + } + } + ); + } + + public void outAAst(AAst prod) + { + prod.apply(new DepthFirstAdapter() + { + public void caseAElem(AElem node) + { + String name = astIds.name(node.getId().getText()); + + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + if(astIds.tokens.get("T" + name) == null) + { + error2(node.getId(), "T" + name); + } + + if(astIds.ignTokens.get("T" + name) != null) + { + error3(node.getId(), "T" + name); + } + + ast_elemTypes.put(node, "T" + name); + } + else + { + if(ast_prods.get("P" + name) == null) + { + error2(node.getId(), "P" + name); + } + ast_elemTypes.put(node, "P" + name); + } + } + else + { + Object token = astIds.tokens.get("T" + name); + Object ignToken = astIds.ignTokens.get("T" + name); + //Object production = astIds.prods.get("P" + name); + Object ast_production = ast_prods.get("P" + name); + //if() + if((token == null) && (ast_production == null)) + { + error2(node.getId(), "P" + name + " and T" + name ); + } + + //if the alternative element is a token + if(token != null) + { + //and also appears to be a valid production, there is an ambiguity + if( ast_production != null ) + { + error4(node.getId(), "P" + name + " and T" + name); + } + + //it should not be an ignored token + if(ignToken != null) + { + error3(node.getId(), "T" + name); + } + + ast_elemTypes.put(node, "T" + name); + } + //the alternative element is a production and everything is fine + else + { + ast_elemTypes.put(node, "P" + name); + } + } + } + } + ); + } + + public void defaultcase(Node node) + { + if(node instanceof Token) + { + Token t = (Token) node; + lastLine = t.getLine(); + lastPos = t.getPos() + t.getText().length(); + } + } + + private static void error(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "Redefinition of " + name + "."); + } + + private void error(String name) + { + throw new RuntimeException( + "[" + lastLine + "," + lastPos + "] " + + "Redefinition of " + name + "."); + } + + private static void error2(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + name + " undefined. If it is a production, It should be defined in AST section"); + } + + private static void error3(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + name + " is ignored."); + } + + private static void error4(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "ambiguous " + name + "."); + } + + private static void error5(Token token) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "class is an invalid element name."); + } + + public String toString() + { + StringBuffer s = new StringBuffer(); + String nl = System.getProperty("line.separator"); + + s.append("Productions:"); + s.append(nl); + s.append(ast_prods); + s.append(nl); + + s.append("Alternatives:"); + s.append(nl); + s.append(ast_alts); + s.append(nl); + + s.append("Elements:"); + s.append(nl); + s.append(ast_elems); + s.append(nl); + + return s.toString(); + } +} diff --git a/src/main/java/org/sablecc/sablecc/ResolveIds.java b/src/main/java/org/sablecc/sablecc/ResolveIds.java new file mode 100644 index 0000000..cfc4256 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ResolveIds.java @@ -0,0 +1,672 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +public class ResolveIds extends DepthFirstAdapter +{ + public final Map helpers = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + public final Map states = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + public final Map tokens = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + public final Map ignTokens = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + public final Map prods = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + + public final Map alts = new TypedHashMap( + StringCast.instance, + NodeCast.instance); + + public final Map elems = new TypedHashMap( + StringCast.instance, + NodeCast.instance); + + public final Map names = new TypedHashMap( + NodeCast.instance, + StringCast.instance); + + public final Map errorNames = new TypedHashMap( + NodeCast.instance, + StringCast.instance); + public final Map elemTypes = new TypedHashMap( + NodeCast.instance, + StringCast.instance); + + public final Map altsElemNameTypes = new TypedHashMap( + StringCast.instance, + StringCast.instance); + + // This map will serve for simpleTerm and simplelistTerm type within an altTransform + // Inside an altTransform, one would look at this map to know its type. (P... or T...) + public final Map altsElemTypes = new TypedHashMap( + StringCast.instance, + StringCast.instance); + + public final Map fixedTokens = new TypedHashMap( + NodeCast.instance, + BooleanCast.instance); + + public final List tokenList = new TypedLinkedList(StringCast.instance); + public final LinkedList stateList = new TypedLinkedList(StringCast.instance); + public File pkgDir; + public String pkgName = ""; + + private boolean processingStates; + private boolean processingIgnTokens; + + String currentProd; + String currentAlt; + private int lastLine; + private int lastPos; + + public ResolveIds(File currentDir) + { + pkgDir = currentDir; + } + + public void inAGrammar(AGrammar node) + { + TPkgId[] temp = (TPkgId []) node.getPackage().toArray(new TPkgId[0]); + if(temp.length > 0) + { + pkgName = temp[0].getText(); + pkgDir = new File(pkgDir, temp[0].getText()); + + for(int i=1; i<temp.length; i++) + { + pkgName += "." + temp[i].getText(); + pkgDir = new File(pkgDir, temp[i].getText()); + } + + if(!pkgDir.exists()) + { + if(!pkgDir.mkdirs()) + { + throw new RuntimeException("Unable to create " + pkgDir.getAbsolutePath()); + } + } + } + } + + public void caseAProd(AProd node) + { + //inAProd code. + currentProd = name(node.getId().getText()); + String name = "P" + currentProd; + + if(prods.put(name, node) != null) + { + error(node.getId(), name); + } + + names.put(node, name); + + //list of inAAlt code. + Object []list_alt = (Object [])node.getAlts().toArray(); + for(int i = 0; i< list_alt.length; i++) + { + ((PAlt)list_alt[i]).apply(this); + } + } + + public void caseAIdBasic(AIdBasic node) + { + String name = node.getId().getText(); + + // Only helpers can be used inside tokens definition + if(helpers.get(name) == null) + { + error2(node.getId(), name); + } + } + + public void outAHelperDef(AHelperDef node) + { + String name = node.getId().getText(); + + // If another helper is used within the current helper, + // it should have been defined before the current one + if(helpers.put(name, node) != null) + { + error(node.getId(), name); + } + + names.put(node, name); + } + + public void outATokenDef(ATokenDef node) + { + String name = "T" + name(node.getId().getText()); + String errorName = errorName(node.getId().getText()); + + //We are making sure that this token is not yet defined. + if(tokens.put(name, node) != null) + { + error(node.getId(), name); + } + + names.put(node, name); + errorNames.put(node, errorName); + tokenList.add(name); + + if(node.getLookAhead() != null) + { + Token token = (Token) node.getSlash(); + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "Look ahead not yet supported."); + } + } + + public void inAStates(AStates node) + { + Object [] list_id = (Object[]) node.getListId().toArray(); + String name; + + for(int i=0; i<list_id.length; i++) + { + name = ((TId)list_id[i]).getText().toUpperCase(); + + if(states.put(name, list_id[i]) != null) + { + error((TId)list_id[i], name); + } + + names.put(list_id[i], name); + stateList.add(name); + } + } + + public void inAIgnTokens(AIgnTokens node) + { + Object [] list_id = (Object[]) node.getListId().toArray(); + String name; + + for(int i=0; i<list_id.length; i++) + { + name = "T" + name(((TId)list_id[i]).getText()); + + if(tokens.get(name) == null) + { + error2((TId)list_id[i], name); + } + + if(ignTokens.put(name, list_id[i]) != null) + { + error((TId)list_id[i], name); + } + names.put(list_id[i], name); + } + } + + private Map stateMap; + + public void inAStateList(AStateList node) + { + stateMap = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NodeCast.instance); + + String name = node.getId().getText().toUpperCase(); + + if(states.get(name) == null) + { + error2(node.getId(), name); + } + + if(stateMap.put(name, node) != null) + { + error(node.getId(), name); + } + } + + public void outAStateList(AStateList node) + { + stateMap = null; + } + + public void inAStateListTail(AStateListTail node) + { + String name = node.getId().getText().toUpperCase(); + + if(states.get(name) == null) + { + error2(node.getId(), name); + } + + if(stateMap.put(name, node) != null) + { + error(node.getId(), name); + } + } + + public void inATransition(ATransition node) + { + String name = node.getId().getText().toUpperCase(); + + if(states.get(name) == null) + { + error2(node.getId(), name); + } + } + + public void caseAAlt(final AAlt alt) + { + if(alt.getAltName() != null) + { + currentAlt = + "A" + + name(alt.getAltName().getText()) + + currentProd; + + if(alts.put(currentAlt, alt) != null) + { + error(alt.getAltName(), currentAlt); + } + + names.put(alt, currentAlt); + } + else + { + + currentAlt = "A" + currentProd; + + if(alts.put(currentAlt, alt) != null) + { + error(currentAlt); + } + names.put(alt, currentAlt); + } + + AElem list_elem[] = (AElem[]) alt.getElems().toArray(new AElem[0]); + for(int i=0; i<list_elem.length;i++) + { + list_elem[i].apply(this); + } + + } + + public void defaultcase(Node node) + { + if(node instanceof Token) + { + Token t = (Token) node; + lastLine = t.getLine(); + lastPos = t.getPos() + t.getText().length(); + } + } + + public void caseAAst(AAst node) + {} + + public void caseAElem(final AElem elem) + { + if(elem.getElemName() != null) + { + String name = currentAlt + "." + + name(elem.getElemName().getText()); + + if(elems.put(name, elem) != null) + { + error(elem.getElemName(), name); + } + + if(elem.getElemName().getText().equals("class")) + { + error5(elem.getElemName()); + } + + names.put(elem, name(elem.getElemName().getText()) ); + } + else + { + String name = currentAlt + "." + + name(elem.getId().getText()); + + if(elems.put(name, elem) != null) + { + error(elem.getId(), name); + } + + if(elem.getId().getText().equals("class")) + { + error5(elem.getId()); + } + + names.put(elem, name(elem.getId().getText())); + } + } + + public void outAProductions(AProductions prod) + { + prod.apply(new DepthFirstAdapter() + { + public void caseAProd(AProd node) + { + //inAProd code. + currentProd = name(node.getId().getText()); + + //list of inAAlt code. + Object []list_alt = (Object [])node.getAlts().toArray(); + for(int i = 0; i< list_alt.length; i++) + { + ((PAlt)list_alt[i]).apply(this); + } + } + + public void caseAAlt(final AAlt alt) + { + if(alt.getAltName() != null) + { + currentAlt = "A" + name(alt.getAltName().getText()) + currentProd; + } + else + { + currentAlt = "A" + currentProd; + } + + AElem[] list_elem = (AElem[]) alt.getElems().toArray(new AElem[0]); + for(int i=0; i<list_elem.length;i++) + { + list_elem[i].apply(this); + } + } + + public void caseAElem(AElem node) + { + String name = name(node.getId().getText()); + String nameOfElem; + + if(node.getElemName() != null) + { + nameOfElem = node.getElemName().getText(); + } + else + { + nameOfElem = node.getId().getText(); + } + + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + if(tokens.get("T" + name) == null) + { + error2(node.getId(), "T" + name); + } + + if(ignTokens.get("T" + name) != null) + { + error3(node.getId(), "T" + name); + } + + elemTypes.put(node, "T" + name); + + if(node.getElemName() != null) + { + altsElemNameTypes.put(currentAlt+"." + node.getElemName().getText(), "T" + name); + } + + String type_name = name; + if(node.getUnOp() instanceof AStarUnOp || node.getUnOp() instanceof AQMarkUnOp) + { + type_name += "?"; + } + altsElemTypes.put(currentAlt+"." + nameOfElem, "T" + type_name); + } + else + { + if(prods.get("P" + name) == null) + { + error2(node.getId(), "P" + name); + } + + elemTypes.put(node, "P" + name); + + if(node.getElemName() != null) + { + altsElemNameTypes.put(currentAlt+"." + node.getElemName().getText(), "P" + name); + } + //altsElemTypes.put(currentAlt+"." + nameOfElem, "P" + name); + String type_name = name; + if(node.getUnOp() instanceof AStarUnOp || node.getUnOp() instanceof AQMarkUnOp) + { + type_name += "?"; + } + altsElemTypes.put(currentAlt+"." + nameOfElem, "P" + type_name); + } + } + else + { + Object token = tokens.get("T" + name); + Object ignToken = ignTokens.get("T" + name); + Object production = prods.get("P" + name); + + if((token == null) && (production == null)) + { + error2(node.getId(), "P" + name + " and T" + name); + } + + if(token != null) + { + if(production != null) + { + error4(node.getId(), "P" + name + " and T" + name); + } + + if(ignToken != null) + { + error3(node.getId(), "T" + name); + } + + elemTypes.put(node, "T" + name); + + if(node.getElemName() != null) + { + altsElemNameTypes.put(currentAlt+"." + node.getElemName().getText(), "T" + name); + } + String type_name = name; + if(node.getUnOp() instanceof AStarUnOp || node.getUnOp() instanceof AQMarkUnOp) + { + type_name += "?"; + } + altsElemTypes.put(currentAlt+"." + nameOfElem, "T" + type_name); + } + else + { + elemTypes.put(node, "P" + name); + + if(node.getElemName() != null) + { + altsElemNameTypes.put(currentAlt+"." + node.getElemName().getText(), "P" + name); + } + String type_name = name; + if(node.getUnOp() instanceof AStarUnOp || node.getUnOp() instanceof AQMarkUnOp) + { + type_name += "?"; + } + altsElemTypes.put(currentAlt+"." + nameOfElem, "P" + type_name); + } + } + } + } + ); + } + + public static String name(String s) + { + StringBuffer result = new StringBuffer(); + boolean upcase = true; + int length = s.length(); + char c; + + for(int i = 0; i < length; i++) + { + c = s.charAt(i); + switch(c) + { + case '_': + upcase = true; + break; + case '$': + result.append(c); + upcase = true; + break; + default: + if(upcase) + { + result.append(Character.toUpperCase(c)); + upcase = false; + } + else + { + result.append(c); + } + break; + } + } + + return result.toString(); + } + + public static String errorName(String s) + { + StringBuffer result = new StringBuffer(); + int length = s.length(); + char c; + + for(int i = 0; i < length; i++) + { + c = s.charAt(i); + switch(c) + { + case '_': + { + result.append(' '); + } + break; + default: + { + result.append(c); + } + break; + } + } + + return result.toString(); + } + + public void reinit() + { + names.clear(); + elemTypes.clear(); + } + + private static void error(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "Redefinition of " + name + "."); + } + + private void error(String name) + { + throw new RuntimeException( + "[" + lastLine + "," + lastPos + "] " + + "Redefinition of " + name + "."); + } + + private static void error2(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + name + " undefined."); + } + + private static void error3(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + name + " is ignored."); + } + + private static void error4(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "ambiguous " + name + "."); + } + + private static void error5(Token token) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "class is an invalid element name."); + } + + public String toString() + { + StringBuffer s = new StringBuffer(); + String nl = System.getProperty("line.separator"); + + s.append("Helpers:"); + s.append(nl); + s.append(helpers); + s.append(nl); + + s.append("States:"); + s.append(nl); + s.append(states); + s.append(nl); + + s.append("Tokens:"); + s.append(nl); + s.append(tokens); + s.append(nl); + + s.append("Ignored Tokens:"); + s.append(nl); + s.append(ignTokens); + s.append(nl); + + s.append("Productions:"); + s.append(nl); + s.append(prods); + s.append(nl); + + s.append("Alternatives:"); + s.append(nl); + s.append(alts); + s.append(nl); + + s.append("Elements:"); + s.append(nl); + s.append(elems); + s.append(nl); + + return s.toString(); + } +} diff --git a/src/main/java/org/sablecc/sablecc/ResolveProdTransformIds.java b/src/main/java/org/sablecc/sablecc/ResolveProdTransformIds.java new file mode 100644 index 0000000..ab242d1 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ResolveProdTransformIds.java @@ -0,0 +1,357 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +/* + * ResolveProdTransformIds + * + * This class computes semantic verifications for production transformations + * in Production section. It makes sure that all transformations specified + * for a production(prod {-> prod_transform1 prod_transform2 prod_transform3...}) + * are defined as production in the section Abstract Syntax Tree. + */ + +public class ResolveProdTransformIds extends DepthFirstAdapter +{ + private ResolveAstIds transformIds; + + private LinkedList listElems; + + private String prod_name; + + public LinkedList listProdTransformList = new LinkedList(); + private LinkedList listProdTransformContainsList; + + //Map of production transformation element type. The key of this map + //is the node of this element in the AST. + public final Map prodTransformElemTypes = new TypedHashMap( + NoCast.instance, + StringCast.instance); + + //This map contains the same information as the other one just above. + //But the keys for this map are String ("ProdName.ElemTransformationName") + public final Map prodTransformElemTypesString = new TypedHashMap( + StringCast.instance, + StringCast.instance); + + //Map of Productions which transformations contains list elements. + public Map mapProdTransformContainsList = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + ListCast.instance); + + //Map of all Production transformations elements. + public final Map prod_transforms = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + NoCast.instance); + + public ResolveProdTransformIds(ResolveAstIds ids) + { + transformIds = ids; + } + + public void caseAProd(final AProd production) + { + prod_name = (String)transformIds.astIds.names.get(production); + + AElem temp[] = + (AElem [])production.getProdTransform().toArray(new AElem[0]); + + listProdTransformContainsList = new LinkedList(); + + listElems = new LinkedList(); + + if( temp.length > 1 ) + { + listProdTransformList.add(prod_name); + } + + for(int i=0; i<temp.length; i++) + { + ((PElem) temp[i]).apply(new DepthFirstAdapter() + { + public void caseAElem(AElem node) + { + String rname = node.getId().getText(); + String name = ResolveIds.name(rname); + String elemName = null; + + if(node.getElemName() != null) + { + elemName = node.getElemName().getText(); + if( listElems.contains(elemName) ) + { + error(node.getElemName(), elemName); + } + listElems.add(elemName); + } + else + { + if(listElems.contains(rname)) + { + error(node.getId(), rname); + } + + listElems.add(rname); + } + + if( (node.getUnOp() != null) && + ( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof APlusUnOp) ) ) + { + + listProdTransformList.add(prod_name); + + if(node.getElemName() != null) + { + listProdTransformContainsList.add(elemName); + } + else + { + listProdTransformContainsList.add(node.getId().getText()); + } + } + + if(node.getSpecifier() != null) + { + if(node.getSpecifier() instanceof ATokenSpecifier) + { + if(transformIds.astIds.tokens.get("T" + name) == null) + { + error2(node.getId(), "T" + name); + } + + if(transformIds.astIds.ignTokens.get("T" + name) != null) + { + error3(node.getId(), "T" + name); + } + + /*****************************************************/ + String type_name = name; + if( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof AQMarkUnOp) ) + { + type_name += "?"; + } + + if( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof APlusUnOp) ) + { + prodTransformElemTypes.put(node, "LT" + type_name); + if(elemName != null) + { + prodTransformElemTypesString.put(prod_name+"."+elemName, "LT" + type_name); + } + else + { + prodTransformElemTypesString.put(prod_name+"."+rname, "LT" + type_name); + } + } + else + { + prodTransformElemTypes.put(node, "T" + type_name); + if(elemName != null) + { + prodTransformElemTypesString.put(prod_name+"."+elemName, "T" + type_name); + } + else + { + prodTransformElemTypesString.put(prod_name+"."+rname, "T" + type_name); + } + } + } + else + { + if(transformIds.ast_prods.get("P" + name) == null) + { + error5(node.getId(), "P" + name); + } + + /*****************************************************/ + String type_name = name; + if( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof AQMarkUnOp) ) + { + type_name += "?"; + } + + if( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof APlusUnOp) ) + { + prodTransformElemTypes.put(node, "LP" + type_name); + if(elemName != null) + { + prodTransformElemTypesString.put(prod_name+"."+elemName, "LP" + type_name); + } + else + { + prodTransformElemTypesString.put(prod_name+"."+rname, "LP" + type_name); + } + } + else + { + prodTransformElemTypes.put(node, "P" + type_name); + if(elemName != null) + { + prodTransformElemTypesString.put(prod_name+"."+elemName, "P" + type_name); + } + else + { + prodTransformElemTypesString.put(prod_name+"."+rname, "P" + type_name); + } + } + } + } + else + { + Object token = transformIds.astIds.tokens.get("T" + name); + Object ignToken = transformIds.astIds.ignTokens.get("T" + name); + Object production = transformIds.astIds.prods.get("P" + name); + Object ast_production = transformIds.ast_prods.get("P" + name); + + if((token == null) && (ast_production == null) && (production == null)) + { + error2(node.getId(), "P" + name + " and T" + name ); + } + + //it seems to be a token + if(token != null) + { + boolean bast_production = false; + //if it's also a ast_production + if(ast_production != null) + { + error4(node.getId(), "P" + name + " and T" + name); + } + + /*****************************************************/ + String type_name = name; + if( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof AQMarkUnOp) ) + { + type_name += "?"; + } + + if( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof APlusUnOp) ) + { + prodTransformElemTypes.put(node, "LT" + type_name); + if(elemName != null) + { + prodTransformElemTypesString.put(prod_name+"."+elemName, "LT" + type_name); + } + else + { + prodTransformElemTypesString.put(prod_name+"."+rname, "LT" + type_name); + } + } + else + { + prodTransformElemTypes.put(node, "T" + type_name); + if(elemName != null) + { + prodTransformElemTypesString.put(prod_name+"."+elemName, "T" + type_name); + } + else + { + prodTransformElemTypesString.put(prod_name+"."+rname, "T" + type_name); + } + } + } + // The element is supposed to be a Production in section AST + else + { + if(ast_production == null) + { + error5(node.getId(), node.getId().getText()); + } + + /*****************************************************/ + String type_name = name; + if( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof AQMarkUnOp) ) + { + type_name += "?"; + } + + if( (node.getUnOp() instanceof AStarUnOp) || + (node.getUnOp() instanceof APlusUnOp) ) + { + prodTransformElemTypes.put(node, "LP" + type_name); + if(elemName != null) + { + prodTransformElemTypesString.put(prod_name+"."+elemName, "LP" + type_name); + } + else + { + prodTransformElemTypesString.put(prod_name+"."+rname, "LP" + type_name); + } + } + else + { + prodTransformElemTypes.put(node, "P" + type_name); + if(elemName != null) + { + prodTransformElemTypesString.put(prod_name+"."+elemName, "P" + type_name); + } + else + { + prodTransformElemTypesString.put(prod_name+"."+rname, "P" + type_name); + } + } + } + } + } + } + ); + } + prod_transforms.put(prod_name, listElems); + mapProdTransformContainsList.put(prod_name, listProdTransformContainsList); + } + + private static void error(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "Redefinition of " + name + "."); + } + + private static void error2(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + name + " undefined."); + } + + private static void error3(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + name + " is ignored."); + } + + private static void error4(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "ambiguous " + name + "."); + } + + private static void error5(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + name+ " must be a production defined in section AST."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/ResolveTransformIds.java b/src/main/java/org/sablecc/sablecc/ResolveTransformIds.java new file mode 100644 index 0000000..d7089fc --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/ResolveTransformIds.java @@ -0,0 +1,1094 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Last Modification date 17-11-2003 + * Addition of type checking for operators + */ +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; +import java.io.*; + +/* + * ResolveTransformIds + * + * This class computes semantic verifications for alternative transformations + * in Production section. It makes sure that all transformations specified + * for an alternative match with their corresponding prod_transform but also + * the alternative transformation is itself correct. + */ + +public class ResolveTransformIds extends DepthFirstAdapter +{ + + private ResolveAstIds transformIds; + private ResolveAltIds altIds; + private ResolveProdTransformIds prodTransformIds; + + private int nbTransformAlt = 0; + private int nbTransformProd = 0; + private String currentAstAlt; + private String currentAstProd; + private String currentProd; + private String currentAlt; + private String currentAstProdName; + + //This Map contains the type of any term of alternative transformation(altTransform) + public final Map altTransformElemTypes = new TypedHashMap( + NodeCast.instance, + StringCast.instance); + + public final Map mapSimpleTermProdTransformation = new TypedHashMap( + StringCast.instance, + ListCast.instance); + + public final Map simpleTermOrsimpleListTermTypes = new TypedHashMap( + NodeCast.instance, + StringCast.instance); + + public ResolveTransformIds(ResolveAstIds ast_ids, ResolveAltIds alt_ids, ResolveProdTransformIds p_ids) + { + transformIds = ast_ids; + altIds = alt_ids; + prodTransformIds = p_ids; + } + + public ResolveProdTransformIds getProdTransformIds() + { + return prodTransformIds; + } + + public void inAProd(final AProd production) + { + nbTransformProd = 0; + currentProd = (String)altIds.ids.names.get(production); + + if(production.getArrow() != null) + { + nbTransformProd = production.getProdTransform().size(); + } + } + + private LinkedList listCurrentAltGlobal; + private LinkedList listCurrentAlt; + private LinkedList listOfListCurrentAlt; + + public void inAAlt(AAlt nodeAlt) + { + nbTransformAlt = 0; + + currentAlt = (String)altIds.ids.names.get(nodeAlt); + listCurrentAltGlobal = (LinkedList)((LinkedList)altIds.alts_elemsGlobal.get(currentAlt)).clone(); + listCurrentAlt = (LinkedList)((LinkedList)altIds.alts_elems.get(currentAlt)).clone(); + listOfListCurrentAlt = (LinkedList)((LinkedList)altIds.alts_elems_list.get(currentAlt)).clone(); + } + + public void inAAltTransform(AAltTransform node) + { + if(node.getTerms().size() == 0) + { + altTransformElemTypes.put(node, "nothing"); + } + else + { + nbTransformAlt = node.getTerms().size(); + } + } + + public void outAAltTransform(AAltTransform node) + { + if(nbTransformAlt != nbTransformProd) + { + error2( node.getRBrace() ); + } + } + + public void outAAlt(AAlt node) + { + lastSimpleTerm = null; + + listCurrentAltGlobal = null; + listCurrentAlt = null; + listOfListCurrentAlt = null; + mapSimpleTermProdTransformation.clear(); + } + + public void outANewTerm(ANewTerm node) + { + LinkedList list = (LinkedList)prodTransformIds.prod_transforms.get(currentProd); + AProdName prodNameNode = (AProdName)node.getProdName(); + + currentAstProd = "P" + ResolveIds.name(prodNameNode.getId().getText()); + currentAstProdName = prodNameNode.getId().getText(); + + if(prodNameNode.getProdNameTail() != null) + { + TId prodNameTailNode = prodNameNode.getProdNameTail(); + currentAstAlt = "A" + ResolveIds.name(prodNameTailNode.getText()) + ResolveIds.name(prodNameNode.getId().getText()); + } + else + { + currentAstAlt = "A" + ResolveIds.name(prodNameNode.getId().getText()); + } + + String currentAstProdName_no_specifier; + if(currentAstProdName.startsWith("P.")) + { + currentAstProdName_no_specifier = currentAstProdName.substring(2); + } + else + { + currentAstProdName_no_specifier = currentAstProdName; + } + + if(transformIds.ast_prods.get(currentAstProd) == null) + { + error7(((AProdName)node.getProdName()).getId(), ((AProdName)node.getProdName()).getId().getText()); + } + + if(transformIds.ast_alts.get(currentAstAlt) == null) + { + error6( ((AProdName)node.getProdName()).getId(), currentAstAlt); + } + + int sizeNewTerm = 0; + if(node.getParams().size() > 0) + { + sizeNewTerm = node.getParams().size(); + } + + int sizeAstAlt = 0; + if( ((AAstAlt)transformIds.ast_alts.get(currentAstAlt) ).getElems() != null) + { + sizeAstAlt = ( (LinkedList)((AAstAlt)transformIds.ast_alts.get(currentAstAlt) ).getElems()).size(); + } + + if(sizeNewTerm != sizeAstAlt) + { + error8( ((AProdName)node.getProdName()).getId(), currentAstAlt); + } + + AProdName aProdName = (AProdName)node.getProdName(); + + String type = "P" + ResolveIds.name(aProdName.getId().getText()); + + altTransformElemTypes.put(node, type); + + AAstAlt astAlt = (AAstAlt)transformIds.ast_alts.get(currentAstAlt); + + if(node.getParams().size() > 0 && astAlt.getElems().size() > 0) + { + Object elemsTable[] = astAlt.getElems().toArray(); + Object paramsTable[] = node.getParams().toArray(); + + String termType, elemType; + + //here, we're checking the type compabitlity between for a new node creation + for(int j=0; j<elemsTable.length; j++) + { + termType = (String)altTransformElemTypes.get(paramsTable[j]); + elemType = (String)transformIds.ast_elemTypes.get(elemsTable[j]); + + PUnOp eventual_ast_alt_elemOperator = ((AElem)elemsTable[j]).getUnOp(); + + checkTypeCompability(elemType, termType, eventual_ast_alt_elemOperator, node.getLPar()); + /* + if( !checkTypeCompabilityWithStar(elemType, termType, eventual_ast_alt_elemOperator) ) + { + error10(node.getLPar(), elemType, termType); + } + */ + } + } + + } + + public void outANewListTerm(ANewListTerm node) + { + LinkedList list = (LinkedList)prodTransformIds.prod_transforms.get(currentProd); + AProdName prodNameNode = (AProdName)node.getProdName(); + + currentAstProdName = prodNameNode.getId().getText(); + currentAstProd = "P" + ResolveIds.name(currentAstProdName); + + if(prodNameNode.getProdNameTail() != null) + { + TId prodNameTailNode = prodNameNode.getProdNameTail(); + currentAstAlt = "A" + ResolveIds.name(prodNameTailNode.getText()) + ResolveIds.name(prodNameNode.getId().getText()); + } + else + { + currentAstAlt = "A" + ResolveIds.name(prodNameNode.getId().getText()); + } + + String currentAstProdName_no_specifier; + if(currentAstProdName.startsWith("P.")) + { + currentAstProdName_no_specifier = currentAstProdName.substring(2); + } + else + { + currentAstProdName_no_specifier = currentAstProdName; + } + + if(transformIds.ast_prods.get(currentAstProd) == null) + { + error7(((AProdName)node.getProdName()).getId(), ((AProdName)node.getProdName()).getId().getText()); + } + + if(transformIds.ast_alts.get(currentAstAlt) == null) + { + error6( ((AProdName)node.getProdName()).getId(), currentAstAlt); + } + + int sizeNewTerm = 0; + if(node.getParams().size() > 0) + { + sizeNewTerm = node.getParams().size(); + } + + int sizeAstAlt = 0; + if( ((AAstAlt)transformIds.ast_alts.get(currentAstAlt) ).getElems() != null) + { + sizeAstAlt = ( (LinkedList)((AAstAlt)transformIds.ast_alts.get(currentAstAlt) ).getElems()).size(); + } + + if(sizeNewTerm != sizeAstAlt) + { + error8( ((AProdName)node.getProdName()).getId(), currentAstAlt); + } + + AProdName aProdName = (AProdName)node.getProdName(); + + String type = "P" + ResolveIds.name(aProdName.getId().getText()); + + altTransformElemTypes.put(node, type); + + AAstAlt astAlt = (AAstAlt)transformIds.ast_alts.get(currentAstAlt); + + if(node.getParams().size() > 0 && astAlt.getElems().size() > 0) + { + Object elemsTable[] = astAlt.getElems().toArray(); + Object paramsTable[] = node.getParams().toArray(); + + String termType, elemType; + + //here, we're checking the type compabitlity between for a new node creation + for(int j=0; j<elemsTable.length; j++) + { + termType = (String)altTransformElemTypes.get(paramsTable[j]); + elemType = (String)transformIds.ast_elemTypes.get(elemsTable[j]); + + PUnOp elemOp = ((AElem)elemsTable[j]).getUnOp(); + + checkTypeCompability(elemType, termType, elemOp, node.getLPar()); + /* + if( !checkTypeCompability(elemType, termType, elemOp) ) + { + error10(node.getLPar(), elemType, termType); + } + */ + + } + } + } + + public void outAListTerm(AListTerm node) + { + if( (node.getListTerms() != null) && (node.getListTerms().size() != 0) ) + { + Object temp[] = node.getListTerms().toArray(); + String firstTermType = (String)altTransformElemTypes.get(temp[0]); + if(firstTermType.endsWith("?")) + { + firstTermType = firstTermType.substring(0, firstTermType.length()-1); + } + + for(int i=1; i<temp.length; i++) + { + String termType = (String)altTransformElemTypes.get(temp[i]); + if(termType.endsWith("?")) + { + termType = termType.substring(0, termType.length()-1); + } + + if(!termType.equals(firstTermType)) + { + error9(node.getLBkt()); + } + } + + if(!firstTermType.startsWith("L")) + { + altTransformElemTypes.put(node, "L" + firstTermType); + } + else + { + altTransformElemTypes.put(node, firstTermType); + } + } + else + { + altTransformElemTypes.put(node, "LNull"); + } + } + + private LinkedList listL; + private LinkedList listP; + private String lastSimpleTerm; + + public void inASimpleTerm(ASimpleTerm node) + { + String name = node.getId().getText(); + String typeOfExplicitElemName = (String)transformIds.astIds.altsElemNameTypes.get( currentAlt+"."+node.getId().getText() ); + String alternativeElemType = (String)transformIds.astIds.altsElemTypes.get( currentAlt+"."+node.getId().getText() ); + + boolean okTermtail = false; + String tmpName = name; + + if( (listCurrentAltGlobal == null) || !listCurrentAltGlobal.contains(name) ) + { + error3(node.getId(), name); + } + else + { + ListIterator iter = null; + iter = listCurrentAltGlobal.listIterator(); + + while(iter.hasNext()) + { + if( name.equals((String)iter.next()) ) + { + if( node.getSimpleTermTail() == null ) + { + iter.remove(); + } + break; + } + } + } + + if( (listCurrentAlt == null) || !listCurrentAlt.contains(name) ) + { + error3(node.getId(), name); + } + else + { + ListIterator iter = null; + iter = listCurrentAlt.listIterator(); + + while(iter.hasNext()) + { + if( name.equals((String)iter.next()) ) + { + if( node.getSimpleTermTail() == null ) + { + iter.remove(); + } + break; + } + } + } + + int position = 0; + + String type; + + if(alternativeElemType.startsWith("T")) + { + if(node.getSimpleTermTail() != null) + { + error4(node.getId()); + } + + altTransformElemTypes.put(node, alternativeElemType); + position = 0; + } + //The element is a production + else + { + listL = null; + + name = "P" + ResolveIds.name(node.getId().getText()); + + if(!name.equals(lastSimpleTerm) ) + { + if(typeOfExplicitElemName != null) + { + if( mapSimpleTermProdTransformation.get(currentAlt+"."+tmpName) == null) + { + if(prodTransformIds.prod_transforms.get(typeOfExplicitElemName) != null) + { + listL = (LinkedList)((LinkedList)prodTransformIds.prod_transforms.get(typeOfExplicitElemName)).clone(); + mapSimpleTermProdTransformation.put(currentAlt+"."+tmpName, listL); + } + } + else + { + listL = (LinkedList)mapSimpleTermProdTransformation.get(currentAlt+"."+tmpName); + } + } + if( mapSimpleTermProdTransformation.get(currentAlt+".P"+tmpName) == null ) + { + listP = (LinkedList)prodTransformIds.prod_transforms.get(name); + if(prodTransformIds.prod_transforms.get(name) != null) + { + listP = (LinkedList)((LinkedList)prodTransformIds.prod_transforms.get(name)).clone(); + mapSimpleTermProdTransformation.put(currentAlt+".P"+tmpName, listP); + } + } + else + { + listP = (LinkedList)mapSimpleTermProdTransformation.get(currentAlt+".P"+tmpName); + } + + listCurrentAlt.remove(lastSimpleTerm); + } + + boolean blistL = false; + + if( ( (typeOfExplicitElemName != null) && (listL!= null) && (listL.size()==1) && ResolveIds.name((String)listL.getFirst()).equals(typeOfExplicitElemName.substring(1)) ) || + ( (typeOfExplicitElemName == null) && (listP!= null) && (listP.size()==1) && listP.contains(node.getId().getText()) ) ) + { + blistL = true; + } + + //the production is transformed but it appears without a term tail. + if( (node.getSimpleTermTail() == null) && + ( (listL != null) || (listP != null) ) && !blistL ) + { + if(typeOfExplicitElemName != null) + { + error1(node.getId(), typeOfExplicitElemName); + } + else + { + error1(node.getId(), node.getId().getText()); + } + } + + //simpletermtail doesn't appear in the production transformation + if( node.getSimpleTermTail() != null ) + { + okTermtail = true; + String strTermTail = node.getSimpleTermTail().getText(); + + if( ( (listL == null) || !listL.contains(strTermTail) ) && + ( (listP == null) || !listP.contains(strTermTail) ) ) + { + error5(node.getId(), node.getId().getText(), strTermTail); + } + else + { + ListIterator iter = null; + + if(listL != null) + { + iter = listL.listIterator(); + + position = listL.indexOf(strTermTail); + + while(iter.hasNext()) + { + if( strTermTail.equals((String)iter.next()) ) + { + iter.remove(); + break; + } + } + } + + if(listP != null) + { + iter = listP.listIterator(); + + position = listP.indexOf(strTermTail); + + while(iter.hasNext()) + { + if( strTermTail.equals((String)iter.next()) ) + { + iter.remove(); + break; + } + } + } + + } + } + + if(node.getSimpleTermTail() != null) + { + String termtail = node.getSimpleTermTail().getText(); + LinkedList listProdContains = null; + if(typeOfExplicitElemName != null) + { + listProdContains = (LinkedList)prodTransformIds.mapProdTransformContainsList.get(typeOfExplicitElemName); + } + else + { + listProdContains = (LinkedList)prodTransformIds.mapProdTransformContainsList.get("P" + ResolveIds.name(node.getId().getText())); + } + } + //The Type of the element without his eventual termtail (term.termtail :: (type of term)) + if(typeOfExplicitElemName != null) + { + simpleTermOrsimpleListTermTypes.put(node, typeOfExplicitElemName); + } + else + { + simpleTermOrsimpleListTermTypes.put(node, "P" + ResolveIds.name(node.getId().getText())); + } + + if(node.getSimpleTermTail() == null) + { + altTransformElemTypes.put(node, alternativeElemType); + position = 0; + } + else + { + String termTail = node.getSimpleTermTail().getText(); + //This boolean is used to ensures that optional operator is properly propagate. + boolean qmark_op = false; + if(alternativeElemType.endsWith("?")) + { + alternativeElemType = alternativeElemType.substring(0, alternativeElemType.length()-1); + qmark_op = true; + } + String typeOfTerm = (String)prodTransformIds.prodTransformElemTypesString.get(alternativeElemType+"."+termTail); + + // The substring is done because we want to ensures that lists term should be wrapped by square brackets + if(typeOfTerm.startsWith("L")) + { + typeOfTerm = typeOfTerm.substring(1); + } + if(qmark_op && !typeOfTerm.endsWith("?")) + { + typeOfTerm += "?"; + } + altTransformElemTypes.put(node, typeOfTerm); + } + } + } + + public void caseANullTerm(ANullTerm node) + { + altTransformElemTypes.put(node, "Null"); + } + + public void inASimpleListTerm(ASimpleListTerm node) + { + String name = node.getId().getText(); + String typeOfExplicitElemName = (String)transformIds.astIds.altsElemNameTypes.get( currentAlt+"."+node.getId().getText() ); + String alternativeElemType = (String)transformIds.astIds.altsElemTypes.get( currentAlt+"."+node.getId().getText() ); + String strTermTail; + String tmpName = name; + + if( (listCurrentAltGlobal == null) || !listCurrentAltGlobal.contains(name) ) + { + error3(node.getId(), name); + } + else + { + ListIterator iter = null; + iter = listCurrentAltGlobal.listIterator(); + + while(iter.hasNext()) + { + if( name.equals((String)iter.next()) ) + { + if( node.getSimpleTermTail() == null ) + { + iter.remove(); + } + break; + } + } + } + + if( ((listCurrentAlt == null) || !listCurrentAlt.contains(name)) && ((listOfListCurrentAlt == null) || !listOfListCurrentAlt.contains(name)) ) + { + error3(node.getId(), name); + } + else + { + ListIterator iter = null; + if( (listCurrentAlt != null) && listCurrentAlt.contains(name) ) + { + iter = listCurrentAlt.listIterator(); + } + else if( (listOfListCurrentAlt != null) && listOfListCurrentAlt.contains(name) ) + { + iter = listOfListCurrentAlt.listIterator(); + } + + while(iter.hasNext()) + { + if( name.equals((String)iter.next()) ) + { + if( node.getSimpleTermTail() == null ) + { + iter.remove(); + } + break; + } + } + } + + int position = 0; + + String type; + if(alternativeElemType.startsWith("T")) + { + //A token can't have term tail + if(node.getSimpleTermTail() != null) + { + error4(node.getId()); + } + + altTransformElemTypes.put(node, alternativeElemType); + position = 0; + } + //it seems to be a production without a specifier + else + { + name = "P" + ResolveIds.name(node.getId().getText()); + + if(!name.equals(lastSimpleTerm) ) + { + if(typeOfExplicitElemName != null) + { + if( mapSimpleTermProdTransformation.get(currentAlt+"."+tmpName) == null) + { + if(prodTransformIds.prod_transforms.get(typeOfExplicitElemName) != null) + { + listL = (LinkedList)((LinkedList)prodTransformIds.prod_transforms.get(typeOfExplicitElemName)).clone(); + mapSimpleTermProdTransformation.put(currentAlt+"."+tmpName, listL); + } + } + else + { + listL = (LinkedList)mapSimpleTermProdTransformation.get(currentAlt+"."+tmpName); + } + } + if( mapSimpleTermProdTransformation.get(currentAlt+".P"+tmpName) == null ) + { + listP = (LinkedList)prodTransformIds.prod_transforms.get(name); + if(prodTransformIds.prod_transforms.get(name) != null) + { + listP = (LinkedList)((LinkedList)prodTransformIds.prod_transforms.get(name)).clone(); + mapSimpleTermProdTransformation.put(currentAlt+".P"+tmpName, listP); + } + } + else + { + listP = (LinkedList)mapSimpleTermProdTransformation.get(currentAlt+".P"+tmpName); + } + + listCurrentAlt.remove(lastSimpleTerm); + } + + boolean blistL = false; + + if( ( (typeOfExplicitElemName != null) && (listL!= null) && (listL.size()==1) && ResolveIds.name((String)listL.getFirst()).equals(typeOfExplicitElemName.substring(1)) ) || + ( (typeOfExplicitElemName == null) && (listP!= null) && (listP.size()==1) && listP.contains(node.getId().getText()) ) ) + { + blistL = true; + } + + //the production is transformed but it appears without a term tail. + if( (node.getSimpleTermTail() == null) && + ( (listL != null) || (listP != null) ) && !blistL ) + { + if(typeOfExplicitElemName != null) + { + error1(node.getId(), typeOfExplicitElemName); + } + else + { + error1(node.getId(), node.getId().getText()); + } + } + + //the production is not transformed but it appears with a term tail. + if(node.getSimpleTermTail() != null) + { + strTermTail = node.getSimpleTermTail().getText(); + + if( ( (listL == null) || !listL.contains(strTermTail) ) && + ( (listP == null) || !listP.contains(strTermTail) ) ) + { + error5(node.getId(), node.getId().getText(), node.getSimpleTermTail().getText() ); + } + else + { + ListIterator iter = null; + + if(listL != null) + { + iter = listL.listIterator(); + + position = listL.indexOf(strTermTail); + + while(iter.hasNext()) + { + if( strTermTail.equals((String)iter.next()) ) + { + iter.remove(); + break; + } + } + } + + if(listP != null) + { + iter = listP.listIterator(); + + position = listP.indexOf(strTermTail); + + while(iter.hasNext()) + { + if( strTermTail.equals((String)iter.next()) ) + { + iter.remove(); + break; + } + } + } + } + } + + if(node.getSimpleTermTail() != null) + { + String termtail = node.getSimpleTermTail().getText(); + LinkedList listProdContains = null; + LinkedList prodContains = null; + if(typeOfExplicitElemName != null) + { + listProdContains = (LinkedList)prodTransformIds.mapProdTransformContainsList.get(typeOfExplicitElemName); + prodContains = (LinkedList)prodTransformIds.prod_transforms.get(typeOfExplicitElemName); + } + else + { + listProdContains = (LinkedList)prodTransformIds.mapProdTransformContainsList.get("P" + ResolveIds.name(node.getId().getText())); + prodContains = (LinkedList)prodTransformIds.prod_transforms.get("P" + ResolveIds.name(node.getId().getText())); + } + + LinkedList lst = (LinkedList)altIds.alts_elems_list.get(currentAlt); + } + + //The Type of the element without his eventual termtail (term.termtail :: (type of term)) + + if(typeOfExplicitElemName != null) + { + simpleTermOrsimpleListTermTypes.put(node, typeOfExplicitElemName); + } + else + { + simpleTermOrsimpleListTermTypes.put(node, "P" + ResolveIds.name(node.getId().getText())); + } + + if(node.getSimpleTermTail() == null) + { + altTransformElemTypes.put(node, alternativeElemType); + position = 0; + } + else + { + String termTail = node.getSimpleTermTail().getText(); + //This boolean is used to ensures that optional operator is properly propagate. + boolean qmark_op = false; + if(alternativeElemType.endsWith("?")) + { + alternativeElemType = alternativeElemType.substring(0, alternativeElemType.length()-1); + qmark_op = true; + } + String typeOfTerm = (String)prodTransformIds.prodTransformElemTypesString.get(alternativeElemType+"."+termTail); + + // The substring is done because we want to ensures that lists term should be wrapped by square brackets + if(typeOfTerm.startsWith("L")) + { + typeOfTerm = typeOfTerm.substring(1); + } + if(qmark_op && !typeOfTerm.endsWith("?")) + { + typeOfTerm += "?"; + } + altTransformElemTypes.put(node, typeOfTerm); + } + } + } + + private Object curr_prodTransformElems[]; + private boolean curr_prod_has_prodTransform; + private boolean firstProduction = false; + + public void outAProductions(AProductions node) + { + LinkedList list = node.getProds(); + AProd prod = (AProd)list.getFirst(); + firstProduction = true; + + if( prodTransformIds.listProdTransformList.contains("P"+ ResolveIds.name( prod.getId().getText()) ) ) + { + error_0(prod.getId()); + } + + Object temp[] = node.getProds().toArray(); + for(int i = 0; i < temp.length; i++) + { + + ((PProd) temp[i]).apply(new DepthFirstAdapter() + { + public void inAProd(AProd production) + { + LinkedList prodTransform = production.getProdTransform(); + String prodTransformElemType = ""; + curr_prodTransformElems = null; + curr_prod_has_prodTransform = false; + + if(production.getArrow() != null && prodTransform.size() >= 1) + { + curr_prod_has_prodTransform = true; + curr_prodTransformElems = prodTransform.toArray(); + prodTransformElemType = (String)prodTransformIds.prodTransformElemTypes.get(curr_prodTransformElems[0]); + } + else if(production.getArrow() == null) + { + curr_prod_has_prodTransform = false; + String []tab = new String[1]; + tab[0] = "P" + ResolveIds.name(production.getId().getText()); + curr_prodTransformElems = (Object[])tab; + prodTransformElemType = (String)curr_prodTransformElems[0]; + } + else + { + curr_prod_has_prodTransform = false; + String []tab = new String[1]; + tab[0] = "nothing"; + curr_prodTransformElems = (Object[])tab; + prodTransformIds.prodTransformElemTypes.put(prodTransform, "nothing"); + prodTransformElemType = (String)curr_prodTransformElems[0]; + } + + if(firstProduction) + { + if( !prodTransformElemType.equals(transformIds.getFirstAstProduction()) ) + { + error11(); + } + firstProduction = false; + } + } + + public void inAAltTransform(AAltTransform node) + { + Object curr_altTransformTerms[] = node.getTerms().toArray(); + + for(int k = 0; k < curr_altTransformTerms.length; k++) + { + String prodTransformElemType, altTransformTermType; + + if(curr_prod_has_prodTransform) + { + prodTransformElemType = (String)prodTransformIds.prodTransformElemTypes.get(curr_prodTransformElems[k]); + } + else + { + prodTransformElemType = (String)curr_prodTransformElems[k]; + } + altTransformTermType = (String)altTransformElemTypes.get(curr_altTransformTerms[k]); + + PUnOp elemOp = ((AElem)curr_prodTransformElems[k]).getUnOp(); + + checkTypeCompability(prodTransformElemType, altTransformTermType, elemOp, node.getLBrace()); + /* + if( !checkTypeCompability(prodTransformElemType, altTransformTermType, elemOp) ) + { + error10(node.getLBrace(), prodTransformElemType, altTransformTermType); + } + */ + + } + + if(curr_altTransformTerms.length == 0) + { + String prodTransformElemType = (String)curr_prodTransformElems[0]; + String altTransformTermType = (String)altTransformElemTypes.get(node); + if(!prodTransformElemType.equals(altTransformTermType)) + { + error10(node.getLBrace(), prodTransformElemType, altTransformTermType); + } + } + } + + } + ); + } + } + + private void checkTypeCompability(String elemType, String termType, PUnOp elemOp, Token token) + { + if( elemOp != null ) + { + if( elemOp instanceof AStarUnOp) + { + if(!elemType.startsWith("L") ) + { + elemType = "L" + elemType; + } + if(!elemType.endsWith("?")) + { + elemType = elemType + "?"; + } + } + else if( elemOp instanceof APlusUnOp) + { + if(!elemType.startsWith("L")) + { + elemType = "L" + elemType; + } + } + else + { + if(!elemType.endsWith("?")) + { + elemType = elemType + "?"; + } + } + } + boolean result; + if(!elemType.endsWith("?")) + { + result = termType.equals(elemType); + } + //elemType ends with a ? + else + { + //the elem type is a list. (elem type is the excpecting type) + if(elemType.startsWith("L")) + { + result = termType.equals(elemType) || + termType.equals(elemType.substring(0, elemType.length()-1)) || + termType.equals("LNull") ; + } + else + { + result = termType.equals(elemType) || + termType.equals(elemType.substring(0, elemType.length()-1)) || + termType.equals("Null") ; + } + } + if(!result) + { + error10(token, elemType, termType); + } + } + + private static void error1(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "production " + name + " was transformed, and may not appear here undecorated."); + } + + private void error2(Token token) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "this alternative transformation is incorrect because the number of "+ + " production transformations and alternatives don't match" ); + } + + private static void error3(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + name + " must be one of the elements on the left side of the arrow "+ + " or is already refered to in this alternative" ); + } + + private static void error4(Token token) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "tokens are never transformed. This syntax is incorrect"); + } + + private static void error5(Token token, String prod_name, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "production " + prod_name + " was never transformed to "+name+ + " or #"+name+"# cannot be refered by #" + prod_name + "# twice in the same alternative"); + } + + private static void error6(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "alternative "+ name +" doesn't exist in section AST"); + } + + private static void error7(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "Production "+ name + " doesn't exist in section AST"); + } + + private static void error8(Token token, String name) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "The number of parameters request for this alternative in "+ + "section AST doesn't match"); + } + + private static void error9(Token token) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "All the elements within a list must have the same type"); + } + + private static void error10(Token token, String prodName, String altName) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "expecting #" + prodName + "# when #" + altName + "# was found"); + } + + private static void error11() + { + throw new RuntimeException( + "The first production transformation must refered to the first production in section AST" + ); + } + + private static void error_0(Token token) + { + throw new RuntimeException( + "[" + token.getLine() + "," + token.getPos() + "] " + + "The first production's transformation must be only one elements without an operator."); + } + + public String toString() + { + StringBuffer s = new StringBuffer(); + String nl = System.getProperty("line.separator"); + + s.append("ast_elems"); + s.append(nl); + s.append(nl); + + return s.toString(); + } +} diff --git a/src/main/java/org/sablecc/sablecc/SableCC.java b/src/main/java/org/sablecc/sablecc/SableCC.java new file mode 100644 index 0000000..235a92e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/SableCC.java @@ -0,0 +1,366 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.io.*; +import java.awt.*; +import java.util.*; +import org.sablecc.sablecc.node.*; +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.lexer.*; +import org.sablecc.sablecc.parser.*; +import java.util.Vector; + +public class SableCC { + private static boolean processInlining = true; + static int inliningMaxAlts = 20; + private static boolean prettyPrinting = false; + + private static final String OPT_LICENSE = "--license"; + private static final String OPT_D = "-d"; + private static final String OPT_NO_INLINE = "--no-inline"; + private static final String OPT_INLINE_MAX_ALTS = "--inline-max-alts"; + private static final String OPT_PRETTY_PRINT = "--pretty-print"; + + private static void displayCopyright() { + System.out.println(); + System.out.println("SableCC version " + Version.VERSION + + " HHU Version"); + System.out + .println("Copyright (C) 1997-2003 Etienne M. Gagnon <etienne.gagnon@uqam.ca> and"); + System.out.println("others. All rights reserved."); + System.out.println(); + System.out + .println("This software comes with ABSOLUTELY NO WARRANTY. This is free software,"); + System.out + .println("and you are welcome to redistribute it under certain conditions."); + System.out.println(); + System.out.println("Type 'sablecc -license' to view"); + System.out.println("the complete copyright notice and license."); + System.out.println(); + } + + private static void displayUsage() { + System.out.println("Usage:"); + System.out.println(" sablecc [" + OPT_D + " destination] [" + + OPT_NO_INLINE + "] [" + OPT_INLINE_MAX_ALTS + " number] [" + + OPT_PRETTY_PRINT + "] filename [filename]..."); + System.out.println(" sablecc " + OPT_LICENSE); + } + + public static void main(String[] arguments) { + String d_option = null; + Vector filename = new Vector(); + + if (arguments.length == 0) { + displayCopyright(); + displayUsage(); + System.exit(1); + } + + if ((arguments.length == 1) && (arguments[0].equals(OPT_LICENSE))) { + new DisplayLicense(); + System.exit(0); + } + + displayCopyright(); + + { + int arg = 0; + while (arg < arguments.length) { + if (arguments[arg].equals(OPT_D)) { + if ((d_option == null) && (++arg < arguments.length)) { + d_option = arguments[arg]; + } else { + displayUsage(); + System.exit(1); + } + } else if (arguments[arg].equals(OPT_NO_INLINE)) { + processInlining = false; + } + /* + * A production is not inlined if it has more than + * inliningMaxAlts alternatives. The default value is 20. + */ + else if (arguments[arg].equals(OPT_INLINE_MAX_ALTS)) { + try { + inliningMaxAlts = Integer.parseInt(arguments[++arg]); + } catch (Exception e) { + displayUsage(); + System.exit(1); + } + } + /* + * if prettyprint flag is set to true, only the transformed + * grammar is printed on standard output + */ + else if (arguments[arg].equals(OPT_PRETTY_PRINT)) { + prettyPrinting = true; + } else { + filename.addElement(arguments[arg]); + } + arg++; + } + + if (filename.size() == 0) { + displayUsage(); + System.exit(1); + } + } + + /* + * extract additional stups-classes from .jar-file + */ + String generated = "."; + boolean found = false; + for (String p : arguments) { + if (found) { + generated = p; + break; + } + + if ("-d".equals(p)) { + found = true; + } + } + + String patchFolder = generated + "/de/hhu/stups/sablecc/patch"; + String[] patchFiles = { "IParser", "IToken", "ITokenListContainer", + "PositionedNode", "SourcePosition", "SourcePositions", + "SourcecodeRange" }; + + new File(patchFolder).mkdirs(); + + for (String f : patchFiles) { + extractPatchFile(patchFolder, f); + } + + try { + for (int i = 0; i < filename.size(); i++) { + processGrammar((String) filename.elementAt(i), d_option); + } + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + System.exit(0); + } + + private static void extractPatchFile(String patchFolder, String patchFile) { + + ClassLoader loader = SableCC.class.getClassLoader(); + InputStream input = loader.getResourceAsStream("patchfiles/" + + patchFile + ".txt"); + String output = ""; + + String outputFile = patchFolder + "/" + patchFile + ".java"; + try { + output = convertStreamToString(input); + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + + Writer writer = null; + try { + File file = new File(outputFile); + writer = new BufferedWriter(new FileWriter(file)); + writer.write(output); + } catch (FileNotFoundException e) { + e.printStackTrace(); + System.exit(1); + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } finally { + try { + if (writer != null) { + writer.close(); + } + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + } + } + + private static String convertStreamToString(InputStream is) + throws IOException { + /* + * To convert the InputStream to String we use the Reader.read(char[] + * buffer) method. We iterate until the Reader return -1 which means + * there's no more data to read. We use the StringWriter class to + * produce the string. + */ + + if (is != null) { + Writer writer = new StringWriter(); + + char[] buffer = new char[1024]; + try { + Reader reader = new BufferedReader(new InputStreamReader(is, + "UTF-8")); + int n; + while ((n = reader.read(buffer)) != -1) { + writer.write(buffer, 0, n); + } + } finally { + is.close(); + } + return writer.toString(); + } else { + return ""; + } + + } + + /** + * The main method for processing grammar file and generating the + * parser/lexer. + * + * @param grammar + * input grammar file name + * @param destDir + * output directory name + */ + public static void processGrammar(String grammar, String destDir) + throws Exception { + File in; + File dir; + + in = new File(grammar); + in = new File(in.getAbsolutePath()); + + if (destDir == null) { + dir = new File(in.getParent()); + } else { + dir = new File(destDir); + dir = new File(dir.getAbsolutePath()); + } + + processGrammar(in, dir); + } + + /** + * The main method for processing grammar file and generating the + * parser/lexer. + * + * @param in + * input grammar file + * @param dir + * output directory + */ + public static void processGrammar(File in, File dir) throws Exception { + if (!in.exists()) { + System.out.println("ERROR: grammar file " + in.getName() + + " does not exist."); + System.exit(1); + } + if (!dir.exists()) { + System.out.println("ERROR: destination directory " + dir.getName() + + " does not exist."); + System.exit(1); + } + + // re-initialize all static structures in the engine + LR0Collection.reinit(); + Symbol.reinit(); + Production.reinit(); + Grammar.reinit(); + + System.out.println("\n -- Generating parser for " + in.getName() + + " in " + dir.getPath()); + + FileReader temp = new FileReader(in); + + // Build the AST + Start tree = new Parser(new Lexer(new PushbackReader( + temp = new FileReader(in), 1000))).parse(); + + temp.close(); + + boolean hasTransformations = false; + + if (((AGrammar) tree.getPGrammar()).getAst() == null) { + System.out + .println("Adding productions and alternative of section AST."); + // AddAstProductions astProductions = new AddAstProductions(); + tree.apply(new AddAstProductions()); + } else { + hasTransformations = true; + } + + System.out.println("Verifying identifiers."); + ResolveIds ids = new ResolveIds(dir); + tree.apply(ids); + + System.out.println("Verifying ast identifiers."); + ResolveAstIds ast_ids = new ResolveAstIds(ids); + tree.apply(ast_ids); + + System.out + .println("Adding empty productions and empty alternative transformation if necessary."); + tree.apply(new AddEventualEmptyTransformationToProductions(ids, ast_ids)); + + System.out + .println("Adding productions and alternative transformation if necessary."); + AddProdTransformAndAltTransform adds = new AddProdTransformAndAltTransform(); + tree.apply(adds); + /* + * System.out.println( + * "Replacing AST + operator by * and removing ? operator if necessary" + * ); tree.apply( new AstTransformations() ); + */ + System.out.println("computing alternative symbol table identifiers."); + ResolveAltIds alt_ids = new ResolveAltIds(ids); + tree.apply(alt_ids); + + System.out.println("Verifying production transform identifiers."); + ResolveProdTransformIds ptransform_ids = new ResolveProdTransformIds( + ast_ids); + tree.apply(ptransform_ids); + + System.out.println("Verifying ast alternatives transform identifiers."); + ResolveTransformIds transform_ids = new ResolveTransformIds(ast_ids, + alt_ids, ptransform_ids); + tree.apply(transform_ids); + + System.out.println("Generating token classes."); + tree.apply(new GenTokens(ids)); + + System.out.println("Generating production classes."); + tree.apply(new GenProds(ast_ids)); + + System.out.println("Generating alternative classes."); + tree.apply(new GenAlts(ast_ids)); + + System.out.println("Generating analysis classes."); + tree.apply(new GenAnalyses(ast_ids)); + + System.out.println("Generating utility classes."); + tree.apply(new GenUtils(ast_ids)); + + try { + System.out.println("Generating the lexer."); + tree.apply(new GenLexer(ids)); + } catch (Exception e) { + System.out.println(e.getMessage()); + throw e; + } + + try { + System.out.println("Generating the parser."); + tree.apply(new GenParser(ids, alt_ids, transform_ids, ast_ids + .getFirstAstProduction(), processInlining, prettyPrinting, + hasTransformations)); + } catch (Exception e) { + System.out.println(e.getMessage()); + throw e; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/StringCast.java b/src/main/java/org/sablecc/sablecc/StringCast.java new file mode 100644 index 0000000..63c9a86 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/StringCast.java @@ -0,0 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class StringCast implements Cast +{ + public final static StringCast instance = new StringCast(); + + private StringCast() + {} + + public Object cast(Object o) + { + return (String) o; + } +} diff --git a/src/main/java/org/sablecc/sablecc/StringComparator.java b/src/main/java/org/sablecc/sablecc/StringComparator.java new file mode 100644 index 0000000..ab7fb2f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/StringComparator.java @@ -0,0 +1,23 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class StringComparator implements Comparator +{ + public final static StringComparator instance = new StringComparator(); + + private StringComparator() + {} + + public int compare(Object o1, Object o2) + { + return ((String) o1).compareTo((String) o2); + } +} diff --git a/src/main/java/org/sablecc/sablecc/Symbol.java b/src/main/java/org/sablecc/sablecc/Symbol.java new file mode 100644 index 0000000..bc10c42 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/Symbol.java @@ -0,0 +1,151 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import java.util.Vector; + +final class Symbol implements Comparable +{ + private static Vector terminals; + private static Vector nonterminals; + private static TreeMap names; + + private static boolean modified_ = true; + private static Symbol[] symbols_; + private static Symbol[] terminals_; + private static Symbol[] nonterminals_; + + final String name; + final String errorName; + final boolean terminal; + final int index; + + static { + reinit(); + } + + Symbol(String name, String errorName, boolean terminal) + { + if(names.get(name) != null) + { + throw new IllegalArgumentException("The symbol " + name + " aready exists."); + } + + if(terminal) + { + terminals.addElement(this); + this.index = terminals.indexOf(this); + } + else + { + nonterminals.addElement(this); + this.index = nonterminals.indexOf(this); + } + + this.name = name; + this.errorName = errorName; + this.terminal = terminal; + names.put(name, this); + modified_ = true; + } + + public static void reinit() + { + terminals = new Vector(); + nonterminals = new Vector(); + names = new TreeMap(StringComparator.instance); + modified_ = true; + symbols_ = null; + terminals_ = null; + nonterminals_ = null; + } + + static Symbol symbol(String name) + { + return (Symbol) names.get(name); + } + + static Symbol symbol(int index, boolean terminal) + { + if(terminal) + { + return (Symbol) terminals.elementAt(index); + } + else + { + return (Symbol) nonterminals.elementAt(index); + } + } + + private static void computeArrays() + { + symbols_ = new Symbol[terminals.size() + nonterminals.size()]; + terminals_ = new Symbol[terminals.size()]; + nonterminals_ = new Symbol[nonterminals.size()]; + + terminals.copyInto(terminals_); + nonterminals.copyInto(nonterminals_); + System.arraycopy(terminals_, 0, symbols_, 0, terminals_.length); + System.arraycopy(nonterminals_, 0, symbols_, terminals_.length, nonterminals_.length); + + modified_ = false; + } + + static Symbol[] symbols() + { + if(modified_) + { + computeArrays(); + } + + return symbols_; + } + + static Symbol[] terminals() + { + if(modified_) + { + computeArrays(); + } + + return terminals_; + } + + static Symbol[] nonterminals() + { + if(modified_) + { + computeArrays(); + } + + return nonterminals_; + } + + public String toString() + { + return name; + } + + public int compareTo(Object object) + { + Symbol symbol = (Symbol) object; + + if(terminal ^ symbol.terminal) + { + if(terminal) + { + return 1; + } + + return -1; + } + + return index - symbol.index; + } +} diff --git a/src/main/java/org/sablecc/sablecc/SymbolSet.java b/src/main/java/org/sablecc/sablecc/SymbolSet.java new file mode 100644 index 0000000..f46e113 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/SymbolSet.java @@ -0,0 +1,207 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; +import java.util.Vector; + +final class SymbolSet implements Cloneable +{ + private final IntSet terminals; + private final IntSet nonterminals; + private boolean empty; + + private boolean modified = true; + private Symbol[] symbols; + + private void computeArray() + { + Vector symbols = new Vector(0); + + int[] elements = terminals.elements(); + for(int i = 0; i < elements.length; i++) + { + symbols.addElement(Symbol.symbol(elements[i], true)); + } + + elements = nonterminals.elements(); + for(int i = 0; i < elements.length; i++) + { + symbols.addElement(Symbol.symbol(elements[i], false)); + } + + this.symbols = new Symbol[symbols.size()]; + symbols.copyInto(this.symbols); + + modified = false; + } + + SymbolSet() + { + this.terminals = new IntSet(); + this.nonterminals= new IntSet(); + } + + private SymbolSet(SymbolSet set + ) + { + this.terminals = (IntSet) set.terminals.clone(); + this.nonterminals = (IntSet) set.nonterminals.clone(); + this.empty = set.empty; + } + + void setTerminal(int terminal) + { + terminals.set(terminal); + modified = true; + } + + void clearTerminal(int terminal) + { + terminals.clear(terminal); + modified = true; + } + + boolean getTerminal(int terminal) + { + return terminals.get(terminal); + } + + void setNonterminal(int nonterminal) + { + nonterminals.set(nonterminal); + modified = true; + } + + void clearNonterminal(int nonterminal) + { + nonterminals.clear(nonterminal); + modified = true; + } + + boolean getNonterminal(int nonterminal) + { + return nonterminals.get(nonterminal); + } + + void setEmpty() + { + empty = true; + modified = true; + } + + void clearEmpty() + { + empty = false; + modified = true; + } + + boolean getEmpty() + { + return empty; + } + + void and(SymbolSet s) + { + terminals.and(s.terminals); + nonterminals.and(s.nonterminals); + empty &= s.empty; + modified = true; + } + + void or(SymbolSet s) + { + terminals.or(s.terminals); + nonterminals.or(s.nonterminals); + empty |= s.empty; + modified = true; + } + + void xor(SymbolSet s) + { + terminals.xor(s.terminals); + nonterminals.xor(s.nonterminals); + empty ^= s.empty; + modified = true; + } + + public int hashCode() + { + return terminals.hashCode() + nonterminals.hashCode() + new Boolean(empty).hashCode(); + } + + public boolean equals(Object obj) + { + if((obj == null) || + (obj.getClass() != this.getClass())) + { + return false; + } + + SymbolSet s = (SymbolSet) obj; + + return terminals.equals(s.terminals) && + nonterminals.equals(s.nonterminals) && + (empty == s.empty); + } + + Symbol[] getSymbols() + { + if(modified) + { + computeArray(); + } + + return symbols; + } + + public String toString() + { + StringBuffer result = new StringBuffer(); + result.append("{"); + + Symbol[] symbols = getSymbols(); + boolean comma = false; + for(int i = 0; i < symbols.length; i++) + { + if(comma) + { + result.append(","); + } + else + { + comma = true; + } + + result.append(symbols[i]); + } + + if(empty) + { + if(comma) + { + result.append(","); + } + else + { + comma = true; + } + + result.append("*empty*"); + } + + result.append("}"); + + return result.toString(); + } + + public Object clone() + { + return new SymbolSet(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/Transitions.java b/src/main/java/org/sablecc/sablecc/Transitions.java new file mode 100644 index 0000000..817c754 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/Transitions.java @@ -0,0 +1,84 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import org.sablecc.sablecc.analysis.*; +import org.sablecc.sablecc.node.*; +import java.util.*; + +public class Transitions extends DepthFirstAdapter +{ + public final Map tokenStates = new TypedHashMap( + NodeCast.instance, + NoCast.instance); + + private String state; + private String transition; + private Map map; + + public void caseAStateList(AStateList node) + { + inAStateList(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getTransition() != null) + { + node.getTransition().apply(this); + } + + outAStateList(node); // We moved this... + + { + Object temp[] = node.getStateLists().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PStateListTail) temp[i]).apply(this); + } + } + } + + public void inATokenDef(ATokenDef node) + { + map = new TypedTreeMap( + StringComparator.instance, + StringCast.instance, + StringCast.instance); + } + + public void inAStateList(AStateList node) + { + state = transition = node.getId().getText().toUpperCase(); + } + + public void inAStateListTail(AStateListTail node) + { + state = transition = node.getId().getText().toUpperCase(); + } + + public void outATransition(ATransition node) + { + transition = node.getId().getText().toUpperCase(); + } + + public void outAStateList(AStateList node) + { + map.put(state, transition); + } + + public void outAStateListTail(AStateListTail node) + { + map.put(state, transition); + } + + public void outATokenDef(ATokenDef node) + { + tokenStates.put(node, map); + } +} diff --git a/src/main/java/org/sablecc/sablecc/TypedHashMap.java b/src/main/java/org/sablecc/sablecc/TypedHashMap.java new file mode 100644 index 0000000..0a20b3f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/TypedHashMap.java @@ -0,0 +1,175 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class TypedHashMap extends HashMap +{ + private Cast keyCast; + private Cast valueCast; + private Set entries; + + public TypedHashMap() + { + super(); + + keyCast = NoCast.instance; + valueCast = NoCast.instance; + } + + public TypedHashMap(int initialCapacity, Cast keyCast, Cast valueCast) + { + super(initialCapacity); + + this.keyCast = keyCast; + this.valueCast = valueCast; + } + + public TypedHashMap(Map map) + { + super(); + + keyCast = NoCast.instance; + valueCast = NoCast.instance; + + Map.Entry[] entries = (Map.Entry[]) map.entrySet().toArray(new Map.Entry[0]); + for(int i = 0; i < entries.length; i++) + { + this.put(entries[i].getKey(),entries[i].getValue()); + } + + } + + public TypedHashMap(Cast keyCast, Cast valueCast) + { + super(); + + this.keyCast = keyCast; + this.valueCast = valueCast; + } + + public Object clone() + { + return new TypedHashMap(this, keyCast, valueCast); + } + + public TypedHashMap(Map map, Cast keyCast, Cast valueCast) + { + super(); + + this.keyCast = keyCast; + this.valueCast = valueCast; + + Map.Entry[] entries = (Map.Entry[]) map.entrySet().toArray(new Map.Entry[0]); + for(int i = 0; i < entries.length; i++) + { + this.put(entries[i].getKey(),entries[i].getValue()); + } + + } + + public Cast getKeyCast() + { + return keyCast; + } + + public Cast getValueCast() + { + return valueCast; + } + + public Set entrySet() + { + if(entries == null) + { + entries = new EntrySet(super.entrySet()); + } + + return entries; + } + + public Object put(Object key, Object value) + { + return super.put(keyCast.cast(key), valueCast.cast(value)); + } + + private class EntrySet extends AbstractSet + { + private Set set + ; + + EntrySet(Set set + ) + { + this.set = set + ; + } + + public int size() + { + return set.size(); + } + + public Iterator iterator() + { + return new EntryIterator(set.iterator()); + } + } + + private class EntryIterator implements Iterator + { + private Iterator iterator; + + EntryIterator(Iterator iterator) + { + this.iterator = iterator; + } + + public boolean hasNext() + { + return iterator.hasNext(); + } + + public Object next() + { + return new TypedEntry((Map.Entry) iterator.next()); + } + + public void remove + () + { + iterator.remove(); + } + } + + private class TypedEntry implements Map.Entry + { + private Map.Entry entry; + + TypedEntry(Map.Entry entry) + { + this.entry = entry; + } + + public Object getKey() + { + return entry.getKey(); + } + + public Object getValue() + { + return entry.getValue(); + } + + public Object setValue(Object value) + { + return entry.setValue(valueCast.cast(value)); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/TypedLinkedList.java b/src/main/java/org/sablecc/sablecc/TypedLinkedList.java new file mode 100644 index 0000000..2e1494b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/TypedLinkedList.java @@ -0,0 +1,121 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class TypedLinkedList extends LinkedList +{ + Cast cast; + + public TypedLinkedList() + { + super(); + + cast = NoCast.instance; + } + + public TypedLinkedList(Collection c) + { + super(c); + + cast = NoCast.instance; + } + + public TypedLinkedList(Cast cast) + { + super(); + + this.cast = cast; + } + + public TypedLinkedList(Collection c, Cast cast) + { + super(c); + + this.cast = cast; + } + + public Cast getCast() + { + return cast; + } + + public void addFirst(Object o) + { + super.addFirst(cast.cast(o)); + } + + public void addLast(Object o) + { + super.addLast(cast.cast(o)); + } + + public ListIterator listIterator(int index) + { + return new TypedLinkedListIterator(super.listIterator(index)); + } + + private class TypedLinkedListIterator implements ListIterator + { + ListIterator iterator; + + TypedLinkedListIterator(ListIterator iterator) + { + this.iterator = iterator; + } + + public boolean hasNext() + { + return iterator.hasNext(); + } + + public Object next() + { + return iterator.next(); + } + + public boolean hasPrevious() + { + return iterator.hasPrevious(); + } + + public Object previous() + { + return iterator.previous(); + } + + public int nextIndex() + { + return iterator.nextIndex(); + } + + public int previousIndex() + { + return iterator.previousIndex(); + } + + public void remove + () + { + iterator.remove(); + } + + public void set + (Object o) + { + iterator.set(cast.cast(o)); + } + + public void add + (Object o) + { + iterator.add(cast.cast(o)); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/TypedTreeMap.java b/src/main/java/org/sablecc/sablecc/TypedTreeMap.java new file mode 100644 index 0000000..e0b3ec2 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/TypedTreeMap.java @@ -0,0 +1,251 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package org.sablecc.sablecc; + +import java.util.*; + +public class TypedTreeMap extends TreeMap +{ + private Cast keyCast; + private Cast valueCast; + private Set entries; + + public TypedTreeMap() + { + super(); + + keyCast = NoCast.instance; + valueCast = NoCast.instance; + } + + public TypedTreeMap(Comparator comparator) + { + super(comparator); + + keyCast = NoCast.instance; + valueCast = NoCast.instance; + } + + public TypedTreeMap(Map map) + { + super(); + + keyCast = NoCast.instance; + valueCast = NoCast.instance; + + Map.Entry[] entries = (Map.Entry[])map.entrySet().toArray(new Map.Entry[0]); + for(int i=0; i < entries.length; i++) + { + this.put(entries[i].getKey(),entries[i].getValue()); + } + } + + /* + public TypedTreeMap(Map map) + { + super(map); + + keyCast = NoCast.instance; + valueCast = NoCast.instance; + } + */ + + public TypedTreeMap(SortedMap smap) + { + super(smap.comparator()); + + keyCast = NoCast.instance; + valueCast = NoCast.instance; + + Map.Entry[] entries = (Map.Entry[])smap.entrySet().toArray(new Map.Entry[0]); + for(int i=0; i < entries.length; i++) + { + this.put(entries[i].getKey(),entries[i].getValue()); + } + + } + /* + public TypedTreeMap(SortedMap smap) + { + super(smap); + + keyCast = NoCast.instance; + valueCast = NoCast.instance; + } + */ + + public TypedTreeMap(Cast keyCast, Cast valueCast) + { + super(); + + this.keyCast = keyCast; + this.valueCast = valueCast; + } + + public TypedTreeMap(Comparator comparator, Cast keyCast, Cast valueCast) + { + super(comparator); + + this.keyCast = keyCast; + this.valueCast = valueCast; + } + + public Object clone() + { + return new TypedTreeMap(this, keyCast, valueCast); + } + + public TypedTreeMap(Map map, Cast keyCast, Cast valueCast) + { + super(); + + this.keyCast = keyCast; + this.valueCast = valueCast; + + Map.Entry[] entries = (Map.Entry[])map.entrySet().toArray(new Map.Entry[0]); + for(int i=0; i < entries.length; i++) + { + this.put(entries[i].getKey(),entries[i].getValue()); + } + + } + + /* + public TypedTreeMap(Map map, Cast keyCast, Cast valueCast) + { + super(map); + + this.keyCast = keyCast; + this.valueCast = valueCast; + } + */ + + public TypedTreeMap(SortedMap smap, Cast keyCast, Cast valueCast) + { + super(smap.comparator()); + + this.keyCast = keyCast; + this.valueCast = valueCast; + + Map.Entry[] entries = (Map.Entry[])smap.entrySet().toArray(new Map.Entry[0]); + for(int i=0; i < entries.length; i++) + { + this.put(entries[i].getKey(),entries[i].getValue()); + } + + } + + /* + public TypedTreeMap(SortedMap smap, Cast keyCast, Cast valueCast) + { + super(smap); + + this.keyCast = keyCast; + this.valueCast = valueCast; + } + */ + + public Cast getKeyCast() + { + return keyCast; + } + + public Cast getValueCast() + { + return valueCast; + } + + public Set entrySet() + { + if(entries == null) + { + entries = new EntrySet(super.entrySet()); + } + + return entries; + } + + public Object put(Object key, Object value) + { + return super.put(keyCast.cast(key), valueCast.cast(value)); + } + + private class EntrySet extends AbstractSet + { + private Set set + ; + + EntrySet(Set set + ) + { + this.set = set + ; + } + + public int size() + { + return set.size(); + } + + public Iterator iterator() + { + return new EntryIterator(set.iterator()); + } + } + + private class EntryIterator implements Iterator + { + private Iterator iterator; + + EntryIterator(Iterator iterator) + { + this.iterator = iterator; + } + + public boolean hasNext() + { + return iterator.hasNext(); + } + + public Object next() + { + return new TypedEntry((Map.Entry) iterator.next()); + } + + public void remove + () + { + iterator.remove(); + } + } + + private class TypedEntry implements Map.Entry + { + private Map.Entry entry; + + TypedEntry(Map.Entry entry) + { + this.entry = entry; + } + + public Object getKey() + { + return entry.getKey(); + } + + public Object getValue() + { + return entry.getValue(); + } + + public Object setValue(Object value) + { + return entry.setValue(valueCast.cast(value)); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/Version.java b/src/main/java/org/sablecc/sablecc/Version.java new file mode 100644 index 0000000..c835fb3 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/Version.java @@ -0,0 +1,6 @@ +package org.sablecc.sablecc; + +public class Version +{ + public static final String VERSION = "3.2"; +} diff --git a/src/main/java/org/sablecc/sablecc/analysis/Analysis.java b/src/main/java/org/sablecc/sablecc/analysis/Analysis.java new file mode 100644 index 0000000..ebd3638 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/analysis/Analysis.java @@ -0,0 +1,102 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.analysis; + +import org.sablecc.sablecc.node.*; + +public interface Analysis extends Switch +{ + Object getIn(Node node); + void setIn(Node node, Object in); + Object getOut(Node node); + void setOut(Node node, Object out); + + void caseStart(Start node); + void caseAGrammar(AGrammar node); + void caseAHelpers(AHelpers node); + void caseAHelperDef(AHelperDef node); + void caseAStates(AStates node); + void caseATokens(ATokens node); + void caseATokenDef(ATokenDef node); + void caseAStateList(AStateList node); + void caseAStateListTail(AStateListTail node); + void caseATransition(ATransition node); + void caseAIgnTokens(AIgnTokens node); + void caseARegExp(ARegExp node); + void caseAConcat(AConcat node); + void caseAUnExp(AUnExp node); + void caseACharBasic(ACharBasic node); + void caseASetBasic(ASetBasic node); + void caseAStringBasic(AStringBasic node); + void caseAIdBasic(AIdBasic node); + void caseARegExpBasic(ARegExpBasic node); + void caseACharChar(ACharChar node); + void caseADecChar(ADecChar node); + void caseAHexChar(AHexChar node); + void caseAOperationSet(AOperationSet node); + void caseAIntervalSet(AIntervalSet node); + void caseAStarUnOp(AStarUnOp node); + void caseAQMarkUnOp(AQMarkUnOp node); + void caseAPlusUnOp(APlusUnOp node); + void caseAPlusBinOp(APlusBinOp node); + void caseAMinusBinOp(AMinusBinOp node); + void caseAProductions(AProductions node); + void caseAProd(AProd node); + void caseAAlt(AAlt node); + void caseAAltTransform(AAltTransform node); + void caseANewTerm(ANewTerm node); + void caseAListTerm(AListTerm node); + void caseASimpleTerm(ASimpleTerm node); + void caseANullTerm(ANullTerm node); + void caseANewListTerm(ANewListTerm node); + void caseASimpleListTerm(ASimpleListTerm node); + void caseAProdName(AProdName node); + void caseAElem(AElem node); + void caseATokenSpecifier(ATokenSpecifier node); + void caseAProductionSpecifier(AProductionSpecifier node); + void caseAAst(AAst node); + void caseAAstProd(AAstProd node); + void caseAAstAlt(AAstAlt node); + + void caseTPkgId(TPkgId node); + void caseTPackage(TPackage node); + void caseTStates(TStates node); + void caseTHelpers(THelpers node); + void caseTTokens(TTokens node); + void caseTIgnored(TIgnored node); + void caseTProductions(TProductions node); + void caseTAbstract(TAbstract node); + void caseTSyntax(TSyntax node); + void caseTTree(TTree node); + void caseTNew(TNew node); + void caseTNull(TNull node); + void caseTTokenSpecifier(TTokenSpecifier node); + void caseTProductionSpecifier(TProductionSpecifier node); + void caseTDot(TDot node); + void caseTDDot(TDDot node); + void caseTSemicolon(TSemicolon node); + void caseTEqual(TEqual node); + void caseTLBkt(TLBkt node); + void caseTRBkt(TRBkt node); + void caseTLPar(TLPar node); + void caseTRPar(TRPar node); + void caseTLBrace(TLBrace node); + void caseTRBrace(TRBrace node); + void caseTPlus(TPlus node); + void caseTMinus(TMinus node); + void caseTQMark(TQMark node); + void caseTStar(TStar node); + void caseTBar(TBar node); + void caseTComma(TComma node); + void caseTSlash(TSlash node); + void caseTArrow(TArrow node); + void caseTColon(TColon node); + void caseTId(TId node); + void caseTChar(TChar node); + void caseTDecChar(TDecChar node); + void caseTHexChar(THexChar node); + void caseTString(TString node); + void caseTBlank(TBlank node); + void caseTComment(TComment node); + void caseEOF(EOF node); +} diff --git a/src/main/java/org/sablecc/sablecc/analysis/AnalysisAdapter.java b/src/main/java/org/sablecc/sablecc/analysis/AnalysisAdapter.java new file mode 100644 index 0000000..b128fdf --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/analysis/AnalysisAdapter.java @@ -0,0 +1,503 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.analysis; + +import java.util.*; +import org.sablecc.sablecc.node.*; + +public class AnalysisAdapter implements Analysis +{ + private Hashtable in; + private Hashtable out; + + public Object getIn(Node node) + { + if(in == null) + { + return null; + } + + return in.get(node); + } + + public void setIn(Node node, Object in) + { + if(this.in == null) + { + this.in = new Hashtable(1); + } + + if(in != null) + { + this.in.put(node, in); + } + else + { + this.in.remove(node); + } + } + + public Object getOut(Node node) + { + if(out == null) + { + return null; + } + + return out.get(node); + } + + public void setOut(Node node, Object out) + { + if(this.out == null) + { + this.out = new Hashtable(1); + } + + if(out != null) + { + this.out.put(node, out); + } + else + { + this.out.remove(node); + } + } + public void caseStart(Start node) + { + defaultCase(node); + } + + public void caseAGrammar(AGrammar node) + { + defaultCase(node); + } + + public void caseAHelpers(AHelpers node) + { + defaultCase(node); + } + + public void caseAHelperDef(AHelperDef node) + { + defaultCase(node); + } + + public void caseAStates(AStates node) + { + defaultCase(node); + } + + public void caseATokens(ATokens node) + { + defaultCase(node); + } + + public void caseATokenDef(ATokenDef node) + { + defaultCase(node); + } + + public void caseAStateList(AStateList node) + { + defaultCase(node); + } + + public void caseAStateListTail(AStateListTail node) + { + defaultCase(node); + } + + public void caseATransition(ATransition node) + { + defaultCase(node); + } + + public void caseAIgnTokens(AIgnTokens node) + { + defaultCase(node); + } + + public void caseARegExp(ARegExp node) + { + defaultCase(node); + } + + public void caseAConcat(AConcat node) + { + defaultCase(node); + } + + public void caseAUnExp(AUnExp node) + { + defaultCase(node); + } + + public void caseACharBasic(ACharBasic node) + { + defaultCase(node); + } + + public void caseASetBasic(ASetBasic node) + { + defaultCase(node); + } + + public void caseAStringBasic(AStringBasic node) + { + defaultCase(node); + } + + public void caseAIdBasic(AIdBasic node) + { + defaultCase(node); + } + + public void caseARegExpBasic(ARegExpBasic node) + { + defaultCase(node); + } + + public void caseACharChar(ACharChar node) + { + defaultCase(node); + } + + public void caseADecChar(ADecChar node) + { + defaultCase(node); + } + + public void caseAHexChar(AHexChar node) + { + defaultCase(node); + } + + public void caseAOperationSet(AOperationSet node) + { + defaultCase(node); + } + + public void caseAIntervalSet(AIntervalSet node) + { + defaultCase(node); + } + + public void caseAStarUnOp(AStarUnOp node) + { + defaultCase(node); + } + + public void caseAQMarkUnOp(AQMarkUnOp node) + { + defaultCase(node); + } + + public void caseAPlusUnOp(APlusUnOp node) + { + defaultCase(node); + } + + public void caseAPlusBinOp(APlusBinOp node) + { + defaultCase(node); + } + + public void caseAMinusBinOp(AMinusBinOp node) + { + defaultCase(node); + } + + public void caseAProductions(AProductions node) + { + defaultCase(node); + } + + public void caseAProd(AProd node) + { + defaultCase(node); + } + + public void caseAAlt(AAlt node) + { + defaultCase(node); + } + + public void caseAAltTransform(AAltTransform node) + { + defaultCase(node); + } + + public void caseANewTerm(ANewTerm node) + { + defaultCase(node); + } + + public void caseAListTerm(AListTerm node) + { + defaultCase(node); + } + + public void caseASimpleTerm(ASimpleTerm node) + { + defaultCase(node); + } + + public void caseANullTerm(ANullTerm node) + { + defaultCase(node); + } + + public void caseANewListTerm(ANewListTerm node) + { + defaultCase(node); + } + + public void caseASimpleListTerm(ASimpleListTerm node) + { + defaultCase(node); + } + + public void caseAProdName(AProdName node) + { + defaultCase(node); + } + + public void caseAElem(AElem node) + { + defaultCase(node); + } + + public void caseATokenSpecifier(ATokenSpecifier node) + { + defaultCase(node); + } + + public void caseAProductionSpecifier(AProductionSpecifier node) + { + defaultCase(node); + } + + public void caseAAst(AAst node) + { + defaultCase(node); + } + + public void caseAAstProd(AAstProd node) + { + defaultCase(node); + } + + public void caseAAstAlt(AAstAlt node) + { + defaultCase(node); + } + + public void caseTPkgId(TPkgId node) + { + defaultCase(node); + } + + public void caseTPackage(TPackage node) + { + defaultCase(node); + } + + public void caseTStates(TStates node) + { + defaultCase(node); + } + + public void caseTHelpers(THelpers node) + { + defaultCase(node); + } + + public void caseTTokens(TTokens node) + { + defaultCase(node); + } + + public void caseTIgnored(TIgnored node) + { + defaultCase(node); + } + + public void caseTProductions(TProductions node) + { + defaultCase(node); + } + + public void caseTAbstract(TAbstract node) + { + defaultCase(node); + } + + public void caseTSyntax(TSyntax node) + { + defaultCase(node); + } + + public void caseTTree(TTree node) + { + defaultCase(node); + } + + public void caseTNew(TNew node) + { + defaultCase(node); + } + + public void caseTNull(TNull node) + { + defaultCase(node); + } + + public void caseTTokenSpecifier(TTokenSpecifier node) + { + defaultCase(node); + } + + public void caseTProductionSpecifier(TProductionSpecifier node) + { + defaultCase(node); + } + + public void caseTDot(TDot node) + { + defaultCase(node); + } + + public void caseTDDot(TDDot node) + { + defaultCase(node); + } + + public void caseTSemicolon(TSemicolon node) + { + defaultCase(node); + } + + public void caseTEqual(TEqual node) + { + defaultCase(node); + } + + public void caseTLBkt(TLBkt node) + { + defaultCase(node); + } + + public void caseTRBkt(TRBkt node) + { + defaultCase(node); + } + + public void caseTLPar(TLPar node) + { + defaultCase(node); + } + + public void caseTRPar(TRPar node) + { + defaultCase(node); + } + + public void caseTLBrace(TLBrace node) + { + defaultCase(node); + } + + public void caseTRBrace(TRBrace node) + { + defaultCase(node); + } + + public void caseTPlus(TPlus node) + { + defaultCase(node); + } + + public void caseTMinus(TMinus node) + { + defaultCase(node); + } + + public void caseTQMark(TQMark node) + { + defaultCase(node); + } + + public void caseTStar(TStar node) + { + defaultCase(node); + } + + public void caseTBar(TBar node) + { + defaultCase(node); + } + + public void caseTComma(TComma node) + { + defaultCase(node); + } + + public void caseTSlash(TSlash node) + { + defaultCase(node); + } + + public void caseTArrow(TArrow node) + { + defaultCase(node); + } + + public void caseTColon(TColon node) + { + defaultCase(node); + } + + public void caseTId(TId node) + { + defaultCase(node); + } + + public void caseTChar(TChar node) + { + defaultCase(node); + } + + public void caseTDecChar(TDecChar node) + { + defaultCase(node); + } + + public void caseTHexChar(THexChar node) + { + defaultCase(node); + } + + public void caseTString(TString node) + { + defaultCase(node); + } + + public void caseTBlank(TBlank node) + { + defaultCase(node); + } + + public void caseTComment(TComment node) + { + defaultCase(node); + } + + public void caseEOF(EOF node) + { + defaultCase(node); + } + + public void defaultCase(Node node) + {} +} diff --git a/src/main/java/org/sablecc/sablecc/analysis/DepthFirstAdapter.java b/src/main/java/org/sablecc/sablecc/analysis/DepthFirstAdapter.java new file mode 100644 index 0000000..156967d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/analysis/DepthFirstAdapter.java @@ -0,0 +1,1130 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.analysis; + +import java.util.*; +import org.sablecc.sablecc.node.*; + +public class DepthFirstAdapter extends AnalysisAdapter +{ + public void inStart(Start node) + { + defaultIn(node); + } + + public void outStart(Start node) + { + defaultOut(node); + } + + public void defaultIn(Node node) + {} + + public void defaultOut(Node node) + {} + + public void caseStart(Start node) + { + inStart(node); + node.getPGrammar().apply(this); + node.getEOF().apply(this); + outStart(node); + } + + public void inAGrammar(AGrammar node) + { + defaultIn(node); + } + + public void outAGrammar(AGrammar node) + { + defaultOut(node); + } + + public void caseAGrammar(AGrammar node) + { + inAGrammar(node); + { + Object temp[] = node.getPackage().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((TPkgId) temp[i]).apply(this); + } + } + if(node.getHelpers() != null) + { + node.getHelpers().apply(this); + } + if(node.getStates() != null) + { + node.getStates().apply(this); + } + if(node.getTokens() != null) + { + node.getTokens().apply(this); + } + if(node.getIgnTokens() != null) + { + node.getIgnTokens().apply(this); + } + if(node.getProductions() != null) + { + node.getProductions().apply(this); + } + if(node.getAst() != null) + { + node.getAst().apply(this); + } + outAGrammar(node); + } + + public void inAHelpers(AHelpers node) + { + defaultIn(node); + } + + public void outAHelpers(AHelpers node) + { + defaultOut(node); + } + + public void caseAHelpers(AHelpers node) + { + inAHelpers(node); + { + Object temp[] = node.getHelperDefs().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PHelperDef) temp[i]).apply(this); + } + } + outAHelpers(node); + } + + public void inAHelperDef(AHelperDef node) + { + defaultIn(node); + } + + public void outAHelperDef(AHelperDef node) + { + defaultOut(node); + } + + public void caseAHelperDef(AHelperDef node) + { + inAHelperDef(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getRegExp() != null) + { + node.getRegExp().apply(this); + } + outAHelperDef(node); + } + + public void inAStates(AStates node) + { + defaultIn(node); + } + + public void outAStates(AStates node) + { + defaultOut(node); + } + + public void caseAStates(AStates node) + { + inAStates(node); + { + Object temp[] = node.getListId().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((TId) temp[i]).apply(this); + } + } + outAStates(node); + } + + public void inATokens(ATokens node) + { + defaultIn(node); + } + + public void outATokens(ATokens node) + { + defaultOut(node); + } + + public void caseATokens(ATokens node) + { + inATokens(node); + { + Object temp[] = node.getTokenDefs().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PTokenDef) temp[i]).apply(this); + } + } + outATokens(node); + } + + public void inATokenDef(ATokenDef node) + { + defaultIn(node); + } + + public void outATokenDef(ATokenDef node) + { + defaultOut(node); + } + + public void caseATokenDef(ATokenDef node) + { + inATokenDef(node); + if(node.getStateList() != null) + { + node.getStateList().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getRegExp() != null) + { + node.getRegExp().apply(this); + } + if(node.getSlash() != null) + { + node.getSlash().apply(this); + } + if(node.getLookAhead() != null) + { + node.getLookAhead().apply(this); + } + outATokenDef(node); + } + + public void inAStateList(AStateList node) + { + defaultIn(node); + } + + public void outAStateList(AStateList node) + { + defaultOut(node); + } + + public void caseAStateList(AStateList node) + { + inAStateList(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getTransition() != null) + { + node.getTransition().apply(this); + } + { + Object temp[] = node.getStateLists().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PStateListTail) temp[i]).apply(this); + } + } + outAStateList(node); + } + + public void inAStateListTail(AStateListTail node) + { + defaultIn(node); + } + + public void outAStateListTail(AStateListTail node) + { + defaultOut(node); + } + + public void caseAStateListTail(AStateListTail node) + { + inAStateListTail(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getTransition() != null) + { + node.getTransition().apply(this); + } + outAStateListTail(node); + } + + public void inATransition(ATransition node) + { + defaultIn(node); + } + + public void outATransition(ATransition node) + { + defaultOut(node); + } + + public void caseATransition(ATransition node) + { + inATransition(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + outATransition(node); + } + + public void inAIgnTokens(AIgnTokens node) + { + defaultIn(node); + } + + public void outAIgnTokens(AIgnTokens node) + { + defaultOut(node); + } + + public void caseAIgnTokens(AIgnTokens node) + { + inAIgnTokens(node); + { + Object temp[] = node.getListId().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((TId) temp[i]).apply(this); + } + } + outAIgnTokens(node); + } + + public void inARegExp(ARegExp node) + { + defaultIn(node); + } + + public void outARegExp(ARegExp node) + { + defaultOut(node); + } + + public void caseARegExp(ARegExp node) + { + inARegExp(node); + { + Object temp[] = node.getConcats().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PConcat) temp[i]).apply(this); + } + } + outARegExp(node); + } + + public void inAConcat(AConcat node) + { + defaultIn(node); + } + + public void outAConcat(AConcat node) + { + defaultOut(node); + } + + public void caseAConcat(AConcat node) + { + inAConcat(node); + { + Object temp[] = node.getUnExps().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PUnExp) temp[i]).apply(this); + } + } + outAConcat(node); + } + + public void inAUnExp(AUnExp node) + { + defaultIn(node); + } + + public void outAUnExp(AUnExp node) + { + defaultOut(node); + } + + public void caseAUnExp(AUnExp node) + { + inAUnExp(node); + if(node.getBasic() != null) + { + node.getBasic().apply(this); + } + if(node.getUnOp() != null) + { + node.getUnOp().apply(this); + } + outAUnExp(node); + } + + public void inACharBasic(ACharBasic node) + { + defaultIn(node); + } + + public void outACharBasic(ACharBasic node) + { + defaultOut(node); + } + + public void caseACharBasic(ACharBasic node) + { + inACharBasic(node); + if(node.getChar() != null) + { + node.getChar().apply(this); + } + outACharBasic(node); + } + + public void inASetBasic(ASetBasic node) + { + defaultIn(node); + } + + public void outASetBasic(ASetBasic node) + { + defaultOut(node); + } + + public void caseASetBasic(ASetBasic node) + { + inASetBasic(node); + if(node.getSet() != null) + { + node.getSet().apply(this); + } + outASetBasic(node); + } + + public void inAStringBasic(AStringBasic node) + { + defaultIn(node); + } + + public void outAStringBasic(AStringBasic node) + { + defaultOut(node); + } + + public void caseAStringBasic(AStringBasic node) + { + inAStringBasic(node); + if(node.getString() != null) + { + node.getString().apply(this); + } + outAStringBasic(node); + } + + public void inAIdBasic(AIdBasic node) + { + defaultIn(node); + } + + public void outAIdBasic(AIdBasic node) + { + defaultOut(node); + } + + public void caseAIdBasic(AIdBasic node) + { + inAIdBasic(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + outAIdBasic(node); + } + + public void inARegExpBasic(ARegExpBasic node) + { + defaultIn(node); + } + + public void outARegExpBasic(ARegExpBasic node) + { + defaultOut(node); + } + + public void caseARegExpBasic(ARegExpBasic node) + { + inARegExpBasic(node); + if(node.getRegExp() != null) + { + node.getRegExp().apply(this); + } + outARegExpBasic(node); + } + + public void inACharChar(ACharChar node) + { + defaultIn(node); + } + + public void outACharChar(ACharChar node) + { + defaultOut(node); + } + + public void caseACharChar(ACharChar node) + { + inACharChar(node); + if(node.getChar() != null) + { + node.getChar().apply(this); + } + outACharChar(node); + } + + public void inADecChar(ADecChar node) + { + defaultIn(node); + } + + public void outADecChar(ADecChar node) + { + defaultOut(node); + } + + public void caseADecChar(ADecChar node) + { + inADecChar(node); + if(node.getDecChar() != null) + { + node.getDecChar().apply(this); + } + outADecChar(node); + } + + public void inAHexChar(AHexChar node) + { + defaultIn(node); + } + + public void outAHexChar(AHexChar node) + { + defaultOut(node); + } + + public void caseAHexChar(AHexChar node) + { + inAHexChar(node); + if(node.getHexChar() != null) + { + node.getHexChar().apply(this); + } + outAHexChar(node); + } + + public void inAOperationSet(AOperationSet node) + { + defaultIn(node); + } + + public void outAOperationSet(AOperationSet node) + { + defaultOut(node); + } + + public void caseAOperationSet(AOperationSet node) + { + inAOperationSet(node); + if(node.getLeft() != null) + { + node.getLeft().apply(this); + } + if(node.getBinOp() != null) + { + node.getBinOp().apply(this); + } + if(node.getRight() != null) + { + node.getRight().apply(this); + } + outAOperationSet(node); + } + + public void inAIntervalSet(AIntervalSet node) + { + defaultIn(node); + } + + public void outAIntervalSet(AIntervalSet node) + { + defaultOut(node); + } + + public void caseAIntervalSet(AIntervalSet node) + { + inAIntervalSet(node); + if(node.getLeft() != null) + { + node.getLeft().apply(this); + } + if(node.getRight() != null) + { + node.getRight().apply(this); + } + outAIntervalSet(node); + } + + public void inAStarUnOp(AStarUnOp node) + { + defaultIn(node); + } + + public void outAStarUnOp(AStarUnOp node) + { + defaultOut(node); + } + + public void caseAStarUnOp(AStarUnOp node) + { + inAStarUnOp(node); + if(node.getStar() != null) + { + node.getStar().apply(this); + } + outAStarUnOp(node); + } + + public void inAQMarkUnOp(AQMarkUnOp node) + { + defaultIn(node); + } + + public void outAQMarkUnOp(AQMarkUnOp node) + { + defaultOut(node); + } + + public void caseAQMarkUnOp(AQMarkUnOp node) + { + inAQMarkUnOp(node); + if(node.getQMark() != null) + { + node.getQMark().apply(this); + } + outAQMarkUnOp(node); + } + + public void inAPlusUnOp(APlusUnOp node) + { + defaultIn(node); + } + + public void outAPlusUnOp(APlusUnOp node) + { + defaultOut(node); + } + + public void caseAPlusUnOp(APlusUnOp node) + { + inAPlusUnOp(node); + if(node.getPlus() != null) + { + node.getPlus().apply(this); + } + outAPlusUnOp(node); + } + + public void inAPlusBinOp(APlusBinOp node) + { + defaultIn(node); + } + + public void outAPlusBinOp(APlusBinOp node) + { + defaultOut(node); + } + + public void caseAPlusBinOp(APlusBinOp node) + { + inAPlusBinOp(node); + outAPlusBinOp(node); + } + + public void inAMinusBinOp(AMinusBinOp node) + { + defaultIn(node); + } + + public void outAMinusBinOp(AMinusBinOp node) + { + defaultOut(node); + } + + public void caseAMinusBinOp(AMinusBinOp node) + { + inAMinusBinOp(node); + outAMinusBinOp(node); + } + + public void inAProductions(AProductions node) + { + defaultIn(node); + } + + public void outAProductions(AProductions node) + { + defaultOut(node); + } + + public void caseAProductions(AProductions node) + { + inAProductions(node); + { + Object temp[] = node.getProds().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PProd) temp[i]).apply(this); + } + } + outAProductions(node); + } + + public void inAProd(AProd node) + { + defaultIn(node); + } + + public void outAProd(AProd node) + { + defaultOut(node); + } + + public void caseAProd(AProd node) + { + inAProd(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getArrow() != null) + { + node.getArrow().apply(this); + } + { + Object temp[] = node.getProdTransform().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PElem) temp[i]).apply(this); + } + } + { + Object temp[] = node.getAlts().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PAlt) temp[i]).apply(this); + } + } + outAProd(node); + } + + public void inAAlt(AAlt node) + { + defaultIn(node); + } + + public void outAAlt(AAlt node) + { + defaultOut(node); + } + + public void caseAAlt(AAlt node) + { + inAAlt(node); + if(node.getAltName() != null) + { + node.getAltName().apply(this); + } + { + Object temp[] = node.getElems().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PElem) temp[i]).apply(this); + } + } + if(node.getAltTransform() != null) + { + node.getAltTransform().apply(this); + } + outAAlt(node); + } + + public void inAAltTransform(AAltTransform node) + { + defaultIn(node); + } + + public void outAAltTransform(AAltTransform node) + { + defaultOut(node); + } + + public void caseAAltTransform(AAltTransform node) + { + inAAltTransform(node); + if(node.getLBrace() != null) + { + node.getLBrace().apply(this); + } + { + Object temp[] = node.getTerms().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PTerm) temp[i]).apply(this); + } + } + if(node.getRBrace() != null) + { + node.getRBrace().apply(this); + } + outAAltTransform(node); + } + + public void inANewTerm(ANewTerm node) + { + defaultIn(node); + } + + public void outANewTerm(ANewTerm node) + { + defaultOut(node); + } + + public void caseANewTerm(ANewTerm node) + { + inANewTerm(node); + if(node.getProdName() != null) + { + node.getProdName().apply(this); + } + if(node.getLPar() != null) + { + node.getLPar().apply(this); + } + { + Object temp[] = node.getParams().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PTerm) temp[i]).apply(this); + } + } + outANewTerm(node); + } + + public void inAListTerm(AListTerm node) + { + defaultIn(node); + } + + public void outAListTerm(AListTerm node) + { + defaultOut(node); + } + + public void caseAListTerm(AListTerm node) + { + inAListTerm(node); + if(node.getLBkt() != null) + { + node.getLBkt().apply(this); + } + { + Object temp[] = node.getListTerms().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PListTerm) temp[i]).apply(this); + } + } + outAListTerm(node); + } + + public void inASimpleTerm(ASimpleTerm node) + { + defaultIn(node); + } + + public void outASimpleTerm(ASimpleTerm node) + { + defaultOut(node); + } + + public void caseASimpleTerm(ASimpleTerm node) + { + inASimpleTerm(node); + if(node.getSpecifier() != null) + { + node.getSpecifier().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getSimpleTermTail() != null) + { + node.getSimpleTermTail().apply(this); + } + outASimpleTerm(node); + } + + public void inANullTerm(ANullTerm node) + { + defaultIn(node); + } + + public void outANullTerm(ANullTerm node) + { + defaultOut(node); + } + + public void caseANullTerm(ANullTerm node) + { + inANullTerm(node); + outANullTerm(node); + } + + public void inANewListTerm(ANewListTerm node) + { + defaultIn(node); + } + + public void outANewListTerm(ANewListTerm node) + { + defaultOut(node); + } + + public void caseANewListTerm(ANewListTerm node) + { + inANewListTerm(node); + if(node.getProdName() != null) + { + node.getProdName().apply(this); + } + if(node.getLPar() != null) + { + node.getLPar().apply(this); + } + { + Object temp[] = node.getParams().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PTerm) temp[i]).apply(this); + } + } + outANewListTerm(node); + } + + public void inASimpleListTerm(ASimpleListTerm node) + { + defaultIn(node); + } + + public void outASimpleListTerm(ASimpleListTerm node) + { + defaultOut(node); + } + + public void caseASimpleListTerm(ASimpleListTerm node) + { + inASimpleListTerm(node); + if(node.getSpecifier() != null) + { + node.getSpecifier().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getSimpleTermTail() != null) + { + node.getSimpleTermTail().apply(this); + } + outASimpleListTerm(node); + } + + public void inAProdName(AProdName node) + { + defaultIn(node); + } + + public void outAProdName(AProdName node) + { + defaultOut(node); + } + + public void caseAProdName(AProdName node) + { + inAProdName(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getProdNameTail() != null) + { + node.getProdNameTail().apply(this); + } + outAProdName(node); + } + + public void inAElem(AElem node) + { + defaultIn(node); + } + + public void outAElem(AElem node) + { + defaultOut(node); + } + + public void caseAElem(AElem node) + { + inAElem(node); + if(node.getElemName() != null) + { + node.getElemName().apply(this); + } + if(node.getSpecifier() != null) + { + node.getSpecifier().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getUnOp() != null) + { + node.getUnOp().apply(this); + } + outAElem(node); + } + + public void inATokenSpecifier(ATokenSpecifier node) + { + defaultIn(node); + } + + public void outATokenSpecifier(ATokenSpecifier node) + { + defaultOut(node); + } + + public void caseATokenSpecifier(ATokenSpecifier node) + { + inATokenSpecifier(node); + outATokenSpecifier(node); + } + + public void inAProductionSpecifier(AProductionSpecifier node) + { + defaultIn(node); + } + + public void outAProductionSpecifier(AProductionSpecifier node) + { + defaultOut(node); + } + + public void caseAProductionSpecifier(AProductionSpecifier node) + { + inAProductionSpecifier(node); + outAProductionSpecifier(node); + } + + public void inAAst(AAst node) + { + defaultIn(node); + } + + public void outAAst(AAst node) + { + defaultOut(node); + } + + public void caseAAst(AAst node) + { + inAAst(node); + { + Object temp[] = node.getProds().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PAstProd) temp[i]).apply(this); + } + } + outAAst(node); + } + + public void inAAstProd(AAstProd node) + { + defaultIn(node); + } + + public void outAAstProd(AAstProd node) + { + defaultOut(node); + } + + public void caseAAstProd(AAstProd node) + { + inAAstProd(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + { + Object temp[] = node.getAlts().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PAstAlt) temp[i]).apply(this); + } + } + outAAstProd(node); + } + + public void inAAstAlt(AAstAlt node) + { + defaultIn(node); + } + + public void outAAstAlt(AAstAlt node) + { + defaultOut(node); + } + + public void caseAAstAlt(AAstAlt node) + { + inAAstAlt(node); + if(node.getAltName() != null) + { + node.getAltName().apply(this); + } + { + Object temp[] = node.getElems().toArray(); + for(int i = 0; i < temp.length; i++) + { + ((PElem) temp[i]).apply(this); + } + } + outAAstAlt(node); + } +} diff --git a/src/main/java/org/sablecc/sablecc/analysis/ReversedDepthFirstAdapter.java b/src/main/java/org/sablecc/sablecc/analysis/ReversedDepthFirstAdapter.java new file mode 100644 index 0000000..b5401eb --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/analysis/ReversedDepthFirstAdapter.java @@ -0,0 +1,1129 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.analysis; + +import org.sablecc.sablecc.node.*; + +public class ReversedDepthFirstAdapter extends AnalysisAdapter +{ + public void inStart(Start node) + { + defaultIn(node); + } + + public void outStart(Start node) + { + defaultOut(node); + } + + public void defaultIn(Node node) + {} + + public void defaultOut(Node node) + {} + + public void caseStart(Start node) + { + inStart(node); + node.getEOF().apply(this); + node.getPGrammar().apply(this); + outStart(node); + } + + public void inAGrammar(AGrammar node) + { + defaultIn(node); + } + + public void outAGrammar(AGrammar node) + { + defaultOut(node); + } + + public void caseAGrammar(AGrammar node) + { + inAGrammar(node); + if(node.getAst() != null) + { + node.getAst().apply(this); + } + if(node.getProductions() != null) + { + node.getProductions().apply(this); + } + if(node.getIgnTokens() != null) + { + node.getIgnTokens().apply(this); + } + if(node.getTokens() != null) + { + node.getTokens().apply(this); + } + if(node.getStates() != null) + { + node.getStates().apply(this); + } + if(node.getHelpers() != null) + { + node.getHelpers().apply(this); + } + { + Object temp[] = node.getPackage().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((TPkgId) temp[i]).apply(this); + } + } + outAGrammar(node); + } + + public void inAHelpers(AHelpers node) + { + defaultIn(node); + } + + public void outAHelpers(AHelpers node) + { + defaultOut(node); + } + + public void caseAHelpers(AHelpers node) + { + inAHelpers(node); + { + Object temp[] = node.getHelperDefs().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PHelperDef) temp[i]).apply(this); + } + } + outAHelpers(node); + } + + public void inAHelperDef(AHelperDef node) + { + defaultIn(node); + } + + public void outAHelperDef(AHelperDef node) + { + defaultOut(node); + } + + public void caseAHelperDef(AHelperDef node) + { + inAHelperDef(node); + if(node.getRegExp() != null) + { + node.getRegExp().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + outAHelperDef(node); + } + + public void inAStates(AStates node) + { + defaultIn(node); + } + + public void outAStates(AStates node) + { + defaultOut(node); + } + + public void caseAStates(AStates node) + { + inAStates(node); + { + Object temp[] = node.getListId().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((TId) temp[i]).apply(this); + } + } + outAStates(node); + } + + public void inATokens(ATokens node) + { + defaultIn(node); + } + + public void outATokens(ATokens node) + { + defaultOut(node); + } + + public void caseATokens(ATokens node) + { + inATokens(node); + { + Object temp[] = node.getTokenDefs().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PTokenDef) temp[i]).apply(this); + } + } + outATokens(node); + } + + public void inATokenDef(ATokenDef node) + { + defaultIn(node); + } + + public void outATokenDef(ATokenDef node) + { + defaultOut(node); + } + + public void caseATokenDef(ATokenDef node) + { + inATokenDef(node); + if(node.getLookAhead() != null) + { + node.getLookAhead().apply(this); + } + if(node.getSlash() != null) + { + node.getSlash().apply(this); + } + if(node.getRegExp() != null) + { + node.getRegExp().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getStateList() != null) + { + node.getStateList().apply(this); + } + outATokenDef(node); + } + + public void inAStateList(AStateList node) + { + defaultIn(node); + } + + public void outAStateList(AStateList node) + { + defaultOut(node); + } + + public void caseAStateList(AStateList node) + { + inAStateList(node); + { + Object temp[] = node.getStateLists().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PStateListTail) temp[i]).apply(this); + } + } + if(node.getTransition() != null) + { + node.getTransition().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + outAStateList(node); + } + + public void inAStateListTail(AStateListTail node) + { + defaultIn(node); + } + + public void outAStateListTail(AStateListTail node) + { + defaultOut(node); + } + + public void caseAStateListTail(AStateListTail node) + { + inAStateListTail(node); + if(node.getTransition() != null) + { + node.getTransition().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + outAStateListTail(node); + } + + public void inATransition(ATransition node) + { + defaultIn(node); + } + + public void outATransition(ATransition node) + { + defaultOut(node); + } + + public void caseATransition(ATransition node) + { + inATransition(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + outATransition(node); + } + + public void inAIgnTokens(AIgnTokens node) + { + defaultIn(node); + } + + public void outAIgnTokens(AIgnTokens node) + { + defaultOut(node); + } + + public void caseAIgnTokens(AIgnTokens node) + { + inAIgnTokens(node); + { + Object temp[] = node.getListId().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((TId) temp[i]).apply(this); + } + } + outAIgnTokens(node); + } + + public void inARegExp(ARegExp node) + { + defaultIn(node); + } + + public void outARegExp(ARegExp node) + { + defaultOut(node); + } + + public void caseARegExp(ARegExp node) + { + inARegExp(node); + { + Object temp[] = node.getConcats().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PConcat) temp[i]).apply(this); + } + } + outARegExp(node); + } + + public void inAConcat(AConcat node) + { + defaultIn(node); + } + + public void outAConcat(AConcat node) + { + defaultOut(node); + } + + public void caseAConcat(AConcat node) + { + inAConcat(node); + { + Object temp[] = node.getUnExps().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PUnExp) temp[i]).apply(this); + } + } + outAConcat(node); + } + + public void inAUnExp(AUnExp node) + { + defaultIn(node); + } + + public void outAUnExp(AUnExp node) + { + defaultOut(node); + } + + public void caseAUnExp(AUnExp node) + { + inAUnExp(node); + if(node.getUnOp() != null) + { + node.getUnOp().apply(this); + } + if(node.getBasic() != null) + { + node.getBasic().apply(this); + } + outAUnExp(node); + } + + public void inACharBasic(ACharBasic node) + { + defaultIn(node); + } + + public void outACharBasic(ACharBasic node) + { + defaultOut(node); + } + + public void caseACharBasic(ACharBasic node) + { + inACharBasic(node); + if(node.getChar() != null) + { + node.getChar().apply(this); + } + outACharBasic(node); + } + + public void inASetBasic(ASetBasic node) + { + defaultIn(node); + } + + public void outASetBasic(ASetBasic node) + { + defaultOut(node); + } + + public void caseASetBasic(ASetBasic node) + { + inASetBasic(node); + if(node.getSet() != null) + { + node.getSet().apply(this); + } + outASetBasic(node); + } + + public void inAStringBasic(AStringBasic node) + { + defaultIn(node); + } + + public void outAStringBasic(AStringBasic node) + { + defaultOut(node); + } + + public void caseAStringBasic(AStringBasic node) + { + inAStringBasic(node); + if(node.getString() != null) + { + node.getString().apply(this); + } + outAStringBasic(node); + } + + public void inAIdBasic(AIdBasic node) + { + defaultIn(node); + } + + public void outAIdBasic(AIdBasic node) + { + defaultOut(node); + } + + public void caseAIdBasic(AIdBasic node) + { + inAIdBasic(node); + if(node.getId() != null) + { + node.getId().apply(this); + } + outAIdBasic(node); + } + + public void inARegExpBasic(ARegExpBasic node) + { + defaultIn(node); + } + + public void outARegExpBasic(ARegExpBasic node) + { + defaultOut(node); + } + + public void caseARegExpBasic(ARegExpBasic node) + { + inARegExpBasic(node); + if(node.getRegExp() != null) + { + node.getRegExp().apply(this); + } + outARegExpBasic(node); + } + + public void inACharChar(ACharChar node) + { + defaultIn(node); + } + + public void outACharChar(ACharChar node) + { + defaultOut(node); + } + + public void caseACharChar(ACharChar node) + { + inACharChar(node); + if(node.getChar() != null) + { + node.getChar().apply(this); + } + outACharChar(node); + } + + public void inADecChar(ADecChar node) + { + defaultIn(node); + } + + public void outADecChar(ADecChar node) + { + defaultOut(node); + } + + public void caseADecChar(ADecChar node) + { + inADecChar(node); + if(node.getDecChar() != null) + { + node.getDecChar().apply(this); + } + outADecChar(node); + } + + public void inAHexChar(AHexChar node) + { + defaultIn(node); + } + + public void outAHexChar(AHexChar node) + { + defaultOut(node); + } + + public void caseAHexChar(AHexChar node) + { + inAHexChar(node); + if(node.getHexChar() != null) + { + node.getHexChar().apply(this); + } + outAHexChar(node); + } + + public void inAOperationSet(AOperationSet node) + { + defaultIn(node); + } + + public void outAOperationSet(AOperationSet node) + { + defaultOut(node); + } + + public void caseAOperationSet(AOperationSet node) + { + inAOperationSet(node); + if(node.getRight() != null) + { + node.getRight().apply(this); + } + if(node.getBinOp() != null) + { + node.getBinOp().apply(this); + } + if(node.getLeft() != null) + { + node.getLeft().apply(this); + } + outAOperationSet(node); + } + + public void inAIntervalSet(AIntervalSet node) + { + defaultIn(node); + } + + public void outAIntervalSet(AIntervalSet node) + { + defaultOut(node); + } + + public void caseAIntervalSet(AIntervalSet node) + { + inAIntervalSet(node); + if(node.getRight() != null) + { + node.getRight().apply(this); + } + if(node.getLeft() != null) + { + node.getLeft().apply(this); + } + outAIntervalSet(node); + } + + public void inAStarUnOp(AStarUnOp node) + { + defaultIn(node); + } + + public void outAStarUnOp(AStarUnOp node) + { + defaultOut(node); + } + + public void caseAStarUnOp(AStarUnOp node) + { + inAStarUnOp(node); + if(node.getStar() != null) + { + node.getStar().apply(this); + } + outAStarUnOp(node); + } + + public void inAQMarkUnOp(AQMarkUnOp node) + { + defaultIn(node); + } + + public void outAQMarkUnOp(AQMarkUnOp node) + { + defaultOut(node); + } + + public void caseAQMarkUnOp(AQMarkUnOp node) + { + inAQMarkUnOp(node); + if(node.getQMark() != null) + { + node.getQMark().apply(this); + } + outAQMarkUnOp(node); + } + + public void inAPlusUnOp(APlusUnOp node) + { + defaultIn(node); + } + + public void outAPlusUnOp(APlusUnOp node) + { + defaultOut(node); + } + + public void caseAPlusUnOp(APlusUnOp node) + { + inAPlusUnOp(node); + if(node.getPlus() != null) + { + node.getPlus().apply(this); + } + outAPlusUnOp(node); + } + + public void inAPlusBinOp(APlusBinOp node) + { + defaultIn(node); + } + + public void outAPlusBinOp(APlusBinOp node) + { + defaultOut(node); + } + + public void caseAPlusBinOp(APlusBinOp node) + { + inAPlusBinOp(node); + outAPlusBinOp(node); + } + + public void inAMinusBinOp(AMinusBinOp node) + { + defaultIn(node); + } + + public void outAMinusBinOp(AMinusBinOp node) + { + defaultOut(node); + } + + public void caseAMinusBinOp(AMinusBinOp node) + { + inAMinusBinOp(node); + outAMinusBinOp(node); + } + + public void inAProductions(AProductions node) + { + defaultIn(node); + } + + public void outAProductions(AProductions node) + { + defaultOut(node); + } + + public void caseAProductions(AProductions node) + { + inAProductions(node); + { + Object temp[] = node.getProds().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PProd) temp[i]).apply(this); + } + } + outAProductions(node); + } + + public void inAProd(AProd node) + { + defaultIn(node); + } + + public void outAProd(AProd node) + { + defaultOut(node); + } + + public void caseAProd(AProd node) + { + inAProd(node); + { + Object temp[] = node.getAlts().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PAlt) temp[i]).apply(this); + } + } + { + Object temp[] = node.getProdTransform().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PElem) temp[i]).apply(this); + } + } + if(node.getArrow() != null) + { + node.getArrow().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + outAProd(node); + } + + public void inAAlt(AAlt node) + { + defaultIn(node); + } + + public void outAAlt(AAlt node) + { + defaultOut(node); + } + + public void caseAAlt(AAlt node) + { + inAAlt(node); + if(node.getAltTransform() != null) + { + node.getAltTransform().apply(this); + } + { + Object temp[] = node.getElems().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PElem) temp[i]).apply(this); + } + } + if(node.getAltName() != null) + { + node.getAltName().apply(this); + } + outAAlt(node); + } + + public void inAAltTransform(AAltTransform node) + { + defaultIn(node); + } + + public void outAAltTransform(AAltTransform node) + { + defaultOut(node); + } + + public void caseAAltTransform(AAltTransform node) + { + inAAltTransform(node); + if(node.getRBrace() != null) + { + node.getRBrace().apply(this); + } + { + Object temp[] = node.getTerms().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PTerm) temp[i]).apply(this); + } + } + if(node.getLBrace() != null) + { + node.getLBrace().apply(this); + } + outAAltTransform(node); + } + + public void inANewTerm(ANewTerm node) + { + defaultIn(node); + } + + public void outANewTerm(ANewTerm node) + { + defaultOut(node); + } + + public void caseANewTerm(ANewTerm node) + { + inANewTerm(node); + { + Object temp[] = node.getParams().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PTerm) temp[i]).apply(this); + } + } + if(node.getLPar() != null) + { + node.getLPar().apply(this); + } + if(node.getProdName() != null) + { + node.getProdName().apply(this); + } + outANewTerm(node); + } + + public void inAListTerm(AListTerm node) + { + defaultIn(node); + } + + public void outAListTerm(AListTerm node) + { + defaultOut(node); + } + + public void caseAListTerm(AListTerm node) + { + inAListTerm(node); + { + Object temp[] = node.getListTerms().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PListTerm) temp[i]).apply(this); + } + } + if(node.getLBkt() != null) + { + node.getLBkt().apply(this); + } + outAListTerm(node); + } + + public void inASimpleTerm(ASimpleTerm node) + { + defaultIn(node); + } + + public void outASimpleTerm(ASimpleTerm node) + { + defaultOut(node); + } + + public void caseASimpleTerm(ASimpleTerm node) + { + inASimpleTerm(node); + if(node.getSimpleTermTail() != null) + { + node.getSimpleTermTail().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getSpecifier() != null) + { + node.getSpecifier().apply(this); + } + outASimpleTerm(node); + } + + public void inANullTerm(ANullTerm node) + { + defaultIn(node); + } + + public void outANullTerm(ANullTerm node) + { + defaultOut(node); + } + + public void caseANullTerm(ANullTerm node) + { + inANullTerm(node); + outANullTerm(node); + } + + public void inANewListTerm(ANewListTerm node) + { + defaultIn(node); + } + + public void outANewListTerm(ANewListTerm node) + { + defaultOut(node); + } + + public void caseANewListTerm(ANewListTerm node) + { + inANewListTerm(node); + { + Object temp[] = node.getParams().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PTerm) temp[i]).apply(this); + } + } + if(node.getLPar() != null) + { + node.getLPar().apply(this); + } + if(node.getProdName() != null) + { + node.getProdName().apply(this); + } + outANewListTerm(node); + } + + public void inASimpleListTerm(ASimpleListTerm node) + { + defaultIn(node); + } + + public void outASimpleListTerm(ASimpleListTerm node) + { + defaultOut(node); + } + + public void caseASimpleListTerm(ASimpleListTerm node) + { + inASimpleListTerm(node); + if(node.getSimpleTermTail() != null) + { + node.getSimpleTermTail().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getSpecifier() != null) + { + node.getSpecifier().apply(this); + } + outASimpleListTerm(node); + } + + public void inAProdName(AProdName node) + { + defaultIn(node); + } + + public void outAProdName(AProdName node) + { + defaultOut(node); + } + + public void caseAProdName(AProdName node) + { + inAProdName(node); + if(node.getProdNameTail() != null) + { + node.getProdNameTail().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + outAProdName(node); + } + + public void inAElem(AElem node) + { + defaultIn(node); + } + + public void outAElem(AElem node) + { + defaultOut(node); + } + + public void caseAElem(AElem node) + { + inAElem(node); + if(node.getUnOp() != null) + { + node.getUnOp().apply(this); + } + if(node.getId() != null) + { + node.getId().apply(this); + } + if(node.getSpecifier() != null) + { + node.getSpecifier().apply(this); + } + if(node.getElemName() != null) + { + node.getElemName().apply(this); + } + outAElem(node); + } + + public void inATokenSpecifier(ATokenSpecifier node) + { + defaultIn(node); + } + + public void outATokenSpecifier(ATokenSpecifier node) + { + defaultOut(node); + } + + public void caseATokenSpecifier(ATokenSpecifier node) + { + inATokenSpecifier(node); + outATokenSpecifier(node); + } + + public void inAProductionSpecifier(AProductionSpecifier node) + { + defaultIn(node); + } + + public void outAProductionSpecifier(AProductionSpecifier node) + { + defaultOut(node); + } + + public void caseAProductionSpecifier(AProductionSpecifier node) + { + inAProductionSpecifier(node); + outAProductionSpecifier(node); + } + + public void inAAst(AAst node) + { + defaultIn(node); + } + + public void outAAst(AAst node) + { + defaultOut(node); + } + + public void caseAAst(AAst node) + { + inAAst(node); + { + Object temp[] = node.getProds().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PAstProd) temp[i]).apply(this); + } + } + outAAst(node); + } + + public void inAAstProd(AAstProd node) + { + defaultIn(node); + } + + public void outAAstProd(AAstProd node) + { + defaultOut(node); + } + + public void caseAAstProd(AAstProd node) + { + inAAstProd(node); + { + Object temp[] = node.getAlts().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PAstAlt) temp[i]).apply(this); + } + } + if(node.getId() != null) + { + node.getId().apply(this); + } + outAAstProd(node); + } + + public void inAAstAlt(AAstAlt node) + { + defaultIn(node); + } + + public void outAAstAlt(AAstAlt node) + { + defaultOut(node); + } + + public void caseAAstAlt(AAstAlt node) + { + inAAstAlt(node); + { + Object temp[] = node.getElems().toArray(); + for(int i = temp.length - 1; i >= 0; i--) + { + ((PElem) temp[i]).apply(this); + } + } + if(node.getAltName() != null) + { + node.getAltName().apply(this); + } + outAAstAlt(node); + } +} diff --git a/src/main/java/org/sablecc/sablecc/lexer/Lexer.java b/src/main/java/org/sablecc/sablecc/lexer/Lexer.java new file mode 100644 index 0000000..d2de0b5 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/lexer/Lexer.java @@ -0,0 +1,1151 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.lexer; + +import java.io.*; +import java.util.*; +import org.sablecc.sablecc.node.*; + +public class Lexer +{ + protected Token token; + protected State state = State.NORMAL; + + private PushbackReader in; + private int line; + private int pos; + private boolean cr; + private boolean eof; + private final StringBuffer text = new StringBuffer(); + + protected void filter() throws LexerException, IOException + {} + + public Lexer(PushbackReader in) + { + this.in = in; + } + + public Token peek() throws LexerException, IOException + { + while(token == null) + { + token = getToken(); + filter(); + } + + return token; + } + + public Token next() throws LexerException, IOException + { + while(token == null) + { + token = getToken(); + filter(); + } + + Token result = token; + token = null; + return result; + } + + protected Token getToken() throws IOException, LexerException + { + int dfa_state = 0; + + int start_pos = pos; + int start_line = line; + + int accept_state = -1; + int accept_token = -1; + int accept_length = -1; + int accept_pos = -1; + int accept_line = -1; + + int[][][] gotoTable = this.gotoTable[state.id()]; + int[] accept = this.accept[state.id()]; + text.setLength(0); + + while(true) + { + int c = getChar(); + + if(c != -1) + { + switch(c) + { + case 10: + if(cr) + { + cr = false; + } + else + { + line++; + pos = 0; + } + break; + case 13: + line++; + pos = 0; + cr = true; + break; + default: + pos++; + cr = false; + break; + }; + + text.append((char) c); + + do + { + int oldState = (dfa_state < -1) ? (-2 -dfa_state) : dfa_state; + + dfa_state = -1; + + int[][] tmp1 = gotoTable[oldState]; + int low = 0; + int high = tmp1.length - 1; + + while(low <= high) + { + int middle = (low + high) / 2; + int[] tmp2 = tmp1[middle]; + + if(c < tmp2[0]) + { + high = middle - 1; + } + else if(c > tmp2[1]) + { + low = middle + 1; + } + else + { + dfa_state = tmp2[2]; + break; + } + } + } + while(dfa_state < -1); + } + else + { + dfa_state = -1; + } + + if(dfa_state >= 0) + { + if(accept[dfa_state] != -1) + { + accept_state = dfa_state; + accept_token = accept[dfa_state]; + accept_length = text.length(); + accept_pos = pos; + accept_line = line; + } + } + else + { + if(accept_state != -1) + { + switch(accept_token) + { + case 0: + { + Token token = new0( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + switch(state.id()) + { + case 1: + state = State.PACKAGE; + break; + } + return token; + } + case 1: + { + Token token = new1( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + switch(state.id()) + { + case 0: + state = State.PACKAGE; + break; + } + return token; + } + case 2: + { + Token token = new2( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 3: + { + Token token = new3( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 4: + { + Token token = new4( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 5: + { + Token token = new5( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 6: + { + Token token = new6( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 7: + { + Token token = new7( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 8: + { + Token token = new8( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 9: + { + Token token = new9( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 10: + { + Token token = new10( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 11: + { + Token token = new11( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 12: + { + Token token = new12( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 13: + { + Token token = new13( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 14: + { + Token token = new14( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 15: + { + Token token = new15( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 16: + { + Token token = new16( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + switch(state.id()) + { + case 0: + state = State.NORMAL; + break; + case 1: + state = State.NORMAL; + break; + } + return token; + } + case 17: + { + Token token = new17( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 18: + { + Token token = new18( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 19: + { + Token token = new19( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 20: + { + Token token = new20( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 21: + { + Token token = new21( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 22: + { + Token token = new22( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 23: + { + Token token = new23( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 24: + { + Token token = new24( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 25: + { + Token token = new25( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 26: + { + Token token = new26( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 27: + { + Token token = new27( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 28: + { + Token token = new28( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 29: + { + Token token = new29( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 30: + { + Token token = new30( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 31: + { + Token token = new31( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 32: + { + Token token = new32( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 33: + { + Token token = new33( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 34: + { + Token token = new34( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 35: + { + Token token = new35( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 36: + { + Token token = new36( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 37: + { + Token token = new37( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 38: + { + Token token = new38( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + case 39: + { + Token token = new39( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + pos = accept_pos; + line = accept_line; + return token; + } + } + } + else + { + if(text.length() > 0) + { + throw new LexerException( + "[" + (start_line + 1) + "," + (start_pos + 1) + "]" + + " Unknown token: " + text); + } + else + { + EOF token = new EOF( + start_line + 1, + start_pos + 1); + return token; + } + } + } + } + } + + Token new0(String text, int line, int pos) + { + return new TPkgId(text, line, pos); + } + Token new1(int line, int pos) + { + return new TPackage(line, pos); + } + Token new2(int line, int pos) + { + return new TStates(line, pos); + } + Token new3(int line, int pos) + { + return new THelpers(line, pos); + } + Token new4(int line, int pos) + { + return new TTokens(line, pos); + } + Token new5(int line, int pos) + { + return new TIgnored(line, pos); + } + Token new6(int line, int pos) + { + return new TProductions(line, pos); + } + Token new7(int line, int pos) + { + return new TAbstract(line, pos); + } + Token new8(int line, int pos) + { + return new TSyntax(line, pos); + } + Token new9(int line, int pos) + { + return new TTree(line, pos); + } + Token new10(int line, int pos) + { + return new TNew(line, pos); + } + Token new11(int line, int pos) + { + return new TNull(line, pos); + } + Token new12(int line, int pos) + { + return new TTokenSpecifier(line, pos); + } + Token new13(int line, int pos) + { + return new TProductionSpecifier(line, pos); + } + Token new14(int line, int pos) + { + return new TDot(line, pos); + } + Token new15(int line, int pos) + { + return new TDDot(line, pos); + } + Token new16(int line, int pos) + { + return new TSemicolon(line, pos); + } + Token new17(int line, int pos) + { + return new TEqual(line, pos); + } + Token new18(int line, int pos) + { + return new TLBkt(line, pos); + } + Token new19(int line, int pos) + { + return new TRBkt(line, pos); + } + Token new20(int line, int pos) + { + return new TLPar(line, pos); + } + Token new21(int line, int pos) + { + return new TRPar(line, pos); + } + Token new22(int line, int pos) + { + return new TLBrace(line, pos); + } + Token new23(int line, int pos) + { + return new TRBrace(line, pos); + } + Token new24(int line, int pos) + { + return new TPlus(line, pos); + } + Token new25(int line, int pos) + { + return new TMinus(line, pos); + } + Token new26(int line, int pos) + { + return new TQMark(line, pos); + } + Token new27(int line, int pos) + { + return new TStar(line, pos); + } + Token new28(int line, int pos) + { + return new TBar(line, pos); + } + Token new29(int line, int pos) + { + return new TComma(line, pos); + } + Token new30(int line, int pos) + { + return new TSlash(line, pos); + } + Token new31(int line, int pos) + { + return new TArrow(line, pos); + } + Token new32(int line, int pos) + { + return new TColon(line, pos); + } + Token new33(String text, int line, int pos) + { + return new TId(text, line, pos); + } + Token new34(String text, int line, int pos) + { + return new TChar(text, line, pos); + } + Token new35(String text, int line, int pos) + { + return new TDecChar(text, line, pos); + } + Token new36(String text, int line, int pos) + { + return new THexChar(text, line, pos); + } + Token new37(String text, int line, int pos) + { + return new TString(text, line, pos); + } + Token new38(String text, int line, int pos) + { + return new TBlank(text, line, pos); + } + Token new39(String text, int line, int pos) + { + return new TComment(text, line, pos); + } + + private int getChar() throws IOException + { + if(eof) + { + return -1; + } + + int result = in.read(); + + if(result == -1) + { + eof = true; + } + + return result; + } + + private void pushBack(int acceptLength) throws IOException + { + int length = text.length(); + for(int i = length - 1; i >= acceptLength; i--) + { + eof = false; + + in.unread(text.charAt(i)); + } + } + + protected void unread(Token token) throws IOException + { + String text = token.getText(); + int length = text.length(); + + for(int i = length - 1; i >= 0; i--) + { + eof = false; + + in.unread(text.charAt(i)); + } + + pos = token.getPos() - 1; + line = token.getLine() - 1; + } + + private String getText(int acceptLength) + { + StringBuffer s = new StringBuffer(acceptLength); + for(int i = 0; i < acceptLength; i++) + { + s.append(text.charAt(i)); + } + + return s.toString(); + } + + private static int[][][][] gotoTable; + /* { + { // NORMAL + {{9, 9, 1}, {10, 10, 2}, {13, 13, 3}, {32, 32, 4}, {39, 39, 5}, {40, 40, 6}, {41, 41, 7}, {42, 42, 8}, {43, 43, 9}, {44, 44, 10}, {45, 45, 11}, {46, 46, 12}, {47, 47, 13}, {48, 48, 14}, {49, 57, 15}, {58, 58, 16}, {59, 59, 17}, {61, 61, 18}, {63, 63, 19}, {65, 65, 20}, {72, 72, 21}, {73, 73, 22}, {78, 78, 23}, {80, 80, 24}, {83, 83, 25}, {84, 84, 26}, {91, 91, 27}, {93, 93, 28}, {97, 122, 29}, {123, 123, 30}, {124, 124, 31}, {125, 125, 32}, }, + {{9, 32, -2}, }, + {{9, 32, -2}, }, + {{9, 9, 1}, {10, 10, 33}, {13, 32, -2}, }, + {{9, 32, -2}, }, + {{0, 9, 34}, {11, 12, 34}, {14, 38, 34}, {39, 39, 35}, {40, 65535, 34}, }, + {}, + {}, + {}, + {}, + {}, + {{62, 62, 36}, }, + {{46, 46, 37}, }, + {{42, 42, 38}, {47, 47, 39}, }, + {{48, 57, 15}, {88, 88, 40}, {120, 120, 41}, }, + {{48, 57, 15}, }, + {}, + {}, + {}, + {}, + {{98, 98, 42}, }, + {{101, 101, 43}, }, + {{103, 103, 44}, }, + {{101, 101, 45}, {117, 117, 46}, }, + {{97, 97, 47}, {114, 114, 48}, }, + {{116, 116, 49}, {121, 121, 50}, }, + {{111, 111, 51}, {114, 114, 52}, }, + {}, + {}, + {{48, 57, 53}, {95, 95, 54}, {97, 122, 55}, }, + {}, + {}, + {}, + {{9, 32, -2}, }, + {{0, 9, 56}, {11, 12, 56}, {14, 38, 56}, {39, 39, 57}, {40, 65535, 56}, }, + {{39, 39, 58}, }, + {}, + {}, + {{0, 41, 59}, {42, 42, 60}, {43, 65535, 59}, }, + {{0, 9, 61}, {10, 10, 62}, {11, 12, 61}, {13, 13, 63}, {14, 65535, 61}, }, + {{48, 57, 64}, {65, 70, 64}, {97, 102, 64}, }, + {{48, 102, -42}, }, + {{115, 115, 65}, }, + {{108, 108, 66}, }, + {{110, 110, 67}, }, + {{119, 119, 68}, }, + {{108, 108, 69}, }, + {{99, 99, 70}, }, + {{111, 111, 71}, }, + {{97, 97, 72}, }, + {{110, 110, 73}, }, + {{107, 107, 74}, }, + {{101, 101, 75}, }, + {{48, 122, -31}, }, + {{97, 122, 76}, }, + {{48, 122, -31}, }, + {{0, 38, -36}, {39, 39, 77}, {40, 65535, 56}, }, + {}, + {}, + {{0, 65535, -40}, }, + {{0, 41, 78}, {42, 42, 60}, {43, 46, 78}, {47, 47, 79}, {48, 65535, 78}, }, + {{0, 65535, -41}, }, + {}, + {{10, 10, 80}, }, + {{48, 102, -42}, }, + {{116, 116, 81}, }, + {{112, 112, 82}, }, + {{111, 111, 83}, }, + {}, + {{108, 108, 84}, }, + {{107, 107, 85}, }, + {{100, 100, 86}, }, + {{116, 116, 87}, }, + {{116, 116, 88}, }, + {{101, 101, 89}, }, + {{101, 101, 90}, }, + {{48, 57, 91}, {95, 95, 54}, {97, 122, 92}, }, + {}, + {{0, 41, 93}, {42, 42, 94}, {43, 65535, 93}, }, + {}, + {}, + {{114, 114, 95}, }, + {{101, 101, 96}, }, + {{114, 114, 97}, }, + {}, + {{97, 97, 98}, }, + {{117, 117, 99}, }, + {{101, 101, 100}, }, + {{97, 97, 101}, }, + {{110, 110, 102}, }, + {}, + {{48, 122, -78}, }, + {{48, 122, -78}, }, + {{0, 65535, -80}, }, + {{0, 41, 78}, {42, 42, 94}, {43, 65535, -62}, }, + {{97, 97, 103}, }, + {{114, 114, 104}, }, + {{101, 101, 105}, }, + {{103, 103, 106}, }, + {{99, 99, 107}, }, + {{115, 115, 108}, }, + {{120, 120, 109}, }, + {{115, 115, 110}, }, + {{99, 99, 111}, }, + {{115, 115, 112}, }, + {{100, 100, 113}, }, + {{101, 101, 114}, }, + {{116, 116, 115}, }, + {}, + {}, + {}, + {{116, 116, 116}, }, + {}, + {}, + {}, + {{105, 105, 117}, }, + {}, + {{111, 111, 118}, }, + {{110, 110, 119}, }, + {{115, 115, 120}, }, + {}, + } + { // PACKAGE + {{9, 9, 1}, {10, 10, 2}, {13, 13, 3}, {32, 32, 4}, {36, 36, 5}, {39, 39, 6}, {40, 40, 7}, {41, 41, 8}, {42, 42, 9}, {43, 43, 10}, {44, 44, 11}, {45, 45, 12}, {46, 46, 13}, {47, 47, 14}, {48, 48, 15}, {49, 57, 16}, {58, 58, 17}, {59, 59, 18}, {61, 61, 19}, {63, 63, 20}, {65, 65, 21}, {66, 71, 22}, {72, 72, 23}, {73, 73, 24}, {74, 77, 22}, {78, 78, 25}, {79, 79, 22}, {80, 80, 26}, {81, 82, 22}, {83, 83, 27}, {84, 84, 28}, {85, 90, 22}, {91, 91, 29}, {93, 93, 30}, {95, 95, 31}, {97, 122, 32}, {123, 123, 33}, {124, 124, 34}, {125, 125, 35}, }, + {{9, 32, -2}, }, + {{9, 32, -2}, }, + {{9, 9, 1}, {10, 10, 36}, {13, 32, -2}, }, + {{9, 32, -2}, }, + {{36, 36, 37}, {48, 57, 38}, {65, 90, 39}, {95, 95, 40}, {97, 122, 41}, }, + {{0, 9, 42}, {11, 12, 42}, {14, 38, 42}, {39, 39, 43}, {40, 65535, 42}, }, + {}, + {}, + {}, + {}, + {}, + {{62, 62, 44}, }, + {{46, 46, 45}, }, + {{42, 42, 46}, {47, 47, 47}, }, + {{48, 57, 16}, {88, 88, 48}, {120, 120, 49}, }, + {{48, 57, 16}, }, + {}, + {}, + {}, + {}, + {{36, 95, -7}, {97, 97, 41}, {98, 98, 50}, {99, 122, 41}, }, + {{36, 122, -7}, }, + {{36, 95, -7}, {97, 100, 41}, {101, 101, 51}, {102, 122, 41}, }, + {{36, 95, -7}, {97, 102, 41}, {103, 103, 52}, {104, 122, 41}, }, + {{36, 100, -25}, {101, 101, 53}, {102, 116, 41}, {117, 117, 54}, {118, 122, 41}, }, + {{36, 95, -7}, {97, 113, 41}, {114, 114, 55}, {115, 122, 41}, }, + {{36, 95, -7}, {97, 115, 41}, {116, 116, 56}, {117, 120, 41}, {121, 121, 57}, {122, 122, 41}, }, + {{36, 95, -7}, {97, 110, 41}, {111, 111, 58}, {112, 113, 41}, {114, 114, 59}, {115, 122, 41}, }, + {}, + {}, + {{36, 122, -7}, }, + {{36, 36, 37}, {48, 57, 60}, {65, 90, 39}, {95, 95, 61}, {97, 122, 62}, }, + {}, + {}, + {}, + {{9, 32, -2}, }, + {{36, 122, -7}, }, + {{36, 122, -7}, }, + {{36, 122, -7}, }, + {{36, 122, -7}, }, + {{36, 122, -7}, }, + {{0, 9, 63}, {11, 12, 63}, {14, 38, 63}, {39, 39, 64}, {40, 65535, 63}, }, + {{39, 39, 65}, }, + {}, + {}, + {{0, 41, 66}, {42, 42, 67}, {43, 65535, 66}, }, + {{0, 9, 68}, {10, 10, 69}, {11, 12, 68}, {13, 13, 70}, {14, 65535, 68}, }, + {{48, 57, 71}, {65, 70, 71}, {97, 102, 71}, }, + {{48, 102, -50}, }, + {{36, 95, -7}, {97, 114, 41}, {115, 115, 72}, {116, 122, 41}, }, + {{36, 95, -7}, {97, 107, 41}, {108, 108, 73}, {109, 122, 41}, }, + {{36, 95, -7}, {97, 109, 41}, {110, 110, 74}, {111, 122, 41}, }, + {{36, 95, -7}, {97, 118, 41}, {119, 119, 75}, {120, 122, 41}, }, + {{36, 107, -53}, {108, 108, 76}, {109, 122, 41}, }, + {{36, 110, -30}, {111, 111, 77}, {112, 122, 41}, }, + {{36, 95, -7}, {97, 97, 78}, {98, 122, 41}, }, + {{36, 109, -54}, {110, 110, 79}, {111, 122, 41}, }, + {{36, 95, -7}, {97, 106, 41}, {107, 107, 80}, {108, 122, 41}, }, + {{36, 100, -25}, {101, 101, 81}, {102, 122, 41}, }, + {{36, 122, -34}, }, + {{36, 95, -7}, {97, 122, 82}, }, + {{36, 122, -34}, }, + {{0, 38, -44}, {39, 39, 83}, {40, 65535, 63}, }, + {}, + {}, + {{0, 65535, -48}, }, + {{0, 41, 84}, {42, 42, 67}, {43, 46, 84}, {47, 47, 85}, {48, 65535, 84}, }, + {{0, 65535, -49}, }, + {}, + {{10, 10, 86}, }, + {{48, 102, -50}, }, + {{36, 115, -29}, {116, 116, 87}, {117, 122, 41}, }, + {{36, 95, -7}, {97, 111, 41}, {112, 112, 88}, {113, 122, 41}, }, + {{36, 110, -30}, {111, 111, 89}, {112, 122, 41}, }, + {{36, 122, -7}, }, + {{36, 107, -53}, {108, 108, 90}, {109, 122, 41}, }, + {{36, 95, -7}, {97, 99, 41}, {100, 100, 91}, {101, 122, 41}, }, + {{36, 115, -29}, {116, 116, 92}, {117, 122, 41}, }, + {{36, 115, -29}, {116, 116, 93}, {117, 122, 41}, }, + {{36, 100, -25}, {101, 101, 94}, {102, 122, 41}, }, + {{36, 100, -25}, {101, 101, 95}, {102, 122, 41}, }, + {{36, 36, 37}, {48, 57, 96}, {65, 95, -34}, {97, 122, 97}, }, + {}, + {{0, 41, 98}, {42, 42, 99}, {43, 65535, 98}, }, + {}, + {}, + {{36, 113, -28}, {114, 114, 100}, {115, 122, 41}, }, + {{36, 100, -25}, {101, 101, 101}, {102, 122, 41}, }, + {{36, 113, -28}, {114, 114, 102}, {115, 122, 41}, }, + {{36, 122, -7}, }, + {{36, 95, -7}, {97, 116, 41}, {117, 117, 103}, {118, 122, 41}, }, + {{36, 100, -25}, {101, 101, 104}, {102, 122, 41}, }, + {{36, 95, -7}, {97, 97, 105}, {98, 122, 41}, }, + {{36, 109, -54}, {110, 110, 106}, {111, 122, 41}, }, + {{36, 122, -7}, }, + {{36, 122, -84}, }, + {{36, 122, -84}, }, + {{0, 65535, -86}, }, + {{0, 41, 84}, {42, 42, 99}, {43, 65535, -69}, }, + {{36, 95, -7}, {97, 97, 107}, {98, 122, 41}, }, + {{36, 113, -28}, {114, 114, 108}, {115, 122, 41}, }, + {{36, 100, -25}, {101, 101, 109}, {102, 122, 41}, }, + {{36, 95, -7}, {97, 98, 41}, {99, 99, 110}, {100, 122, 41}, }, + {{36, 114, -52}, {115, 115, 111}, {116, 122, 41}, }, + {{36, 95, -7}, {97, 119, 41}, {120, 120, 112}, {121, 122, 41}, }, + {{36, 114, -52}, {115, 115, 113}, {116, 122, 41}, }, + {{36, 98, -105}, {99, 99, 114}, {100, 122, 41}, }, + {{36, 114, -52}, {115, 115, 115}, {116, 122, 41}, }, + {{36, 99, -79}, {100, 100, 116}, {101, 122, 41}, }, + {{36, 115, -29}, {116, 116, 117}, {117, 122, 41}, }, + {{36, 122, -7}, }, + {{36, 122, -7}, }, + {{36, 122, -7}, }, + {{36, 115, -29}, {116, 116, 118}, {117, 122, 41}, }, + {{36, 122, -7}, }, + {{36, 122, -7}, }, + {{36, 95, -7}, {97, 104, 41}, {105, 105, 119}, {106, 122, 41}, }, + {{36, 122, -7}, }, + {{36, 110, -30}, {111, 111, 120}, {112, 122, 41}, }, + {{36, 109, -54}, {110, 110, 121}, {111, 122, 41}, }, + {{36, 114, -52}, {115, 115, 122}, {116, 122, 41}, }, + {{36, 122, -7}, }, + } + };*/ + + private static int[][] accept; + /* { + // NORMAL + {-1, 38, 38, 38, 38, -1, 20, 21, 27, 24, 29, 25, 14, 30, 35, 35, 32, 16, 17, 26, -1, -1, -1, -1, 13, -1, 12, 18, 19, 33, 22, 28, 23, 38, -1, -1, 31, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, 33, -1, 34, 34, -1, -1, -1, 39, 39, 36, -1, -1, -1, 10, -1, -1, -1, -1, -1, -1, -1, 33, 37, -1, 39, 39, -1, -1, -1, 11, -1, -1, -1, -1, -1, 9, 33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 8, 4, -1, 3, 5, 1, -1, 7, -1, -1, -1, 6, }, + // PACKAGE + {-1, 38, 38, 38, 38, 0, -1, 20, 21, 27, 24, 29, 25, 14, 30, 35, 35, 32, 16, 17, 26, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 0, 0, 22, 28, 23, 38, 0, 0, 0, 0, 0, -1, -1, 31, 15, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 34, 34, -1, -1, -1, 39, 39, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, -1, 39, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, + + };*/ + + public static class State + { + public final static State NORMAL = new State(0); + public final static State PACKAGE = new State(1); + + private int id; + + private State(int id) + { + this.id = id; + } + + public int id() + { + return id; + } + } + + static + { + try + { + DataInputStream s = new DataInputStream( + new BufferedInputStream( + Lexer.class.getResourceAsStream("lexer.dat"))); + + // read gotoTable + int length = s.readInt(); + gotoTable = new int[length][][][]; + for(int i = 0; i < gotoTable.length; i++) + { + length = s.readInt(); + gotoTable[i] = new int[length][][]; + for(int j = 0; j < gotoTable[i].length; j++) + { + length = s.readInt(); + gotoTable[i][j] = new int[length][3]; + for(int k = 0; k < gotoTable[i][j].length; k++) + { + for(int l = 0; l < 3; l++) + { + gotoTable[i][j][k][l] = s.readInt(); + } + } + } + } + + // read accept + length = s.readInt(); + accept = new int[length][]; + for(int i = 0; i < accept.length; i++) + { + length = s.readInt(); + accept[i] = new int[length]; + for(int j = 0; j < accept[i].length; j++) + { + accept[i][j] = s.readInt(); + } + } + + s.close(); + } + catch(Exception e) + { + throw new RuntimeException("The file \"lexer.dat\" is either missing or corrupted."); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/lexer/LexerException.java b/src/main/java/org/sablecc/sablecc/lexer/LexerException.java new file mode 100644 index 0000000..3e888e4 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/lexer/LexerException.java @@ -0,0 +1,11 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.lexer; + +public class LexerException extends Exception +{ + public LexerException(String message) + { + super(message); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AAlt.java b/src/main/java/org/sablecc/sablecc/node/AAlt.java new file mode 100644 index 0000000..97b1e8c --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AAlt.java @@ -0,0 +1,189 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AAlt extends PAlt +{ + private TId _altName_; + private final LinkedList _elems_ = new TypedLinkedList(new Elems_Cast()); + private PAltTransform _altTransform_; + + public AAlt() + {} + + public AAlt( + TId _altName_, + List _elems_, + PAltTransform _altTransform_) + { + setAltName(_altName_); + + { + this._elems_.clear(); + this._elems_.addAll(_elems_); + } + + setAltTransform(_altTransform_); + + } + public Object clone() + { + return new AAlt( + (TId) cloneNode(_altName_), + cloneList(_elems_), + (PAltTransform) cloneNode(_altTransform_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAAlt(this); + } + + public TId getAltName() + { + return _altName_; + } + + public void setAltName(TId node) + { + if(_altName_ != null) + { + _altName_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _altName_ = node; + } + + public LinkedList getElems() + { + return _elems_; + } + + public void setElems(List list) + { + _elems_.clear(); + _elems_.addAll(list); + } + + public PAltTransform getAltTransform() + { + return _altTransform_; + } + + public void setAltTransform(PAltTransform node) + { + if(_altTransform_ != null) + { + _altTransform_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _altTransform_ = node; + } + + public String toString() + { + return "" + + toString(_altName_) + + toString(_elems_) + + toString(_altTransform_); + } + + void removeChild(Node child) + { + if(_altName_ == child) + { + _altName_ = null; + return; + } + + if(_elems_.remove(child)) + { + return; + } + + if(_altTransform_ == child) + { + _altTransform_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_altName_ == oldChild) + { + setAltName((TId) newChild); + return; + } + + for(ListIterator i = _elems_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + if(_altTransform_ == oldChild) + { + setAltTransform((PAltTransform) newChild); + return; + } + + } + + private class Elems_Cast implements Cast + { + public Object cast(Object o) + { + PElem node = (PElem) o; + + if((node.parent() != null) && + (node.parent() != AAlt.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AAlt.this)) + { + node.parent(AAlt.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AAltTransform.java b/src/main/java/org/sablecc/sablecc/node/AAltTransform.java new file mode 100644 index 0000000..2cd658d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AAltTransform.java @@ -0,0 +1,189 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AAltTransform extends PAltTransform +{ + private TLBrace _lBrace_; + private final LinkedList _terms_ = new TypedLinkedList(new Terms_Cast()); + private TRBrace _rBrace_; + + public AAltTransform() + {} + + public AAltTransform( + TLBrace _lBrace_, + List _terms_, + TRBrace _rBrace_) + { + setLBrace(_lBrace_); + + { + this._terms_.clear(); + this._terms_.addAll(_terms_); + } + + setRBrace(_rBrace_); + + } + public Object clone() + { + return new AAltTransform( + (TLBrace) cloneNode(_lBrace_), + cloneList(_terms_), + (TRBrace) cloneNode(_rBrace_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAAltTransform(this); + } + + public TLBrace getLBrace() + { + return _lBrace_; + } + + public void setLBrace(TLBrace node) + { + if(_lBrace_ != null) + { + _lBrace_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _lBrace_ = node; + } + + public LinkedList getTerms() + { + return _terms_; + } + + public void setTerms(List list) + { + _terms_.clear(); + _terms_.addAll(list); + } + + public TRBrace getRBrace() + { + return _rBrace_; + } + + public void setRBrace(TRBrace node) + { + if(_rBrace_ != null) + { + _rBrace_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _rBrace_ = node; + } + + public String toString() + { + return "" + + toString(_lBrace_) + + toString(_terms_) + + toString(_rBrace_); + } + + void removeChild(Node child) + { + if(_lBrace_ == child) + { + _lBrace_ = null; + return; + } + + if(_terms_.remove(child)) + { + return; + } + + if(_rBrace_ == child) + { + _rBrace_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_lBrace_ == oldChild) + { + setLBrace((TLBrace) newChild); + return; + } + + for(ListIterator i = _terms_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + if(_rBrace_ == oldChild) + { + setRBrace((TRBrace) newChild); + return; + } + + } + + private class Terms_Cast implements Cast + { + public Object cast(Object o) + { + PTerm node = (PTerm) o; + + if((node.parent() != null) && + (node.parent() != AAltTransform.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AAltTransform.this)) + { + node.parent(AAltTransform.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AAst.java b/src/main/java/org/sablecc/sablecc/node/AAst.java new file mode 100644 index 0000000..a7b682b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AAst.java @@ -0,0 +1,103 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AAst extends PAst +{ + private final LinkedList _prods_ = new TypedLinkedList(new Prods_Cast()); + + public AAst() + {} + + public AAst( + List _prods_) + { + { + this._prods_.clear(); + this._prods_.addAll(_prods_); + } + + } + public Object clone() + { + return new AAst( + cloneList(_prods_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAAst(this); + } + + public LinkedList getProds() + { + return _prods_; + } + + public void setProds(List list) + { + _prods_.clear(); + _prods_.addAll(list); + } + + public String toString() + { + return "" + + toString(_prods_); + } + + void removeChild(Node child) + { + if(_prods_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _prods_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class Prods_Cast implements Cast + { + public Object cast(Object o) + { + PAstProd node = (PAstProd) o; + + if((node.parent() != null) && + (node.parent() != AAst.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AAst.this)) + { + node.parent(AAst.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AAstAlt.java b/src/main/java/org/sablecc/sablecc/node/AAstAlt.java new file mode 100644 index 0000000..d47495f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AAstAlt.java @@ -0,0 +1,146 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AAstAlt extends PAstAlt +{ + private TId _altName_; + private final LinkedList _elems_ = new TypedLinkedList(new Elems_Cast()); + + public AAstAlt() + {} + + public AAstAlt( + TId _altName_, + List _elems_) + { + setAltName(_altName_); + + { + this._elems_.clear(); + this._elems_.addAll(_elems_); + } + + } + public Object clone() + { + return new AAstAlt( + (TId) cloneNode(_altName_), + cloneList(_elems_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAAstAlt(this); + } + + public TId getAltName() + { + return _altName_; + } + + public void setAltName(TId node) + { + if(_altName_ != null) + { + _altName_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _altName_ = node; + } + + public LinkedList getElems() + { + return _elems_; + } + + public void setElems(List list) + { + _elems_.clear(); + _elems_.addAll(list); + } + + public String toString() + { + return "" + + toString(_altName_) + + toString(_elems_); + } + + void removeChild(Node child) + { + if(_altName_ == child) + { + _altName_ = null; + return; + } + + if(_elems_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_altName_ == oldChild) + { + setAltName((TId) newChild); + return; + } + + for(ListIterator i = _elems_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class Elems_Cast implements Cast + { + public Object cast(Object o) + { + PElem node = (PElem) o; + + if((node.parent() != null) && + (node.parent() != AAstAlt.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AAstAlt.this)) + { + node.parent(AAstAlt.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AAstProd.java b/src/main/java/org/sablecc/sablecc/node/AAstProd.java new file mode 100644 index 0000000..85ee56f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AAstProd.java @@ -0,0 +1,146 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AAstProd extends PAstProd +{ + private TId _id_; + private final LinkedList _alts_ = new TypedLinkedList(new Alts_Cast()); + + public AAstProd() + {} + + public AAstProd( + TId _id_, + List _alts_) + { + setId(_id_); + + { + this._alts_.clear(); + this._alts_.addAll(_alts_); + } + + } + public Object clone() + { + return new AAstProd( + (TId) cloneNode(_id_), + cloneList(_alts_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAAstProd(this); + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public LinkedList getAlts() + { + return _alts_; + } + + public void setAlts(List list) + { + _alts_.clear(); + _alts_.addAll(list); + } + + public String toString() + { + return "" + + toString(_id_) + + toString(_alts_); + } + + void removeChild(Node child) + { + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_alts_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + for(ListIterator i = _alts_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class Alts_Cast implements Cast + { + public Object cast(Object o) + { + PAstAlt node = (PAstAlt) o; + + if((node.parent() != null) && + (node.parent() != AAstProd.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AAstProd.this)) + { + node.parent(AAstProd.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ACharBasic.java b/src/main/java/org/sablecc/sablecc/node/ACharBasic.java new file mode 100644 index 0000000..e0c320a --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ACharBasic.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ACharBasic extends PBasic +{ + private PChar _char_; + + public ACharBasic() + {} + + public ACharBasic( + PChar _char_) + { + setChar(_char_); + + } + public Object clone() + { + return new ACharBasic( + (PChar) cloneNode(_char_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseACharBasic(this); + } + + public PChar getChar() + { + return _char_; + } + + public void setChar(PChar node) + { + if(_char_ != null) + { + _char_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _char_ = node; + } + + public String toString() + { + return "" + + toString(_char_); + } + + void removeChild(Node child) + { + if(_char_ == child) + { + _char_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_char_ == oldChild) + { + setChar((PChar) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ACharChar.java b/src/main/java/org/sablecc/sablecc/node/ACharChar.java new file mode 100644 index 0000000..e7cd222 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ACharChar.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ACharChar extends PChar +{ + private TChar _char_; + + public ACharChar() + {} + + public ACharChar( + TChar _char_) + { + setChar(_char_); + + } + public Object clone() + { + return new ACharChar( + (TChar) cloneNode(_char_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseACharChar(this); + } + + public TChar getChar() + { + return _char_; + } + + public void setChar(TChar node) + { + if(_char_ != null) + { + _char_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _char_ = node; + } + + public String toString() + { + return "" + + toString(_char_); + } + + void removeChild(Node child) + { + if(_char_ == child) + { + _char_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_char_ == oldChild) + { + setChar((TChar) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AConcat.java b/src/main/java/org/sablecc/sablecc/node/AConcat.java new file mode 100644 index 0000000..41a8d0b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AConcat.java @@ -0,0 +1,103 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AConcat extends PConcat +{ + private final LinkedList _unExps_ = new TypedLinkedList(new UnExps_Cast()); + + public AConcat() + {} + + public AConcat( + List _unExps_) + { + { + this._unExps_.clear(); + this._unExps_.addAll(_unExps_); + } + + } + public Object clone() + { + return new AConcat( + cloneList(_unExps_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAConcat(this); + } + + public LinkedList getUnExps() + { + return _unExps_; + } + + public void setUnExps(List list) + { + _unExps_.clear(); + _unExps_.addAll(list); + } + + public String toString() + { + return "" + + toString(_unExps_); + } + + void removeChild(Node child) + { + if(_unExps_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _unExps_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class UnExps_Cast implements Cast + { + public Object cast(Object o) + { + PUnExp node = (PUnExp) o; + + if((node.parent() != null) && + (node.parent() != AConcat.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AConcat.this)) + { + node.parent(AConcat.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ADecChar.java b/src/main/java/org/sablecc/sablecc/node/ADecChar.java new file mode 100644 index 0000000..6807187 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ADecChar.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ADecChar extends PChar +{ + private TDecChar _decChar_; + + public ADecChar() + {} + + public ADecChar( + TDecChar _decChar_) + { + setDecChar(_decChar_); + + } + public Object clone() + { + return new ADecChar( + (TDecChar) cloneNode(_decChar_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseADecChar(this); + } + + public TDecChar getDecChar() + { + return _decChar_; + } + + public void setDecChar(TDecChar node) + { + if(_decChar_ != null) + { + _decChar_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _decChar_ = node; + } + + public String toString() + { + return "" + + toString(_decChar_); + } + + void removeChild(Node child) + { + if(_decChar_ == child) + { + _decChar_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_decChar_ == oldChild) + { + setDecChar((TDecChar) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AElem.java b/src/main/java/org/sablecc/sablecc/node/AElem.java new file mode 100644 index 0000000..891d0b6 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AElem.java @@ -0,0 +1,211 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AElem extends PElem +{ + private TId _elemName_; + private PSpecifier _specifier_; + private TId _id_; + private PUnOp _unOp_; + + public AElem() + {} + + public AElem( + TId _elemName_, + PSpecifier _specifier_, + TId _id_, + PUnOp _unOp_) + { + setElemName(_elemName_); + + setSpecifier(_specifier_); + + setId(_id_); + + setUnOp(_unOp_); + + } + public Object clone() + { + return new AElem( + (TId) cloneNode(_elemName_), + (PSpecifier) cloneNode(_specifier_), + (TId) cloneNode(_id_), + (PUnOp) cloneNode(_unOp_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAElem(this); + } + + public TId getElemName() + { + return _elemName_; + } + + public void setElemName(TId node) + { + if(_elemName_ != null) + { + _elemName_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _elemName_ = node; + } + + public PSpecifier getSpecifier() + { + return _specifier_; + } + + public void setSpecifier(PSpecifier node) + { + if(_specifier_ != null) + { + _specifier_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _specifier_ = node; + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public PUnOp getUnOp() + { + return _unOp_; + } + + public void setUnOp(PUnOp node) + { + if(_unOp_ != null) + { + _unOp_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _unOp_ = node; + } + + public String toString() + { + return "" + + toString(_elemName_) + + toString(_specifier_) + + toString(_id_) + + toString(_unOp_); + } + + void removeChild(Node child) + { + if(_elemName_ == child) + { + _elemName_ = null; + return; + } + + if(_specifier_ == child) + { + _specifier_ = null; + return; + } + + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_unOp_ == child) + { + _unOp_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_elemName_ == oldChild) + { + setElemName((TId) newChild); + return; + } + + if(_specifier_ == oldChild) + { + setSpecifier((PSpecifier) newChild); + return; + } + + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_unOp_ == oldChild) + { + setUnOp((PUnOp) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AGrammar.java b/src/main/java/org/sablecc/sablecc/node/AGrammar.java new file mode 100644 index 0000000..c8b4fb3 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AGrammar.java @@ -0,0 +1,361 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AGrammar extends PGrammar +{ + private final LinkedList _package_ = new TypedLinkedList(new Package_Cast()); + private PHelpers _helpers_; + private PStates _states_; + private PTokens _tokens_; + private PIgnTokens _ignTokens_; + private PProductions _productions_; + private PAst _ast_; + + public AGrammar() + {} + + public AGrammar( + List _package_, + PHelpers _helpers_, + PStates _states_, + PTokens _tokens_, + PIgnTokens _ignTokens_, + PProductions _productions_, + PAst _ast_) + { + { + this._package_.clear(); + this._package_.addAll(_package_); + } + + setHelpers(_helpers_); + + setStates(_states_); + + setTokens(_tokens_); + + setIgnTokens(_ignTokens_); + + setProductions(_productions_); + + setAst(_ast_); + + } + public Object clone() + { + return new AGrammar( + cloneList(_package_), + (PHelpers) cloneNode(_helpers_), + (PStates) cloneNode(_states_), + (PTokens) cloneNode(_tokens_), + (PIgnTokens) cloneNode(_ignTokens_), + (PProductions) cloneNode(_productions_), + (PAst) cloneNode(_ast_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAGrammar(this); + } + + public LinkedList getPackage() + { + return _package_; + } + + public void setPackage(List list) + { + _package_.clear(); + _package_.addAll(list); + } + + public PHelpers getHelpers() + { + return _helpers_; + } + + public void setHelpers(PHelpers node) + { + if(_helpers_ != null) + { + _helpers_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _helpers_ = node; + } + + public PStates getStates() + { + return _states_; + } + + public void setStates(PStates node) + { + if(_states_ != null) + { + _states_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _states_ = node; + } + + public PTokens getTokens() + { + return _tokens_; + } + + public void setTokens(PTokens node) + { + if(_tokens_ != null) + { + _tokens_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _tokens_ = node; + } + + public PIgnTokens getIgnTokens() + { + return _ignTokens_; + } + + public void setIgnTokens(PIgnTokens node) + { + if(_ignTokens_ != null) + { + _ignTokens_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _ignTokens_ = node; + } + + public PProductions getProductions() + { + return _productions_; + } + + public void setProductions(PProductions node) + { + if(_productions_ != null) + { + _productions_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _productions_ = node; + } + + public PAst getAst() + { + return _ast_; + } + + public void setAst(PAst node) + { + if(_ast_ != null) + { + _ast_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _ast_ = node; + } + + public String toString() + { + return "" + + toString(_package_) + + toString(_helpers_) + + toString(_states_) + + toString(_tokens_) + + toString(_ignTokens_) + + toString(_productions_) + + toString(_ast_); + } + + void removeChild(Node child) + { + if(_package_.remove(child)) + { + return; + } + + if(_helpers_ == child) + { + _helpers_ = null; + return; + } + + if(_states_ == child) + { + _states_ = null; + return; + } + + if(_tokens_ == child) + { + _tokens_ = null; + return; + } + + if(_ignTokens_ == child) + { + _ignTokens_ = null; + return; + } + + if(_productions_ == child) + { + _productions_ = null; + return; + } + + if(_ast_ == child) + { + _ast_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _package_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + if(_helpers_ == oldChild) + { + setHelpers((PHelpers) newChild); + return; + } + + if(_states_ == oldChild) + { + setStates((PStates) newChild); + return; + } + + if(_tokens_ == oldChild) + { + setTokens((PTokens) newChild); + return; + } + + if(_ignTokens_ == oldChild) + { + setIgnTokens((PIgnTokens) newChild); + return; + } + + if(_productions_ == oldChild) + { + setProductions((PProductions) newChild); + return; + } + + if(_ast_ == oldChild) + { + setAst((PAst) newChild); + return; + } + + } + + private class Package_Cast implements Cast + { + public Object cast(Object o) + { + TPkgId node = (TPkgId) o; + + if((node.parent() != null) && + (node.parent() != AGrammar.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AGrammar.this)) + { + node.parent(AGrammar.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AHelperDef.java b/src/main/java/org/sablecc/sablecc/node/AHelperDef.java new file mode 100644 index 0000000..d9cff12 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AHelperDef.java @@ -0,0 +1,125 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AHelperDef extends PHelperDef +{ + private TId _id_; + private PRegExp _regExp_; + + public AHelperDef() + {} + + public AHelperDef( + TId _id_, + PRegExp _regExp_) + { + setId(_id_); + + setRegExp(_regExp_); + + } + public Object clone() + { + return new AHelperDef( + (TId) cloneNode(_id_), + (PRegExp) cloneNode(_regExp_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAHelperDef(this); + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public PRegExp getRegExp() + { + return _regExp_; + } + + public void setRegExp(PRegExp node) + { + if(_regExp_ != null) + { + _regExp_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _regExp_ = node; + } + + public String toString() + { + return "" + + toString(_id_) + + toString(_regExp_); + } + + void removeChild(Node child) + { + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_regExp_ == child) + { + _regExp_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_regExp_ == oldChild) + { + setRegExp((PRegExp) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AHelpers.java b/src/main/java/org/sablecc/sablecc/node/AHelpers.java new file mode 100644 index 0000000..0b9caec --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AHelpers.java @@ -0,0 +1,103 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AHelpers extends PHelpers +{ + private final LinkedList _helperDefs_ = new TypedLinkedList(new HelperDefs_Cast()); + + public AHelpers() + {} + + public AHelpers( + List _helperDefs_) + { + { + this._helperDefs_.clear(); + this._helperDefs_.addAll(_helperDefs_); + } + + } + public Object clone() + { + return new AHelpers( + cloneList(_helperDefs_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAHelpers(this); + } + + public LinkedList getHelperDefs() + { + return _helperDefs_; + } + + public void setHelperDefs(List list) + { + _helperDefs_.clear(); + _helperDefs_.addAll(list); + } + + public String toString() + { + return "" + + toString(_helperDefs_); + } + + void removeChild(Node child) + { + if(_helperDefs_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _helperDefs_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class HelperDefs_Cast implements Cast + { + public Object cast(Object o) + { + PHelperDef node = (PHelperDef) o; + + if((node.parent() != null) && + (node.parent() != AHelpers.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AHelpers.this)) + { + node.parent(AHelpers.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AHexChar.java b/src/main/java/org/sablecc/sablecc/node/AHexChar.java new file mode 100644 index 0000000..8d047cf --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AHexChar.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AHexChar extends PChar +{ + private THexChar _hexChar_; + + public AHexChar() + {} + + public AHexChar( + THexChar _hexChar_) + { + setHexChar(_hexChar_); + + } + public Object clone() + { + return new AHexChar( + (THexChar) cloneNode(_hexChar_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAHexChar(this); + } + + public THexChar getHexChar() + { + return _hexChar_; + } + + public void setHexChar(THexChar node) + { + if(_hexChar_ != null) + { + _hexChar_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _hexChar_ = node; + } + + public String toString() + { + return "" + + toString(_hexChar_); + } + + void removeChild(Node child) + { + if(_hexChar_ == child) + { + _hexChar_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_hexChar_ == oldChild) + { + setHexChar((THexChar) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AIdBasic.java b/src/main/java/org/sablecc/sablecc/node/AIdBasic.java new file mode 100644 index 0000000..a3ea1f7 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AIdBasic.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AIdBasic extends PBasic +{ + private TId _id_; + + public AIdBasic() + {} + + public AIdBasic( + TId _id_) + { + setId(_id_); + + } + public Object clone() + { + return new AIdBasic( + (TId) cloneNode(_id_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAIdBasic(this); + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public String toString() + { + return "" + + toString(_id_); + } + + void removeChild(Node child) + { + if(_id_ == child) + { + _id_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AIgnTokens.java b/src/main/java/org/sablecc/sablecc/node/AIgnTokens.java new file mode 100644 index 0000000..872eb27 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AIgnTokens.java @@ -0,0 +1,103 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AIgnTokens extends PIgnTokens +{ + private final LinkedList _listId_ = new TypedLinkedList(new ListId_Cast()); + + public AIgnTokens() + {} + + public AIgnTokens( + List _listId_) + { + { + this._listId_.clear(); + this._listId_.addAll(_listId_); + } + + } + public Object clone() + { + return new AIgnTokens( + cloneList(_listId_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAIgnTokens(this); + } + + public LinkedList getListId() + { + return _listId_; + } + + public void setListId(List list) + { + _listId_.clear(); + _listId_.addAll(list); + } + + public String toString() + { + return "" + + toString(_listId_); + } + + void removeChild(Node child) + { + if(_listId_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _listId_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class ListId_Cast implements Cast + { + public Object cast(Object o) + { + TId node = (TId) o; + + if((node.parent() != null) && + (node.parent() != AIgnTokens.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AIgnTokens.this)) + { + node.parent(AIgnTokens.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AIntervalSet.java b/src/main/java/org/sablecc/sablecc/node/AIntervalSet.java new file mode 100644 index 0000000..d9c40f9 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AIntervalSet.java @@ -0,0 +1,125 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AIntervalSet extends PSet +{ + private PChar _left_; + private PChar _right_; + + public AIntervalSet() + {} + + public AIntervalSet( + PChar _left_, + PChar _right_) + { + setLeft(_left_); + + setRight(_right_); + + } + public Object clone() + { + return new AIntervalSet( + (PChar) cloneNode(_left_), + (PChar) cloneNode(_right_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAIntervalSet(this); + } + + public PChar getLeft() + { + return _left_; + } + + public void setLeft(PChar node) + { + if(_left_ != null) + { + _left_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _left_ = node; + } + + public PChar getRight() + { + return _right_; + } + + public void setRight(PChar node) + { + if(_right_ != null) + { + _right_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _right_ = node; + } + + public String toString() + { + return "" + + toString(_left_) + + toString(_right_); + } + + void removeChild(Node child) + { + if(_left_ == child) + { + _left_ = null; + return; + } + + if(_right_ == child) + { + _right_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_left_ == oldChild) + { + setLeft((PChar) newChild); + return; + } + + if(_right_ == oldChild) + { + setRight((PChar) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AListTerm.java b/src/main/java/org/sablecc/sablecc/node/AListTerm.java new file mode 100644 index 0000000..7a0a593 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AListTerm.java @@ -0,0 +1,146 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AListTerm extends PTerm +{ + private TLBkt _lBkt_; + private final LinkedList _listTerms_ = new TypedLinkedList(new ListTerms_Cast()); + + public AListTerm() + {} + + public AListTerm( + TLBkt _lBkt_, + List _listTerms_) + { + setLBkt(_lBkt_); + + { + this._listTerms_.clear(); + this._listTerms_.addAll(_listTerms_); + } + + } + public Object clone() + { + return new AListTerm( + (TLBkt) cloneNode(_lBkt_), + cloneList(_listTerms_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAListTerm(this); + } + + public TLBkt getLBkt() + { + return _lBkt_; + } + + public void setLBkt(TLBkt node) + { + if(_lBkt_ != null) + { + _lBkt_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _lBkt_ = node; + } + + public LinkedList getListTerms() + { + return _listTerms_; + } + + public void setListTerms(List list) + { + _listTerms_.clear(); + _listTerms_.addAll(list); + } + + public String toString() + { + return "" + + toString(_lBkt_) + + toString(_listTerms_); + } + + void removeChild(Node child) + { + if(_lBkt_ == child) + { + _lBkt_ = null; + return; + } + + if(_listTerms_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_lBkt_ == oldChild) + { + setLBkt((TLBkt) newChild); + return; + } + + for(ListIterator i = _listTerms_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class ListTerms_Cast implements Cast + { + public Object cast(Object o) + { + PListTerm node = (PListTerm) o; + + if((node.parent() != null) && + (node.parent() != AListTerm.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AListTerm.this)) + { + node.parent(AListTerm.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AMinusBinOp.java b/src/main/java/org/sablecc/sablecc/node/AMinusBinOp.java new file mode 100644 index 0000000..b79f005 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AMinusBinOp.java @@ -0,0 +1,33 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AMinusBinOp extends PBinOp +{ + + public AMinusBinOp() + {} + public Object clone() + { + return new AMinusBinOp(); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAMinusBinOp(this); + } + + public String toString() + { + return ""; + } + + void removeChild(Node child) + {} + + void replaceChild(Node oldChild, Node newChild) + {} +} diff --git a/src/main/java/org/sablecc/sablecc/node/ANewListTerm.java b/src/main/java/org/sablecc/sablecc/node/ANewListTerm.java new file mode 100644 index 0000000..82e42e7 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ANewListTerm.java @@ -0,0 +1,189 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ANewListTerm extends PListTerm +{ + private PProdName _prodName_; + private TLPar _lPar_; + private final LinkedList _params_ = new TypedLinkedList(new Params_Cast()); + + public ANewListTerm() + {} + + public ANewListTerm( + PProdName _prodName_, + TLPar _lPar_, + List _params_) + { + setProdName(_prodName_); + + setLPar(_lPar_); + + { + this._params_.clear(); + this._params_.addAll(_params_); + } + + } + public Object clone() + { + return new ANewListTerm( + (PProdName) cloneNode(_prodName_), + (TLPar) cloneNode(_lPar_), + cloneList(_params_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseANewListTerm(this); + } + + public PProdName getProdName() + { + return _prodName_; + } + + public void setProdName(PProdName node) + { + if(_prodName_ != null) + { + _prodName_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _prodName_ = node; + } + + public TLPar getLPar() + { + return _lPar_; + } + + public void setLPar(TLPar node) + { + if(_lPar_ != null) + { + _lPar_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _lPar_ = node; + } + + public LinkedList getParams() + { + return _params_; + } + + public void setParams(List list) + { + _params_.clear(); + _params_.addAll(list); + } + + public String toString() + { + return "" + + toString(_prodName_) + + toString(_lPar_) + + toString(_params_); + } + + void removeChild(Node child) + { + if(_prodName_ == child) + { + _prodName_ = null; + return; + } + + if(_lPar_ == child) + { + _lPar_ = null; + return; + } + + if(_params_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_prodName_ == oldChild) + { + setProdName((PProdName) newChild); + return; + } + + if(_lPar_ == oldChild) + { + setLPar((TLPar) newChild); + return; + } + + for(ListIterator i = _params_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class Params_Cast implements Cast + { + public Object cast(Object o) + { + PTerm node = (PTerm) o; + + if((node.parent() != null) && + (node.parent() != ANewListTerm.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != ANewListTerm.this)) + { + node.parent(ANewListTerm.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ANewTerm.java b/src/main/java/org/sablecc/sablecc/node/ANewTerm.java new file mode 100644 index 0000000..bf8afbb --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ANewTerm.java @@ -0,0 +1,189 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ANewTerm extends PTerm +{ + private PProdName _prodName_; + private TLPar _lPar_; + private final LinkedList _params_ = new TypedLinkedList(new Params_Cast()); + + public ANewTerm() + {} + + public ANewTerm( + PProdName _prodName_, + TLPar _lPar_, + List _params_) + { + setProdName(_prodName_); + + setLPar(_lPar_); + + { + this._params_.clear(); + this._params_.addAll(_params_); + } + + } + public Object clone() + { + return new ANewTerm( + (PProdName) cloneNode(_prodName_), + (TLPar) cloneNode(_lPar_), + cloneList(_params_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseANewTerm(this); + } + + public PProdName getProdName() + { + return _prodName_; + } + + public void setProdName(PProdName node) + { + if(_prodName_ != null) + { + _prodName_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _prodName_ = node; + } + + public TLPar getLPar() + { + return _lPar_; + } + + public void setLPar(TLPar node) + { + if(_lPar_ != null) + { + _lPar_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _lPar_ = node; + } + + public LinkedList getParams() + { + return _params_; + } + + public void setParams(List list) + { + _params_.clear(); + _params_.addAll(list); + } + + public String toString() + { + return "" + + toString(_prodName_) + + toString(_lPar_) + + toString(_params_); + } + + void removeChild(Node child) + { + if(_prodName_ == child) + { + _prodName_ = null; + return; + } + + if(_lPar_ == child) + { + _lPar_ = null; + return; + } + + if(_params_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_prodName_ == oldChild) + { + setProdName((PProdName) newChild); + return; + } + + if(_lPar_ == oldChild) + { + setLPar((TLPar) newChild); + return; + } + + for(ListIterator i = _params_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class Params_Cast implements Cast + { + public Object cast(Object o) + { + PTerm node = (PTerm) o; + + if((node.parent() != null) && + (node.parent() != ANewTerm.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != ANewTerm.this)) + { + node.parent(ANewTerm.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ANullTerm.java b/src/main/java/org/sablecc/sablecc/node/ANullTerm.java new file mode 100644 index 0000000..cc08054 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ANullTerm.java @@ -0,0 +1,33 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ANullTerm extends PTerm +{ + + public ANullTerm() + {} + public Object clone() + { + return new ANullTerm(); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseANullTerm(this); + } + + public String toString() + { + return ""; + } + + void removeChild(Node child) + {} + + void replaceChild(Node oldChild, Node newChild) + {} +} diff --git a/src/main/java/org/sablecc/sablecc/node/AOperationSet.java b/src/main/java/org/sablecc/sablecc/node/AOperationSet.java new file mode 100644 index 0000000..722a3d1 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AOperationSet.java @@ -0,0 +1,168 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AOperationSet extends PSet +{ + private PBasic _left_; + private PBinOp _binOp_; + private PBasic _right_; + + public AOperationSet() + {} + + public AOperationSet( + PBasic _left_, + PBinOp _binOp_, + PBasic _right_) + { + setLeft(_left_); + + setBinOp(_binOp_); + + setRight(_right_); + + } + public Object clone() + { + return new AOperationSet( + (PBasic) cloneNode(_left_), + (PBinOp) cloneNode(_binOp_), + (PBasic) cloneNode(_right_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAOperationSet(this); + } + + public PBasic getLeft() + { + return _left_; + } + + public void setLeft(PBasic node) + { + if(_left_ != null) + { + _left_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _left_ = node; + } + + public PBinOp getBinOp() + { + return _binOp_; + } + + public void setBinOp(PBinOp node) + { + if(_binOp_ != null) + { + _binOp_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _binOp_ = node; + } + + public PBasic getRight() + { + return _right_; + } + + public void setRight(PBasic node) + { + if(_right_ != null) + { + _right_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _right_ = node; + } + + public String toString() + { + return "" + + toString(_left_) + + toString(_binOp_) + + toString(_right_); + } + + void removeChild(Node child) + { + if(_left_ == child) + { + _left_ = null; + return; + } + + if(_binOp_ == child) + { + _binOp_ = null; + return; + } + + if(_right_ == child) + { + _right_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_left_ == oldChild) + { + setLeft((PBasic) newChild); + return; + } + + if(_binOp_ == oldChild) + { + setBinOp((PBinOp) newChild); + return; + } + + if(_right_ == oldChild) + { + setRight((PBasic) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/APlusBinOp.java b/src/main/java/org/sablecc/sablecc/node/APlusBinOp.java new file mode 100644 index 0000000..047de4f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/APlusBinOp.java @@ -0,0 +1,33 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class APlusBinOp extends PBinOp +{ + + public APlusBinOp() + {} + public Object clone() + { + return new APlusBinOp(); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAPlusBinOp(this); + } + + public String toString() + { + return ""; + } + + void removeChild(Node child) + {} + + void replaceChild(Node oldChild, Node newChild) + {} +} diff --git a/src/main/java/org/sablecc/sablecc/node/APlusUnOp.java b/src/main/java/org/sablecc/sablecc/node/APlusUnOp.java new file mode 100644 index 0000000..1daee86 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/APlusUnOp.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class APlusUnOp extends PUnOp +{ + private TPlus _plus_; + + public APlusUnOp() + {} + + public APlusUnOp( + TPlus _plus_) + { + setPlus(_plus_); + + } + public Object clone() + { + return new APlusUnOp( + (TPlus) cloneNode(_plus_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAPlusUnOp(this); + } + + public TPlus getPlus() + { + return _plus_; + } + + public void setPlus(TPlus node) + { + if(_plus_ != null) + { + _plus_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _plus_ = node; + } + + public String toString() + { + return "" + + toString(_plus_); + } + + void removeChild(Node child) + { + if(_plus_ == child) + { + _plus_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_plus_ == oldChild) + { + setPlus((TPlus) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AProd.java b/src/main/java/org/sablecc/sablecc/node/AProd.java new file mode 100644 index 0000000..53c37b6 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AProd.java @@ -0,0 +1,253 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AProd extends PProd +{ + private TId _id_; + private TArrow _arrow_; + private final LinkedList _prodTransform_ = new TypedLinkedList(new ProdTransform_Cast()); + private final LinkedList _alts_ = new TypedLinkedList(new Alts_Cast()); + + public AProd() + {} + + public AProd( + TId _id_, + TArrow _arrow_, + List _prodTransform_, + List _alts_) + { + setId(_id_); + + setArrow(_arrow_); + + { + this._prodTransform_.clear(); + this._prodTransform_.addAll(_prodTransform_); + } + + { + this._alts_.clear(); + this._alts_.addAll(_alts_); + } + + } + public Object clone() + { + return new AProd( + (TId) cloneNode(_id_), + (TArrow) cloneNode(_arrow_), + cloneList(_prodTransform_), + cloneList(_alts_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAProd(this); + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public TArrow getArrow() + { + return _arrow_; + } + + public void setArrow(TArrow node) + { + if(_arrow_ != null) + { + _arrow_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _arrow_ = node; + } + + public LinkedList getProdTransform() + { + return _prodTransform_; + } + + public void setProdTransform(List list) + { + _prodTransform_.clear(); + _prodTransform_.addAll(list); + } + + public LinkedList getAlts() + { + return _alts_; + } + + public void setAlts(List list) + { + _alts_.clear(); + _alts_.addAll(list); + } + + public String toString() + { + return "" + + toString(_id_) + + toString(_arrow_) + + toString(_prodTransform_) + + toString(_alts_); + } + + void removeChild(Node child) + { + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_arrow_ == child) + { + _arrow_ = null; + return; + } + + if(_prodTransform_.remove(child)) + { + return; + } + + if(_alts_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_arrow_ == oldChild) + { + setArrow((TArrow) newChild); + return; + } + + for(ListIterator i = _prodTransform_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + for(ListIterator i = _alts_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class ProdTransform_Cast implements Cast + { + public Object cast(Object o) + { + PElem node = (PElem) o; + + if((node.parent() != null) && + (node.parent() != AProd.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AProd.this)) + { + node.parent(AProd.this); + } + + return node; + } + } + + private class Alts_Cast implements Cast + { + public Object cast(Object o) + { + PAlt node = (PAlt) o; + + if((node.parent() != null) && + (node.parent() != AProd.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AProd.this)) + { + node.parent(AProd.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AProdName.java b/src/main/java/org/sablecc/sablecc/node/AProdName.java new file mode 100644 index 0000000..03a3fa1 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AProdName.java @@ -0,0 +1,125 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AProdName extends PProdName +{ + private TId _id_; + private TId _prodNameTail_; + + public AProdName() + {} + + public AProdName( + TId _id_, + TId _prodNameTail_) + { + setId(_id_); + + setProdNameTail(_prodNameTail_); + + } + public Object clone() + { + return new AProdName( + (TId) cloneNode(_id_), + (TId) cloneNode(_prodNameTail_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAProdName(this); + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public TId getProdNameTail() + { + return _prodNameTail_; + } + + public void setProdNameTail(TId node) + { + if(_prodNameTail_ != null) + { + _prodNameTail_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _prodNameTail_ = node; + } + + public String toString() + { + return "" + + toString(_id_) + + toString(_prodNameTail_); + } + + void removeChild(Node child) + { + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_prodNameTail_ == child) + { + _prodNameTail_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_prodNameTail_ == oldChild) + { + setProdNameTail((TId) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AProductionSpecifier.java b/src/main/java/org/sablecc/sablecc/node/AProductionSpecifier.java new file mode 100644 index 0000000..75b2c2d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AProductionSpecifier.java @@ -0,0 +1,33 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AProductionSpecifier extends PSpecifier +{ + + public AProductionSpecifier() + {} + public Object clone() + { + return new AProductionSpecifier(); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAProductionSpecifier(this); + } + + public String toString() + { + return ""; + } + + void removeChild(Node child) + {} + + void replaceChild(Node oldChild, Node newChild) + {} +} diff --git a/src/main/java/org/sablecc/sablecc/node/AProductions.java b/src/main/java/org/sablecc/sablecc/node/AProductions.java new file mode 100644 index 0000000..f3d9fc8 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AProductions.java @@ -0,0 +1,103 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AProductions extends PProductions +{ + private final LinkedList _prods_ = new TypedLinkedList(new Prods_Cast()); + + public AProductions() + {} + + public AProductions( + List _prods_) + { + { + this._prods_.clear(); + this._prods_.addAll(_prods_); + } + + } + public Object clone() + { + return new AProductions( + cloneList(_prods_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAProductions(this); + } + + public LinkedList getProds() + { + return _prods_; + } + + public void setProds(List list) + { + _prods_.clear(); + _prods_.addAll(list); + } + + public String toString() + { + return "" + + toString(_prods_); + } + + void removeChild(Node child) + { + if(_prods_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _prods_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class Prods_Cast implements Cast + { + public Object cast(Object o) + { + PProd node = (PProd) o; + + if((node.parent() != null) && + (node.parent() != AProductions.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AProductions.this)) + { + node.parent(AProductions.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AQMarkUnOp.java b/src/main/java/org/sablecc/sablecc/node/AQMarkUnOp.java new file mode 100644 index 0000000..497cdf4 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AQMarkUnOp.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AQMarkUnOp extends PUnOp +{ + private TQMark _qMark_; + + public AQMarkUnOp() + {} + + public AQMarkUnOp( + TQMark _qMark_) + { + setQMark(_qMark_); + + } + public Object clone() + { + return new AQMarkUnOp( + (TQMark) cloneNode(_qMark_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAQMarkUnOp(this); + } + + public TQMark getQMark() + { + return _qMark_; + } + + public void setQMark(TQMark node) + { + if(_qMark_ != null) + { + _qMark_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _qMark_ = node; + } + + public String toString() + { + return "" + + toString(_qMark_); + } + + void removeChild(Node child) + { + if(_qMark_ == child) + { + _qMark_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_qMark_ == oldChild) + { + setQMark((TQMark) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ARegExp.java b/src/main/java/org/sablecc/sablecc/node/ARegExp.java new file mode 100644 index 0000000..d07a142 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ARegExp.java @@ -0,0 +1,103 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ARegExp extends PRegExp +{ + private final LinkedList _concats_ = new TypedLinkedList(new Concats_Cast()); + + public ARegExp() + {} + + public ARegExp( + List _concats_) + { + { + this._concats_.clear(); + this._concats_.addAll(_concats_); + } + + } + public Object clone() + { + return new ARegExp( + cloneList(_concats_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseARegExp(this); + } + + public LinkedList getConcats() + { + return _concats_; + } + + public void setConcats(List list) + { + _concats_.clear(); + _concats_.addAll(list); + } + + public String toString() + { + return "" + + toString(_concats_); + } + + void removeChild(Node child) + { + if(_concats_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _concats_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class Concats_Cast implements Cast + { + public Object cast(Object o) + { + PConcat node = (PConcat) o; + + if((node.parent() != null) && + (node.parent() != ARegExp.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != ARegExp.this)) + { + node.parent(ARegExp.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ARegExpBasic.java b/src/main/java/org/sablecc/sablecc/node/ARegExpBasic.java new file mode 100644 index 0000000..208d45a --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ARegExpBasic.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ARegExpBasic extends PBasic +{ + private PRegExp _regExp_; + + public ARegExpBasic() + {} + + public ARegExpBasic( + PRegExp _regExp_) + { + setRegExp(_regExp_); + + } + public Object clone() + { + return new ARegExpBasic( + (PRegExp) cloneNode(_regExp_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseARegExpBasic(this); + } + + public PRegExp getRegExp() + { + return _regExp_; + } + + public void setRegExp(PRegExp node) + { + if(_regExp_ != null) + { + _regExp_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _regExp_ = node; + } + + public String toString() + { + return "" + + toString(_regExp_); + } + + void removeChild(Node child) + { + if(_regExp_ == child) + { + _regExp_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_regExp_ == oldChild) + { + setRegExp((PRegExp) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ASetBasic.java b/src/main/java/org/sablecc/sablecc/node/ASetBasic.java new file mode 100644 index 0000000..eb4ad7f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ASetBasic.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ASetBasic extends PBasic +{ + private PSet _set_; + + public ASetBasic() + {} + + public ASetBasic( + PSet _set_) + { + setSet(_set_); + + } + public Object clone() + { + return new ASetBasic( + (PSet) cloneNode(_set_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseASetBasic(this); + } + + public PSet getSet() + { + return _set_; + } + + public void setSet(PSet node) + { + if(_set_ != null) + { + _set_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _set_ = node; + } + + public String toString() + { + return "" + + toString(_set_); + } + + void removeChild(Node child) + { + if(_set_ == child) + { + _set_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_set_ == oldChild) + { + setSet((PSet) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ASimpleListTerm.java b/src/main/java/org/sablecc/sablecc/node/ASimpleListTerm.java new file mode 100644 index 0000000..c97addb --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ASimpleListTerm.java @@ -0,0 +1,168 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ASimpleListTerm extends PListTerm +{ + private PSpecifier _specifier_; + private TId _id_; + private TId _simpleTermTail_; + + public ASimpleListTerm() + {} + + public ASimpleListTerm( + PSpecifier _specifier_, + TId _id_, + TId _simpleTermTail_) + { + setSpecifier(_specifier_); + + setId(_id_); + + setSimpleTermTail(_simpleTermTail_); + + } + public Object clone() + { + return new ASimpleListTerm( + (PSpecifier) cloneNode(_specifier_), + (TId) cloneNode(_id_), + (TId) cloneNode(_simpleTermTail_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseASimpleListTerm(this); + } + + public PSpecifier getSpecifier() + { + return _specifier_; + } + + public void setSpecifier(PSpecifier node) + { + if(_specifier_ != null) + { + _specifier_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _specifier_ = node; + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public TId getSimpleTermTail() + { + return _simpleTermTail_; + } + + public void setSimpleTermTail(TId node) + { + if(_simpleTermTail_ != null) + { + _simpleTermTail_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _simpleTermTail_ = node; + } + + public String toString() + { + return "" + + toString(_specifier_) + + toString(_id_) + + toString(_simpleTermTail_); + } + + void removeChild(Node child) + { + if(_specifier_ == child) + { + _specifier_ = null; + return; + } + + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_simpleTermTail_ == child) + { + _simpleTermTail_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_specifier_ == oldChild) + { + setSpecifier((PSpecifier) newChild); + return; + } + + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_simpleTermTail_ == oldChild) + { + setSimpleTermTail((TId) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ASimpleTerm.java b/src/main/java/org/sablecc/sablecc/node/ASimpleTerm.java new file mode 100644 index 0000000..2b03fb3 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ASimpleTerm.java @@ -0,0 +1,168 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ASimpleTerm extends PTerm +{ + private PSpecifier _specifier_; + private TId _id_; + private TId _simpleTermTail_; + + public ASimpleTerm() + {} + + public ASimpleTerm( + PSpecifier _specifier_, + TId _id_, + TId _simpleTermTail_) + { + setSpecifier(_specifier_); + + setId(_id_); + + setSimpleTermTail(_simpleTermTail_); + + } + public Object clone() + { + return new ASimpleTerm( + (PSpecifier) cloneNode(_specifier_), + (TId) cloneNode(_id_), + (TId) cloneNode(_simpleTermTail_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseASimpleTerm(this); + } + + public PSpecifier getSpecifier() + { + return _specifier_; + } + + public void setSpecifier(PSpecifier node) + { + if(_specifier_ != null) + { + _specifier_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _specifier_ = node; + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public TId getSimpleTermTail() + { + return _simpleTermTail_; + } + + public void setSimpleTermTail(TId node) + { + if(_simpleTermTail_ != null) + { + _simpleTermTail_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _simpleTermTail_ = node; + } + + public String toString() + { + return "" + + toString(_specifier_) + + toString(_id_) + + toString(_simpleTermTail_); + } + + void removeChild(Node child) + { + if(_specifier_ == child) + { + _specifier_ = null; + return; + } + + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_simpleTermTail_ == child) + { + _simpleTermTail_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_specifier_ == oldChild) + { + setSpecifier((PSpecifier) newChild); + return; + } + + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_simpleTermTail_ == oldChild) + { + setSimpleTermTail((TId) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AStarUnOp.java b/src/main/java/org/sablecc/sablecc/node/AStarUnOp.java new file mode 100644 index 0000000..2488d76 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AStarUnOp.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AStarUnOp extends PUnOp +{ + private TStar _star_; + + public AStarUnOp() + {} + + public AStarUnOp( + TStar _star_) + { + setStar(_star_); + + } + public Object clone() + { + return new AStarUnOp( + (TStar) cloneNode(_star_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAStarUnOp(this); + } + + public TStar getStar() + { + return _star_; + } + + public void setStar(TStar node) + { + if(_star_ != null) + { + _star_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _star_ = node; + } + + public String toString() + { + return "" + + toString(_star_); + } + + void removeChild(Node child) + { + if(_star_ == child) + { + _star_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_star_ == oldChild) + { + setStar((TStar) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AStateList.java b/src/main/java/org/sablecc/sablecc/node/AStateList.java new file mode 100644 index 0000000..1e87a23 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AStateList.java @@ -0,0 +1,189 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AStateList extends PStateList +{ + private TId _id_; + private PTransition _transition_; + private final LinkedList _stateLists_ = new TypedLinkedList(new StateLists_Cast()); + + public AStateList() + {} + + public AStateList( + TId _id_, + PTransition _transition_, + List _stateLists_) + { + setId(_id_); + + setTransition(_transition_); + + { + this._stateLists_.clear(); + this._stateLists_.addAll(_stateLists_); + } + + } + public Object clone() + { + return new AStateList( + (TId) cloneNode(_id_), + (PTransition) cloneNode(_transition_), + cloneList(_stateLists_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAStateList(this); + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public PTransition getTransition() + { + return _transition_; + } + + public void setTransition(PTransition node) + { + if(_transition_ != null) + { + _transition_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _transition_ = node; + } + + public LinkedList getStateLists() + { + return _stateLists_; + } + + public void setStateLists(List list) + { + _stateLists_.clear(); + _stateLists_.addAll(list); + } + + public String toString() + { + return "" + + toString(_id_) + + toString(_transition_) + + toString(_stateLists_); + } + + void removeChild(Node child) + { + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_transition_ == child) + { + _transition_ = null; + return; + } + + if(_stateLists_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_transition_ == oldChild) + { + setTransition((PTransition) newChild); + return; + } + + for(ListIterator i = _stateLists_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class StateLists_Cast implements Cast + { + public Object cast(Object o) + { + PStateListTail node = (PStateListTail) o; + + if((node.parent() != null) && + (node.parent() != AStateList.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AStateList.this)) + { + node.parent(AStateList.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AStateListTail.java b/src/main/java/org/sablecc/sablecc/node/AStateListTail.java new file mode 100644 index 0000000..c46e0bd --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AStateListTail.java @@ -0,0 +1,125 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AStateListTail extends PStateListTail +{ + private TId _id_; + private PTransition _transition_; + + public AStateListTail() + {} + + public AStateListTail( + TId _id_, + PTransition _transition_) + { + setId(_id_); + + setTransition(_transition_); + + } + public Object clone() + { + return new AStateListTail( + (TId) cloneNode(_id_), + (PTransition) cloneNode(_transition_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAStateListTail(this); + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public PTransition getTransition() + { + return _transition_; + } + + public void setTransition(PTransition node) + { + if(_transition_ != null) + { + _transition_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _transition_ = node; + } + + public String toString() + { + return "" + + toString(_id_) + + toString(_transition_); + } + + void removeChild(Node child) + { + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_transition_ == child) + { + _transition_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_transition_ == oldChild) + { + setTransition((PTransition) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AStates.java b/src/main/java/org/sablecc/sablecc/node/AStates.java new file mode 100644 index 0000000..ecbadc8 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AStates.java @@ -0,0 +1,103 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AStates extends PStates +{ + private final LinkedList _listId_ = new TypedLinkedList(new ListId_Cast()); + + public AStates() + {} + + public AStates( + List _listId_) + { + { + this._listId_.clear(); + this._listId_.addAll(_listId_); + } + + } + public Object clone() + { + return new AStates( + cloneList(_listId_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAStates(this); + } + + public LinkedList getListId() + { + return _listId_; + } + + public void setListId(List list) + { + _listId_.clear(); + _listId_.addAll(list); + } + + public String toString() + { + return "" + + toString(_listId_); + } + + void removeChild(Node child) + { + if(_listId_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _listId_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class ListId_Cast implements Cast + { + public Object cast(Object o) + { + TId node = (TId) o; + + if((node.parent() != null) && + (node.parent() != AStates.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != AStates.this)) + { + node.parent(AStates.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AStringBasic.java b/src/main/java/org/sablecc/sablecc/node/AStringBasic.java new file mode 100644 index 0000000..2d8f988 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AStringBasic.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AStringBasic extends PBasic +{ + private TString _string_; + + public AStringBasic() + {} + + public AStringBasic( + TString _string_) + { + setString(_string_); + + } + public Object clone() + { + return new AStringBasic( + (TString) cloneNode(_string_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAStringBasic(this); + } + + public TString getString() + { + return _string_; + } + + public void setString(TString node) + { + if(_string_ != null) + { + _string_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _string_ = node; + } + + public String toString() + { + return "" + + toString(_string_); + } + + void removeChild(Node child) + { + if(_string_ == child) + { + _string_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_string_ == oldChild) + { + setString((TString) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ATokenDef.java b/src/main/java/org/sablecc/sablecc/node/ATokenDef.java new file mode 100644 index 0000000..c52f52f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ATokenDef.java @@ -0,0 +1,254 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ATokenDef extends PTokenDef +{ + private PStateList _stateList_; + private TId _id_; + private PRegExp _regExp_; + private TSlash _slash_; + private PRegExp _lookAhead_; + + public ATokenDef() + {} + + public ATokenDef( + PStateList _stateList_, + TId _id_, + PRegExp _regExp_, + TSlash _slash_, + PRegExp _lookAhead_) + { + setStateList(_stateList_); + + setId(_id_); + + setRegExp(_regExp_); + + setSlash(_slash_); + + setLookAhead(_lookAhead_); + + } + public Object clone() + { + return new ATokenDef( + (PStateList) cloneNode(_stateList_), + (TId) cloneNode(_id_), + (PRegExp) cloneNode(_regExp_), + (TSlash) cloneNode(_slash_), + (PRegExp) cloneNode(_lookAhead_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseATokenDef(this); + } + + public PStateList getStateList() + { + return _stateList_; + } + + public void setStateList(PStateList node) + { + if(_stateList_ != null) + { + _stateList_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _stateList_ = node; + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public PRegExp getRegExp() + { + return _regExp_; + } + + public void setRegExp(PRegExp node) + { + if(_regExp_ != null) + { + _regExp_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _regExp_ = node; + } + + public TSlash getSlash() + { + return _slash_; + } + + public void setSlash(TSlash node) + { + if(_slash_ != null) + { + _slash_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _slash_ = node; + } + + public PRegExp getLookAhead() + { + return _lookAhead_; + } + + public void setLookAhead(PRegExp node) + { + if(_lookAhead_ != null) + { + _lookAhead_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _lookAhead_ = node; + } + + public String toString() + { + return "" + + toString(_stateList_) + + toString(_id_) + + toString(_regExp_) + + toString(_slash_) + + toString(_lookAhead_); + } + + void removeChild(Node child) + { + if(_stateList_ == child) + { + _stateList_ = null; + return; + } + + if(_id_ == child) + { + _id_ = null; + return; + } + + if(_regExp_ == child) + { + _regExp_ = null; + return; + } + + if(_slash_ == child) + { + _slash_ = null; + return; + } + + if(_lookAhead_ == child) + { + _lookAhead_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_stateList_ == oldChild) + { + setStateList((PStateList) newChild); + return; + } + + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + if(_regExp_ == oldChild) + { + setRegExp((PRegExp) newChild); + return; + } + + if(_slash_ == oldChild) + { + setSlash((TSlash) newChild); + return; + } + + if(_lookAhead_ == oldChild) + { + setLookAhead((PRegExp) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ATokenSpecifier.java b/src/main/java/org/sablecc/sablecc/node/ATokenSpecifier.java new file mode 100644 index 0000000..0828026 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ATokenSpecifier.java @@ -0,0 +1,33 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ATokenSpecifier extends PSpecifier +{ + + public ATokenSpecifier() + {} + public Object clone() + { + return new ATokenSpecifier(); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseATokenSpecifier(this); + } + + public String toString() + { + return ""; + } + + void removeChild(Node child) + {} + + void replaceChild(Node oldChild, Node newChild) + {} +} diff --git a/src/main/java/org/sablecc/sablecc/node/ATokens.java b/src/main/java/org/sablecc/sablecc/node/ATokens.java new file mode 100644 index 0000000..918c9c8 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ATokens.java @@ -0,0 +1,103 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ATokens extends PTokens +{ + private final LinkedList _tokenDefs_ = new TypedLinkedList(new TokenDefs_Cast()); + + public ATokens() + {} + + public ATokens( + List _tokenDefs_) + { + { + this._tokenDefs_.clear(); + this._tokenDefs_.addAll(_tokenDefs_); + } + + } + public Object clone() + { + return new ATokens( + cloneList(_tokenDefs_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseATokens(this); + } + + public LinkedList getTokenDefs() + { + return _tokenDefs_; + } + + public void setTokenDefs(List list) + { + _tokenDefs_.clear(); + _tokenDefs_.addAll(list); + } + + public String toString() + { + return "" + + toString(_tokenDefs_); + } + + void removeChild(Node child) + { + if(_tokenDefs_.remove(child)) + { + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + for(ListIterator i = _tokenDefs_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(newChild); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + } + + private class TokenDefs_Cast implements Cast + { + public Object cast(Object o) + { + PTokenDef node = (PTokenDef) o; + + if((node.parent() != null) && + (node.parent() != ATokens.this)) + { + node.parent().removeChild(node); + } + + if((node.parent() == null) || + (node.parent() != ATokens.this)) + { + node.parent(ATokens.this); + } + + return node; + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/ATransition.java b/src/main/java/org/sablecc/sablecc/node/ATransition.java new file mode 100644 index 0000000..ac6157f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/ATransition.java @@ -0,0 +1,82 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class ATransition extends PTransition +{ + private TId _id_; + + public ATransition() + {} + + public ATransition( + TId _id_) + { + setId(_id_); + + } + public Object clone() + { + return new ATransition( + (TId) cloneNode(_id_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseATransition(this); + } + + public TId getId() + { + return _id_; + } + + public void setId(TId node) + { + if(_id_ != null) + { + _id_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _id_ = node; + } + + public String toString() + { + return "" + + toString(_id_); + } + + void removeChild(Node child) + { + if(_id_ == child) + { + _id_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_id_ == oldChild) + { + setId((TId) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/AUnExp.java b/src/main/java/org/sablecc/sablecc/node/AUnExp.java new file mode 100644 index 0000000..b3ad503 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/AUnExp.java @@ -0,0 +1,125 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public final class AUnExp extends PUnExp +{ + private PBasic _basic_; + private PUnOp _unOp_; + + public AUnExp() + {} + + public AUnExp( + PBasic _basic_, + PUnOp _unOp_) + { + setBasic(_basic_); + + setUnOp(_unOp_); + + } + public Object clone() + { + return new AUnExp( + (PBasic) cloneNode(_basic_), + (PUnOp) cloneNode(_unOp_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseAUnExp(this); + } + + public PBasic getBasic() + { + return _basic_; + } + + public void setBasic(PBasic node) + { + if(_basic_ != null) + { + _basic_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _basic_ = node; + } + + public PUnOp getUnOp() + { + return _unOp_; + } + + public void setUnOp(PUnOp node) + { + if(_unOp_ != null) + { + _unOp_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _unOp_ = node; + } + + public String toString() + { + return "" + + toString(_basic_) + + toString(_unOp_); + } + + void removeChild(Node child) + { + if(_basic_ == child) + { + _basic_ = null; + return; + } + + if(_unOp_ == child) + { + _unOp_ = null; + return; + } + + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_basic_ == oldChild) + { + setBasic((PBasic) newChild); + return; + } + + if(_unOp_ == oldChild) + { + setUnOp((PUnOp) newChild); + return; + } + + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/Cast.java b/src/main/java/org/sablecc/sablecc/node/Cast.java new file mode 100644 index 0000000..920b94b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/Cast.java @@ -0,0 +1,8 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public interface Cast +{ + Object cast(Object o); +} diff --git a/src/main/java/org/sablecc/sablecc/node/EOF.java b/src/main/java/org/sablecc/sablecc/node/EOF.java new file mode 100644 index 0000000..0133752 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/EOF.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class EOF extends Token +{ + public EOF() + { + setText(""); + } + + public EOF(int line, int pos) + { + setText(""); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new EOF(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseEOF(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/NoCast.java b/src/main/java/org/sablecc/sablecc/node/NoCast.java new file mode 100644 index 0000000..1678661 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/NoCast.java @@ -0,0 +1,16 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public class NoCast implements Cast +{ + public final static NoCast instance = new NoCast(); + + private NoCast() + {} + + public Object cast(Object o) + { + return o; + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/Node.java b/src/main/java/org/sablecc/sablecc/node/Node.java new file mode 100644 index 0000000..e554520 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/Node.java @@ -0,0 +1,78 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; +import org.sablecc.sablecc.analysis.*; + +public abstract class Node implements Switchable, Cloneable +{ + private Node parent; + + public abstract Object clone(); + + public Node parent() + { + return parent; + } + + void parent(Node parent) + { + this.parent = parent; + } + + abstract void removeChild(Node child); + abstract void replaceChild(Node oldChild, Node newChild); + + public void replaceBy(Node node) + { + if(parent != null) + { + parent.replaceChild(this, node); + } + } + + protected String toString(Node node) + { + if(node != null) + { + return node.toString(); + } + + return ""; + } + + protected String toString(List list) + { + StringBuffer s = new StringBuffer(); + + for(Iterator i = list.iterator(); i.hasNext();) + { + s.append(i.next()); + } + + return s.toString(); + } + + protected Node cloneNode(Node node) + { + if(node != null) + { + return (Node) node.clone(); + } + + return null; + } + + protected List cloneList(List list) + { + List clone = new LinkedList(); + + for(Iterator i = list.iterator(); i.hasNext();) + { + clone.add(((Node) i.next()).clone()); + } + + return clone; + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/NodeCast.java b/src/main/java/org/sablecc/sablecc/node/NodeCast.java new file mode 100644 index 0000000..9ee7fc3 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/NodeCast.java @@ -0,0 +1,16 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public class NodeCast implements Cast +{ + public final static NodeCast instance = new NodeCast(); + + private NodeCast() + {} + + public Object cast(Object o) + { + return (Node) o; + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/PAlt.java b/src/main/java/org/sablecc/sablecc/node/PAlt.java new file mode 100644 index 0000000..765b8b0 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PAlt.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PAlt extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PAltTransform.java b/src/main/java/org/sablecc/sablecc/node/PAltTransform.java new file mode 100644 index 0000000..58b590e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PAltTransform.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PAltTransform extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PAst.java b/src/main/java/org/sablecc/sablecc/node/PAst.java new file mode 100644 index 0000000..aa65dd7 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PAst.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PAst extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PAstAlt.java b/src/main/java/org/sablecc/sablecc/node/PAstAlt.java new file mode 100644 index 0000000..edabab5 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PAstAlt.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PAstAlt extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PAstProd.java b/src/main/java/org/sablecc/sablecc/node/PAstProd.java new file mode 100644 index 0000000..7ca1e78 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PAstProd.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PAstProd extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PBasic.java b/src/main/java/org/sablecc/sablecc/node/PBasic.java new file mode 100644 index 0000000..cbd72e5 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PBasic.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PBasic extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PBinOp.java b/src/main/java/org/sablecc/sablecc/node/PBinOp.java new file mode 100644 index 0000000..a2286b4 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PBinOp.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PBinOp extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PChar.java b/src/main/java/org/sablecc/sablecc/node/PChar.java new file mode 100644 index 0000000..70fdd12 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PChar.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PChar extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PConcat.java b/src/main/java/org/sablecc/sablecc/node/PConcat.java new file mode 100644 index 0000000..c97f5d9 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PConcat.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PConcat extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PElem.java b/src/main/java/org/sablecc/sablecc/node/PElem.java new file mode 100644 index 0000000..66dbb70 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PElem.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PElem extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PGrammar.java b/src/main/java/org/sablecc/sablecc/node/PGrammar.java new file mode 100644 index 0000000..2e4f19f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PGrammar.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PGrammar extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PHelperDef.java b/src/main/java/org/sablecc/sablecc/node/PHelperDef.java new file mode 100644 index 0000000..8a2b109 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PHelperDef.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PHelperDef extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PHelpers.java b/src/main/java/org/sablecc/sablecc/node/PHelpers.java new file mode 100644 index 0000000..1553c87 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PHelpers.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PHelpers extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PIgnTokens.java b/src/main/java/org/sablecc/sablecc/node/PIgnTokens.java new file mode 100644 index 0000000..253de6e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PIgnTokens.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PIgnTokens extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PListTerm.java b/src/main/java/org/sablecc/sablecc/node/PListTerm.java new file mode 100644 index 0000000..35837af --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PListTerm.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PListTerm extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PProd.java b/src/main/java/org/sablecc/sablecc/node/PProd.java new file mode 100644 index 0000000..2c72802 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PProd.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PProd extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PProdName.java b/src/main/java/org/sablecc/sablecc/node/PProdName.java new file mode 100644 index 0000000..7da2e3d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PProdName.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PProdName extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PProductions.java b/src/main/java/org/sablecc/sablecc/node/PProductions.java new file mode 100644 index 0000000..f5f954b --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PProductions.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PProductions extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PRegExp.java b/src/main/java/org/sablecc/sablecc/node/PRegExp.java new file mode 100644 index 0000000..6d1e436 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PRegExp.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PRegExp extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PSet.java b/src/main/java/org/sablecc/sablecc/node/PSet.java new file mode 100644 index 0000000..cbddf9a --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PSet.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PSet extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PSpecifier.java b/src/main/java/org/sablecc/sablecc/node/PSpecifier.java new file mode 100644 index 0000000..99cb14e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PSpecifier.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PSpecifier extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PStateList.java b/src/main/java/org/sablecc/sablecc/node/PStateList.java new file mode 100644 index 0000000..6bc1132 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PStateList.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PStateList extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PStateListTail.java b/src/main/java/org/sablecc/sablecc/node/PStateListTail.java new file mode 100644 index 0000000..d34ca70 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PStateListTail.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PStateListTail extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PStates.java b/src/main/java/org/sablecc/sablecc/node/PStates.java new file mode 100644 index 0000000..c01e872 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PStates.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PStates extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PTerm.java b/src/main/java/org/sablecc/sablecc/node/PTerm.java new file mode 100644 index 0000000..49feaaf --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PTerm.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PTerm extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PTokenDef.java b/src/main/java/org/sablecc/sablecc/node/PTokenDef.java new file mode 100644 index 0000000..c9e7f2d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PTokenDef.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PTokenDef extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PTokens.java b/src/main/java/org/sablecc/sablecc/node/PTokens.java new file mode 100644 index 0000000..0539578 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PTokens.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PTokens extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PTransition.java b/src/main/java/org/sablecc/sablecc/node/PTransition.java new file mode 100644 index 0000000..e651f5e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PTransition.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PTransition extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PUnExp.java b/src/main/java/org/sablecc/sablecc/node/PUnExp.java new file mode 100644 index 0000000..e16b6e9 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PUnExp.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PUnExp extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/PUnOp.java b/src/main/java/org/sablecc/sablecc/node/PUnOp.java new file mode 100644 index 0000000..48e2582 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/PUnOp.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class PUnOp extends Node + {} diff --git a/src/main/java/org/sablecc/sablecc/node/Start.java b/src/main/java/org/sablecc/sablecc/node/Start.java new file mode 100644 index 0000000..0806caa --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/Start.java @@ -0,0 +1,121 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class Start extends Node +{ + private PGrammar _pGrammar_; + private EOF _eof_; + + public Start() + {} + + public Start( + PGrammar _pGrammar_, + EOF _eof_) + { + setPGrammar(_pGrammar_); + setEOF(_eof_); + } + + public Object clone() + { + return new Start( + (PGrammar) cloneNode(_pGrammar_), + (EOF) cloneNode(_eof_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseStart(this); + } + + public PGrammar getPGrammar() + { + return _pGrammar_; + } + + public void setPGrammar(PGrammar node) + { + if(_pGrammar_ != null) + { + _pGrammar_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _pGrammar_ = node; + } + + public EOF getEOF() + { + return _eof_; + } + + public void setEOF(EOF node) + { + if(_eof_ != null) + { + _eof_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + _eof_ = node; + } + + void removeChild(Node child) + { + if(_pGrammar_ == child) + { + _pGrammar_ = null; + return; + } + + if(_eof_ == child) + { + _eof_ = null; + return; + } + } + + void replaceChild(Node oldChild, Node newChild) + { + if(_pGrammar_ == oldChild) + { + setPGrammar((PGrammar) newChild); + return; + } + + if(_eof_ == oldChild) + { + setEOF((EOF) newChild); + return; + } + } + + public String toString() + { + return "" + + toString(_pGrammar_) + + toString(_eof_); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/Switch.java b/src/main/java/org/sablecc/sablecc/node/Switch.java new file mode 100644 index 0000000..8cadd36 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/Switch.java @@ -0,0 +1,6 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public interface Switch + {} diff --git a/src/main/java/org/sablecc/sablecc/node/Switchable.java b/src/main/java/org/sablecc/sablecc/node/Switchable.java new file mode 100644 index 0000000..6e0ef86 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/Switchable.java @@ -0,0 +1,8 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public interface Switchable +{ + void apply(Switch sw); +} diff --git a/src/main/java/org/sablecc/sablecc/node/TAbstract.java b/src/main/java/org/sablecc/sablecc/node/TAbstract.java new file mode 100644 index 0000000..754a507 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TAbstract.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TAbstract extends Token +{ + public TAbstract() + { + super.setText("Abstract"); + } + + public TAbstract(int line, int pos) + { + super.setText("Abstract"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TAbstract(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTAbstract(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TAbstract text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TArrow.java b/src/main/java/org/sablecc/sablecc/node/TArrow.java new file mode 100644 index 0000000..dcfedee --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TArrow.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TArrow extends Token +{ + public TArrow() + { + super.setText("->"); + } + + public TArrow(int line, int pos) + { + super.setText("->"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TArrow(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTArrow(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TArrow text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TBar.java b/src/main/java/org/sablecc/sablecc/node/TBar.java new file mode 100644 index 0000000..507ae38 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TBar.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TBar extends Token +{ + public TBar() + { + super.setText("|"); + } + + public TBar(int line, int pos) + { + super.setText("|"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TBar(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTBar(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TBar text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TBlank.java b/src/main/java/org/sablecc/sablecc/node/TBlank.java new file mode 100644 index 0000000..585bca2 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TBlank.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TBlank extends Token +{ + public TBlank(String text) + { + setText(text); + } + + public TBlank(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TBlank(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTBlank(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TChar.java b/src/main/java/org/sablecc/sablecc/node/TChar.java new file mode 100644 index 0000000..c5b6bd5 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TChar.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TChar extends Token +{ + public TChar(String text) + { + setText(text); + } + + public TChar(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TChar(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTChar(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TColon.java b/src/main/java/org/sablecc/sablecc/node/TColon.java new file mode 100644 index 0000000..678a3b5 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TColon.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TColon extends Token +{ + public TColon() + { + super.setText(":"); + } + + public TColon(int line, int pos) + { + super.setText(":"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TColon(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTColon(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TColon text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TComma.java b/src/main/java/org/sablecc/sablecc/node/TComma.java new file mode 100644 index 0000000..b0364e7 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TComma.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TComma extends Token +{ + public TComma() + { + super.setText(","); + } + + public TComma(int line, int pos) + { + super.setText(","); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TComma(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTComma(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TComma text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TComment.java b/src/main/java/org/sablecc/sablecc/node/TComment.java new file mode 100644 index 0000000..4056f52 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TComment.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TComment extends Token +{ + public TComment(String text) + { + setText(text); + } + + public TComment(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TComment(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTComment(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TDDot.java b/src/main/java/org/sablecc/sablecc/node/TDDot.java new file mode 100644 index 0000000..0243d22 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TDDot.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TDDot extends Token +{ + public TDDot() + { + super.setText(".."); + } + + public TDDot(int line, int pos) + { + super.setText(".."); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TDDot(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTDDot(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TDDot text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TDecChar.java b/src/main/java/org/sablecc/sablecc/node/TDecChar.java new file mode 100644 index 0000000..f9c4688 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TDecChar.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TDecChar extends Token +{ + public TDecChar(String text) + { + setText(text); + } + + public TDecChar(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TDecChar(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTDecChar(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TDot.java b/src/main/java/org/sablecc/sablecc/node/TDot.java new file mode 100644 index 0000000..84df19e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TDot.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TDot extends Token +{ + public TDot() + { + super.setText("."); + } + + public TDot(int line, int pos) + { + super.setText("."); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TDot(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTDot(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TDot text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TEqual.java b/src/main/java/org/sablecc/sablecc/node/TEqual.java new file mode 100644 index 0000000..1ff8e6d --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TEqual.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TEqual extends Token +{ + public TEqual() + { + super.setText("="); + } + + public TEqual(int line, int pos) + { + super.setText("="); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TEqual(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTEqual(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TEqual text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/THelpers.java b/src/main/java/org/sablecc/sablecc/node/THelpers.java new file mode 100644 index 0000000..8ed8c1e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/THelpers.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class THelpers extends Token +{ + public THelpers() + { + super.setText("Helpers"); + } + + public THelpers(int line, int pos) + { + super.setText("Helpers"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new THelpers(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTHelpers(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change THelpers text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/THexChar.java b/src/main/java/org/sablecc/sablecc/node/THexChar.java new file mode 100644 index 0000000..b3d7d91 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/THexChar.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class THexChar extends Token +{ + public THexChar(String text) + { + setText(text); + } + + public THexChar(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new THexChar(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTHexChar(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TId.java b/src/main/java/org/sablecc/sablecc/node/TId.java new file mode 100644 index 0000000..7ba0ed9 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TId.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TId extends Token +{ + public TId(String text) + { + setText(text); + } + + public TId(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TId(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTId(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TIgnored.java b/src/main/java/org/sablecc/sablecc/node/TIgnored.java new file mode 100644 index 0000000..230eef8 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TIgnored.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TIgnored extends Token +{ + public TIgnored() + { + super.setText("Ignored"); + } + + public TIgnored(int line, int pos) + { + super.setText("Ignored"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TIgnored(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTIgnored(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TIgnored text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TLBkt.java b/src/main/java/org/sablecc/sablecc/node/TLBkt.java new file mode 100644 index 0000000..64c6015 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TLBkt.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TLBkt extends Token +{ + public TLBkt() + { + super.setText("["); + } + + public TLBkt(int line, int pos) + { + super.setText("["); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TLBkt(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTLBkt(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TLBkt text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TLBrace.java b/src/main/java/org/sablecc/sablecc/node/TLBrace.java new file mode 100644 index 0000000..062bc75 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TLBrace.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TLBrace extends Token +{ + public TLBrace() + { + super.setText("{"); + } + + public TLBrace(int line, int pos) + { + super.setText("{"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TLBrace(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTLBrace(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TLBrace text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TLPar.java b/src/main/java/org/sablecc/sablecc/node/TLPar.java new file mode 100644 index 0000000..eb69710 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TLPar.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TLPar extends Token +{ + public TLPar() + { + super.setText("("); + } + + public TLPar(int line, int pos) + { + super.setText("("); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TLPar(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTLPar(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TLPar text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TMinus.java b/src/main/java/org/sablecc/sablecc/node/TMinus.java new file mode 100644 index 0000000..6e655a9 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TMinus.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TMinus extends Token +{ + public TMinus() + { + super.setText("-"); + } + + public TMinus(int line, int pos) + { + super.setText("-"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TMinus(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTMinus(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TMinus text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TNew.java b/src/main/java/org/sablecc/sablecc/node/TNew.java new file mode 100644 index 0000000..4d3b87e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TNew.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TNew extends Token +{ + public TNew() + { + super.setText("New"); + } + + public TNew(int line, int pos) + { + super.setText("New"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TNew(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTNew(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TNew text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TNull.java b/src/main/java/org/sablecc/sablecc/node/TNull.java new file mode 100644 index 0000000..4b523c7 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TNull.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TNull extends Token +{ + public TNull() + { + super.setText("Null"); + } + + public TNull(int line, int pos) + { + super.setText("Null"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TNull(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTNull(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TNull text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TPackage.java b/src/main/java/org/sablecc/sablecc/node/TPackage.java new file mode 100644 index 0000000..10003fa --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TPackage.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TPackage extends Token +{ + public TPackage() + { + super.setText("Package"); + } + + public TPackage(int line, int pos) + { + super.setText("Package"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TPackage(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTPackage(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TPackage text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TPkgId.java b/src/main/java/org/sablecc/sablecc/node/TPkgId.java new file mode 100644 index 0000000..0390d21 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TPkgId.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TPkgId extends Token +{ + public TPkgId(String text) + { + setText(text); + } + + public TPkgId(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TPkgId(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTPkgId(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TPlus.java b/src/main/java/org/sablecc/sablecc/node/TPlus.java new file mode 100644 index 0000000..d7e48a7 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TPlus.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TPlus extends Token +{ + public TPlus() + { + super.setText("+"); + } + + public TPlus(int line, int pos) + { + super.setText("+"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TPlus(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTPlus(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TPlus text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TProductionSpecifier.java b/src/main/java/org/sablecc/sablecc/node/TProductionSpecifier.java new file mode 100644 index 0000000..8cb21c2 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TProductionSpecifier.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TProductionSpecifier extends Token +{ + public TProductionSpecifier() + { + super.setText("P"); + } + + public TProductionSpecifier(int line, int pos) + { + super.setText("P"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TProductionSpecifier(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTProductionSpecifier(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TProductionSpecifier text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TProductions.java b/src/main/java/org/sablecc/sablecc/node/TProductions.java new file mode 100644 index 0000000..6d201b5 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TProductions.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TProductions extends Token +{ + public TProductions() + { + super.setText("Productions"); + } + + public TProductions(int line, int pos) + { + super.setText("Productions"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TProductions(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTProductions(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TProductions text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TQMark.java b/src/main/java/org/sablecc/sablecc/node/TQMark.java new file mode 100644 index 0000000..b07059f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TQMark.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TQMark extends Token +{ + public TQMark() + { + super.setText("?"); + } + + public TQMark(int line, int pos) + { + super.setText("?"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TQMark(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTQMark(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TQMark text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TRBkt.java b/src/main/java/org/sablecc/sablecc/node/TRBkt.java new file mode 100644 index 0000000..a32f0e7 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TRBkt.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TRBkt extends Token +{ + public TRBkt() + { + super.setText("]"); + } + + public TRBkt(int line, int pos) + { + super.setText("]"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TRBkt(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTRBkt(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TRBkt text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TRBrace.java b/src/main/java/org/sablecc/sablecc/node/TRBrace.java new file mode 100644 index 0000000..26e4a85 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TRBrace.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TRBrace extends Token +{ + public TRBrace() + { + super.setText("}"); + } + + public TRBrace(int line, int pos) + { + super.setText("}"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TRBrace(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTRBrace(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TRBrace text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TRPar.java b/src/main/java/org/sablecc/sablecc/node/TRPar.java new file mode 100644 index 0000000..856a375 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TRPar.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TRPar extends Token +{ + public TRPar() + { + super.setText(")"); + } + + public TRPar(int line, int pos) + { + super.setText(")"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TRPar(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTRPar(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TRPar text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TSemicolon.java b/src/main/java/org/sablecc/sablecc/node/TSemicolon.java new file mode 100644 index 0000000..c768657 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TSemicolon.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TSemicolon extends Token +{ + public TSemicolon() + { + super.setText(";"); + } + + public TSemicolon(int line, int pos) + { + super.setText(";"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TSemicolon(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTSemicolon(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TSemicolon text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TSlash.java b/src/main/java/org/sablecc/sablecc/node/TSlash.java new file mode 100644 index 0000000..c371062 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TSlash.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TSlash extends Token +{ + public TSlash() + { + super.setText("/"); + } + + public TSlash(int line, int pos) + { + super.setText("/"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TSlash(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTSlash(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TSlash text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TStar.java b/src/main/java/org/sablecc/sablecc/node/TStar.java new file mode 100644 index 0000000..e962327 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TStar.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TStar extends Token +{ + public TStar() + { + super.setText("*"); + } + + public TStar(int line, int pos) + { + super.setText("*"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TStar(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTStar(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TStar text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TStates.java b/src/main/java/org/sablecc/sablecc/node/TStates.java new file mode 100644 index 0000000..6933885 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TStates.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TStates extends Token +{ + public TStates() + { + super.setText("States"); + } + + public TStates(int line, int pos) + { + super.setText("States"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TStates(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTStates(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TStates text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TString.java b/src/main/java/org/sablecc/sablecc/node/TString.java new file mode 100644 index 0000000..daf4908 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TString.java @@ -0,0 +1,30 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TString extends Token +{ + public TString(String text) + { + setText(text); + } + + public TString(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TString(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTString(this); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TSyntax.java b/src/main/java/org/sablecc/sablecc/node/TSyntax.java new file mode 100644 index 0000000..3b24e0e --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TSyntax.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TSyntax extends Token +{ + public TSyntax() + { + super.setText("Syntax"); + } + + public TSyntax(int line, int pos) + { + super.setText("Syntax"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TSyntax(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTSyntax(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TSyntax text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TTokenSpecifier.java b/src/main/java/org/sablecc/sablecc/node/TTokenSpecifier.java new file mode 100644 index 0000000..ec0360f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TTokenSpecifier.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TTokenSpecifier extends Token +{ + public TTokenSpecifier() + { + super.setText("T"); + } + + public TTokenSpecifier(int line, int pos) + { + super.setText("T"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TTokenSpecifier(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTTokenSpecifier(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TTokenSpecifier text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TTokens.java b/src/main/java/org/sablecc/sablecc/node/TTokens.java new file mode 100644 index 0000000..f815231 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TTokens.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TTokens extends Token +{ + public TTokens() + { + super.setText("Tokens"); + } + + public TTokens(int line, int pos) + { + super.setText("Tokens"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TTokens(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTTokens(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TTokens text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/TTree.java b/src/main/java/org/sablecc/sablecc/node/TTree.java new file mode 100644 index 0000000..46ae387 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TTree.java @@ -0,0 +1,35 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import org.sablecc.sablecc.analysis.*; + +public final class TTree extends Token +{ + public TTree() + { + super.setText("Tree"); + } + + public TTree(int line, int pos) + { + super.setText("Tree"); + setLine(line); + setPos(pos); + } + + public Object clone() + { + return new TTree(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseTTree(this); + } + + public void setText(String text) + { + throw new RuntimeException("Cannot change TTree text."); + } +} diff --git a/src/main/java/org/sablecc/sablecc/node/Token.java b/src/main/java/org/sablecc/sablecc/node/Token.java new file mode 100644 index 0000000..ec21ec9 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/Token.java @@ -0,0 +1,51 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +public abstract class Token extends Node +{ + private String text; + private int line; + private int pos; + + public String getText() + { + return text; + } + + public void setText(String text) + { + this.text = text; + } + + public int getLine() + { + return line; + } + + public void setLine(int line) + { + this.line = line; + } + + public int getPos() + { + return pos; + } + + public void setPos(int pos) + { + this.pos = pos; + } + + public String toString() + { + return text + " "; + } + + void removeChild(Node child) + {} + + void replaceChild(Node oldChild, Node newChild) + {} +} diff --git a/src/main/java/org/sablecc/sablecc/node/TypedLinkedList.java b/src/main/java/org/sablecc/sablecc/node/TypedLinkedList.java new file mode 100644 index 0000000..7c9ebd6 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/node/TypedLinkedList.java @@ -0,0 +1,149 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.node; + +import java.util.*; + +public class TypedLinkedList extends LinkedList +{ + Cast cast; + + public TypedLinkedList() + { + super(); + + cast = NoCast.instance; + } + + public TypedLinkedList(Collection c) + { + super(c); + + cast = NoCast.instance; + } + + public TypedLinkedList(Cast cast) + { + super(); + + this.cast = cast; + } + + public TypedLinkedList(Collection c, Cast cast) + { + super(c); + + this.cast = cast; + } + + public Cast getCast() + { + return cast; + } + + public void add + (int index, Object element) + { + super.add(index, cast.cast(element)); + } + + public boolean add + (Object o) + { + return super.add(cast.cast(o)); + } + + public boolean addAll(Collection c) + { + Object[] elements = c.toArray(); + for(int i=0; i<elements.length; i++) + { + super.add(cast.cast(elements[i])); + } + return true; + } + + public boolean addAll(int index, Collection c) + { + int pos = index; + Object[] elements = c.toArray(); + for(int i=0; i<elements.length; i++) + { + super.add(pos++, cast.cast(elements[i])); + } + return true; + } + + public void addFirst(Object o) + { + super.addFirst(cast.cast(o)); + } + + public void addLast(Object o) + { + super.addLast(cast.cast(o)); + } + + public ListIterator listIterator(int index) + { + return new TypedLinkedListIterator(super.listIterator(index)); + } + + private class TypedLinkedListIterator implements ListIterator + { + ListIterator iterator; + + TypedLinkedListIterator(ListIterator iterator) + { + this.iterator = iterator; + } + + public boolean hasNext() + { + return iterator.hasNext(); + } + + public Object next() + { + return iterator.next(); + } + + public boolean hasPrevious() + { + return iterator.hasPrevious(); + } + + public Object previous() + { + return iterator.previous(); + } + + public int nextIndex() + { + return iterator.nextIndex(); + } + + public int previousIndex() + { + return iterator.previousIndex(); + } + + public void remove + () + { + iterator.remove(); + } + + public void set + (Object o) + { + iterator.set(cast.cast(o)); + } + + public void add + (Object o) + { + iterator.add(cast.cast(o)); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/parser/Parser.java b/src/main/java/org/sablecc/sablecc/parser/Parser.java new file mode 100644 index 0000000..69bc5db --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/parser/Parser.java @@ -0,0 +1,9277 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.parser; + +import org.sablecc.sablecc.lexer.*; +import org.sablecc.sablecc.node.*; +import org.sablecc.sablecc.analysis.*; +import java.util.*; + +import java.io.DataInputStream; +import java.io.BufferedInputStream; +import java.io.IOException; + +public class Parser +{ + public final Analysis ignoredTokens = new AnalysisAdapter(); + + protected ArrayList nodeList; + + private final Lexer lexer; + private final ListIterator stack = new LinkedList().listIterator(); + private int last_shift; + private int last_pos; + private int last_line; + private Token last_token; + private final TokenIndex converter = new TokenIndex(); + private final int[] action = new int[2]; + + private final static int SHIFT = 0; + private final static int REDUCE = 1; + private final static int ACCEPT = 2; + private final static int ERROR = 3; + + public Parser(Lexer lexer) + { + this.lexer = lexer; + } + + private void push(int numstate, ArrayList listNode) throws ParserException, LexerException, IOException + { + this.nodeList = listNode; + + if(!stack.hasNext()) + { + stack.add(new State(numstate, this.nodeList)); + return; + } + + State s = (State) stack.next(); + s.state = numstate; + s.nodes = this.nodeList; + } + + private int goTo(int index) + { + int state = state(); + int low = 1; + int high = gotoTable[index].length - 1; + int value = gotoTable[index][0][1]; + + while(low <= high) + { + int middle = (low + high) / 2; + + if(state < gotoTable[index][middle][0]) + { + high = middle - 1; + } + else if(state > gotoTable[index][middle][0]) + { + low = middle + 1; + } + else + { + value = gotoTable[index][middle][1]; + break; + } + } + + return value; + } + + private int state() + { + State s = (State) stack.previous(); + stack.next(); + return s.state; + } + + private ArrayList pop() + { + return (ArrayList) ((State) stack.previous()).nodes; + } + + private int index(Switchable token) + { + converter.index = -1; + token.apply(converter); + return converter.index; + } + + public Start parse() throws ParserException, LexerException, IOException + { + push(0, null); + List ign = null; + while(true) + { + while(index(lexer.peek()) == -1) + { + if(ign == null) + { + ign = new TypedLinkedList(NodeCast.instance); + } + + ign.add(lexer.next()); + } + + if(ign != null) + { + ignoredTokens.setIn(lexer.peek(), ign); + ign = null; + } + + last_pos = lexer.peek().getPos(); + last_line = lexer.peek().getLine(); + last_token = lexer.peek(); + + int index = index(lexer.peek()); + action[0] = actionTable[state()][0][1]; + action[1] = actionTable[state()][0][2]; + + int low = 1; + int high = actionTable[state()].length - 1; + + while(low <= high) + { + int middle = (low + high) / 2; + + if(index < actionTable[state()][middle][0]) + { + high = middle - 1; + } + else if(index > actionTable[state()][middle][0]) + { + low = middle + 1; + } + else + { + action[0] = actionTable[state()][middle][1]; + action[1] = actionTable[state()][middle][2]; + break; + } + } + + switch(action[0]) + { + case SHIFT: + { + ArrayList list = new ArrayList(); + list.add(lexer.next()); + push(action[1], list); + last_shift = action[1]; + } + break; + case REDUCE: + switch(action[1]) + { + case 0: /* reduce AAgrammar1Grammar */ + { + ArrayList list = new0(); + push(goTo(0), list); + } + break; + case 1: /* reduce AAgrammar2Grammar */ + { + ArrayList list = new1(); + push(goTo(0), list); + } + break; + case 2: /* reduce AAgrammar3Grammar */ + { + ArrayList list = new2(); + push(goTo(0), list); + } + break; + case 3: /* reduce AAgrammar4Grammar */ + { + ArrayList list = new3(); + push(goTo(0), list); + } + break; + case 4: /* reduce AAgrammar5Grammar */ + { + ArrayList list = new4(); + push(goTo(0), list); + } + break; + case 5: /* reduce AAgrammar6Grammar */ + { + ArrayList list = new5(); + push(goTo(0), list); + } + break; + case 6: /* reduce AAgrammar7Grammar */ + { + ArrayList list = new6(); + push(goTo(0), list); + } + break; + case 7: /* reduce AAgrammar8Grammar */ + { + ArrayList list = new7(); + push(goTo(0), list); + } + break; + case 8: /* reduce AAgrammar9Grammar */ + { + ArrayList list = new8(); + push(goTo(0), list); + } + break; + case 9: /* reduce AAgrammar10Grammar */ + { + ArrayList list = new9(); + push(goTo(0), list); + } + break; + case 10: /* reduce AAgrammar11Grammar */ + { + ArrayList list = new10(); + push(goTo(0), list); + } + break; + case 11: /* reduce AAgrammar12Grammar */ + { + ArrayList list = new11(); + push(goTo(0), list); + } + break; + case 12: /* reduce AAgrammar13Grammar */ + { + ArrayList list = new12(); + push(goTo(0), list); + } + break; + case 13: /* reduce AAgrammar14Grammar */ + { + ArrayList list = new13(); + push(goTo(0), list); + } + break; + case 14: /* reduce AAgrammar15Grammar */ + { + ArrayList list = new14(); + push(goTo(0), list); + } + break; + case 15: /* reduce AAgrammar16Grammar */ + { + ArrayList list = new15(); + push(goTo(0), list); + } + break; + case 16: /* reduce AAgrammar17Grammar */ + { + ArrayList list = new16(); + push(goTo(0), list); + } + break; + case 17: /* reduce AAgrammar18Grammar */ + { + ArrayList list = new17(); + push(goTo(0), list); + } + break; + case 18: /* reduce AAgrammar19Grammar */ + { + ArrayList list = new18(); + push(goTo(0), list); + } + break; + case 19: /* reduce AAgrammar20Grammar */ + { + ArrayList list = new19(); + push(goTo(0), list); + } + break; + case 20: /* reduce AAgrammar21Grammar */ + { + ArrayList list = new20(); + push(goTo(0), list); + } + break; + case 21: /* reduce AAgrammar22Grammar */ + { + ArrayList list = new21(); + push(goTo(0), list); + } + break; + case 22: /* reduce AAgrammar23Grammar */ + { + ArrayList list = new22(); + push(goTo(0), list); + } + break; + case 23: /* reduce AAgrammar24Grammar */ + { + ArrayList list = new23(); + push(goTo(0), list); + } + break; + case 24: /* reduce AAgrammar25Grammar */ + { + ArrayList list = new24(); + push(goTo(0), list); + } + break; + case 25: /* reduce AAgrammar26Grammar */ + { + ArrayList list = new25(); + push(goTo(0), list); + } + break; + case 26: /* reduce AAgrammar27Grammar */ + { + ArrayList list = new26(); + push(goTo(0), list); + } + break; + case 27: /* reduce AAgrammar28Grammar */ + { + ArrayList list = new27(); + push(goTo(0), list); + } + break; + case 28: /* reduce AAgrammar29Grammar */ + { + ArrayList list = new28(); + push(goTo(0), list); + } + break; + case 29: /* reduce AAgrammar30Grammar */ + { + ArrayList list = new29(); + push(goTo(0), list); + } + break; + case 30: /* reduce AAgrammar31Grammar */ + { + ArrayList list = new30(); + push(goTo(0), list); + } + break; + case 31: /* reduce AAgrammar32Grammar */ + { + ArrayList list = new31(); + push(goTo(0), list); + } + break; + case 32: /* reduce AAgrammar33Grammar */ + { + ArrayList list = new32(); + push(goTo(0), list); + } + break; + case 33: /* reduce AAgrammar34Grammar */ + { + ArrayList list = new33(); + push(goTo(0), list); + } + break; + case 34: /* reduce AAgrammar35Grammar */ + { + ArrayList list = new34(); + push(goTo(0), list); + } + break; + case 35: /* reduce AAgrammar36Grammar */ + { + ArrayList list = new35(); + push(goTo(0), list); + } + break; + case 36: /* reduce AAgrammar37Grammar */ + { + ArrayList list = new36(); + push(goTo(0), list); + } + break; + case 37: /* reduce AAgrammar38Grammar */ + { + ArrayList list = new37(); + push(goTo(0), list); + } + break; + case 38: /* reduce AAgrammar39Grammar */ + { + ArrayList list = new38(); + push(goTo(0), list); + } + break; + case 39: /* reduce AAgrammar40Grammar */ + { + ArrayList list = new39(); + push(goTo(0), list); + } + break; + case 40: /* reduce AAgrammar41Grammar */ + { + ArrayList list = new40(); + push(goTo(0), list); + } + break; + case 41: /* reduce AAgrammar42Grammar */ + { + ArrayList list = new41(); + push(goTo(0), list); + } + break; + case 42: /* reduce AAgrammar43Grammar */ + { + ArrayList list = new42(); + push(goTo(0), list); + } + break; + case 43: /* reduce AAgrammar44Grammar */ + { + ArrayList list = new43(); + push(goTo(0), list); + } + break; + case 44: /* reduce AAgrammar45Grammar */ + { + ArrayList list = new44(); + push(goTo(0), list); + } + break; + case 45: /* reduce AAgrammar46Grammar */ + { + ArrayList list = new45(); + push(goTo(0), list); + } + break; + case 46: /* reduce AAgrammar47Grammar */ + { + ArrayList list = new46(); + push(goTo(0), list); + } + break; + case 47: /* reduce AAgrammar48Grammar */ + { + ArrayList list = new47(); + push(goTo(0), list); + } + break; + case 48: /* reduce AAgrammar49Grammar */ + { + ArrayList list = new48(); + push(goTo(0), list); + } + break; + case 49: /* reduce AAgrammar50Grammar */ + { + ArrayList list = new49(); + push(goTo(0), list); + } + break; + case 50: /* reduce AAgrammar51Grammar */ + { + ArrayList list = new50(); + push(goTo(0), list); + } + break; + case 51: /* reduce AAgrammar52Grammar */ + { + ArrayList list = new51(); + push(goTo(0), list); + } + break; + case 52: /* reduce AAgrammar53Grammar */ + { + ArrayList list = new52(); + push(goTo(0), list); + } + break; + case 53: /* reduce AAgrammar54Grammar */ + { + ArrayList list = new53(); + push(goTo(0), list); + } + break; + case 54: /* reduce AAgrammar55Grammar */ + { + ArrayList list = new54(); + push(goTo(0), list); + } + break; + case 55: /* reduce AAgrammar56Grammar */ + { + ArrayList list = new55(); + push(goTo(0), list); + } + break; + case 56: /* reduce AAgrammar57Grammar */ + { + ArrayList list = new56(); + push(goTo(0), list); + } + break; + case 57: /* reduce AAgrammar58Grammar */ + { + ArrayList list = new57(); + push(goTo(0), list); + } + break; + case 58: /* reduce AAgrammar59Grammar */ + { + ArrayList list = new58(); + push(goTo(0), list); + } + break; + case 59: /* reduce AAgrammar60Grammar */ + { + ArrayList list = new59(); + push(goTo(0), list); + } + break; + case 60: /* reduce AAgrammar61Grammar */ + { + ArrayList list = new60(); + push(goTo(0), list); + } + break; + case 61: /* reduce AAgrammar62Grammar */ + { + ArrayList list = new61(); + push(goTo(0), list); + } + break; + case 62: /* reduce AAgrammar63Grammar */ + { + ArrayList list = new62(); + push(goTo(0), list); + } + break; + case 63: /* reduce AAgrammar64Grammar */ + { + ArrayList list = new63(); + push(goTo(0), list); + } + break; + case 64: /* reduce AAgrammar65Grammar */ + { + ArrayList list = new64(); + push(goTo(0), list); + } + break; + case 65: /* reduce AAgrammar66Grammar */ + { + ArrayList list = new65(); + push(goTo(0), list); + } + break; + case 66: /* reduce AAgrammar67Grammar */ + { + ArrayList list = new66(); + push(goTo(0), list); + } + break; + case 67: /* reduce AAgrammar68Grammar */ + { + ArrayList list = new67(); + push(goTo(0), list); + } + break; + case 68: /* reduce AAgrammar69Grammar */ + { + ArrayList list = new68(); + push(goTo(0), list); + } + break; + case 69: /* reduce AAgrammar70Grammar */ + { + ArrayList list = new69(); + push(goTo(0), list); + } + break; + case 70: /* reduce AAgrammar71Grammar */ + { + ArrayList list = new70(); + push(goTo(0), list); + } + break; + case 71: /* reduce AAgrammar72Grammar */ + { + ArrayList list = new71(); + push(goTo(0), list); + } + break; + case 72: /* reduce AAgrammar73Grammar */ + { + ArrayList list = new72(); + push(goTo(0), list); + } + break; + case 73: /* reduce AAgrammar74Grammar */ + { + ArrayList list = new73(); + push(goTo(0), list); + } + break; + case 74: /* reduce AAgrammar75Grammar */ + { + ArrayList list = new74(); + push(goTo(0), list); + } + break; + case 75: /* reduce AAgrammar76Grammar */ + { + ArrayList list = new75(); + push(goTo(0), list); + } + break; + case 76: /* reduce AAgrammar77Grammar */ + { + ArrayList list = new76(); + push(goTo(0), list); + } + break; + case 77: /* reduce AAgrammar78Grammar */ + { + ArrayList list = new77(); + push(goTo(0), list); + } + break; + case 78: /* reduce AAgrammar79Grammar */ + { + ArrayList list = new78(); + push(goTo(0), list); + } + break; + case 79: /* reduce AAgrammar80Grammar */ + { + ArrayList list = new79(); + push(goTo(0), list); + } + break; + case 80: /* reduce AAgrammar81Grammar */ + { + ArrayList list = new80(); + push(goTo(0), list); + } + break; + case 81: /* reduce AAgrammar82Grammar */ + { + ArrayList list = new81(); + push(goTo(0), list); + } + break; + case 82: /* reduce AAgrammar83Grammar */ + { + ArrayList list = new82(); + push(goTo(0), list); + } + break; + case 83: /* reduce AAgrammar84Grammar */ + { + ArrayList list = new83(); + push(goTo(0), list); + } + break; + case 84: /* reduce AAgrammar85Grammar */ + { + ArrayList list = new84(); + push(goTo(0), list); + } + break; + case 85: /* reduce AAgrammar86Grammar */ + { + ArrayList list = new85(); + push(goTo(0), list); + } + break; + case 86: /* reduce AAgrammar87Grammar */ + { + ArrayList list = new86(); + push(goTo(0), list); + } + break; + case 87: /* reduce AAgrammar88Grammar */ + { + ArrayList list = new87(); + push(goTo(0), list); + } + break; + case 88: /* reduce AAgrammar89Grammar */ + { + ArrayList list = new88(); + push(goTo(0), list); + } + break; + case 89: /* reduce AAgrammar90Grammar */ + { + ArrayList list = new89(); + push(goTo(0), list); + } + break; + case 90: /* reduce AAgrammar91Grammar */ + { + ArrayList list = new90(); + push(goTo(0), list); + } + break; + case 91: /* reduce AAgrammar92Grammar */ + { + ArrayList list = new91(); + push(goTo(0), list); + } + break; + case 92: /* reduce AAgrammar93Grammar */ + { + ArrayList list = new92(); + push(goTo(0), list); + } + break; + case 93: /* reduce AAgrammar94Grammar */ + { + ArrayList list = new93(); + push(goTo(0), list); + } + break; + case 94: /* reduce AAgrammar95Grammar */ + { + ArrayList list = new94(); + push(goTo(0), list); + } + break; + case 95: /* reduce AAgrammar96Grammar */ + { + ArrayList list = new95(); + push(goTo(0), list); + } + break; + case 96: /* reduce AAgrammar97Grammar */ + { + ArrayList list = new96(); + push(goTo(0), list); + } + break; + case 97: /* reduce AAgrammar98Grammar */ + { + ArrayList list = new97(); + push(goTo(0), list); + } + break; + case 98: /* reduce AAgrammar99Grammar */ + { + ArrayList list = new98(); + push(goTo(0), list); + } + break; + case 99: /* reduce AAgrammar100Grammar */ + { + ArrayList list = new99(); + push(goTo(0), list); + } + break; + case 100: /* reduce AAgrammar101Grammar */ + { + ArrayList list = new100(); + push(goTo(0), list); + } + break; + case 101: /* reduce AAgrammar102Grammar */ + { + ArrayList list = new101(); + push(goTo(0), list); + } + break; + case 102: /* reduce AAgrammar103Grammar */ + { + ArrayList list = new102(); + push(goTo(0), list); + } + break; + case 103: /* reduce AAgrammar104Grammar */ + { + ArrayList list = new103(); + push(goTo(0), list); + } + break; + case 104: /* reduce AAgrammar105Grammar */ + { + ArrayList list = new104(); + push(goTo(0), list); + } + break; + case 105: /* reduce AAgrammar106Grammar */ + { + ArrayList list = new105(); + push(goTo(0), list); + } + break; + case 106: /* reduce AAgrammar107Grammar */ + { + ArrayList list = new106(); + push(goTo(0), list); + } + break; + case 107: /* reduce AAgrammar108Grammar */ + { + ArrayList list = new107(); + push(goTo(0), list); + } + break; + case 108: /* reduce AAgrammar109Grammar */ + { + ArrayList list = new108(); + push(goTo(0), list); + } + break; + case 109: /* reduce AAgrammar110Grammar */ + { + ArrayList list = new109(); + push(goTo(0), list); + } + break; + case 110: /* reduce AAgrammar111Grammar */ + { + ArrayList list = new110(); + push(goTo(0), list); + } + break; + case 111: /* reduce AAgrammar112Grammar */ + { + ArrayList list = new111(); + push(goTo(0), list); + } + break; + case 112: /* reduce AAgrammar113Grammar */ + { + ArrayList list = new112(); + push(goTo(0), list); + } + break; + case 113: /* reduce AAgrammar114Grammar */ + { + ArrayList list = new113(); + push(goTo(0), list); + } + break; + case 114: /* reduce AAgrammar115Grammar */ + { + ArrayList list = new114(); + push(goTo(0), list); + } + break; + case 115: /* reduce AAgrammar116Grammar */ + { + ArrayList list = new115(); + push(goTo(0), list); + } + break; + case 116: /* reduce AAgrammar117Grammar */ + { + ArrayList list = new116(); + push(goTo(0), list); + } + break; + case 117: /* reduce AAgrammar118Grammar */ + { + ArrayList list = new117(); + push(goTo(0), list); + } + break; + case 118: /* reduce AAgrammar119Grammar */ + { + ArrayList list = new118(); + push(goTo(0), list); + } + break; + case 119: /* reduce AAgrammar120Grammar */ + { + ArrayList list = new119(); + push(goTo(0), list); + } + break; + case 120: /* reduce AAgrammar121Grammar */ + { + ArrayList list = new120(); + push(goTo(0), list); + } + break; + case 121: /* reduce AAgrammar122Grammar */ + { + ArrayList list = new121(); + push(goTo(0), list); + } + break; + case 122: /* reduce AAgrammar123Grammar */ + { + ArrayList list = new122(); + push(goTo(0), list); + } + break; + case 123: /* reduce AAgrammar124Grammar */ + { + ArrayList list = new123(); + push(goTo(0), list); + } + break; + case 124: /* reduce AAgrammar125Grammar */ + { + ArrayList list = new124(); + push(goTo(0), list); + } + break; + case 125: /* reduce AAgrammar126Grammar */ + { + ArrayList list = new125(); + push(goTo(0), list); + } + break; + case 126: /* reduce AAgrammar127Grammar */ + { + ArrayList list = new126(); + push(goTo(0), list); + } + break; + case 127: /* reduce AAgrammar128Grammar */ + { + ArrayList list = new127(); + push(goTo(0), list); + } + break; + case 128: /* reduce APackage */ + { + ArrayList list = new128(); + push(goTo(1), list); + } + break; + case 129: /* reduce AApkgname1PkgName */ + { + ArrayList list = new129(); + push(goTo(2), list); + } + break; + case 130: /* reduce AApkgname2PkgName */ + { + ArrayList list = new130(); + push(goTo(2), list); + } + break; + case 131: /* reduce APkgNameTail */ + { + ArrayList list = new131(); + push(goTo(3), list); + } + break; + case 132: /* reduce AHelpers */ + { + ArrayList list = new132(); + push(goTo(4), list); + } + break; + case 133: /* reduce AHelperDef */ + { + ArrayList list = new133(); + push(goTo(5), list); + } + break; + case 134: /* reduce AStates */ + { + ArrayList list = new134(); + push(goTo(6), list); + } + break; + case 135: /* reduce AAidlist1IdList */ + { + ArrayList list = new135(); + push(goTo(7), list); + } + break; + case 136: /* reduce AAidlist2IdList */ + { + ArrayList list = new136(); + push(goTo(7), list); + } + break; + case 137: /* reduce AIdListTail */ + { + ArrayList list = new137(); + push(goTo(8), list); + } + break; + case 138: /* reduce ATokens */ + { + ArrayList list = new138(); + push(goTo(9), list); + } + break; + case 139: /* reduce AAtokendef1TokenDef */ + { + ArrayList list = new139(); + push(goTo(10), list); + } + break; + case 140: /* reduce AAtokendef2TokenDef */ + { + ArrayList list = new140(); + push(goTo(10), list); + } + break; + case 141: /* reduce AAtokendef3TokenDef */ + { + ArrayList list = new141(); + push(goTo(10), list); + } + break; + case 142: /* reduce AAtokendef4TokenDef */ + { + ArrayList list = new142(); + push(goTo(10), list); + } + break; + case 143: /* reduce AAstatelist1StateList */ + { + ArrayList list = new143(); + push(goTo(11), list); + } + break; + case 144: /* reduce AAstatelist2StateList */ + { + ArrayList list = new144(); + push(goTo(11), list); + } + break; + case 145: /* reduce AAstatelist3StateList */ + { + ArrayList list = new145(); + push(goTo(11), list); + } + break; + case 146: /* reduce AAstatelist4StateList */ + { + ArrayList list = new146(); + push(goTo(11), list); + } + break; + case 147: /* reduce AAstatelisttail1StateListTail */ + { + ArrayList list = new147(); + push(goTo(12), list); + } + break; + case 148: /* reduce AAstatelisttail2StateListTail */ + { + ArrayList list = new148(); + push(goTo(12), list); + } + break; + case 149: /* reduce ATransition */ + { + ArrayList list = new149(); + push(goTo(13), list); + } + break; + case 150: /* reduce AAigntokens1IgnTokens */ + { + ArrayList list = new150(); + push(goTo(14), list); + } + break; + case 151: /* reduce AAigntokens2IgnTokens */ + { + ArrayList list = new151(); + push(goTo(14), list); + } + break; + case 152: /* reduce ALookAhead */ + { + ArrayList list = new152(); + push(goTo(15), list); + } + break; + case 153: /* reduce AAregexp1RegExp */ + { + ArrayList list = new153(); + push(goTo(16), list); + } + break; + case 154: /* reduce AAregexp2RegExp */ + { + ArrayList list = new154(); + push(goTo(16), list); + } + break; + case 155: /* reduce ARegExpTail */ + { + ArrayList list = new155(); + push(goTo(17), list); + } + break; + case 156: /* reduce AAconcat1Concat */ + { + ArrayList list = new156(); + push(goTo(18), list); + } + break; + case 157: /* reduce AAconcat2Concat */ + { + ArrayList list = new157(); + push(goTo(18), list); + } + break; + case 158: /* reduce AAunexp1UnExp */ + { + ArrayList list = new158(); + push(goTo(19), list); + } + break; + case 159: /* reduce AAunexp2UnExp */ + { + ArrayList list = new159(); + push(goTo(19), list); + } + break; + case 160: /* reduce ACharBasic */ + { + ArrayList list = new160(); + push(goTo(20), list); + } + break; + case 161: /* reduce ASetBasic */ + { + ArrayList list = new161(); + push(goTo(20), list); + } + break; + case 162: /* reduce AStringBasic */ + { + ArrayList list = new162(); + push(goTo(20), list); + } + break; + case 163: /* reduce AIdBasic */ + { + ArrayList list = new163(); + push(goTo(20), list); + } + break; + case 164: /* reduce ARegExpBasic */ + { + ArrayList list = new164(); + push(goTo(20), list); + } + break; + case 165: /* reduce ACharChar */ + { + ArrayList list = new165(); + push(goTo(21), list); + } + break; + case 166: /* reduce ADecChar */ + { + ArrayList list = new166(); + push(goTo(21), list); + } + break; + case 167: /* reduce AHexChar */ + { + ArrayList list = new167(); + push(goTo(21), list); + } + break; + case 168: /* reduce AOperationSet */ + { + ArrayList list = new168(); + push(goTo(22), list); + } + break; + case 169: /* reduce AIntervalSet */ + { + ArrayList list = new169(); + push(goTo(22), list); + } + break; + case 170: /* reduce AStarUnOp */ + { + ArrayList list = new170(); + push(goTo(23), list); + } + break; + case 171: /* reduce AQMarkUnOp */ + { + ArrayList list = new171(); + push(goTo(23), list); + } + break; + case 172: /* reduce APlusUnOp */ + { + ArrayList list = new172(); + push(goTo(23), list); + } + break; + case 173: /* reduce APlusBinOp */ + { + ArrayList list = new173(); + push(goTo(24), list); + } + break; + case 174: /* reduce AMinusBinOp */ + { + ArrayList list = new174(); + push(goTo(24), list); + } + break; + case 175: /* reduce AProductions */ + { + ArrayList list = new175(); + push(goTo(25), list); + } + break; + case 176: /* reduce AAprod1Prod */ + { + ArrayList list = new176(); + push(goTo(26), list); + } + break; + case 177: /* reduce AAprod2Prod */ + { + ArrayList list = new177(); + push(goTo(26), list); + } + break; + case 178: /* reduce AAprodtransform1ProdTransform */ + { + ArrayList list = new178(); + push(goTo(27), list); + } + break; + case 179: /* reduce AAprodtransform2ProdTransform */ + { + ArrayList list = new179(); + push(goTo(27), list); + } + break; + case 180: /* reduce AAalts1Alts */ + { + ArrayList list = new180(); + push(goTo(28), list); + } + break; + case 181: /* reduce AAalts2Alts */ + { + ArrayList list = new181(); + push(goTo(28), list); + } + break; + case 182: /* reduce AAltsTail */ + { + ArrayList list = new182(); + push(goTo(29), list); + } + break; + case 183: /* reduce AAalt1Alt */ + { + ArrayList list = new183(); + push(goTo(30), list); + } + break; + case 184: /* reduce AAalt2Alt */ + { + ArrayList list = new184(); + push(goTo(30), list); + } + break; + case 185: /* reduce AAalt3Alt */ + { + ArrayList list = new185(); + push(goTo(30), list); + } + break; + case 186: /* reduce AAalt4Alt */ + { + ArrayList list = new186(); + push(goTo(30), list); + } + break; + case 187: /* reduce AAalt5Alt */ + { + ArrayList list = new187(); + push(goTo(30), list); + } + break; + case 188: /* reduce AAalt6Alt */ + { + ArrayList list = new188(); + push(goTo(30), list); + } + break; + case 189: /* reduce AAalt7Alt */ + { + ArrayList list = new189(); + push(goTo(30), list); + } + break; + case 190: /* reduce AAalt8Alt */ + { + ArrayList list = new190(); + push(goTo(30), list); + } + break; + case 191: /* reduce AAalttransform1AltTransform */ + { + ArrayList list = new191(); + push(goTo(31), list); + } + break; + case 192: /* reduce AAalttransform2AltTransform */ + { + ArrayList list = new192(); + push(goTo(31), list); + } + break; + case 193: /* reduce AAnewterm1Term */ + { + ArrayList list = new193(); + push(goTo(32), list); + } + break; + case 194: /* reduce AAnewterm2Term */ + { + ArrayList list = new194(); + push(goTo(32), list); + } + break; + case 195: /* reduce AAlistterm1Term */ + { + ArrayList list = new195(); + push(goTo(32), list); + } + break; + case 196: /* reduce AAlistterm2Term */ + { + ArrayList list = new196(); + push(goTo(32), list); + } + break; + case 197: /* reduce AAsimpleterm1Term */ + { + ArrayList list = new197(); + push(goTo(32), list); + } + break; + case 198: /* reduce AAsimpleterm2Term */ + { + ArrayList list = new198(); + push(goTo(32), list); + } + break; + case 199: /* reduce AAsimpleterm3Term */ + { + ArrayList list = new199(); + push(goTo(32), list); + } + break; + case 200: /* reduce AAsimpleterm4Term */ + { + ArrayList list = new200(); + push(goTo(32), list); + } + break; + case 201: /* reduce ANullTerm */ + { + ArrayList list = new201(); + push(goTo(32), list); + } + break; + case 202: /* reduce AAlistoflistterm1ListOfListTerm */ + { + ArrayList list = new202(); + push(goTo(33), list); + } + break; + case 203: /* reduce AAlistoflistterm2ListOfListTerm */ + { + ArrayList list = new203(); + push(goTo(33), list); + } + break; + case 204: /* reduce AAnewlistterm1ListTerm */ + { + ArrayList list = new204(); + push(goTo(34), list); + } + break; + case 205: /* reduce AAnewlistterm2ListTerm */ + { + ArrayList list = new205(); + push(goTo(34), list); + } + break; + case 206: /* reduce AAsimplelistterm1ListTerm */ + { + ArrayList list = new206(); + push(goTo(34), list); + } + break; + case 207: /* reduce AAsimplelistterm2ListTerm */ + { + ArrayList list = new207(); + push(goTo(34), list); + } + break; + case 208: /* reduce AAsimplelistterm3ListTerm */ + { + ArrayList list = new208(); + push(goTo(34), list); + } + break; + case 209: /* reduce AAsimplelistterm4ListTerm */ + { + ArrayList list = new209(); + push(goTo(34), list); + } + break; + case 210: /* reduce AListTermTail */ + { + ArrayList list = new210(); + push(goTo(35), list); + } + break; + case 211: /* reduce ASimpleTermTail */ + { + ArrayList list = new211(); + push(goTo(36), list); + } + break; + case 212: /* reduce AAprodname1ProdName */ + { + ArrayList list = new212(); + push(goTo(37), list); + } + break; + case 213: /* reduce AAprodname2ProdName */ + { + ArrayList list = new213(); + push(goTo(37), list); + } + break; + case 214: /* reduce AProdNameTail */ + { + ArrayList list = new214(); + push(goTo(38), list); + } + break; + case 215: /* reduce AAparams1Params */ + { + ArrayList list = new215(); + push(goTo(39), list); + } + break; + case 216: /* reduce AAparams2Params */ + { + ArrayList list = new216(); + push(goTo(39), list); + } + break; + case 217: /* reduce AParamsTail */ + { + ArrayList list = new217(); + push(goTo(40), list); + } + break; + case 218: /* reduce AAltName */ + { + ArrayList list = new218(); + push(goTo(41), list); + } + break; + case 219: /* reduce AAelem1Elem */ + { + ArrayList list = new219(); + push(goTo(42), list); + } + break; + case 220: /* reduce AAelem2Elem */ + { + ArrayList list = new220(); + push(goTo(42), list); + } + break; + case 221: /* reduce AAelem3Elem */ + { + ArrayList list = new221(); + push(goTo(42), list); + } + break; + case 222: /* reduce AAelem4Elem */ + { + ArrayList list = new222(); + push(goTo(42), list); + } + break; + case 223: /* reduce AAelem5Elem */ + { + ArrayList list = new223(); + push(goTo(42), list); + } + break; + case 224: /* reduce AAelem6Elem */ + { + ArrayList list = new224(); + push(goTo(42), list); + } + break; + case 225: /* reduce AAelem7Elem */ + { + ArrayList list = new225(); + push(goTo(42), list); + } + break; + case 226: /* reduce AAelem8Elem */ + { + ArrayList list = new226(); + push(goTo(42), list); + } + break; + case 227: /* reduce AElemName */ + { + ArrayList list = new227(); + push(goTo(43), list); + } + break; + case 228: /* reduce ATokenSpecifier */ + { + ArrayList list = new228(); + push(goTo(44), list); + } + break; + case 229: /* reduce AProductionSpecifier */ + { + ArrayList list = new229(); + push(goTo(44), list); + } + break; + case 230: /* reduce AAst */ + { + ArrayList list = new230(); + push(goTo(45), list); + } + break; + case 231: /* reduce AAstProd */ + { + ArrayList list = new231(); + push(goTo(46), list); + } + break; + case 232: /* reduce AAastalts1AstAlts */ + { + ArrayList list = new232(); + push(goTo(47), list); + } + break; + case 233: /* reduce AAastalts2AstAlts */ + { + ArrayList list = new233(); + push(goTo(47), list); + } + break; + case 234: /* reduce AAstAltsTail */ + { + ArrayList list = new234(); + push(goTo(48), list); + } + break; + case 235: /* reduce AAastalt1AstAlt */ + { + ArrayList list = new235(); + push(goTo(49), list); + } + break; + case 236: /* reduce AAastalt2AstAlt */ + { + ArrayList list = new236(); + push(goTo(49), list); + } + break; + case 237: /* reduce AAastalt3AstAlt */ + { + ArrayList list = new237(); + push(goTo(49), list); + } + break; + case 238: /* reduce AAastalt4AstAlt */ + { + ArrayList list = new238(); + push(goTo(49), list); + } + break; + case 239: /* reduce ATerminal$PkgNameTail */ + { + ArrayList list = new239(); + push(goTo(50), list); + } + break; + case 240: /* reduce ANonTerminal$PkgNameTail */ + { + ArrayList list = new240(); + push(goTo(50), list); + } + break; + case 241: /* reduce ATerminal$HelperDef */ + { + ArrayList list = new241(); + push(goTo(51), list); + } + break; + case 242: /* reduce ANonTerminal$HelperDef */ + { + ArrayList list = new242(); + push(goTo(51), list); + } + break; + case 243: /* reduce ATerminal$IdListTail */ + { + ArrayList list = new243(); + push(goTo(52), list); + } + break; + case 244: /* reduce ANonTerminal$IdListTail */ + { + ArrayList list = new244(); + push(goTo(52), list); + } + break; + case 245: /* reduce ATerminal$TokenDef */ + { + ArrayList list = new245(); + push(goTo(53), list); + } + break; + case 246: /* reduce ANonTerminal$TokenDef */ + { + ArrayList list = new246(); + push(goTo(53), list); + } + break; + case 247: /* reduce ATerminal$StateListTail */ + { + ArrayList list = new247(); + push(goTo(54), list); + } + break; + case 248: /* reduce ANonTerminal$StateListTail */ + { + ArrayList list = new248(); + push(goTo(54), list); + } + break; + case 249: /* reduce ATerminal$RegExpTail */ + { + ArrayList list = new249(); + push(goTo(55), list); + } + break; + case 250: /* reduce ANonTerminal$RegExpTail */ + { + ArrayList list = new250(); + push(goTo(55), list); + } + break; + case 251: /* reduce ATerminal$UnExp */ + { + ArrayList list = new251(); + push(goTo(56), list); + } + break; + case 252: /* reduce ANonTerminal$UnExp */ + { + ArrayList list = new252(); + push(goTo(56), list); + } + break; + case 253: /* reduce ATerminal$Prod */ + { + ArrayList list = new253(); + push(goTo(57), list); + } + break; + case 254: /* reduce ANonTerminal$Prod */ + { + ArrayList list = new254(); + push(goTo(57), list); + } + break; + case 255: /* reduce ATerminal$Elem */ + { + ArrayList list = new255(); + push(goTo(58), list); + } + break; + case 256: /* reduce ANonTerminal$Elem */ + { + ArrayList list = new256(); + push(goTo(58), list); + } + break; + case 257: /* reduce ATerminal$AltsTail */ + { + ArrayList list = new257(); + push(goTo(59), list); + } + break; + case 258: /* reduce ANonTerminal$AltsTail */ + { + ArrayList list = new258(); + push(goTo(59), list); + } + break; + case 259: /* reduce ATerminal$Term */ + { + ArrayList list = new259(); + push(goTo(60), list); + } + break; + case 260: /* reduce ANonTerminal$Term */ + { + ArrayList list = new260(); + push(goTo(60), list); + } + break; + case 261: /* reduce ATerminal$ListTermTail */ + { + ArrayList list = new261(); + push(goTo(61), list); + } + break; + case 262: /* reduce ANonTerminal$ListTermTail */ + { + ArrayList list = new262(); + push(goTo(61), list); + } + break; + case 263: /* reduce ATerminal$ParamsTail */ + { + ArrayList list = new263(); + push(goTo(62), list); + } + break; + case 264: /* reduce ANonTerminal$ParamsTail */ + { + ArrayList list = new264(); + push(goTo(62), list); + } + break; + case 265: /* reduce ATerminal$AstProd */ + { + ArrayList list = new265(); + push(goTo(63), list); + } + break; + case 266: /* reduce ANonTerminal$AstProd */ + { + ArrayList list = new266(); + push(goTo(63), list); + } + break; + case 267: /* reduce ATerminal$AstAltsTail */ + { + ArrayList list = new267(); + push(goTo(64), list); + } + break; + case 268: /* reduce ANonTerminal$AstAltsTail */ + { + ArrayList list = new268(); + push(goTo(64), list); + } + break; + } + break; + case ACCEPT: + { + EOF node2 = (EOF) lexer.next(); + PGrammar node1 = (PGrammar) ((ArrayList)pop()).get(0); + Start node = new Start(node1, node2); + return node; + } + case ERROR: + throw new ParserException(last_token, + "[" + last_line + "," + last_pos + "] " + + errorMessages[errors[action[1]]]); + } + } + } + + ArrayList new0() /* reduce AAgrammar1Grammar */ + { + ArrayList nodeList = new ArrayList(); + + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + {} + + pgrammarNode1 = new AGrammar(listNode2, null, null, null, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new1() /* reduce AAgrammar2Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + + pgrammarNode1 = new AGrammar(listNode3, null, null, null, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new2() /* reduce AAgrammar3Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, null, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new3() /* reduce AAgrammar4Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, null, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new4() /* reduce AAgrammar5Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, null, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new5() /* reduce AAgrammar6Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, null, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new6() /* reduce AAgrammar7Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, null, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new7() /* reduce AAgrammar8Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, null, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new8() /* reduce AAgrammar9Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + PTokens ptokensNode5; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + {} + ptokensNode5 = (PTokens)nodeArrayList1.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, ptokensNode5, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new9() /* reduce AAgrammar10Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + PTokens ptokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + ptokensNode6 = (PTokens)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, ptokensNode6, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new10() /* reduce AAgrammar11Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + PTokens ptokensNode5; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, ptokensNode5, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new11() /* reduce AAgrammar12Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + PTokens ptokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, ptokensNode6, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new12() /* reduce AAgrammar13Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + PTokens ptokensNode5; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, ptokensNode5, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new13() /* reduce AAgrammar14Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + PTokens ptokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, ptokensNode6, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new14() /* reduce AAgrammar15Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + PTokens ptokensNode5; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + ptokensNode5 = (PTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, ptokensNode5, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new15() /* reduce AAgrammar16Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + PTokens ptokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + ptokensNode6 = (PTokens)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, ptokensNode6, null, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new16() /* reduce AAgrammar17Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + {} + pigntokensNode6 = (PIgnTokens)nodeArrayList1.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, null, pigntokensNode6, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new17() /* reduce AAgrammar18Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pigntokensNode7 = (PIgnTokens)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, null, pigntokensNode7, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new18() /* reduce AAgrammar19Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, null, pigntokensNode6, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new19() /* reduce AAgrammar20Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, null, pigntokensNode7, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new20() /* reduce AAgrammar21Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, null, pigntokensNode6, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new21() /* reduce AAgrammar22Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, null, pigntokensNode7, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new22() /* reduce AAgrammar23Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, null, pigntokensNode6, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new23() /* reduce AAgrammar24Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, null, pigntokensNode7, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new24() /* reduce AAgrammar25Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + {} + ptokensNode5 = (PTokens)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, ptokensNode5, pigntokensNode6, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new25() /* reduce AAgrammar26Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + ptokensNode6 = (PTokens)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, ptokensNode6, pigntokensNode7, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new26() /* reduce AAgrammar27Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, ptokensNode5, pigntokensNode6, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new27() /* reduce AAgrammar28Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, ptokensNode6, pigntokensNode7, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new28() /* reduce AAgrammar29Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, ptokensNode5, pigntokensNode6, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new29() /* reduce AAgrammar30Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, ptokensNode6, pigntokensNode7, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new30() /* reduce AAgrammar31Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + ptokensNode5 = (PTokens)nodeArrayList3.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, ptokensNode5, pigntokensNode6, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new31() /* reduce AAgrammar32Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + ptokensNode6 = (PTokens)nodeArrayList4.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, ptokensNode6, pigntokensNode7, null, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new32() /* reduce AAgrammar33Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + pproductionsNode7 = (PProductions)nodeArrayList1.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, null, null, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new33() /* reduce AAgrammar34Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pproductionsNode8 = (PProductions)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, null, null, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new34() /* reduce AAgrammar35Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pproductionsNode7 = (PProductions)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, null, null, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new35() /* reduce AAgrammar36Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pproductionsNode8 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, null, null, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new36() /* reduce AAgrammar37Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + Object nullNode5 = null; + Object nullNode6 = null; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + pproductionsNode7 = (PProductions)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, null, null, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new37() /* reduce AAgrammar38Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + Object nullNode6 = null; + Object nullNode7 = null; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + pproductionsNode8 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, null, null, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new38() /* reduce AAgrammar39Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + Object nullNode5 = null; + Object nullNode6 = null; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, null, null, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new39() /* reduce AAgrammar40Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + Object nullNode6 = null; + Object nullNode7 = null; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, null, null, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new40() /* reduce AAgrammar41Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + PTokens ptokensNode5; + Object nullNode6 = null; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + ptokensNode5 = (PTokens)nodeArrayList1.get(0); + pproductionsNode7 = (PProductions)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, ptokensNode5, null, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new41() /* reduce AAgrammar42Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + PTokens ptokensNode6; + Object nullNode7 = null; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + ptokensNode6 = (PTokens)nodeArrayList2.get(0); + pproductionsNode8 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, ptokensNode6, null, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new42() /* reduce AAgrammar43Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + PTokens ptokensNode5; + Object nullNode6 = null; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, ptokensNode5, null, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new43() /* reduce AAgrammar44Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + PTokens ptokensNode6; + Object nullNode7 = null; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, ptokensNode6, null, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new44() /* reduce AAgrammar45Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + PTokens ptokensNode5; + Object nullNode6 = null; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, ptokensNode5, null, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new45() /* reduce AAgrammar46Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + PTokens ptokensNode6; + Object nullNode7 = null; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, ptokensNode6, null, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new46() /* reduce AAgrammar47Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + PTokens ptokensNode5; + Object nullNode6 = null; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + ptokensNode5 = (PTokens)nodeArrayList3.get(0); + pproductionsNode7 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, ptokensNode5, null, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new47() /* reduce AAgrammar48Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + PTokens ptokensNode6; + Object nullNode7 = null; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + ptokensNode6 = (PTokens)nodeArrayList4.get(0); + pproductionsNode8 = (PProductions)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, ptokensNode6, null, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new48() /* reduce AAgrammar49Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + pigntokensNode6 = (PIgnTokens)nodeArrayList1.get(0); + pproductionsNode7 = (PProductions)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, null, pigntokensNode6, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new49() /* reduce AAgrammar50Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pigntokensNode7 = (PIgnTokens)nodeArrayList2.get(0); + pproductionsNode8 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, null, pigntokensNode7, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new50() /* reduce AAgrammar51Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, null, pigntokensNode6, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new51() /* reduce AAgrammar52Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, null, pigntokensNode7, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new52() /* reduce AAgrammar53Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, null, pigntokensNode6, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new53() /* reduce AAgrammar54Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, null, pigntokensNode7, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new54() /* reduce AAgrammar55Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode7 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, null, pigntokensNode6, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new55() /* reduce AAgrammar56Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pproductionsNode8 = (PProductions)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, null, pigntokensNode7, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new56() /* reduce AAgrammar57Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + ptokensNode5 = (PTokens)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, ptokensNode5, pigntokensNode6, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new57() /* reduce AAgrammar58Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + ptokensNode6 = (PTokens)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, ptokensNode6, pigntokensNode7, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new58() /* reduce AAgrammar59Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode7 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, ptokensNode5, pigntokensNode6, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new59() /* reduce AAgrammar60Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pproductionsNode8 = (PProductions)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, ptokensNode6, pigntokensNode7, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new60() /* reduce AAgrammar61Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode7 = (PProductions)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, ptokensNode5, pigntokensNode6, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new61() /* reduce AAgrammar62Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pproductionsNode8 = (PProductions)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, ptokensNode6, pigntokensNode7, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new62() /* reduce AAgrammar63Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + Object nullNode8 = null; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + ptokensNode5 = (PTokens)nodeArrayList3.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList4.get(0); + pproductionsNode7 = (PProductions)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, ptokensNode5, pigntokensNode6, pproductionsNode7, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new63() /* reduce AAgrammar64Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + Object nullNode9 = null; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + ptokensNode6 = (PTokens)nodeArrayList4.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList5.get(0); + pproductionsNode8 = (PProductions)nodeArrayList6.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, ptokensNode6, pigntokensNode7, pproductionsNode8, null); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new64() /* reduce AAgrammar65Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + PAst pastNode8; + {} + pastNode8 = (PAst)nodeArrayList1.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, null, null, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new65() /* reduce AAgrammar66Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pastNode9 = (PAst)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, null, null, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new66() /* reduce AAgrammar67Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pastNode8 = (PAst)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, null, null, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new67() /* reduce AAgrammar68Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pastNode9 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, null, null, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new68() /* reduce AAgrammar69Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + PAst pastNode8; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + pastNode8 = (PAst)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, null, null, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new69() /* reduce AAgrammar70Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + pastNode9 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, null, null, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new70() /* reduce AAgrammar71Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, null, null, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new71() /* reduce AAgrammar72Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + Object nullNode6 = null; + Object nullNode7 = null; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, null, null, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new72() /* reduce AAgrammar73Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + PTokens ptokensNode5; + Object nullNode6 = null; + Object nullNode7 = null; + PAst pastNode8; + {} + ptokensNode5 = (PTokens)nodeArrayList1.get(0); + pastNode8 = (PAst)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, ptokensNode5, null, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new73() /* reduce AAgrammar74Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + PTokens ptokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + ptokensNode6 = (PTokens)nodeArrayList2.get(0); + pastNode9 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, ptokensNode6, null, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new74() /* reduce AAgrammar75Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + PTokens ptokensNode5; + Object nullNode6 = null; + Object nullNode7 = null; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, ptokensNode5, null, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new75() /* reduce AAgrammar76Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + PTokens ptokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, ptokensNode6, null, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new76() /* reduce AAgrammar77Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + PTokens ptokensNode5; + Object nullNode6 = null; + Object nullNode7 = null; + PAst pastNode8; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, ptokensNode5, null, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new77() /* reduce AAgrammar78Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + PTokens ptokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, ptokensNode6, null, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new78() /* reduce AAgrammar79Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + PTokens ptokensNode5; + Object nullNode6 = null; + Object nullNode7 = null; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + ptokensNode5 = (PTokens)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, ptokensNode5, null, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new79() /* reduce AAgrammar80Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + PTokens ptokensNode6; + Object nullNode7 = null; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + ptokensNode6 = (PTokens)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, ptokensNode6, null, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new80() /* reduce AAgrammar81Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + PAst pastNode8; + {} + pigntokensNode6 = (PIgnTokens)nodeArrayList1.get(0); + pastNode8 = (PAst)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, null, pigntokensNode6, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new81() /* reduce AAgrammar82Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pigntokensNode7 = (PIgnTokens)nodeArrayList2.get(0); + pastNode9 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, null, pigntokensNode7, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new82() /* reduce AAgrammar83Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, null, pigntokensNode6, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new83() /* reduce AAgrammar84Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, null, pigntokensNode7, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new84() /* reduce AAgrammar85Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + PAst pastNode8; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, null, pigntokensNode6, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new85() /* reduce AAgrammar86Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, null, pigntokensNode7, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new86() /* reduce AAgrammar87Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, null, pigntokensNode6, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new87() /* reduce AAgrammar88Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, null, pigntokensNode7, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new88() /* reduce AAgrammar89Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + PAst pastNode8; + {} + ptokensNode5 = (PTokens)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, ptokensNode5, pigntokensNode6, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new89() /* reduce AAgrammar90Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + ptokensNode6 = (PTokens)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, ptokensNode6, pigntokensNode7, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new90() /* reduce AAgrammar91Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, ptokensNode5, pigntokensNode6, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new91() /* reduce AAgrammar92Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, ptokensNode6, pigntokensNode7, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new92() /* reduce AAgrammar93Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + PAst pastNode8; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, ptokensNode5, pigntokensNode6, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new93() /* reduce AAgrammar94Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, ptokensNode6, pigntokensNode7, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new94() /* reduce AAgrammar95Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + Object nullNode7 = null; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + ptokensNode5 = (PTokens)nodeArrayList3.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList4.get(0); + pastNode8 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, ptokensNode5, pigntokensNode6, null, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new95() /* reduce AAgrammar96Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + Object nullNode8 = null; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + ptokensNode6 = (PTokens)nodeArrayList4.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList5.get(0); + pastNode9 = (PAst)nodeArrayList6.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, ptokensNode6, pigntokensNode7, null, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new96() /* reduce AAgrammar97Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + PProductions pproductionsNode7; + PAst pastNode8; + {} + pproductionsNode7 = (PProductions)nodeArrayList1.get(0); + pastNode8 = (PAst)nodeArrayList2.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, null, null, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new97() /* reduce AAgrammar98Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pproductionsNode8 = (PProductions)nodeArrayList2.get(0); + pastNode9 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, null, null, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new98() /* reduce AAgrammar99Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + PProductions pproductionsNode7; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pproductionsNode7 = (PProductions)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, null, null, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new99() /* reduce AAgrammar100Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + Object nullNode6 = null; + Object nullNode7 = null; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pproductionsNode8 = (PProductions)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, null, null, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new100() /* reduce AAgrammar101Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + Object nullNode5 = null; + Object nullNode6 = null; + PProductions pproductionsNode7; + PAst pastNode8; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + pproductionsNode7 = (PProductions)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, null, null, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new101() /* reduce AAgrammar102Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + Object nullNode6 = null; + Object nullNode7 = null; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + pproductionsNode8 = (PProductions)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, null, null, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new102() /* reduce AAgrammar103Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + Object nullNode5 = null; + Object nullNode6 = null; + PProductions pproductionsNode7; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, null, null, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new103() /* reduce AAgrammar104Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + Object nullNode6 = null; + Object nullNode7 = null; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, null, null, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new104() /* reduce AAgrammar105Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + PTokens ptokensNode5; + Object nullNode6 = null; + PProductions pproductionsNode7; + PAst pastNode8; + {} + ptokensNode5 = (PTokens)nodeArrayList1.get(0); + pproductionsNode7 = (PProductions)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, ptokensNode5, null, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new105() /* reduce AAgrammar106Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + PTokens ptokensNode6; + Object nullNode7 = null; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + ptokensNode6 = (PTokens)nodeArrayList2.get(0); + pproductionsNode8 = (PProductions)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, ptokensNode6, null, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new106() /* reduce AAgrammar107Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + PTokens ptokensNode5; + Object nullNode6 = null; + PProductions pproductionsNode7; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, ptokensNode5, null, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new107() /* reduce AAgrammar108Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + PTokens ptokensNode6; + Object nullNode7 = null; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, ptokensNode6, null, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new108() /* reduce AAgrammar109Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + PTokens ptokensNode5; + Object nullNode6 = null; + PProductions pproductionsNode7; + PAst pastNode8; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, ptokensNode5, null, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new109() /* reduce AAgrammar110Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + PTokens ptokensNode6; + Object nullNode7 = null; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, ptokensNode6, null, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new110() /* reduce AAgrammar111Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + PTokens ptokensNode5; + Object nullNode6 = null; + PProductions pproductionsNode7; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + ptokensNode5 = (PTokens)nodeArrayList3.get(0); + pproductionsNode7 = (PProductions)nodeArrayList4.get(0); + pastNode8 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, ptokensNode5, null, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new111() /* reduce AAgrammar112Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + PTokens ptokensNode6; + Object nullNode7 = null; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + ptokensNode6 = (PTokens)nodeArrayList4.get(0); + pproductionsNode8 = (PProductions)nodeArrayList5.get(0); + pastNode9 = (PAst)nodeArrayList6.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, ptokensNode6, null, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new112() /* reduce AAgrammar113Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + PAst pastNode8; + {} + pigntokensNode6 = (PIgnTokens)nodeArrayList1.get(0); + pproductionsNode7 = (PProductions)nodeArrayList2.get(0); + pastNode8 = (PAst)nodeArrayList3.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, null, pigntokensNode6, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new113() /* reduce AAgrammar114Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pigntokensNode7 = (PIgnTokens)nodeArrayList2.get(0); + pproductionsNode8 = (PProductions)nodeArrayList3.get(0); + pastNode9 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, null, pigntokensNode7, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new114() /* reduce AAgrammar115Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, null, pigntokensNode6, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new115() /* reduce AAgrammar116Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, null, pigntokensNode7, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new116() /* reduce AAgrammar117Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + PAst pastNode8; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, null, pigntokensNode6, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new117() /* reduce AAgrammar118Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, null, pigntokensNode7, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new118() /* reduce AAgrammar119Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + Object nullNode5 = null; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode7 = (PProductions)nodeArrayList4.get(0); + pastNode8 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, null, pigntokensNode6, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new119() /* reduce AAgrammar120Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + Object nullNode6 = null; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pproductionsNode8 = (PProductions)nodeArrayList5.get(0); + pastNode9 = (PAst)nodeArrayList6.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, null, pigntokensNode7, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new120() /* reduce AAgrammar121Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + Object nullNode4 = null; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + PAst pastNode8; + {} + ptokensNode5 = (PTokens)nodeArrayList1.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList2.get(0); + pproductionsNode7 = (PProductions)nodeArrayList3.get(0); + pastNode8 = (PAst)nodeArrayList4.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, null, ptokensNode5, pigntokensNode6, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new121() /* reduce AAgrammar122Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + Object nullNode5 = null; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + ptokensNode6 = (PTokens)nodeArrayList2.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode8 = (PProductions)nodeArrayList4.get(0); + pastNode9 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, null, ptokensNode6, pigntokensNode7, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new122() /* reduce AAgrammar123Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + Object nullNode4 = null; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode7 = (PProductions)nodeArrayList4.get(0); + pastNode8 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, null, ptokensNode5, pigntokensNode6, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new123() /* reduce AAgrammar124Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + Object nullNode5 = null; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pproductionsNode8 = (PProductions)nodeArrayList5.get(0); + pastNode9 = (PAst)nodeArrayList6.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, null, ptokensNode6, pigntokensNode7, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new124() /* reduce AAgrammar125Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + Object nullNode3 = null; + PStates pstatesNode4; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + PAst pastNode8; + {} + pstatesNode4 = (PStates)nodeArrayList1.get(0); + ptokensNode5 = (PTokens)nodeArrayList2.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList3.get(0); + pproductionsNode7 = (PProductions)nodeArrayList4.get(0); + pastNode8 = (PAst)nodeArrayList5.get(0); + + pgrammarNode1 = new AGrammar(listNode2, null, pstatesNode4, ptokensNode5, pigntokensNode6, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new125() /* reduce AAgrammar126Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + PStates pstatesNode5; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + pstatesNode5 = (PStates)nodeArrayList2.get(0); + ptokensNode6 = (PTokens)nodeArrayList3.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList4.get(0); + pproductionsNode8 = (PProductions)nodeArrayList5.get(0); + pastNode9 = (PAst)nodeArrayList6.get(0); + + pgrammarNode1 = new AGrammar(listNode3, null, pstatesNode5, ptokensNode6, pigntokensNode7, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new126() /* reduce AAgrammar127Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + PHelpers phelpersNode3; + PStates pstatesNode4; + PTokens ptokensNode5; + PIgnTokens pigntokensNode6; + PProductions pproductionsNode7; + PAst pastNode8; + {} + phelpersNode3 = (PHelpers)nodeArrayList1.get(0); + pstatesNode4 = (PStates)nodeArrayList2.get(0); + ptokensNode5 = (PTokens)nodeArrayList3.get(0); + pigntokensNode6 = (PIgnTokens)nodeArrayList4.get(0); + pproductionsNode7 = (PProductions)nodeArrayList5.get(0); + pastNode8 = (PAst)nodeArrayList6.get(0); + + pgrammarNode1 = new AGrammar(listNode2, phelpersNode3, pstatesNode4, ptokensNode5, pigntokensNode6, pproductionsNode7, pastNode8); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new127() /* reduce AAgrammar128Grammar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList7 = (ArrayList) pop(); + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PGrammar pgrammarNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + PHelpers phelpersNode4; + PStates pstatesNode5; + PTokens ptokensNode6; + PIgnTokens pigntokensNode7; + PProductions pproductionsNode8; + PAst pastNode9; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + phelpersNode4 = (PHelpers)nodeArrayList2.get(0); + pstatesNode5 = (PStates)nodeArrayList3.get(0); + ptokensNode6 = (PTokens)nodeArrayList4.get(0); + pigntokensNode7 = (PIgnTokens)nodeArrayList5.get(0); + pproductionsNode8 = (PProductions)nodeArrayList6.get(0); + pastNode9 = (PAst)nodeArrayList7.get(0); + + pgrammarNode1 = new AGrammar(listNode3, phelpersNode4, pstatesNode5, ptokensNode6, pigntokensNode7, pproductionsNode8, pastNode9); + } + nodeList.add(pgrammarNode1); + return nodeList; + } + + ArrayList new128() /* reduce APackage */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + listNode1 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode2.addAll(listNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new129() /* reduce AApkgname1PkgName */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + TPkgId tpkgidNode1; + tpkgidNode1 = (TPkgId)nodeArrayList1.get(0); + if(tpkgidNode1 != null) + { + listNode2.add(tpkgidNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new130() /* reduce AApkgname2PkgName */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TPkgId tpkgidNode1; + TypedLinkedList listNode2 = new TypedLinkedList(); + tpkgidNode1 = (TPkgId)nodeArrayList1.get(0); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(tpkgidNode1 != null) + { + listNode3.add(tpkgidNode1); + } + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new131() /* reduce APkgNameTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TPkgId tpkgidNode1; + tpkgidNode1 = (TPkgId)nodeArrayList2.get(0); + nodeList.add(tpkgidNode1); + return nodeList; + } + + ArrayList new132() /* reduce AHelpers */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PHelpers phelpersNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + + phelpersNode1 = new AHelpers(listNode3); + } + nodeList.add(phelpersNode1); + return nodeList; + } + + ArrayList new133() /* reduce AHelperDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PHelperDef phelperdefNode1; + { + TId tidNode2; + PRegExp pregexpNode3; + tidNode2 = (TId)nodeArrayList1.get(0); + pregexpNode3 = (PRegExp)nodeArrayList3.get(0); + + phelperdefNode1 = new AHelperDef(tidNode2, pregexpNode3); + } + nodeList.add(phelperdefNode1); + return nodeList; + } + + ArrayList new134() /* reduce AStates */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PStates pstatesNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + + pstatesNode1 = new AStates(listNode3); + } + nodeList.add(pstatesNode1); + return nodeList; + } + + ArrayList new135() /* reduce AAidlist1IdList */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + TId tidNode1; + tidNode1 = (TId)nodeArrayList1.get(0); + if(tidNode1 != null) + { + listNode2.add(tidNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new136() /* reduce AAidlist2IdList */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TId tidNode1; + TypedLinkedList listNode2 = new TypedLinkedList(); + tidNode1 = (TId)nodeArrayList1.get(0); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(tidNode1 != null) + { + listNode3.add(tidNode1); + } + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new137() /* reduce AIdListTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TId tidNode1; + tidNode1 = (TId)nodeArrayList2.get(0); + nodeList.add(tidNode1); + return nodeList; + } + + ArrayList new138() /* reduce ATokens */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTokens ptokensNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + + ptokensNode1 = new ATokens(listNode3); + } + nodeList.add(ptokensNode1); + return nodeList; + } + + ArrayList new139() /* reduce AAtokendef1TokenDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTokenDef ptokendefNode1; + { + Object nullNode2 = null; + TId tidNode3; + PRegExp pregexpNode4; + Object nullNode5 = null; + Object nullNode6 = null; + tidNode3 = (TId)nodeArrayList1.get(0); + pregexpNode4 = (PRegExp)nodeArrayList3.get(0); + + ptokendefNode1 = new ATokenDef(null, tidNode3, pregexpNode4, null, null); + } + nodeList.add(ptokendefNode1); + return nodeList; + } + + ArrayList new140() /* reduce AAtokendef2TokenDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTokenDef ptokendefNode1; + { + PStateList pstatelistNode2; + TId tidNode3; + PRegExp pregexpNode4; + Object nullNode5 = null; + Object nullNode6 = null; + pstatelistNode2 = (PStateList)nodeArrayList1.get(0); + tidNode3 = (TId)nodeArrayList2.get(0); + pregexpNode4 = (PRegExp)nodeArrayList4.get(0); + + ptokendefNode1 = new ATokenDef(pstatelistNode2, tidNode3, pregexpNode4, null, null); + } + nodeList.add(ptokendefNode1); + return nodeList; + } + + ArrayList new141() /* reduce AAtokendef3TokenDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTokenDef ptokendefNode1; + { + Object nullNode2 = null; + TId tidNode3; + PRegExp pregexpNode4; + TSlash tslashNode5; + PRegExp pregexpNode6; + tidNode3 = (TId)nodeArrayList1.get(0); + pregexpNode4 = (PRegExp)nodeArrayList3.get(0); + tslashNode5 = (TSlash)nodeArrayList4.get(0); + pregexpNode6 = (PRegExp)nodeArrayList4.get(1); + + ptokendefNode1 = new ATokenDef(null, tidNode3, pregexpNode4, tslashNode5, pregexpNode6); + } + nodeList.add(ptokendefNode1); + return nodeList; + } + + ArrayList new142() /* reduce AAtokendef4TokenDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList6 = (ArrayList) pop(); + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTokenDef ptokendefNode1; + { + PStateList pstatelistNode2; + TId tidNode3; + PRegExp pregexpNode4; + TSlash tslashNode5; + PRegExp pregexpNode6; + pstatelistNode2 = (PStateList)nodeArrayList1.get(0); + tidNode3 = (TId)nodeArrayList2.get(0); + pregexpNode4 = (PRegExp)nodeArrayList4.get(0); + tslashNode5 = (TSlash)nodeArrayList5.get(0); + pregexpNode6 = (PRegExp)nodeArrayList5.get(1); + + ptokendefNode1 = new ATokenDef(pstatelistNode2, tidNode3, pregexpNode4, tslashNode5, pregexpNode6); + } + nodeList.add(ptokendefNode1); + return nodeList; + } + + ArrayList new143() /* reduce AAstatelist1StateList */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PStateList pstatelistNode1; + { + TId tidNode2; + Object nullNode3 = null; + TypedLinkedList listNode4 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList2.get(0); + {} + + pstatelistNode1 = new AStateList(tidNode2, null, listNode4); + } + nodeList.add(pstatelistNode1); + return nodeList; + } + + ArrayList new144() /* reduce AAstatelist2StateList */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PStateList pstatelistNode1; + { + TId tidNode2; + PTransition ptransitionNode3; + TypedLinkedList listNode4 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList2.get(0); + ptransitionNode3 = (PTransition)nodeArrayList3.get(0); + {} + + pstatelistNode1 = new AStateList(tidNode2, ptransitionNode3, listNode4); + } + nodeList.add(pstatelistNode1); + return nodeList; + } + + ArrayList new145() /* reduce AAstatelist3StateList */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PStateList pstatelistNode1; + { + TId tidNode2; + Object nullNode3 = null; + TypedLinkedList listNode5 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList2.get(0); + { + TypedLinkedList listNode4 = new TypedLinkedList(); + listNode4 = (TypedLinkedList)nodeArrayList3.get(0); + if(listNode4 != null) + { + listNode5.addAll(listNode4); + } + } + + pstatelistNode1 = new AStateList(tidNode2, null, listNode5); + } + nodeList.add(pstatelistNode1); + return nodeList; + } + + ArrayList new146() /* reduce AAstatelist4StateList */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PStateList pstatelistNode1; + { + TId tidNode2; + PTransition ptransitionNode3; + TypedLinkedList listNode5 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList2.get(0); + ptransitionNode3 = (PTransition)nodeArrayList3.get(0); + { + TypedLinkedList listNode4 = new TypedLinkedList(); + listNode4 = (TypedLinkedList)nodeArrayList4.get(0); + if(listNode4 != null) + { + listNode5.addAll(listNode4); + } + } + + pstatelistNode1 = new AStateList(tidNode2, ptransitionNode3, listNode5); + } + nodeList.add(pstatelistNode1); + return nodeList; + } + + ArrayList new147() /* reduce AAstatelisttail1StateListTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PStateListTail pstatelisttailNode1; + { + TId tidNode2; + Object nullNode3 = null; + tidNode2 = (TId)nodeArrayList2.get(0); + + pstatelisttailNode1 = new AStateListTail(tidNode2, null); + } + nodeList.add(pstatelisttailNode1); + return nodeList; + } + + ArrayList new148() /* reduce AAstatelisttail2StateListTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PStateListTail pstatelisttailNode1; + { + TId tidNode2; + PTransition ptransitionNode3; + tidNode2 = (TId)nodeArrayList2.get(0); + ptransitionNode3 = (PTransition)nodeArrayList3.get(0); + + pstatelisttailNode1 = new AStateListTail(tidNode2, ptransitionNode3); + } + nodeList.add(pstatelisttailNode1); + return nodeList; + } + + ArrayList new149() /* reduce ATransition */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTransition ptransitionNode1; + { + TId tidNode2; + tidNode2 = (TId)nodeArrayList2.get(0); + + ptransitionNode1 = new ATransition(tidNode2); + } + nodeList.add(ptransitionNode1); + return nodeList; + } + + ArrayList new150() /* reduce AAigntokens1IgnTokens */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PIgnTokens pigntokensNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + {} + + pigntokensNode1 = new AIgnTokens(listNode2); + } + nodeList.add(pigntokensNode1); + return nodeList; + } + + ArrayList new151() /* reduce AAigntokens2IgnTokens */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PIgnTokens pigntokensNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList3.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + + pigntokensNode1 = new AIgnTokens(listNode3); + } + nodeList.add(pigntokensNode1); + return nodeList; + } + + ArrayList new152() /* reduce ALookAhead */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TSlash tslashNode1; + PRegExp pregexpNode2; + tslashNode1 = (TSlash)nodeArrayList1.get(0); + pregexpNode2 = (PRegExp)nodeArrayList2.get(0); + nodeList.add(tslashNode1); + nodeList.add(pregexpNode2); + return nodeList; + } + + ArrayList new153() /* reduce AAregexp1RegExp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PRegExp pregexpNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + { + PConcat pconcatNode2; + pconcatNode2 = (PConcat)nodeArrayList1.get(0); + if(pconcatNode2 != null) + { + listNode3.add(pconcatNode2); + } + } + + pregexpNode1 = new ARegExp(listNode3); + } + nodeList.add(pregexpNode1); + return nodeList; + } + + ArrayList new154() /* reduce AAregexp2RegExp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PRegExp pregexpNode1; + { + TypedLinkedList listNode4 = new TypedLinkedList(); + { + PConcat pconcatNode2; + TypedLinkedList listNode3 = new TypedLinkedList(); + pconcatNode2 = (PConcat)nodeArrayList1.get(0); + listNode3 = (TypedLinkedList)nodeArrayList2.get(0); + if(pconcatNode2 != null) + { + listNode4.add(pconcatNode2); + } + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + + pregexpNode1 = new ARegExp(listNode4); + } + nodeList.add(pregexpNode1); + return nodeList; + } + + ArrayList new155() /* reduce ARegExpTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PConcat pconcatNode1; + pconcatNode1 = (PConcat)nodeArrayList2.get(0); + nodeList.add(pconcatNode1); + return nodeList; + } + + ArrayList new156() /* reduce AAconcat1Concat */ + { + ArrayList nodeList = new ArrayList(); + + PConcat pconcatNode1; + { + TypedLinkedList listNode2 = new TypedLinkedList(); + {} + + pconcatNode1 = new AConcat(listNode2); + } + nodeList.add(pconcatNode1); + return nodeList; + } + + ArrayList new157() /* reduce AAconcat2Concat */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PConcat pconcatNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + + pconcatNode1 = new AConcat(listNode3); + } + nodeList.add(pconcatNode1); + return nodeList; + } + + ArrayList new158() /* reduce AAunexp1UnExp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PUnExp punexpNode1; + { + PBasic pbasicNode2; + Object nullNode3 = null; + pbasicNode2 = (PBasic)nodeArrayList1.get(0); + + punexpNode1 = new AUnExp(pbasicNode2, null); + } + nodeList.add(punexpNode1); + return nodeList; + } + + ArrayList new159() /* reduce AAunexp2UnExp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PUnExp punexpNode1; + { + PBasic pbasicNode2; + PUnOp punopNode3; + pbasicNode2 = (PBasic)nodeArrayList1.get(0); + punopNode3 = (PUnOp)nodeArrayList2.get(0); + + punexpNode1 = new AUnExp(pbasicNode2, punopNode3); + } + nodeList.add(punexpNode1); + return nodeList; + } + + ArrayList new160() /* reduce ACharBasic */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PBasic pbasicNode1; + { + PChar pcharNode2; + pcharNode2 = (PChar)nodeArrayList1.get(0); + + pbasicNode1 = new ACharBasic(pcharNode2); + } + nodeList.add(pbasicNode1); + return nodeList; + } + + ArrayList new161() /* reduce ASetBasic */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PBasic pbasicNode1; + { + PSet psetNode2; + psetNode2 = (PSet)nodeArrayList1.get(0); + + pbasicNode1 = new ASetBasic(psetNode2); + } + nodeList.add(pbasicNode1); + return nodeList; + } + + ArrayList new162() /* reduce AStringBasic */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PBasic pbasicNode1; + { + TString tstringNode2; + tstringNode2 = (TString)nodeArrayList1.get(0); + + pbasicNode1 = new AStringBasic(tstringNode2); + } + nodeList.add(pbasicNode1); + return nodeList; + } + + ArrayList new163() /* reduce AIdBasic */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PBasic pbasicNode1; + { + TId tidNode2; + tidNode2 = (TId)nodeArrayList1.get(0); + + pbasicNode1 = new AIdBasic(tidNode2); + } + nodeList.add(pbasicNode1); + return nodeList; + } + + ArrayList new164() /* reduce ARegExpBasic */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PBasic pbasicNode1; + { + PRegExp pregexpNode2; + pregexpNode2 = (PRegExp)nodeArrayList2.get(0); + + pbasicNode1 = new ARegExpBasic(pregexpNode2); + } + nodeList.add(pbasicNode1); + return nodeList; + } + + ArrayList new165() /* reduce ACharChar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PChar pcharNode1; + { + TChar tcharNode2; + tcharNode2 = (TChar)nodeArrayList1.get(0); + + pcharNode1 = new ACharChar(tcharNode2); + } + nodeList.add(pcharNode1); + return nodeList; + } + + ArrayList new166() /* reduce ADecChar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PChar pcharNode1; + { + TDecChar tdeccharNode2; + tdeccharNode2 = (TDecChar)nodeArrayList1.get(0); + + pcharNode1 = new ADecChar(tdeccharNode2); + } + nodeList.add(pcharNode1); + return nodeList; + } + + ArrayList new167() /* reduce AHexChar */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PChar pcharNode1; + { + THexChar thexcharNode2; + thexcharNode2 = (THexChar)nodeArrayList1.get(0); + + pcharNode1 = new AHexChar(thexcharNode2); + } + nodeList.add(pcharNode1); + return nodeList; + } + + ArrayList new168() /* reduce AOperationSet */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PSet psetNode1; + { + PBasic pbasicNode2; + PBinOp pbinopNode3; + PBasic pbasicNode4; + pbasicNode2 = (PBasic)nodeArrayList2.get(0); + pbinopNode3 = (PBinOp)nodeArrayList3.get(0); + pbasicNode4 = (PBasic)nodeArrayList4.get(0); + + psetNode1 = new AOperationSet(pbasicNode2, pbinopNode3, pbasicNode4); + } + nodeList.add(psetNode1); + return nodeList; + } + + ArrayList new169() /* reduce AIntervalSet */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PSet psetNode1; + { + PChar pcharNode2; + PChar pcharNode3; + pcharNode2 = (PChar)nodeArrayList2.get(0); + pcharNode3 = (PChar)nodeArrayList4.get(0); + + psetNode1 = new AIntervalSet(pcharNode2, pcharNode3); + } + nodeList.add(psetNode1); + return nodeList; + } + + ArrayList new170() /* reduce AStarUnOp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PUnOp punopNode1; + { + TStar tstarNode2; + tstarNode2 = (TStar)nodeArrayList1.get(0); + + punopNode1 = new AStarUnOp(tstarNode2); + } + nodeList.add(punopNode1); + return nodeList; + } + + ArrayList new171() /* reduce AQMarkUnOp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PUnOp punopNode1; + { + TQMark tqmarkNode2; + tqmarkNode2 = (TQMark)nodeArrayList1.get(0); + + punopNode1 = new AQMarkUnOp(tqmarkNode2); + } + nodeList.add(punopNode1); + return nodeList; + } + + ArrayList new172() /* reduce APlusUnOp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PUnOp punopNode1; + { + TPlus tplusNode2; + tplusNode2 = (TPlus)nodeArrayList1.get(0); + + punopNode1 = new APlusUnOp(tplusNode2); + } + nodeList.add(punopNode1); + return nodeList; + } + + ArrayList new173() /* reduce APlusBinOp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PBinOp pbinopNode1; + { + + pbinopNode1 = new APlusBinOp(); + } + nodeList.add(pbinopNode1); + return nodeList; + } + + ArrayList new174() /* reduce AMinusBinOp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PBinOp pbinopNode1; + { + + pbinopNode1 = new AMinusBinOp(); + } + nodeList.add(pbinopNode1); + return nodeList; + } + + ArrayList new175() /* reduce AProductions */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PProductions pproductionsNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + + pproductionsNode1 = new AProductions(listNode3); + } + nodeList.add(pproductionsNode1); + return nodeList; + } + + ArrayList new176() /* reduce AAprod1Prod */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PProd pprodNode1; + { + TId tidNode2; + Object nullNode3 = null; + TypedLinkedList listNode4 = new TypedLinkedList(); + TypedLinkedList listNode6 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList1.get(0); + {} + + { + TypedLinkedList listNode5 = new TypedLinkedList(); + listNode5 = (TypedLinkedList)nodeArrayList3.get(0); + if(listNode5 != null) + { + listNode6.addAll(listNode5); + } + } + + pprodNode1 = new AProd(tidNode2, null, listNode4, listNode6); + } + nodeList.add(pprodNode1); + return nodeList; + } + + ArrayList new177() /* reduce AAprod2Prod */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PProd pprodNode1; + { + TId tidNode2; + TArrow tarrowNode3; + TypedLinkedList listNode5 = new TypedLinkedList(); + TypedLinkedList listNode7 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList1.get(0); + tarrowNode3 = (TArrow)nodeArrayList2.get(0); + { + TypedLinkedList listNode4 = new TypedLinkedList(); + listNode4 = (TypedLinkedList)nodeArrayList2.get(1); + if(listNode4 != null) + { + listNode5.addAll(listNode4); + } + } + { + TypedLinkedList listNode6 = new TypedLinkedList(); + listNode6 = (TypedLinkedList)nodeArrayList4.get(0); + if(listNode6 != null) + { + listNode7.addAll(listNode6); + } + } + + pprodNode1 = new AProd(tidNode2, tarrowNode3, listNode5, listNode7); + } + nodeList.add(pprodNode1); + return nodeList; + } + + ArrayList new178() /* reduce AAprodtransform1ProdTransform */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TArrow tarrowNode1; + TypedLinkedList listNode2 = new TypedLinkedList(); + tarrowNode1 = (TArrow)nodeArrayList2.get(0); + {} + nodeList.add(tarrowNode1); + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new179() /* reduce AAprodtransform2ProdTransform */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TArrow tarrowNode1; + TypedLinkedList listNode3 = new TypedLinkedList(); + tarrowNode1 = (TArrow)nodeArrayList2.get(0); + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList3.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + nodeList.add(tarrowNode1); + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new180() /* reduce AAalts1Alts */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PAlt paltNode1; + paltNode1 = (PAlt)nodeArrayList1.get(0); + if(paltNode1 != null) + { + listNode2.add(paltNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new181() /* reduce AAalts2Alts */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + PAlt paltNode1; + TypedLinkedList listNode2 = new TypedLinkedList(); + paltNode1 = (PAlt)nodeArrayList1.get(0); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(paltNode1 != null) + { + listNode3.add(paltNode1); + } + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new182() /* reduce AAltsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAlt paltNode1; + paltNode1 = (PAlt)nodeArrayList2.get(0); + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new183() /* reduce AAalt1Alt */ + { + ArrayList nodeList = new ArrayList(); + + PAlt paltNode1; + { + Object nullNode2 = null; + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + {} + + paltNode1 = new AAlt(null, listNode3, null); + } + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new184() /* reduce AAalt2Alt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAlt paltNode1; + { + TId tidNode2; + TypedLinkedList listNode3 = new TypedLinkedList(); + Object nullNode4 = null; + tidNode2 = (TId)nodeArrayList1.get(0); + {} + + paltNode1 = new AAlt(tidNode2, listNode3, null); + } + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new185() /* reduce AAalt3Alt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAlt paltNode1; + { + Object nullNode2 = null; + TypedLinkedList listNode4 = new TypedLinkedList(); + Object nullNode5 = null; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + + paltNode1 = new AAlt(null, listNode4, null); + } + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new186() /* reduce AAalt4Alt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAlt paltNode1; + { + TId tidNode2; + TypedLinkedList listNode4 = new TypedLinkedList(); + Object nullNode5 = null; + tidNode2 = (TId)nodeArrayList1.get(0); + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + + paltNode1 = new AAlt(tidNode2, listNode4, null); + } + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new187() /* reduce AAalt5Alt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAlt paltNode1; + { + Object nullNode2 = null; + TypedLinkedList listNode3 = new TypedLinkedList(); + PAltTransform palttransformNode4; + {} + palttransformNode4 = (PAltTransform)nodeArrayList1.get(0); + + paltNode1 = new AAlt(null, listNode3, palttransformNode4); + } + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new188() /* reduce AAalt6Alt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAlt paltNode1; + { + TId tidNode2; + TypedLinkedList listNode3 = new TypedLinkedList(); + PAltTransform palttransformNode4; + tidNode2 = (TId)nodeArrayList1.get(0); + {} + palttransformNode4 = (PAltTransform)nodeArrayList2.get(0); + + paltNode1 = new AAlt(tidNode2, listNode3, palttransformNode4); + } + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new189() /* reduce AAalt7Alt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAlt paltNode1; + { + Object nullNode2 = null; + TypedLinkedList listNode4 = new TypedLinkedList(); + PAltTransform palttransformNode5; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + palttransformNode5 = (PAltTransform)nodeArrayList2.get(0); + + paltNode1 = new AAlt(null, listNode4, palttransformNode5); + } + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new190() /* reduce AAalt8Alt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAlt paltNode1; + { + TId tidNode2; + TypedLinkedList listNode4 = new TypedLinkedList(); + PAltTransform palttransformNode5; + tidNode2 = (TId)nodeArrayList1.get(0); + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + palttransformNode5 = (PAltTransform)nodeArrayList3.get(0); + + paltNode1 = new AAlt(tidNode2, listNode4, palttransformNode5); + } + nodeList.add(paltNode1); + return nodeList; + } + + ArrayList new191() /* reduce AAalttransform1AltTransform */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAltTransform palttransformNode1; + { + TLBrace tlbraceNode2; + TypedLinkedList listNode3 = new TypedLinkedList(); + TRBrace trbraceNode4; + tlbraceNode2 = (TLBrace)nodeArrayList1.get(0); + {} + trbraceNode4 = (TRBrace)nodeArrayList3.get(0); + + palttransformNode1 = new AAltTransform(tlbraceNode2, listNode3, trbraceNode4); + } + nodeList.add(palttransformNode1); + return nodeList; + } + + ArrayList new192() /* reduce AAalttransform2AltTransform */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAltTransform palttransformNode1; + { + TLBrace tlbraceNode2; + TypedLinkedList listNode4 = new TypedLinkedList(); + TRBrace trbraceNode5; + tlbraceNode2 = (TLBrace)nodeArrayList1.get(0); + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList3.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + trbraceNode5 = (TRBrace)nodeArrayList4.get(0); + + palttransformNode1 = new AAltTransform(tlbraceNode2, listNode4, trbraceNode5); + } + nodeList.add(palttransformNode1); + return nodeList; + } + + ArrayList new193() /* reduce AAnewterm1Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + PProdName pprodnameNode2; + TLPar tlparNode3; + TypedLinkedList listNode4 = new TypedLinkedList(); + pprodnameNode2 = (PProdName)nodeArrayList2.get(0); + tlparNode3 = (TLPar)nodeArrayList3.get(0); + {} + + ptermNode1 = new ANewTerm(pprodnameNode2, tlparNode3, listNode4); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new194() /* reduce AAnewterm2Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + PProdName pprodnameNode2; + TLPar tlparNode3; + TypedLinkedList listNode5 = new TypedLinkedList(); + pprodnameNode2 = (PProdName)nodeArrayList2.get(0); + tlparNode3 = (TLPar)nodeArrayList3.get(0); + { + TypedLinkedList listNode4 = new TypedLinkedList(); + listNode4 = (TypedLinkedList)nodeArrayList4.get(0); + if(listNode4 != null) + { + listNode5.addAll(listNode4); + } + } + + ptermNode1 = new ANewTerm(pprodnameNode2, tlparNode3, listNode5); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new195() /* reduce AAlistterm1Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + TLBkt tlbktNode2; + TypedLinkedList listNode3 = new TypedLinkedList(); + tlbktNode2 = (TLBkt)nodeArrayList1.get(0); + {} + + ptermNode1 = new AListTerm(tlbktNode2, listNode3); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new196() /* reduce AAlistterm2Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + TLBkt tlbktNode2; + TypedLinkedList listNode4 = new TypedLinkedList(); + tlbktNode2 = (TLBkt)nodeArrayList1.get(0); + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + + ptermNode1 = new AListTerm(tlbktNode2, listNode4); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new197() /* reduce AAsimpleterm1Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + Object nullNode2 = null; + TId tidNode3; + Object nullNode4 = null; + tidNode3 = (TId)nodeArrayList1.get(0); + + ptermNode1 = new ASimpleTerm(null, tidNode3, null); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new198() /* reduce AAsimpleterm2Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + PSpecifier pspecifierNode2; + TId tidNode3; + Object nullNode4 = null; + pspecifierNode2 = (PSpecifier)nodeArrayList1.get(0); + tidNode3 = (TId)nodeArrayList2.get(0); + + ptermNode1 = new ASimpleTerm(pspecifierNode2, tidNode3, null); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new199() /* reduce AAsimpleterm3Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + Object nullNode2 = null; + TId tidNode3; + TId tidNode4; + tidNode3 = (TId)nodeArrayList1.get(0); + tidNode4 = (TId)nodeArrayList2.get(0); + + ptermNode1 = new ASimpleTerm(null, tidNode3, tidNode4); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new200() /* reduce AAsimpleterm4Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + PSpecifier pspecifierNode2; + TId tidNode3; + TId tidNode4; + pspecifierNode2 = (PSpecifier)nodeArrayList1.get(0); + tidNode3 = (TId)nodeArrayList2.get(0); + tidNode4 = (TId)nodeArrayList3.get(0); + + ptermNode1 = new ASimpleTerm(pspecifierNode2, tidNode3, tidNode4); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new201() /* reduce ANullTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + { + + ptermNode1 = new ANullTerm(); + } + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new202() /* reduce AAlistoflistterm1ListOfListTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PListTerm plisttermNode1; + plisttermNode1 = (PListTerm)nodeArrayList1.get(0); + if(plisttermNode1 != null) + { + listNode2.add(plisttermNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new203() /* reduce AAlistoflistterm2ListOfListTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + PListTerm plisttermNode1; + TypedLinkedList listNode2 = new TypedLinkedList(); + plisttermNode1 = (PListTerm)nodeArrayList1.get(0); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(plisttermNode1 != null) + { + listNode3.add(plisttermNode1); + } + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new204() /* reduce AAnewlistterm1ListTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PListTerm plisttermNode1; + { + PProdName pprodnameNode2; + TLPar tlparNode3; + TypedLinkedList listNode4 = new TypedLinkedList(); + pprodnameNode2 = (PProdName)nodeArrayList2.get(0); + tlparNode3 = (TLPar)nodeArrayList3.get(0); + {} + + plisttermNode1 = new ANewListTerm(pprodnameNode2, tlparNode3, listNode4); + } + nodeList.add(plisttermNode1); + return nodeList; + } + + ArrayList new205() /* reduce AAnewlistterm2ListTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList5 = (ArrayList) pop(); + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PListTerm plisttermNode1; + { + PProdName pprodnameNode2; + TLPar tlparNode3; + TypedLinkedList listNode5 = new TypedLinkedList(); + pprodnameNode2 = (PProdName)nodeArrayList2.get(0); + tlparNode3 = (TLPar)nodeArrayList3.get(0); + { + TypedLinkedList listNode4 = new TypedLinkedList(); + listNode4 = (TypedLinkedList)nodeArrayList4.get(0); + if(listNode4 != null) + { + listNode5.addAll(listNode4); + } + } + + plisttermNode1 = new ANewListTerm(pprodnameNode2, tlparNode3, listNode5); + } + nodeList.add(plisttermNode1); + return nodeList; + } + + ArrayList new206() /* reduce AAsimplelistterm1ListTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PListTerm plisttermNode1; + { + Object nullNode2 = null; + TId tidNode3; + Object nullNode4 = null; + tidNode3 = (TId)nodeArrayList1.get(0); + + plisttermNode1 = new ASimpleListTerm(null, tidNode3, null); + } + nodeList.add(plisttermNode1); + return nodeList; + } + + ArrayList new207() /* reduce AAsimplelistterm2ListTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PListTerm plisttermNode1; + { + PSpecifier pspecifierNode2; + TId tidNode3; + Object nullNode4 = null; + pspecifierNode2 = (PSpecifier)nodeArrayList1.get(0); + tidNode3 = (TId)nodeArrayList2.get(0); + + plisttermNode1 = new ASimpleListTerm(pspecifierNode2, tidNode3, null); + } + nodeList.add(plisttermNode1); + return nodeList; + } + + ArrayList new208() /* reduce AAsimplelistterm3ListTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PListTerm plisttermNode1; + { + Object nullNode2 = null; + TId tidNode3; + TId tidNode4; + tidNode3 = (TId)nodeArrayList1.get(0); + tidNode4 = (TId)nodeArrayList2.get(0); + + plisttermNode1 = new ASimpleListTerm(null, tidNode3, tidNode4); + } + nodeList.add(plisttermNode1); + return nodeList; + } + + ArrayList new209() /* reduce AAsimplelistterm4ListTerm */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PListTerm plisttermNode1; + { + PSpecifier pspecifierNode2; + TId tidNode3; + TId tidNode4; + pspecifierNode2 = (PSpecifier)nodeArrayList1.get(0); + tidNode3 = (TId)nodeArrayList2.get(0); + tidNode4 = (TId)nodeArrayList3.get(0); + + plisttermNode1 = new ASimpleListTerm(pspecifierNode2, tidNode3, tidNode4); + } + nodeList.add(plisttermNode1); + return nodeList; + } + + ArrayList new210() /* reduce AListTermTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PListTerm plisttermNode1; + plisttermNode1 = (PListTerm)nodeArrayList2.get(0); + nodeList.add(plisttermNode1); + return nodeList; + } + + ArrayList new211() /* reduce ASimpleTermTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TId tidNode1; + tidNode1 = (TId)nodeArrayList2.get(0); + nodeList.add(tidNode1); + return nodeList; + } + + ArrayList new212() /* reduce AAprodname1ProdName */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PProdName pprodnameNode1; + { + TId tidNode2; + Object nullNode3 = null; + tidNode2 = (TId)nodeArrayList1.get(0); + + pprodnameNode1 = new AProdName(tidNode2, null); + } + nodeList.add(pprodnameNode1); + return nodeList; + } + + ArrayList new213() /* reduce AAprodname2ProdName */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PProdName pprodnameNode1; + { + TId tidNode2; + TId tidNode3; + tidNode2 = (TId)nodeArrayList1.get(0); + tidNode3 = (TId)nodeArrayList2.get(0); + + pprodnameNode1 = new AProdName(tidNode2, tidNode3); + } + nodeList.add(pprodnameNode1); + return nodeList; + } + + ArrayList new214() /* reduce AProdNameTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TId tidNode1; + tidNode1 = (TId)nodeArrayList2.get(0); + nodeList.add(tidNode1); + return nodeList; + } + + ArrayList new215() /* reduce AAparams1Params */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PTerm ptermNode1; + ptermNode1 = (PTerm)nodeArrayList1.get(0); + if(ptermNode1 != null) + { + listNode2.add(ptermNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new216() /* reduce AAparams2Params */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + PTerm ptermNode1; + TypedLinkedList listNode2 = new TypedLinkedList(); + ptermNode1 = (PTerm)nodeArrayList1.get(0); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(ptermNode1 != null) + { + listNode3.add(ptermNode1); + } + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new217() /* reduce AParamsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PTerm ptermNode1; + ptermNode1 = (PTerm)nodeArrayList2.get(0); + nodeList.add(ptermNode1); + return nodeList; + } + + ArrayList new218() /* reduce AAltName */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TId tidNode1; + tidNode1 = (TId)nodeArrayList2.get(0); + nodeList.add(tidNode1); + return nodeList; + } + + ArrayList new219() /* reduce AAelem1Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PElem pelemNode1; + { + Object nullNode2 = null; + Object nullNode3 = null; + TId tidNode4; + Object nullNode5 = null; + tidNode4 = (TId)nodeArrayList1.get(0); + + pelemNode1 = new AElem(null, null, tidNode4, null); + } + nodeList.add(pelemNode1); + return nodeList; + } + + ArrayList new220() /* reduce AAelem2Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PElem pelemNode1; + { + TId tidNode2; + Object nullNode3 = null; + TId tidNode4; + Object nullNode5 = null; + tidNode2 = (TId)nodeArrayList1.get(0); + tidNode4 = (TId)nodeArrayList2.get(0); + + pelemNode1 = new AElem(tidNode2, null, tidNode4, null); + } + nodeList.add(pelemNode1); + return nodeList; + } + + ArrayList new221() /* reduce AAelem3Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PElem pelemNode1; + { + Object nullNode2 = null; + PSpecifier pspecifierNode3; + TId tidNode4; + Object nullNode5 = null; + pspecifierNode3 = (PSpecifier)nodeArrayList1.get(0); + tidNode4 = (TId)nodeArrayList2.get(0); + + pelemNode1 = new AElem(null, pspecifierNode3, tidNode4, null); + } + nodeList.add(pelemNode1); + return nodeList; + } + + ArrayList new222() /* reduce AAelem4Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PElem pelemNode1; + { + TId tidNode2; + PSpecifier pspecifierNode3; + TId tidNode4; + Object nullNode5 = null; + tidNode2 = (TId)nodeArrayList1.get(0); + pspecifierNode3 = (PSpecifier)nodeArrayList2.get(0); + tidNode4 = (TId)nodeArrayList3.get(0); + + pelemNode1 = new AElem(tidNode2, pspecifierNode3, tidNode4, null); + } + nodeList.add(pelemNode1); + return nodeList; + } + + ArrayList new223() /* reduce AAelem5Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PElem pelemNode1; + { + Object nullNode2 = null; + Object nullNode3 = null; + TId tidNode4; + PUnOp punopNode5; + tidNode4 = (TId)nodeArrayList1.get(0); + punopNode5 = (PUnOp)nodeArrayList2.get(0); + + pelemNode1 = new AElem(null, null, tidNode4, punopNode5); + } + nodeList.add(pelemNode1); + return nodeList; + } + + ArrayList new224() /* reduce AAelem6Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PElem pelemNode1; + { + TId tidNode2; + Object nullNode3 = null; + TId tidNode4; + PUnOp punopNode5; + tidNode2 = (TId)nodeArrayList1.get(0); + tidNode4 = (TId)nodeArrayList2.get(0); + punopNode5 = (PUnOp)nodeArrayList3.get(0); + + pelemNode1 = new AElem(tidNode2, null, tidNode4, punopNode5); + } + nodeList.add(pelemNode1); + return nodeList; + } + + ArrayList new225() /* reduce AAelem7Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PElem pelemNode1; + { + Object nullNode2 = null; + PSpecifier pspecifierNode3; + TId tidNode4; + PUnOp punopNode5; + pspecifierNode3 = (PSpecifier)nodeArrayList1.get(0); + tidNode4 = (TId)nodeArrayList2.get(0); + punopNode5 = (PUnOp)nodeArrayList3.get(0); + + pelemNode1 = new AElem(null, pspecifierNode3, tidNode4, punopNode5); + } + nodeList.add(pelemNode1); + return nodeList; + } + + ArrayList new226() /* reduce AAelem8Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PElem pelemNode1; + { + TId tidNode2; + PSpecifier pspecifierNode3; + TId tidNode4; + PUnOp punopNode5; + tidNode2 = (TId)nodeArrayList1.get(0); + pspecifierNode3 = (PSpecifier)nodeArrayList2.get(0); + tidNode4 = (TId)nodeArrayList3.get(0); + punopNode5 = (PUnOp)nodeArrayList4.get(0); + + pelemNode1 = new AElem(tidNode2, pspecifierNode3, tidNode4, punopNode5); + } + nodeList.add(pelemNode1); + return nodeList; + } + + ArrayList new227() /* reduce AElemName */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TId tidNode1; + tidNode1 = (TId)nodeArrayList2.get(0); + nodeList.add(tidNode1); + return nodeList; + } + + ArrayList new228() /* reduce ATokenSpecifier */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PSpecifier pspecifierNode1; + { + + pspecifierNode1 = new ATokenSpecifier(); + } + nodeList.add(pspecifierNode1); + return nodeList; + } + + ArrayList new229() /* reduce AProductionSpecifier */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PSpecifier pspecifierNode1; + { + + pspecifierNode1 = new AProductionSpecifier(); + } + nodeList.add(pspecifierNode1); + return nodeList; + } + + ArrayList new230() /* reduce AAst */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAst pastNode1; + { + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode2 = new TypedLinkedList(); + listNode2 = (TypedLinkedList)nodeArrayList4.get(0); + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + + pastNode1 = new AAst(listNode3); + } + nodeList.add(pastNode1); + return nodeList; + } + + ArrayList new231() /* reduce AAstProd */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList4 = (ArrayList) pop(); + ArrayList nodeArrayList3 = (ArrayList) pop(); + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAstProd pastprodNode1; + { + TId tidNode2; + TypedLinkedList listNode4 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList1.get(0); + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList3.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + + pastprodNode1 = new AAstProd(tidNode2, listNode4); + } + nodeList.add(pastprodNode1); + return nodeList; + } + + ArrayList new232() /* reduce AAastalts1AstAlts */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PAstAlt pastaltNode1; + pastaltNode1 = (PAstAlt)nodeArrayList1.get(0); + if(pastaltNode1 != null) + { + listNode2.add(pastaltNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new233() /* reduce AAastalts2AstAlts */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + PAstAlt pastaltNode1; + TypedLinkedList listNode2 = new TypedLinkedList(); + pastaltNode1 = (PAstAlt)nodeArrayList1.get(0); + listNode2 = (TypedLinkedList)nodeArrayList2.get(0); + if(pastaltNode1 != null) + { + listNode3.add(pastaltNode1); + } + if(listNode2 != null) + { + listNode3.addAll(listNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new234() /* reduce AAstAltsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAstAlt pastaltNode1; + pastaltNode1 = (PAstAlt)nodeArrayList2.get(0); + nodeList.add(pastaltNode1); + return nodeList; + } + + ArrayList new235() /* reduce AAastalt1AstAlt */ + { + ArrayList nodeList = new ArrayList(); + + PAstAlt pastaltNode1; + { + Object nullNode2 = null; + TypedLinkedList listNode3 = new TypedLinkedList(); + {} + + pastaltNode1 = new AAstAlt(null, listNode3); + } + nodeList.add(pastaltNode1); + return nodeList; + } + + ArrayList new236() /* reduce AAastalt2AstAlt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAstAlt pastaltNode1; + { + TId tidNode2; + TypedLinkedList listNode3 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList1.get(0); + {} + + pastaltNode1 = new AAstAlt(tidNode2, listNode3); + } + nodeList.add(pastaltNode1); + return nodeList; + } + + ArrayList new237() /* reduce AAastalt3AstAlt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAstAlt pastaltNode1; + { + Object nullNode2 = null; + TypedLinkedList listNode4 = new TypedLinkedList(); + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList1.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + + pastaltNode1 = new AAstAlt(null, listNode4); + } + nodeList.add(pastaltNode1); + return nodeList; + } + + ArrayList new238() /* reduce AAastalt4AstAlt */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + PAstAlt pastaltNode1; + { + TId tidNode2; + TypedLinkedList listNode4 = new TypedLinkedList(); + tidNode2 = (TId)nodeArrayList1.get(0); + { + TypedLinkedList listNode3 = new TypedLinkedList(); + listNode3 = (TypedLinkedList)nodeArrayList2.get(0); + if(listNode3 != null) + { + listNode4.addAll(listNode3); + } + } + + pastaltNode1 = new AAstAlt(tidNode2, listNode4); + } + nodeList.add(pastaltNode1); + return nodeList; + } + + ArrayList new239() /* reduce ATerminal$PkgNameTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + TPkgId tpkgidNode1; + tpkgidNode1 = (TPkgId)nodeArrayList1.get(0); + if(tpkgidNode1 != null) + { + listNode2.add(tpkgidNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new240() /* reduce ANonTerminal$PkgNameTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + TPkgId tpkgidNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + tpkgidNode2 = (TPkgId)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(tpkgidNode2 != null) + { + listNode3.add(tpkgidNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new241() /* reduce ATerminal$HelperDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PHelperDef phelperdefNode1; + phelperdefNode1 = (PHelperDef)nodeArrayList1.get(0); + if(phelperdefNode1 != null) + { + listNode2.add(phelperdefNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new242() /* reduce ANonTerminal$HelperDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PHelperDef phelperdefNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + phelperdefNode2 = (PHelperDef)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(phelperdefNode2 != null) + { + listNode3.add(phelperdefNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new243() /* reduce ATerminal$IdListTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + TId tidNode1; + tidNode1 = (TId)nodeArrayList1.get(0); + if(tidNode1 != null) + { + listNode2.add(tidNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new244() /* reduce ANonTerminal$IdListTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + TId tidNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + tidNode2 = (TId)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(tidNode2 != null) + { + listNode3.add(tidNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new245() /* reduce ATerminal$TokenDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PTokenDef ptokendefNode1; + ptokendefNode1 = (PTokenDef)nodeArrayList1.get(0); + if(ptokendefNode1 != null) + { + listNode2.add(ptokendefNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new246() /* reduce ANonTerminal$TokenDef */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PTokenDef ptokendefNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + ptokendefNode2 = (PTokenDef)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(ptokendefNode2 != null) + { + listNode3.add(ptokendefNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new247() /* reduce ATerminal$StateListTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PStateListTail pstatelisttailNode1; + pstatelisttailNode1 = (PStateListTail)nodeArrayList1.get(0); + if(pstatelisttailNode1 != null) + { + listNode2.add(pstatelisttailNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new248() /* reduce ANonTerminal$StateListTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PStateListTail pstatelisttailNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + pstatelisttailNode2 = (PStateListTail)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(pstatelisttailNode2 != null) + { + listNode3.add(pstatelisttailNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new249() /* reduce ATerminal$RegExpTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PConcat pconcatNode1; + pconcatNode1 = (PConcat)nodeArrayList1.get(0); + if(pconcatNode1 != null) + { + listNode2.add(pconcatNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new250() /* reduce ANonTerminal$RegExpTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PConcat pconcatNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + pconcatNode2 = (PConcat)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(pconcatNode2 != null) + { + listNode3.add(pconcatNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new251() /* reduce ATerminal$UnExp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PUnExp punexpNode1; + punexpNode1 = (PUnExp)nodeArrayList1.get(0); + if(punexpNode1 != null) + { + listNode2.add(punexpNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new252() /* reduce ANonTerminal$UnExp */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PUnExp punexpNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + punexpNode2 = (PUnExp)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(punexpNode2 != null) + { + listNode3.add(punexpNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new253() /* reduce ATerminal$Prod */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PProd pprodNode1; + pprodNode1 = (PProd)nodeArrayList1.get(0); + if(pprodNode1 != null) + { + listNode2.add(pprodNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new254() /* reduce ANonTerminal$Prod */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PProd pprodNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + pprodNode2 = (PProd)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(pprodNode2 != null) + { + listNode3.add(pprodNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new255() /* reduce ATerminal$Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PElem pelemNode1; + pelemNode1 = (PElem)nodeArrayList1.get(0); + if(pelemNode1 != null) + { + listNode2.add(pelemNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new256() /* reduce ANonTerminal$Elem */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PElem pelemNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + pelemNode2 = (PElem)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(pelemNode2 != null) + { + listNode3.add(pelemNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new257() /* reduce ATerminal$AltsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PAlt paltNode1; + paltNode1 = (PAlt)nodeArrayList1.get(0); + if(paltNode1 != null) + { + listNode2.add(paltNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new258() /* reduce ANonTerminal$AltsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PAlt paltNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + paltNode2 = (PAlt)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(paltNode2 != null) + { + listNode3.add(paltNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new259() /* reduce ATerminal$Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PTerm ptermNode1; + ptermNode1 = (PTerm)nodeArrayList1.get(0); + if(ptermNode1 != null) + { + listNode2.add(ptermNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new260() /* reduce ANonTerminal$Term */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PTerm ptermNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + ptermNode2 = (PTerm)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(ptermNode2 != null) + { + listNode3.add(ptermNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new261() /* reduce ATerminal$ListTermTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PListTerm plisttermNode1; + plisttermNode1 = (PListTerm)nodeArrayList1.get(0); + if(plisttermNode1 != null) + { + listNode2.add(plisttermNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new262() /* reduce ANonTerminal$ListTermTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PListTerm plisttermNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + plisttermNode2 = (PListTerm)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(plisttermNode2 != null) + { + listNode3.add(plisttermNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new263() /* reduce ATerminal$ParamsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PTerm ptermNode1; + ptermNode1 = (PTerm)nodeArrayList1.get(0); + if(ptermNode1 != null) + { + listNode2.add(ptermNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new264() /* reduce ANonTerminal$ParamsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PTerm ptermNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + ptermNode2 = (PTerm)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(ptermNode2 != null) + { + listNode3.add(ptermNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new265() /* reduce ATerminal$AstProd */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PAstProd pastprodNode1; + pastprodNode1 = (PAstProd)nodeArrayList1.get(0); + if(pastprodNode1 != null) + { + listNode2.add(pastprodNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new266() /* reduce ANonTerminal$AstProd */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PAstProd pastprodNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + pastprodNode2 = (PAstProd)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(pastprodNode2 != null) + { + listNode3.add(pastprodNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + ArrayList new267() /* reduce ATerminal$AstAltsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode2 = new TypedLinkedList(); + { + PAstAlt pastaltNode1; + pastaltNode1 = (PAstAlt)nodeArrayList1.get(0); + if(pastaltNode1 != null) + { + listNode2.add(pastaltNode1); + } + } + nodeList.add(listNode2); + return nodeList; + } + + ArrayList new268() /* reduce ANonTerminal$AstAltsTail */ + { + ArrayList nodeList = new ArrayList(); + + ArrayList nodeArrayList2 = (ArrayList) pop(); + ArrayList nodeArrayList1 = (ArrayList) pop(); + TypedLinkedList listNode3 = new TypedLinkedList(); + { + TypedLinkedList listNode1 = new TypedLinkedList(); + PAstAlt pastaltNode2; + listNode1 = (TypedLinkedList)nodeArrayList1.get(0); + pastaltNode2 = (PAstAlt)nodeArrayList2.get(0); + if(listNode1 != null) + { + listNode3.addAll(listNode1); + } + if(pastaltNode2 != null) + { + listNode3.add(pastaltNode2); + } + } + nodeList.add(listNode3); + return nodeList; + } + + private static int[][][] actionTable; + /* { + {{-1, REDUCE, 0}, {1, SHIFT, 1}, {2, SHIFT, 2}, {3, SHIFT, 3}, {4, SHIFT, 4}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, ERROR, 1}, {0, SHIFT, 16}, }, + {{-1, ERROR, 2}, {33, SHIFT, 18}, }, + {{-1, ERROR, 3}, {33, SHIFT, 20}, }, + {{-1, ERROR, 4}, {22, SHIFT, 23}, {33, SHIFT, 24}, }, + {{-1, ERROR, 5}, {4, SHIFT, 28}, }, + {{-1, ERROR, 6}, {33, SHIFT, 29}, }, + {{-1, ERROR, 7}, {8, SHIFT, 32}, }, + {{-1, ERROR, 8}, {38, ACCEPT, -1}, }, + {{-1, REDUCE, 1}, {2, SHIFT, 2}, {3, SHIFT, 3}, {4, SHIFT, 4}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 2}, {2, SHIFT, 2}, {4, SHIFT, 4}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 4}, {4, SHIFT, 4}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 8}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 16}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 32}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 64}, }, + {{-1, ERROR, 16}, {14, SHIFT, 54}, {16, SHIFT, 55}, }, + {{-1, REDUCE, 128}, }, + {{-1, REDUCE, 135}, {29, SHIFT, 58}, }, + {{-1, ERROR, 19}, {16, SHIFT, 61}, }, + {{-1, ERROR, 20}, {17, SHIFT, 62}, }, + {{-1, REDUCE, 241}, }, + {{-1, REDUCE, 132}, {33, SHIFT, 20}, }, + {{-1, ERROR, 23}, {33, SHIFT, 64}, }, + {{-1, ERROR, 24}, {17, SHIFT, 65}, }, + {{-1, REDUCE, 245}, }, + {{-1, ERROR, 26}, {33, SHIFT, 66}, }, + {{-1, REDUCE, 138}, {22, SHIFT, 23}, {33, SHIFT, 24}, }, + {{-1, ERROR, 28}, {16, SHIFT, 68}, {33, SHIFT, 18}, }, + {{-1, ERROR, 29}, {17, SHIFT, 70}, {22, SHIFT, 71}, }, + {{-1, REDUCE, 253}, }, + {{-1, REDUCE, 175}, {33, SHIFT, 29}, }, + {{-1, ERROR, 32}, {9, SHIFT, 74}, }, + {{-1, REDUCE, 3}, {2, SHIFT, 2}, {4, SHIFT, 4}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 5}, {4, SHIFT, 4}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 9}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 17}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 33}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 65}, }, + {{-1, REDUCE, 6}, {4, SHIFT, 4}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 10}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 18}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 34}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 66}, }, + {{-1, REDUCE, 12}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 20}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 36}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 68}, }, + {{-1, REDUCE, 24}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 40}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 72}, }, + {{-1, REDUCE, 48}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 80}, }, + {{-1, REDUCE, 96}, }, + {{-1, ERROR, 54}, {0, SHIFT, 110}, }, + {{-1, REDUCE, 129}, }, + {{-1, REDUCE, 239}, }, + {{-1, ERROR, 57}, {14, SHIFT, 54}, {16, SHIFT, 111}, }, + {{-1, ERROR, 58}, {33, SHIFT, 113}, }, + {{-1, REDUCE, 243}, }, + {{-1, REDUCE, 136}, {29, SHIFT, 58}, }, + {{-1, REDUCE, 134}, }, + {{-1, REDUCE, 156}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, REDUCE, 242}, }, + {{-1, ERROR, 64}, {23, SHIFT, 129}, {29, SHIFT, 130}, {31, SHIFT, 131}, }, + {{-1, REDUCE, 156}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, ERROR, 66}, {17, SHIFT, 136}, }, + {{-1, REDUCE, 246}, }, + {{-1, REDUCE, 150}, }, + {{-1, ERROR, 69}, {16, SHIFT, 137}, }, + {{-1, REDUCE, 183}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {22, SHIFT, 141}, {33, SHIFT, 142}, }, + {{-1, ERROR, 71}, {31, SHIFT, 151}, }, + {{-1, ERROR, 72}, {17, SHIFT, 152}, }, + {{-1, REDUCE, 254}, }, + {{-1, ERROR, 74}, {33, SHIFT, 153}, }, + {{-1, REDUCE, 7}, {4, SHIFT, 4}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 11}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 19}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 35}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 67}, }, + {{-1, REDUCE, 13}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 21}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 37}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 69}, }, + {{-1, REDUCE, 25}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 41}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 73}, }, + {{-1, REDUCE, 49}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 81}, }, + {{-1, REDUCE, 97}, }, + {{-1, REDUCE, 14}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 22}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 38}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 70}, }, + {{-1, REDUCE, 26}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 42}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 74}, }, + {{-1, REDUCE, 50}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 82}, }, + {{-1, REDUCE, 98}, }, + {{-1, REDUCE, 28}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 44}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 76}, }, + {{-1, REDUCE, 52}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 84}, }, + {{-1, REDUCE, 100}, }, + {{-1, REDUCE, 56}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 88}, }, + {{-1, REDUCE, 104}, }, + {{-1, REDUCE, 112}, }, + {{-1, REDUCE, 131}, }, + {{-1, REDUCE, 130}, }, + {{-1, REDUCE, 240}, }, + {{-1, REDUCE, 137}, }, + {{-1, REDUCE, 244}, }, + {{-1, ERROR, 115}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, REDUCE, 156}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, REDUCE, 163}, }, + {{-1, REDUCE, 165}, }, + {{-1, REDUCE, 166}, }, + {{-1, REDUCE, 167}, }, + {{-1, REDUCE, 162}, }, + {{-1, ERROR, 122}, {16, SHIFT, 194}, }, + {{-1, REDUCE, 153}, {28, SHIFT, 195}, }, + {{-1, REDUCE, 251}, }, + {{-1, REDUCE, 158}, {24, SHIFT, 198}, {26, SHIFT, 199}, {27, SHIFT, 200}, }, + {{-1, REDUCE, 160}, }, + {{-1, REDUCE, 161}, }, + {{-1, REDUCE, 157}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, REDUCE, 143}, }, + {{-1, ERROR, 130}, {33, SHIFT, 203}, }, + {{-1, ERROR, 131}, {33, SHIFT, 204}, }, + {{-1, REDUCE, 247}, }, + {{-1, ERROR, 133}, {23, SHIFT, 205}, {29, SHIFT, 130}, }, + {{-1, ERROR, 134}, {23, SHIFT, 207}, {29, SHIFT, 130}, }, + {{-1, ERROR, 135}, {16, SHIFT, 209}, {30, SHIFT, 210}, }, + {{-1, REDUCE, 156}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, REDUCE, 151}, }, + {{-1, ERROR, 138}, {14, SHIFT, 213}, }, + {{-1, ERROR, 139}, {14, SHIFT, 214}, }, + {{-1, ERROR, 140}, {33, SHIFT, 215}, }, + {{-1, ERROR, 141}, {31, SHIFT, 216}, {33, SHIFT, 217}, }, + {{-1, REDUCE, 219}, {24, SHIFT, 198}, {26, SHIFT, 199}, {27, SHIFT, 200}, }, + {{-1, ERROR, 143}, {16, SHIFT, 219}, }, + {{-1, REDUCE, 180}, {28, SHIFT, 220}, }, + {{-1, REDUCE, 187}, }, + {{-1, REDUCE, 184}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {22, SHIFT, 223}, {33, SHIFT, 142}, }, + {{-1, REDUCE, 255}, }, + {{-1, ERROR, 148}, {12, SHIFT, 138}, {13, SHIFT, 139}, {33, SHIFT, 226}, }, + {{-1, ERROR, 149}, {33, SHIFT, 228}, }, + {{-1, REDUCE, 185}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {22, SHIFT, 223}, {33, SHIFT, 142}, }, + {{-1, ERROR, 151}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {23, SHIFT, 231}, {33, SHIFT, 142}, }, + {{-1, REDUCE, 183}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {22, SHIFT, 141}, {33, SHIFT, 142}, }, + {{-1, ERROR, 153}, {17, SHIFT, 234}, }, + {{-1, REDUCE, 265}, }, + {{-1, REDUCE, 230}, {33, SHIFT, 153}, }, + {{-1, REDUCE, 15}, {5, SHIFT, 5}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 23}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 39}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 71}, }, + {{-1, REDUCE, 27}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 43}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 75}, }, + {{-1, REDUCE, 51}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 83}, }, + {{-1, REDUCE, 99}, }, + {{-1, REDUCE, 29}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 45}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 77}, }, + {{-1, REDUCE, 53}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 85}, }, + {{-1, REDUCE, 101}, }, + {{-1, REDUCE, 57}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 89}, }, + {{-1, REDUCE, 105}, }, + {{-1, REDUCE, 113}, }, + {{-1, REDUCE, 30}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 46}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 78}, }, + {{-1, REDUCE, 54}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 86}, }, + {{-1, REDUCE, 102}, }, + {{-1, REDUCE, 58}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 90}, }, + {{-1, REDUCE, 106}, }, + {{-1, REDUCE, 114}, }, + {{-1, REDUCE, 60}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 92}, }, + {{-1, REDUCE, 108}, }, + {{-1, REDUCE, 116}, }, + {{-1, REDUCE, 120}, }, + {{-1, ERROR, 191}, {24, SHIFT, 257}, {25, SHIFT, 258}, }, + {{-1, REDUCE, 160}, {15, SHIFT, 260}, }, + {{-1, ERROR, 193}, {21, SHIFT, 261}, }, + {{-1, REDUCE, 133}, }, + {{-1, REDUCE, 156}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, REDUCE, 249}, }, + {{-1, REDUCE, 154}, {28, SHIFT, 195}, }, + {{-1, REDUCE, 172}, }, + {{-1, REDUCE, 171}, }, + {{-1, REDUCE, 170}, }, + {{-1, REDUCE, 159}, }, + {{-1, REDUCE, 252}, }, + {{-1, REDUCE, 147}, {31, SHIFT, 131}, }, + {{-1, REDUCE, 149}, }, + {{-1, REDUCE, 144}, }, + {{-1, ERROR, 206}, {23, SHIFT, 265}, {29, SHIFT, 130}, }, + {{-1, REDUCE, 145}, }, + {{-1, REDUCE, 248}, }, + {{-1, REDUCE, 139}, }, + {{-1, REDUCE, 156}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, ERROR, 211}, {16, SHIFT, 267}, }, + {{-1, ERROR, 212}, {16, SHIFT, 268}, {30, SHIFT, 210}, }, + {{-1, REDUCE, 228}, }, + {{-1, REDUCE, 229}, }, + {{-1, ERROR, 215}, {19, SHIFT, 270}, }, + {{-1, ERROR, 216}, {10, SHIFT, 271}, {11, SHIFT, 272}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 273}, {23, SHIFT, 274}, {33, SHIFT, 275}, }, + {{-1, ERROR, 217}, {23, SHIFT, 279}, }, + {{-1, REDUCE, 223}, }, + {{-1, REDUCE, 176}, }, + {{-1, REDUCE, 183}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {22, SHIFT, 141}, {33, SHIFT, 142}, }, + {{-1, REDUCE, 257}, }, + {{-1, REDUCE, 181}, {28, SHIFT, 220}, }, + {{-1, ERROR, 223}, {31, SHIFT, 216}, }, + {{-1, REDUCE, 188}, }, + {{-1, REDUCE, 186}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {22, SHIFT, 223}, {33, SHIFT, 142}, }, + {{-1, REDUCE, 220}, {24, SHIFT, 198}, {26, SHIFT, 199}, {27, SHIFT, 200}, }, + {{-1, ERROR, 227}, {33, SHIFT, 284}, }, + {{-1, REDUCE, 221}, {24, SHIFT, 198}, {26, SHIFT, 199}, {27, SHIFT, 200}, }, + {{-1, REDUCE, 189}, }, + {{-1, REDUCE, 256}, }, + {{-1, REDUCE, 178}, }, + {{-1, ERROR, 232}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {23, SHIFT, 286}, {33, SHIFT, 142}, }, + {{-1, ERROR, 233}, {16, SHIFT, 287}, }, + {{-1, REDUCE, 235}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {22, SHIFT, 288}, {33, SHIFT, 142}, }, + {{-1, REDUCE, 266}, }, + {{-1, REDUCE, 31}, {6, SHIFT, 6}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 47}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 79}, }, + {{-1, REDUCE, 55}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 87}, }, + {{-1, REDUCE, 103}, }, + {{-1, REDUCE, 59}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 91}, }, + {{-1, REDUCE, 107}, }, + {{-1, REDUCE, 115}, }, + {{-1, REDUCE, 61}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 93}, }, + {{-1, REDUCE, 109}, }, + {{-1, REDUCE, 117}, }, + {{-1, REDUCE, 121}, }, + {{-1, REDUCE, 62}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 94}, }, + {{-1, REDUCE, 110}, }, + {{-1, REDUCE, 118}, }, + {{-1, REDUCE, 122}, }, + {{-1, REDUCE, 124}, }, + {{-1, REDUCE, 173}, }, + {{-1, REDUCE, 174}, }, + {{-1, ERROR, 259}, {18, SHIFT, 115}, {20, SHIFT, 116}, {33, SHIFT, 117}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, {37, SHIFT, 121}, }, + {{-1, ERROR, 260}, {34, SHIFT, 118}, {35, SHIFT, 119}, {36, SHIFT, 120}, }, + {{-1, REDUCE, 164}, }, + {{-1, REDUCE, 155}, }, + {{-1, REDUCE, 250}, }, + {{-1, REDUCE, 148}, }, + {{-1, REDUCE, 146}, }, + {{-1, REDUCE, 152}, }, + {{-1, REDUCE, 141}, }, + {{-1, REDUCE, 140}, }, + {{-1, ERROR, 269}, {16, SHIFT, 302}, }, + {{-1, ERROR, 270}, {32, SHIFT, 303}, }, + {{-1, ERROR, 271}, {33, SHIFT, 304}, }, + {{-1, REDUCE, 201}, }, + {{-1, ERROR, 273}, {10, SHIFT, 306}, {12, SHIFT, 138}, {13, SHIFT, 139}, {19, SHIFT, 307}, {33, SHIFT, 308}, }, + {{-1, REDUCE, 191}, }, + {{-1, REDUCE, 197}, {14, SHIFT, 312}, }, + {{-1, REDUCE, 259}, }, + {{-1, ERROR, 277}, {33, SHIFT, 314}, }, + {{-1, ERROR, 278}, {10, SHIFT, 271}, {11, SHIFT, 272}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 273}, {23, SHIFT, 315}, {33, SHIFT, 275}, }, + {{-1, REDUCE, 218}, }, + {{-1, REDUCE, 182}, }, + {{-1, REDUCE, 258}, }, + {{-1, REDUCE, 190}, }, + {{-1, REDUCE, 224}, }, + {{-1, REDUCE, 222}, {24, SHIFT, 198}, {26, SHIFT, 199}, {27, SHIFT, 200}, }, + {{-1, REDUCE, 225}, }, + {{-1, REDUCE, 179}, }, + {{-1, REDUCE, 177}, }, + {{-1, ERROR, 288}, {33, SHIFT, 217}, }, + {{-1, REDUCE, 236}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {33, SHIFT, 142}, }, + {{-1, ERROR, 290}, {16, SHIFT, 319}, }, + {{-1, REDUCE, 232}, {28, SHIFT, 320}, }, + {{-1, REDUCE, 237}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {33, SHIFT, 142}, }, + {{-1, REDUCE, 63}, {7, SHIFT, 7}, }, + {{-1, REDUCE, 95}, }, + {{-1, REDUCE, 111}, }, + {{-1, REDUCE, 119}, }, + {{-1, REDUCE, 123}, }, + {{-1, REDUCE, 125}, }, + {{-1, REDUCE, 126}, }, + {{-1, ERROR, 300}, {19, SHIFT, 324}, }, + {{-1, ERROR, 301}, {19, SHIFT, 325}, }, + {{-1, REDUCE, 142}, }, + {{-1, REDUCE, 227}, }, + {{-1, REDUCE, 212}, {14, SHIFT, 326}, }, + {{-1, ERROR, 305}, {20, SHIFT, 328}, }, + {{-1, ERROR, 306}, {33, SHIFT, 304}, }, + {{-1, REDUCE, 195}, }, + {{-1, REDUCE, 206}, {14, SHIFT, 312}, }, + {{-1, ERROR, 309}, {19, SHIFT, 331}, }, + {{-1, REDUCE, 202}, {29, SHIFT, 332}, }, + {{-1, ERROR, 311}, {33, SHIFT, 335}, }, + {{-1, ERROR, 312}, {33, SHIFT, 336}, }, + {{-1, REDUCE, 199}, }, + {{-1, REDUCE, 198}, {14, SHIFT, 312}, }, + {{-1, REDUCE, 192}, }, + {{-1, REDUCE, 260}, }, + {{-1, REDUCE, 226}, }, + {{-1, REDUCE, 238}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {33, SHIFT, 142}, }, + {{-1, REDUCE, 231}, }, + {{-1, REDUCE, 235}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 140}, {22, SHIFT, 288}, {33, SHIFT, 142}, }, + {{-1, REDUCE, 267}, }, + {{-1, REDUCE, 233}, {28, SHIFT, 320}, }, + {{-1, REDUCE, 127}, }, + {{-1, REDUCE, 168}, }, + {{-1, REDUCE, 169}, }, + {{-1, ERROR, 326}, {33, SHIFT, 340}, }, + {{-1, REDUCE, 213}, }, + {{-1, ERROR, 328}, {10, SHIFT, 271}, {11, SHIFT, 272}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 273}, {21, SHIFT, 341}, {33, SHIFT, 275}, }, + {{-1, ERROR, 329}, {20, SHIFT, 344}, }, + {{-1, REDUCE, 208}, }, + {{-1, REDUCE, 196}, }, + {{-1, ERROR, 332}, {10, SHIFT, 306}, {12, SHIFT, 138}, {13, SHIFT, 139}, {33, SHIFT, 308}, }, + {{-1, REDUCE, 261}, }, + {{-1, REDUCE, 203}, {29, SHIFT, 332}, }, + {{-1, REDUCE, 207}, {14, SHIFT, 312}, }, + {{-1, REDUCE, 211}, }, + {{-1, REDUCE, 200}, }, + {{-1, REDUCE, 234}, }, + {{-1, REDUCE, 268}, }, + {{-1, REDUCE, 214}, }, + {{-1, REDUCE, 193}, }, + {{-1, REDUCE, 215}, {29, SHIFT, 348}, }, + {{-1, ERROR, 343}, {21, SHIFT, 351}, }, + {{-1, ERROR, 344}, {10, SHIFT, 271}, {11, SHIFT, 272}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 273}, {21, SHIFT, 352}, {33, SHIFT, 275}, }, + {{-1, REDUCE, 210}, }, + {{-1, REDUCE, 262}, }, + {{-1, REDUCE, 209}, }, + {{-1, ERROR, 348}, {10, SHIFT, 271}, {11, SHIFT, 272}, {12, SHIFT, 138}, {13, SHIFT, 139}, {18, SHIFT, 273}, {33, SHIFT, 275}, }, + {{-1, REDUCE, 263}, }, + {{-1, REDUCE, 216}, {29, SHIFT, 348}, }, + {{-1, REDUCE, 194}, }, + {{-1, REDUCE, 204}, }, + {{-1, ERROR, 353}, {21, SHIFT, 356}, }, + {{-1, REDUCE, 217}, }, + {{-1, REDUCE, 264}, }, + {{-1, REDUCE, 205}, }, + };*/ + private static int[][][] gotoTable; + /* { + {{-1, 8}, }, + {{-1, 9}, }, + {{-1, 17}, }, + {{-1, 56}, {57, 112}, }, + {{-1, 10}, {9, 33}, }, + {{-1, 21}, {22, 63}, }, + {{-1, 11}, {9, 34}, {10, 39}, {33, 75}, }, + {{-1, 19}, {28, 69}, }, + {{-1, 59}, {60, 114}, }, + {{-1, 12}, {9, 35}, {10, 40}, {11, 44}, {33, 76}, {34, 80}, {39, 90}, {75, 156}, }, + {{-1, 25}, {27, 67}, }, + {{-1, 26}, }, + {{-1, 132}, {134, 208}, {206, 208}, }, + {{-1, 133}, {203, 264}, }, + {{-1, 13}, {9, 36}, {10, 41}, {11, 45}, {12, 48}, {33, 77}, {34, 81}, {35, 84}, {39, 91}, {40, 94}, {44, 100}, {75, 157}, {76, 160}, {80, 166}, {90, 176}, {156, 236}, }, + {{-1, 211}, {212, 269}, }, + {{-1, 122}, {65, 135}, {116, 193}, {136, 212}, {210, 266}, }, + {{-1, 196}, {197, 263}, }, + {{-1, 123}, {195, 262}, }, + {{-1, 124}, {128, 202}, }, + {{-1, 125}, {115, 191}, {259, 300}, }, + {{-1, 126}, {115, 192}, {260, 301}, }, + {{-1, 127}, }, + {{-1, 201}, {142, 218}, {226, 283}, {228, 285}, {284, 317}, }, + {{-1, 259}, }, + {{-1, 14}, {9, 37}, {10, 42}, {11, 46}, {12, 49}, {13, 51}, {33, 78}, {34, 82}, {35, 85}, {36, 87}, {39, 92}, {40, 95}, {41, 97}, {44, 101}, {45, 103}, {48, 106}, {75, 158}, {76, 161}, {77, 163}, {80, 167}, {81, 169}, {84, 172}, {90, 177}, {91, 179}, {94, 182}, {100, 186}, {156, 237}, {157, 239}, {160, 242}, {166, 246}, {176, 251}, {236, 293}, }, + {{-1, 30}, {31, 73}, }, + {{-1, 72}, }, + {{-1, 143}, {152, 233}, }, + {{-1, 221}, {222, 281}, }, + {{-1, 144}, {220, 280}, }, + {{-1, 145}, {146, 224}, {150, 229}, {225, 282}, }, + {{-1, 342}, {216, 276}, {278, 316}, {348, 354}, }, + {{-1, 309}, }, + {{-1, 310}, {332, 345}, }, + {{-1, 333}, {334, 346}, }, + {{-1, 313}, {308, 330}, {314, 337}, {335, 347}, }, + {{-1, 305}, {306, 329}, }, + {{-1, 327}, }, + {{-1, 343}, {344, 353}, }, + {{-1, 349}, {350, 355}, }, + {{-1, 146}, {234, 289}, {320, 289}, }, + {{-1, 147}, {150, 230}, {225, 230}, {232, 230}, {292, 230}, {318, 230}, }, + {{-1, 148}, }, + {{-1, 149}, {148, 227}, {216, 277}, {273, 311}, {278, 277}, {328, 277}, {332, 311}, {344, 277}, {348, 277}, }, + {{-1, 15}, {9, 38}, {10, 43}, {11, 47}, {12, 50}, {13, 52}, {14, 53}, {33, 79}, {34, 83}, {35, 86}, {36, 88}, {37, 89}, {39, 93}, {40, 96}, {41, 98}, {42, 99}, {44, 102}, {45, 104}, {46, 105}, {48, 107}, {49, 108}, {51, 109}, {75, 159}, {76, 162}, {77, 164}, {78, 165}, {80, 168}, {81, 170}, {82, 171}, {84, 173}, {85, 174}, {87, 175}, {90, 178}, {91, 180}, {92, 181}, {94, 183}, {95, 184}, {97, 185}, {100, 187}, {101, 188}, {103, 189}, {106, 190}, {156, 238}, {157, 240}, {158, 241}, {160, 243}, {161, 244}, {163, 245}, {166, 247}, {167, 248}, {169, 249}, {172, 250}, {176, 252}, {177, 253}, {179, 254}, {182, 255}, {186, 256}, {236, 294}, {237, 295}, {239, 296}, {242, 297}, {246, 298}, {251, 299}, {293, 323}, }, + {{-1, 154}, {155, 235}, }, + {{-1, 290}, }, + {{-1, 321}, {322, 339}, }, + {{-1, 291}, {320, 338}, }, + {{-1, 57}, }, + {{-1, 22}, }, + {{-1, 60}, }, + {{-1, 27}, }, + {{-1, 134}, {133, 206}, }, + {{-1, 197}, }, + {{-1, 128}, }, + {{-1, 31}, }, + {{-1, 150}, {146, 225}, {151, 232}, {234, 292}, {289, 318}, {320, 292}, }, + {{-1, 222}, }, + {{-1, 278}, }, + {{-1, 334}, }, + {{-1, 350}, }, + {{-1, 155}, }, + {{-1, 322}, }, + };*/ + private static String[] errorMessages; + /* { + "expecting: 'Package', 'States', 'Helpers', 'Tokens', 'Ignored', 'Productions', 'Abstract', EOF", + "expecting: pkg id", + "expecting: id", + "expecting: '{', id", + "expecting: 'Tokens'", + "expecting: 'Syntax'", + "expecting: EOF", + "expecting: 'States', 'Helpers', 'Tokens', 'Ignored', 'Productions', 'Abstract', EOF", + "expecting: 'States', 'Tokens', 'Ignored', 'Productions', 'Abstract', EOF", + "expecting: 'Tokens', 'Ignored', 'Productions', 'Abstract', EOF", + "expecting: 'Ignored', 'Productions', 'Abstract', EOF", + "expecting: 'Productions', 'Abstract', EOF", + "expecting: 'Abstract', EOF", + "expecting: '.', ';'", + "expecting: ';', ','", + "expecting: ';'", + "expecting: '='", + "expecting: 'States', 'Tokens', 'Ignored', 'Productions', 'Abstract', id, EOF", + "expecting: 'Ignored', 'Productions', 'Abstract', '{', id, EOF", + "expecting: ';', id", + "expecting: '=', '{'", + "expecting: 'Abstract', id, EOF", + "expecting: 'Tree'", + "expecting: ';', '[', '(', '|', id, char, dec char, hex char, string", + "expecting: '}', ',', '->'", + "expecting: ';', '[', '(', '|', '/', id, char, dec char, hex char, string", + "expecting: 'T', 'P', ';', '[', '{', '|', id", + "expecting: '->'", + "expecting: '[', '(', id, char, dec char, hex char, string", + "expecting: '[', '(', ')', '|', id, char, dec char, hex char, string", + "expecting: ';', '[', ']', '(', ')', '+', '-', '?', '*', '|', '/', id, char, dec char, hex char, string", + "expecting: '..', ';', '[', ']', '(', ')', '+', '-', '?', '*', '|', '/', id, char, dec char, hex char, string", + "expecting: ';', ')', '|', '/'", + "expecting: ';', '[', '(', ')', '|', '/', id, char, dec char, hex char, string", + "expecting: ';', '[', '(', ')', '+', '?', '*', '|', '/', id, char, dec char, hex char, string", + "expecting: ';', '[', ']', '(', ')', '+', '?', '*', '|', '/', id, char, dec char, hex char, string", + "expecting: '}', ','", + "expecting: ';', '/'", + "expecting: '.'", + "expecting: '->', id", + "expecting: 'T', 'P', ';', '[', '{', '}', '+', '?', '*', '|', id", + "expecting: ';', '|'", + "expecting: 'T', 'P', ';', '[', '{', '}', '|', id", + "expecting: 'T', 'P', id", + "expecting: 'T', 'P', '[', '}', id", + "expecting: id, EOF", + "expecting: '+', '-'", + "expecting: '..', '+', '-'", + "expecting: ')'", + "expecting: 'T', 'P', ';', '[', '(', ')', '{', '}', '|', '/', id, char, dec char, hex char, string", + "expecting: ']'", + "expecting: 'New', 'Null', 'T', 'P', '[', '}', id", + "expecting: '}'", + "expecting: char, dec char, hex char", + "expecting: ':'", + "expecting: 'New', 'Null', 'T', 'P', '[', ')', '}', ',', id", + "expecting: 'New', 'T', 'P', ']', id", + "expecting: 'New', 'Null', 'T', 'P', '.', '[', ')', '}', ',', id", + "expecting: 'T', 'P', ';', '[', '|', id", + "expecting: '.', '('", + "expecting: '('", + "expecting: '.', ']', ','", + "expecting: ']', ','", + "expecting: 'New', 'Null', 'T', 'P', '[', ')', id", + "expecting: 'New', 'T', 'P', id", + "expecting: 'New', 'Null', 'T', 'P', '[', ']', ')', '}', ',', id", + "expecting: ')', ','", + "expecting: 'New', 'Null', 'T', 'P', '[', id", + };*/ + private static int[] errors; + /* { + 0, 1, 2, 2, 3, 4, 2, 5, 6, 7, 8, 9, 10, 11, 12, 6, 13, 7, 14, 15, 16, 17, 17, 2, 16, 18, 2, 18, 19, 20, 21, 21, 22, 8, 9, 10, 11, 12, 6, 9, 10, 11, 12, 6, 10, 11, 12, 6, 11, 12, 6, 12, 6, 6, 1, 7, 13, 13, 2, 14, 14, 9, 23, 17, 24, 25, 16, 18, 11, 15, 26, 27, 16, 21, 2, 9, 10, 11, 12, 6, 10, 11, 12, 6, 11, 12, 6, 12, 6, 6, 10, 11, 12, 6, 11, 12, 6, 12, 6, 6, 11, 12, 6, 12, 6, 6, 12, 6, 6, 6, 13, 7, 13, 14, 14, 28, 29, 30, 31, 31, 31, 30, 15, 32, 33, 34, 35, 30, 33, 2, 2, 2, 36, 36, 36, 37, 25, 11, 38, 38, 2, 39, 40, 15, 41, 41, 26, 42, 43, 2, 26, 44, 26, 16, 45, 45, 10, 11, 12, 6, 11, 12, 6, 12, 6, 6, 11, 12, 6, 12, 6, 6, 12, 6, 6, 6, 11, 12, 6, 12, 6, 6, 12, 6, 6, 6, 12, 6, 6, 6, 6, 46, 47, 48, 17, 33, 32, 32, 49, 49, 49, 33, 33, 24, 36, 2, 36, 2, 36, 18, 23, 15, 37, 2, 2, 50, 51, 52, 42, 21, 26, 41, 41, 27, 41, 26, 40, 2, 40, 41, 42, 16, 44, 15, 26, 45, 11, 12, 6, 12, 6, 6, 12, 6, 6, 6, 12, 6, 6, 6, 6, 12, 6, 6, 6, 6, 6, 28, 28, 28, 53, 30, 32, 32, 36, 2, 15, 18, 18, 15, 54, 2, 55, 56, 41, 57, 51, 2, 51, 26, 41, 41, 41, 42, 40, 42, 16, 21, 2, 58, 15, 41, 58, 12, 6, 6, 6, 6, 6, 6, 50, 50, 18, 43, 59, 60, 2, 55, 61, 50, 62, 2, 2, 55, 57, 41, 51, 42, 58, 45, 26, 41, 41, 6, 30, 30, 2, 60, 63, 60, 62, 55, 64, 62, 62, 61, 65, 55, 41, 41, 60, 55, 66, 48, 63, 62, 62, 62, 67, 66, 66, 55, 62, 48, 66, 66, 62, + };*/ + + static + { + try + { + DataInputStream s = new DataInputStream( + new BufferedInputStream( + Parser.class.getResourceAsStream("parser.dat"))); + + // read actionTable + int length = s.readInt(); + actionTable = new int[length][][]; + for(int i = 0; i < actionTable.length; i++) + { + length = s.readInt(); + actionTable[i] = new int[length][3]; + for(int j = 0; j < actionTable[i].length; j++) + { + for(int k = 0; k < 3; k++) + { + actionTable[i][j][k] = s.readInt(); + } + } + } + + // read gotoTable + length = s.readInt(); + gotoTable = new int[length][][]; + for(int i = 0; i < gotoTable.length; i++) + { + length = s.readInt(); + gotoTable[i] = new int[length][2]; + for(int j = 0; j < gotoTable[i].length; j++) + { + for(int k = 0; k < 2; k++) + { + gotoTable[i][j][k] = s.readInt(); + } + } + } + + // read errorMessages + length = s.readInt(); + errorMessages = new String[length]; + for(int i = 0; i < errorMessages.length; i++) + { + length = s.readInt(); + StringBuffer buffer = new StringBuffer(); + + for(int j = 0; j < length; j++) + { + buffer.append(s.readChar()); + } + errorMessages[i] = buffer.toString(); + } + + // read errors + length = s.readInt(); + errors = new int[length]; + for(int i = 0; i < errors.length; i++) + { + errors[i] = s.readInt(); + } + + s.close(); + } + catch(Exception e) + { + throw new RuntimeException("The file \"parser.dat\" is either missing or corrupted."); + } + } +} diff --git a/src/main/java/org/sablecc/sablecc/parser/ParserException.java b/src/main/java/org/sablecc/sablecc/parser/ParserException.java new file mode 100644 index 0000000..da9525f --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/parser/ParserException.java @@ -0,0 +1,21 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.parser; + +import org.sablecc.sablecc.node.*; + +public class ParserException extends Exception +{ + Token token; + + public ParserException(Token token, String message) + { + super(message); + this.token = token; + } + + public Token getToken() + { + return token; + } +} diff --git a/src/main/java/org/sablecc/sablecc/parser/State.java b/src/main/java/org/sablecc/sablecc/parser/State.java new file mode 100644 index 0000000..1807f8c --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/parser/State.java @@ -0,0 +1,17 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.parser; + +import java.util.ArrayList; + +final class State +{ + int state; + ArrayList nodes; + + State(int state, ArrayList nodes) + { + this.state = state; + this.nodes = nodes; + } +} diff --git a/src/main/java/org/sablecc/sablecc/parser/TokenIndex.java b/src/main/java/org/sablecc/sablecc/parser/TokenIndex.java new file mode 100644 index 0000000..088f948 --- /dev/null +++ b/src/main/java/org/sablecc/sablecc/parser/TokenIndex.java @@ -0,0 +1,206 @@ +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package org.sablecc.sablecc.parser; + +import org.sablecc.sablecc.node.*; +import org.sablecc.sablecc.analysis.*; + +class TokenIndex extends AnalysisAdapter +{ + int index; + + public void caseTPkgId(TPkgId node) + { + index = 0; + } + + public void caseTPackage(TPackage node) + { + index = 1; + } + + public void caseTStates(TStates node) + { + index = 2; + } + + public void caseTHelpers(THelpers node) + { + index = 3; + } + + public void caseTTokens(TTokens node) + { + index = 4; + } + + public void caseTIgnored(TIgnored node) + { + index = 5; + } + + public void caseTProductions(TProductions node) + { + index = 6; + } + + public void caseTAbstract(TAbstract node) + { + index = 7; + } + + public void caseTSyntax(TSyntax node) + { + index = 8; + } + + public void caseTTree(TTree node) + { + index = 9; + } + + public void caseTNew(TNew node) + { + index = 10; + } + + public void caseTNull(TNull node) + { + index = 11; + } + + public void caseTTokenSpecifier(TTokenSpecifier node) + { + index = 12; + } + + public void caseTProductionSpecifier(TProductionSpecifier node) + { + index = 13; + } + + public void caseTDot(TDot node) + { + index = 14; + } + + public void caseTDDot(TDDot node) + { + index = 15; + } + + public void caseTSemicolon(TSemicolon node) + { + index = 16; + } + + public void caseTEqual(TEqual node) + { + index = 17; + } + + public void caseTLBkt(TLBkt node) + { + index = 18; + } + + public void caseTRBkt(TRBkt node) + { + index = 19; + } + + public void caseTLPar(TLPar node) + { + index = 20; + } + + public void caseTRPar(TRPar node) + { + index = 21; + } + + public void caseTLBrace(TLBrace node) + { + index = 22; + } + + public void caseTRBrace(TRBrace node) + { + index = 23; + } + + public void caseTPlus(TPlus node) + { + index = 24; + } + + public void caseTMinus(TMinus node) + { + index = 25; + } + + public void caseTQMark(TQMark node) + { + index = 26; + } + + public void caseTStar(TStar node) + { + index = 27; + } + + public void caseTBar(TBar node) + { + index = 28; + } + + public void caseTComma(TComma node) + { + index = 29; + } + + public void caseTSlash(TSlash node) + { + index = 30; + } + + public void caseTArrow(TArrow node) + { + index = 31; + } + + public void caseTColon(TColon node) + { + index = 32; + } + + public void caseTId(TId node) + { + index = 33; + } + + public void caseTChar(TChar node) + { + index = 34; + } + + public void caseTDecChar(TDecChar node) + { + index = 35; + } + + public void caseTHexChar(THexChar node) + { + index = 36; + } + + public void caseTString(TString node) + { + index = 37; + } + + public void caseEOF(EOF node) + { + index = 38; + } +} diff --git a/src/main/resources/org/sablecc/sablecc/alternatives.txt b/src/main/resources/org/sablecc/sablecc/alternatives.txt new file mode 100644 index 0000000..8714aa5 --- /dev/null +++ b/src/main/resources/org/sablecc/sablecc/alternatives.txt @@ -0,0 +1,273 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +Macro:AlternativeHeader1 +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + + +$ + +Macro:AlternativeHeaderList +import java.util.*; + +$ + +Macro:AlternativeHeader2 +import $0$.*; + +@SuppressWarnings("nls") +public final class $1$ extends $2$ +{ + +$ + +Macro:NodeElement + private $0$ _$1$_; + +$ + +Macro:ListElement + private final LinkedList<$0$> _$1$_ = new LinkedList<$0$>(); + +$ + +Macro:ConstructorHeader + + public $0$( +$ + +Macro:ConstructorHeaderDeclNode + + @SuppressWarnings("hiding") $0$ _$1$_$2$ +$ + +Macro:ConstructorHeaderDeclList + + @SuppressWarnings("hiding") List<$0$> _$1$_$2$ +$ + +Macro:ConstructorBodyHeader +) + { + // Constructor + +$ + +Macro:ConstructorBodyNode + set$0$(_$1$_); + + +$ + +Macro:ConstructorBodyList + set$0$(_$1$_); + + +$ + +Macro:ConstructorBodyTail + } + +$ + +Macro:CloneHeader + + @Override + public Object clone() + { + return new $0$( +$ + +Macro:CloneBodyNode + + cloneNode(this._$1$_)$2$ +$ + +Macro:CloneBodyList + + cloneList(this._$0$_)$1$ +$ + +Macro:CloneTail +); + } + +$ + +Macro:Apply + + public void apply(Switch sw) + { + ((Analysis) sw).case$0$(this); + } + +$ + +Macro:GetSetNode + + public $0$ get$1$() + { + return this._$2$_; + } + + public void set$1$($0$ node) + { + if(this._$2$_ != null) + { + this._$2$_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + this._$2$_ = node; + } + +$ + +Macro:GetSetList + + public LinkedList<$2$> get$0$() + { + return this._$1$_; + } + + public void set$0$(List<$2$> list) + { + this._$1$_.clear(); + this._$1$_.addAll(list); + for($2$ e : list) + { + if(e.parent() != null) + { + e.parent().removeChild(e); + } + + e.parent(this); + } + } + +$ + +Macro:ToStringHeader + + @Override + public String toString() + { + return "" +$ + +Macro:ToStringBodyNode + + + toString(this._$0$_) +$ + +Macro:ToStringBodyList + + + toString(this._$0$_) +$ + +Macro:ToStringTail +; + } + +$ + +Macro:RemoveChildHeader + + @Override + void removeChild(@SuppressWarnings("unused") Node child) + { + // Remove child + +$ + +Macro:RemoveChildNode + if(this._$0$_ == child) + { + this._$0$_ = null; + return; + } + + +$ + +Macro:RemoveChildList + if(this._$0$_.remove(child)) + { + return; + } + + +$ + +Macro:RemoveChildTail + throw new RuntimeException("Not a child."); + } + +$ + +Macro:ReplaceChildHeader + + @Override + void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) + { + // Replace child + +$ + +Macro:ReplaceChildNode + if(this._$0$_ == oldChild) + { + set$1$(($2$) newChild); + return; + } + + +$ + +Macro:ReplaceChildList + for(ListIterator<$1$> i = this._$0$_.listIterator(); i.hasNext();) + { + if(i.next() == oldChild) + { + if(newChild != null) + { + i.set(($1$) newChild); + newChild.parent(this); + oldChild.parent(null); + return; + } + + i.remove(); + oldChild.parent(null); + return; + } + } + + +$ + +Macro:ReplaceChildTail + throw new RuntimeException("Not a child."); + } + +$ + +Macro:AlternativeTail +} + +$ diff --git a/src/main/resources/org/sablecc/sablecc/analyses.txt b/src/main/resources/org/sablecc/sablecc/analyses.txt new file mode 100644 index 0000000..949fb5b --- /dev/null +++ b/src/main/resources/org/sablecc/sablecc/analyses.txt @@ -0,0 +1,287 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +Macro:AnalysisHeader +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import $1$.*; + +public interface Analysis extends Switch +{ + Object getIn(Node node); + void setIn(Node node, Object o); + Object getOut(Node node); + void setOut(Node node, Object o); + + +$ +Macro:AnalysisStart + void caseStart(Start node); + +$ + +Macro:AnalysisBody + void case$0$($0$ node); + +$ + +Macro:AnalysisTail + void caseEOF(EOF node); +} + +$ + +Macro:AnalysisAdapterHeader +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import java.util.*; +import $1$.*; + +public class AnalysisAdapter implements Analysis +{ + private Hashtable<Node,Object> in; + private Hashtable<Node,Object> out; + + public Object getIn(Node node) + { + if(this.in == null) + { + return null; + } + + return this.in.get(node); + } + + public void setIn(Node node, Object o) + { + if(this.in == null) + { + this.in = new Hashtable<Node,Object>(1); + } + + if(o != null) + { + this.in.put(node, o); + } + else + { + this.in.remove(node); + } + } + + public Object getOut(Node node) + { + if(this.out == null) + { + return null; + } + + return this.out.get(node); + } + + public void setOut(Node node, Object o) + { + if(this.out == null) + { + this.out = new Hashtable<Node,Object>(1); + } + + if(o != null) + { + this.out.put(node, o); + } + else + { + this.out.remove(node); + } + } + +$ + +Macro:AnalysisAdapterStart + + public void caseStart(Start node) + { + defaultCase(node); + } + +$ + +Macro:AnalysisAdapterBody + + public void case$0$($0$ node) + { + defaultCase(node); + } + +$ + +Macro:AnalysisAdapterTail + + public void caseEOF(EOF node) + { + defaultCase(node); + } + + public void defaultCase(@SuppressWarnings("unused") Node node) + { + // do nothing + } +} + +$ + +Macro:DepthFirstAdapterHeader +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import java.util.*; +import $1$.*; + +public class DepthFirstAdapter extends AnalysisAdapter +{ + public void inStart(Start node) + { + defaultIn(node); + } + + public void outStart(Start node) + { + defaultOut(node); + } + + public void defaultIn(@SuppressWarnings("unused") Node node) + { + // Do nothing + } + + public void defaultOut(@SuppressWarnings("unused") Node node) + { + // Do nothing + } + + @Override + public void caseStart(Start node) + { + inStart(node); + node.get$2$().apply(this); + node.getEOF().apply(this); + outStart(node); + } + +$ + +Macro:ReversedDepthFirstAdapterHeader +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import java.util.*; +import $1$.*; + +public class ReversedDepthFirstAdapter extends AnalysisAdapter +{ + public void inStart(Start node) + { + defaultIn(node); + } + + public void outStart(Start node) + { + defaultOut(node); + } + + public void defaultIn(@SuppressWarnings("unused") Node node) + { + // Do nothing + } + + public void defaultOut(@SuppressWarnings("unused") Node node) + { + // Do nothing + } + + @Override + public void caseStart(Start node) + { + inStart(node); + node.getEOF().apply(this); + node.get$2$().apply(this); + outStart(node); + } + +$ + +Macro:DepthFirstAdapterInOut + + public void in$0$($0$ node) + { + defaultIn(node); + } + + public void out$0$($0$ node) + { + defaultOut(node); + } + +$ + +Macro:DepthFirstAdapterCaseHeader + + @Override + public void case$0$($0$ node) + { + in$0$(node); + +$ + +Macro:DepthFirstAdapterCaseBodyNode + if(node.get$0$() != null) + { + node.get$0$().apply(this); + } + +$ + +Macro:DepthFirstAdapterCaseBodyList + { + List<$1$> copy = new ArrayList<$1$>(node.get$0$()); + for($1$ e : copy) + { + e.apply(this); + } + } + +$ + +Macro:ReversedDepthFirstAdapterCaseBodyList + { + List<$1$> copy = new ArrayList<$1$>(node.get$0$()); + Collections.reverse(copy); + for($1$ e : copy) + { + e.apply(this); + } + } + +$ + +Macro:DepthFirstAdapterCaseTail + out$0$(node); + } + +$ + +Macro:DepthFirstAdapterTail +} + +$ diff --git a/src/main/resources/org/sablecc/sablecc/lexer.txt b/src/main/resources/org/sablecc/sablecc/lexer.txt new file mode 100644 index 0000000..709b312 --- /dev/null +++ b/src/main/resources/org/sablecc/sablecc/lexer.txt @@ -0,0 +1,454 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +Macro:LexerException +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +@SuppressWarnings("serial") +public class LexerException extends Exception +{ + public LexerException(String message) + { + super(message); + } +} + +$ + +Macro:LexerHeader +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import java.io.*; +import java.util.*; +import $1$.*; +import de.hhu.stups.sablecc.patch.*; + + +@SuppressWarnings("nls") +public class Lexer implements ITokenListContainer +{ + protected Token token; + protected State state = State.$2$; + + private PushbackReader in; + private int line; + private int pos; + private boolean cr; + private boolean eof; + private final StringBuffer text = new StringBuffer(); + + private List<IToken> tokenList; + + private IToken tok; + + public List<IToken> getTokenList() { + return tokenList; + } + + private void setToken(Token t) { + tok = t; + token = t; + } + + + public void setTokenList(final List<IToken> list) { + tokenList = list; + } + + @SuppressWarnings("unused") + protected void filter() throws LexerException, IOException + { + // Do nothing + } + + protected void filterWrap() throws LexerException, IOException + { + filter(); + if (token != null) { + getTokenList().add(token); + } + } + + + public Lexer(@SuppressWarnings("hiding") PushbackReader in) + { + this.in = in; + setTokenList(new ArrayList<IToken>()); + } + + public Token peek() throws LexerException, IOException + { + while(this.token == null) + { + this.setToken(getToken()); + filterWrap(); + } + + return this.token; + } + + public Token next() throws LexerException, IOException + { + while(this.token == null) + { + this.setToken(getToken()); + filterWrap(); + } + + Token result = this.token; + this.setToken(null); + return result; + } + + protected Token getToken() throws IOException, LexerException + { + int dfa_state = 0; + + int start_pos = this.pos; + int start_line = this.line; + + int accept_state = -1; + int accept_token = -1; + int accept_length = -1; + int accept_pos = -1; + int accept_line = -1; + + @SuppressWarnings("hiding") int[][][] gotoTable = Lexer.gotoTable[this.state.id()]; + @SuppressWarnings("hiding") int[] accept = Lexer.accept[this.state.id()]; + this.text.setLength(0); + + while(true) + { + int c = getChar(); + + if(c != -1) + { + switch(c) + { + case 10: + if(this.cr) + { + this.cr = false; + } + else + { + this.line++; + this.pos = 0; + } + break; + case 13: + this.line++; + this.pos = 0; + this.cr = true; + break; + default: + this.pos++; + this.cr = false; + break; + } + + this.text.append((char) c); + + do + { + int oldState = (dfa_state < -1) ? (-2 -dfa_state) : dfa_state; + + dfa_state = -1; + + int[][] tmp1 = gotoTable[oldState]; + int low = 0; + int high = tmp1.length - 1; + + while(low <= high) + { + int middle = (low + high) / 2; + int[] tmp2 = tmp1[middle]; + + if(c < tmp2[0]) + { + high = middle - 1; + } + else if(c > tmp2[1]) + { + low = middle + 1; + } + else + { + dfa_state = tmp2[2]; + break; + } + } + }while(dfa_state < -1); + } + else + { + dfa_state = -1; + } + + if(dfa_state >= 0) + { + if(accept[dfa_state] != -1) + { + accept_state = dfa_state; + accept_token = accept[dfa_state]; + accept_length = this.text.length(); + accept_pos = this.pos; + accept_line = this.line; + } + } + else + { + if(accept_state != -1) + { + switch(accept_token) + { + +$ + +Macro:LexerVariableToken + case $0$: + { + @SuppressWarnings("hiding") Token token = new$0$( + getText(accept_length), + start_line + 1, + start_pos + 1); + pushBack(accept_length); + this.pos = accept_pos; + this.line = accept_line; + +$ + +Macro:LexerFixedToken + case $0$: + { + @SuppressWarnings("hiding") Token token = new$0$( + start_line + 1, + start_pos + 1); + pushBack(accept_length); + this.pos = accept_pos; + this.line = accept_line; + +$ + +Macro:TokenSwitchHeader + switch(state.id()) + { + +$ + +Macro:TokenCase + case $0$: state = State.$1$; break; + +$ + +Macro:TokenSwitchTail + } + +$ + +Macro:LexerTokenTail + return token; + } + +$ + +Macro:LexerBody1 + } + } + else + { + if(this.text.length() > 0) + { + throw new LexerException( + "[" + (start_line + 1) + "," + (start_pos + 1) + "]" + + " Unknown token: " + this.text); + } + + @SuppressWarnings("hiding") EOF token = new EOF( + start_line + 1, + start_pos + 1); + return token; + } + } + } + } + + +$ + +Macro:LexerNewVariableToken + Token new$0$(@SuppressWarnings("hiding") String text, @SuppressWarnings("hiding") int line, @SuppressWarnings("hiding") int pos) { return new $1$(text, line, pos); } + +$ + +Macro:LexerNewFixedToken + Token new$0$(@SuppressWarnings("hiding") int line, @SuppressWarnings("hiding") int pos) { return new $1$(line, pos); } + +$ + +Macro:LexerBody2 + + private int getChar() throws IOException + { + if(this.eof) + { + return -1; + } + + int result = this.in.read(); + + if(result == -1) + { + this.eof = true; + } + + return result; + } + + private void pushBack(int acceptLength) throws IOException + { + int length = this.text.length(); + for(int i = length - 1; i >= acceptLength; i--) + { + this.eof = false; + + this.in.unread(this.text.charAt(i)); + } + } + + protected void unread(@SuppressWarnings("hiding") Token token) throws IOException + { + @SuppressWarnings("hiding") String text = token.getText(); + int length = text.length(); + + for(int i = length - 1; i >= 0; i--) + { + this.eof = false; + + this.in.unread(text.charAt(i)); + } + + this.pos = token.getPos() - 1; + this.line = token.getLine() - 1; + } + + private String getText(int acceptLength) + { + StringBuffer s = new StringBuffer(acceptLength); + for(int i = 0; i < acceptLength; i++) + { + s.append(this.text.charAt(i)); + } + + return s.toString(); + } + + private static int[][][][] gotoTable; +/* { + +$ + +Macro:LexerAcceptHeader + };*/ + + private static int[][] accept; +/* { + +$ + +Macro:LexerAcceptTail + };*/ + + +$ + +Macro:LexerStateHeader + public static class State + { + +$ + +Macro:LexerStateBody + public final static State $0$ = new State($1$); + +$ + +Macro:LexerStateTail + + private int id; + + private State(@SuppressWarnings("hiding") int id) + { + this.id = id; + } + + public int id() + { + return this.id; + } + } + +$ + +Macro:LexerTail + + static + { + try + { + DataInputStream s = new DataInputStream( + new BufferedInputStream( + Lexer.class.getResourceAsStream("lexer.dat"))); + + // read gotoTable + int length = s.readInt(); + gotoTable = new int[length][][][]; + for(int i = 0; i < gotoTable.length; i++) + { + length = s.readInt(); + gotoTable[i] = new int[length][][]; + for(int j = 0; j < gotoTable[i].length; j++) + { + length = s.readInt(); + gotoTable[i][j] = new int[length][3]; + for(int k = 0; k < gotoTable[i][j].length; k++) + { + for(int l = 0; l < 3; l++) + { + gotoTable[i][j][k][l] = s.readInt(); + } + } + } + } + + // read accept + length = s.readInt(); + accept = new int[length][]; + for(int i = 0; i < accept.length; i++) + { + length = s.readInt(); + accept[i] = new int[length]; + for(int j = 0; j < accept[i].length; j++) + { + accept[i][j] = s.readInt(); + } + } + + s.close(); + } + catch(Exception e) + { + throw new RuntimeException("The file \"lexer.dat\" is either missing or corrupted."); + } + } +} + +$ diff --git a/src/main/resources/org/sablecc/sablecc/lexer/lexer.dat b/src/main/resources/org/sablecc/sablecc/lexer/lexer.dat new file mode 100644 index 0000000000000000000000000000000000000000..a5f45e37fab189f9cbe23f709b58309d554f07f4 GIT binary patch literal 7508 zcmZQzU|?ckV5nqZU{GLSVBmyeMg|53E+_`c^D;0nfG{&u9Y`$;0|SFP6tglgFlazA z8v_G_CKR(XFfeFAF$V(!gEka{?9pLhU;tr|J-Q4G3?R(Sz`&pf#XJlQ4Ej(EvfF@x zfdPd17#J7~85kHW85kJ&85kI>pjd!`fx#Mz1sNC^Y@t|)fq}suiiH^%7#yKkgn@y< z1Byi%7#KXESd4*z!4HbX85kG>pjd)|fgu=*B^ekPLZDcRfq@|!ilrGC7-FGVhJk@0 zk%57sih+SamVtqx8j9r@7#M1xSe}7_p%#ikVG0U&P}nH^|Ns9V0|Ns(9~Ax|c@PH4 zfx-@i6`}EiOCKnH7@%>h#K6D+3TIIGg4m$&RAXRZ0I^~5sSJtB|No)lAid}qWWOB) z0|N-FK-~(9J5^}9g2g?^d{|t9>;U-#6qm3#j9_430AWxXs$gJX0AWxX0@;DA4x1a2 z7#J8p7-SbneJTS30|<lC8i=3Hz`y{)ptJ@`%OE)r2Bo)B1_lNY2Duv~2Z}Ec2D!C} zfq?;pLH2{>N*EXzKp2$vK=}oPjiCO_XJB9eVPmKskUkS6$0GaJl!1XE9*WJ7(ug^d zdJq%jc2GRS;uJX!Es)|6#D>Kohz$x~5C(;<1_J{)4ng7|^FZPt49YVgJ3tuZHV_R8 zZ&3aLg(C>tK=LYBKS&(eeo)>5r8^J?#Xl@Pfy6<16@)=~jt^=-NE~DjC@ewla)9PR zHwFd<5E~TcX;3!Eogj5-|NsBL22EGR3=9k)49dG8`5XoY1`u|F%I7gKFo3W#lwZ!k zzyQK7P(Da42)jc0$qWn(APlk}WF9E)K-e8B4{{F(gUSbxJjiSi29*&Yel`OG0|<LT z)q~O#2zx{MAoo}O|Ns9Xln*isR1Ww+`N;C1Z~=wC+W-Im??B5_P#pOp<v~#Vfz*I7 z$bJS;xc>kD{{{mC11w%Z@dqlmKye4c(D(zFryy}qng(HiNI43QSCBZedDlS}K-~z6 zTM!17e;_p=HzUUhC@+9;AXI$;0|NsH2SNFu@C0E{nF%r$WCkb>Kp0eZg7}~?1mRGq zo)iWK1`rN|@<HZ<a5x$tR91lWgTfqyBcbvjHV8*CFff3^735}6dIOcu*z#Nq$YD^m zASNgbLFG3n{6IJkDGz|eL25u4WH%^}gD}Wk5FcbO2q!?@0+It^P~5}xfY=}mDz89# zKxGdIgVG|157H09pfCXOL25x5BnIMx(jW+f@(RpMkRL&5Z4=a9bUrMtY(VoTDDFXi z1Yx*8|NsAg2x<<<UJwSAoglkGegWYOs65C`Ae;&1gVcd=7L*V269|Li7o;DQe?b@& z{~$i7j0fRdsCtkb2!s3wk_YJpVNe<Z@j-GR3`%1lJ}8VpxDcuz<Q5PHxe+7}N;e=3 z(gO-B7)F)@$-~4!G)NBQ9}ot`3rq~;1`sZT+68hW2!qNPkRFg7APn*kNDrv42jyW< z`3=G#HK4o%!l1eYR6c?*D2;;ZeGmq<r$F^62!rx8NIwXJ+Ebu<5rjeQDNq^(VNiPt z6n7vDvIA7#fiTDpP+bSYpmG^h&w((gz6aHFAPlk_R2G0RsO|uz84w1wr$F@^D9?b} zQ=obRghA~oP#plmp!O7~JO^P=dkR#}gD|K)1uCCG7}TBumCc~?6x5yqm7^dGYEOa6 zP!I;Sr$FT=sGI|-0i{O}2DPm~WfTa5#6jf`2!q;Lpt1&3zJSC*<q8Oc+FYRW1cX6t zE>Kwl%KsoWpnMO)p!OFi|AH{6{RPUiAPj1MfzmjrYzD;vDBeIA)SiO1(Ln7YSQ`!0 zE&|0RD7<0yGCCg=ryzL{2FZcq1B5~G3JP~z`ap3GQUk)E_7f;RK=A--JAuL!<R?&i z0J$54LFobJc2If%=?A4fkiDQZ0g8K2oP*e)I0l&mVuQ>8VNhCuwGTkzAid}q<bF{7 z4#J@H1mc6z4+w+O6eul&^nx%*43wT=7!(dLKY-E_sLTdokQgYRfG{Ynfy@Mnf&2<m zhwcVgzKH+-|Nl>DdkN%kke@;2C<uevVW6@C6ptWrkeQ%x1eJ>*J=n|ul^r0ppfUr5 zL2Wlsxe7A_n;wunNDru-17T1b4^$q)^nl_3WN*s<|Noyu+o2${L2W*eUQl@h(hn+I zKp52i1C=Q-{n+dTm2V(DpmGg_LG46PSp(ApDjz_0B8Lx19;63k9|(im4<P$MVGa@p zwOv6N6y_jvKo}&B%`8wk2a*Goe;^Dh4?txwy1PJS1IS*OS+ICSj|*5Bf!vIo&Oz-J zZ0Q_S&Vb?@WG*Nj!psHHAhSW~9XU^d%!S1}NS+ct$gLoIKz4x2I9Q$nv0-@%#0KRj z5C*knVR;H94zeF44#FV6fy@G7P~HI1pl}71lc4+q!l3r6HmGgKz`y_!N46i-mIaj~ zAPj29!rTH92bC)z3~JB9+T0*<kUg-x1uBa{ZUCtPu|Z)9N|PWq$ekc{p!VH41_lOf z=@69mK<)*_F$jaob5Pm>#S2Irn;uZz50V4b`5+7`_d)eNK0P3LkRDLF17T1d0ZMoH z^nmgZNDrt!24PS;9F*2!dO+a-N(b5h|NlP??K^<n18R?h>_b<V_y7O@N6<bU$Zk*_ z1xoYi>X7psC_F*+7pOc!SC{+$|Nm3aJ_^WBpt=oYE=(P^umiQDKz;&+Aqa!&K#-eZ zdSHG+FKa+`Bq&~C>OgS|@;fL`+=KR4L40JlgVciRRdlr=J3#3a)Hk_;)HeauyU6Jr zqy~gR`eE(O3ut{4Q2h)_;~)%8=it5xNE}vYfa-1oX!-|<Bb#>~WC67O1<C^;4C^N# zr(KYnLH;ZL|NsAEXrCRFPC<PLP#FmFD=1vCg*hlrKyskC24PTr1uExYdSGUwrw>s7 z1Ee0N4&-i-8$e+Ws()bm(9<8NPDf6E*xUrF*FbIp)mI=4YR`b`6qsEwv(fzv>f0du z7neFvn+Tga^mGO4BOs?Mn0e^xKy4Fbbud4H!UMUy2lbOc<q;?yg3=`@|A71iqCrs& zG9N^P{0_=fpmYPmpzwf|ksxu98W0Al2iZ~h|Ns9dNaHY|FawoWAhSVc!PKF<8x*F< z?uMyDHxHx+**x^PhWQudFHqcr`~ymVAiF`~48owc1E|a*<R(zt0%RY$I%Km!=7ahx zps+w!hhFZ0$`nu<hp9t%J2HO_G_Qfe6qJr(d|3Woh1Q=0<yTPrfG|9c{{R2K8>$Xu z4!XNR<r+43qlY=D+(Qm?Slpn;At)~)hZnZE0NDqM3y>Q@7*rmE(g-X}U}hKn|Ns9C zbleGKHz?dd@d#6g&1_KJ12P*__kb{{OaQgBV0v(w4Ju=h&4#H<`v3p`bm&+W$gQ9{ zm>9Q$+>6b;<p2NwZ-kDqfXo4@0i}C%_o0_1pfn4@Fm=f31eC@J@nQZ!Hy4x#NHG^% zn1k{ND9k~50E9tt07~b$+zN9GdKnIjFPJ`<I`ljQice5lKv##JUO@7o@CDHz_o0Uo zsP9zy|37#f4%9b;W2hLYKMm?fgZj6izA~r}3+fw#+MS?2ET}IE!k~UDsNV$Yqf3GG zB4g0J0Eo}PzyRtCg8J^DK0By?3+f+(`pcj`IjDXIDFco7gZjk$U=EoC0|SF1NGlQz z>O(7m#9$byEujJv1JR&4ClHMbgUn=LU{D3g!^{A&VHh+n4r3$J(76wgzrk)pmLr7? zZ9jp=URXf-pk*7Voz4j5vx8_DW?*0d^{J{sd<F&vcpO973{Y{h;u=)x5x}tchABgd vbC@794RQ|%GcYh<O$W$oiDg60!<z<(H4CZ^CH|peL{T8OfG|;t$y5XYU4Ur2 literal 0 HcmV?d00001 diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt new file mode 100644 index 0000000..c91e7af --- /dev/null +++ b/src/main/resources/org/sablecc/sablecc/parser.txt @@ -0,0 +1,703 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +Macro:ParserHeader +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import $1$.*; +import $2$.*; +import $3$.*; +import java.util.*; +import de.hhu.stups.sablecc.patch.*; + + +import java.io.DataInputStream; +import java.io.BufferedInputStream; +import java.io.IOException; + +@SuppressWarnings("nls") +public class Parser implements IParser +{ + public final Analysis ignoredTokens = new AnalysisAdapter(); + + protected ArrayList nodeList; + + private final Lexer lexer; + private final ListIterator stack = new LinkedList().listIterator(); + private int last_pos; + private int last_line; + private Token last_token; + private final TokenIndex converter = new TokenIndex(); + private final int[] action = new int[2]; + + private final static int SHIFT = 0; + private final static int REDUCE = 1; + private final static int ACCEPT = 2; + private final static int ERROR = 3; + + private ArrayList firstPopped = null; + private ArrayList lastPopped = null; + private ITokenListContainer lex; + + public Parser(@SuppressWarnings("hiding") Lexer lexer) + { + this.lexer = lexer; + this.lex = lexer; + } + + + private Map<PositionedNode, SourcecodeRange> mapping = new HashMap<PositionedNode, SourcecodeRange>(); + public Map<PositionedNode, SourcecodeRange> getMapping() { return this.mapping; } + + @SuppressWarnings("unchecked") + private void checkResult(Object elementToCheck) { + // nodes with no tokens or sub nodes at all may exist + if (this.firstPopped == null) { + return; + } + + if (elementToCheck instanceof LinkedList) { + /* + * special case: this is a list of nodes, for example an identifier + * list, so we don't want to check the list but the last element + * added to it + */ + final LinkedList nodeList = (LinkedList) elementToCheck; + + if (nodeList.size() > 0) { + elementToCheck = nodeList.get(nodeList.size() - 1); + } else { + // no positions for empty lists... + return; + } + } + + if (!(elementToCheck instanceof PositionedNode)) { + throw new Error( + "Unexpected elementToCheck (not instanceof PositionedNode): " + + elementToCheck.getClass().getSimpleName() + "/" + + elementToCheck); + } + + if (!this.getMapping().containsKey(elementToCheck)) { + final PositionedNode node = (PositionedNode) elementToCheck; + + // dealing with a one-token element + if (this.lastPopped == null) { + this.lastPopped = this.firstPopped; + } + + final int begin = findBeginPos(this.lastPopped, node); + final int end = findEndPos(this.firstPopped); + final SourcecodeRange range = new SourcecodeRange(begin, end); + + this.getMapping().put(node, range); + + node.setStartPos(createBeginPos(begin)); + node.setEndPos(createEndPos(end)); + } + } + + @SuppressWarnings({ "unchecked", "unused" }) + private int findBeginPos(final ArrayList list, + PositionedNode n) { + Object first = list.get(0); + if (!(first instanceof PositionedNode) && !(first instanceof IToken)) { + List list2 = (List) first; + + if (list2.size() > 0) { + first = list2.get(0); + } else { + /* + * Sometimes (haven't found out why) we get empty list here. In + * the only observed cases we were looking for the source range + * of the whole parse unit. Then the index is 0. + */ + return 0; + } + } + + if (first instanceof IToken) { + return findIndex((IToken) first); + } + + final PositionedNode node = (PositionedNode) first; + final SourcecodeRange item = this.getMapping().get(node); + if (item == null){ + System.err.println(n.getClass().getSimpleName() + " / " + node.getClass().getSimpleName() + ": " + node); + } + return item.getBeginIndex(); + } + + @SuppressWarnings({ "unchecked", "unused" }) + private int findEndPos(final ArrayList list) { + Object last = list.get(list.size() - 1); + if (!(last instanceof PositionedNode) && !(last instanceof IToken)) { + final List list2 = (List) last; + last = list2.get(list2.size() - 1); + } + + if (last instanceof IToken) { + return findIndex((IToken) last); + } + + final PositionedNode node = (PositionedNode) last; + final SourcecodeRange item = this.getMapping().get(node); + return item.getEndIndex(); + } + + private int findIndex(final IToken token) { + final List<IToken> list = this.lex.getTokenList(); + + for (int i = list.size() - 1; i >= 0; i--) { + if (list.get(i) == token) { + return i; + } + } + + return -1; + } + + private SourcePosition createBeginPos(final int index) { + final List<IToken> list = this.lex.getTokenList(); + final IToken token = list.get(index); + return new SourcePosition(token.getLine(), token.getPos()); + } + + private SourcePosition createEndPos(final int index) { + final List<IToken> list = this.lex.getTokenList(); + final IToken token = list.get(index); + return new SourcePosition(token.getLine(), token.getPos() + + token.getText().length()); + } + +$ + +Macro:ParserInliningPushHeader + @SuppressWarnings({"unchecked","unused"}) + private void push(int numstate, ArrayList listNode) throws ParserException, LexerException, IOException + { + this.nodeList = listNode; + + +$ + +Macro:ParserNoInliningPushHeader + protected void filter() throws ParserException, LexerException, IOException + { + // Empty body + } + + private void push(int numstate, ArrayList listNode, boolean hidden) throws ParserException, LexerException, IOException + { + this.nodeList = listNode; + + if(!hidden) + { + filter(); + } + + +$ + +Macro:ParserCommon + if(!this.stack.hasNext()) + { + this.stack.add(new State(numstate, this.nodeList)); + return; + } + + State s = (State) this.stack.next(); + s.state = numstate; + s.nodes = this.nodeList; + } + + private int goTo(int index) + { + int state = state(); + int low = 1; + int high = gotoTable[index].length - 1; + int value = gotoTable[index][0][1]; + + while(low <= high) + { + int middle = (low + high) / 2; + + if(state < gotoTable[index][middle][0]) + { + high = middle - 1; + } + else if(state > gotoTable[index][middle][0]) + { + low = middle + 1; + } + else + { + value = gotoTable[index][middle][1]; + break; + } + } + + return value; + } + + private int state() + { + State s = (State) this.stack.previous(); + this.stack.next(); + return s.state; + } + + private ArrayList pop() + { + ArrayList list = ((State) this.stack.previous()).nodes; + if (this.firstPopped == null) { + this.firstPopped = list; + } else { + this.lastPopped = list; + } + return list; + } + + private int index(Switchable token) + { + this.converter.index = -1; + token.apply(this.converter); + return this.converter.index; + } + + @SuppressWarnings("unchecked") + public Start parse() throws ParserException, LexerException, IOException + { + this.getMapping().clear(); + + push(0, null$0$); + List<Node> ign = null; + while(true) + { + while(index(this.lexer.peek()) == -1) + { + if(ign == null) + { + ign = new LinkedList<Node>(); + } + + ign.add(this.lexer.next()); + } + + if(ign != null) + { + this.ignoredTokens.setIn(this.lexer.peek(), ign); + ign = null; + } + + this.last_pos = this.lexer.peek().getPos(); + this.last_line = this.lexer.peek().getLine(); + this.last_token = this.lexer.peek(); + + int index = index(this.lexer.peek()); + this.action[0] = Parser.actionTable[state()][0][1]; + this.action[1] = Parser.actionTable[state()][0][2]; + + int low = 1; + int high = Parser.actionTable[state()].length - 1; + + while(low <= high) + { + int middle = (low + high) / 2; + + if(index < Parser.actionTable[state()][middle][0]) + { + high = middle - 1; + } + else if(index > Parser.actionTable[state()][middle][0]) + { + low = middle + 1; + } + else + { + this.action[0] = Parser.actionTable[state()][middle][1]; + this.action[1] = Parser.actionTable[state()][middle][2]; + break; + } + } + + switch(this.action[0]) + { + case SHIFT: + { + ArrayList list = new ArrayList(); + list.add(this.lexer.next()); + push(this.action[1], list$1$); + } + break; + case REDUCE: + switch(this.action[1]) + { + +$ + +Macro:ParserInliningReduce + case $0$: /* reduce $2$ */ + { + ArrayList list = new$0$(); + push(goTo($1$), list); + } + break; + +$ + +Macro:ParserNoInliningReduce + case $0$: /* reduce $3$ */ + { + ArrayList list = new$0$(); + push(goTo($1$), list, $2$); + } + break; + +$ + +Macro:ParserParseTail + } + break; + case ACCEPT: + { + EOF node2 = (EOF) this.lexer.next(); + $0$ node1 = ($0$) pop().get(0); + Start node = new Start(node1, node2); + return node; + } + case ERROR: + throw new ParserException(this.last_token, + "[" + this.last_line + "," + this.last_pos + "] " + + Parser.errorMessages[Parser.errors[this.action[1]]]); + } + } + } + + +$ + +Macro:ParserNewHeader + + + @SuppressWarnings("unchecked") + ArrayList new$0$() /* reduce $1$ */ + { + this.firstPopped = null; + this.lastPopped = null; + @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList(); + + +$ + +Macro:ParserNewBodyDecl + @SuppressWarnings("unused") ArrayList nodeArrayList$0$ = pop(); + +$ + +Macro:ParserNewBodyDeclNull + ArrayList nodeArrayList$0$ = null; + +$ + +Macro:ParserBraceOpening + { + // Block + +$ + +Macro:ParserBraceClosing + } + +$ + +Macro:ParserSimpleVariableDeclaration + $0$ $1$Node$2$; + +$ + +Macro:ParserListVariableDeclaration + LinkedList listNode$0$ = new LinkedList(); + +$ + +Macro:ParserNullVariableDeclaration + @SuppressWarnings("unused") Object nullNode$0$ = null; + +$ + +Macro:ParserSimpleTerm + $0$Node$1$ = ($2$)nodeArrayList$3$.get($4$); + +$ + +Macro:ParserNewBodyNew + + $0$Node$1$ = new $2$( +$ + +Macro:ParserNew&ListBodyParams +$0$Node$1$ +$ + +Macro:ParserNew&ListBodyParamsNull +$0$ +$ + +Macro:ParserNewBodyNewTail +); + +$ + +Macro:ParserTypedLinkedListAdd + if($2$Node$3$ != null) + { + $0$Node$1$.add($2$Node$3$); + } + +$ + +Macro:ParserTypedLinkedListAddAll + if($2$Node$3$ != null) //Macro:ParserTypedLinkedListAddAll + { + $0$Node$1$.addAll($2$Node$3$); + //$0$Node$1$ = $2$Node$3$; + } + +$ + +Macro:ParserTypedLinkedListAddAll2 + if($2$ != null) //Macro:ParserTypedLinkedListAddAll2 + { + $0$Node$1$.addAll($2$); + } + +$ + +Macro:ParserNewBodyListAdd + nodeList.add($0$Node$1$); + +$ + +Macro:ParserNewTail + // return nodeList; + final ArrayList containerList = nodeList; + Object elementToCheck = containerList.get(0); + checkResult(elementToCheck); + + return containerList; + } + +$ + +Macro:ParserActionHeader + + + private static int[][][] actionTable; +/* { + +$ + +Macro:ParserActionTail + };*/ + +$ + +Macro:ParserGotoHeader + private static int[][][] gotoTable; +/* { + +$ + +Macro:ParserGotoTail + };*/ + +$ + +Macro:ParserErrorsHeader + private static String[] errorMessages; +/* { + +$ + +Macro:ParserErrorsTail + };*/ + +$ + +Macro:ParserErrorIndexHeader + private static int[] errors; +/* { + +$ + +Macro:ParserErrorIndexTail + + };*/ + +$ + +Macro:ParserTail + + static + { + try + { + DataInputStream s = new DataInputStream( + new BufferedInputStream( + Parser.class.getResourceAsStream("parser.dat"))); + + // read actionTable + int length = s.readInt(); + Parser.actionTable = new int[length][][]; + for(int i = 0; i < Parser.actionTable.length; i++) + { + length = s.readInt(); + Parser.actionTable[i] = new int[length][3]; + for(int j = 0; j < Parser.actionTable[i].length; j++) + { + for(int k = 0; k < 3; k++) + { + Parser.actionTable[i][j][k] = s.readInt(); + } + } + } + + // read gotoTable + length = s.readInt(); + gotoTable = new int[length][][]; + for(int i = 0; i < gotoTable.length; i++) + { + length = s.readInt(); + gotoTable[i] = new int[length][2]; + for(int j = 0; j < gotoTable[i].length; j++) + { + for(int k = 0; k < 2; k++) + { + gotoTable[i][j][k] = s.readInt(); + } + } + } + + // read errorMessages + length = s.readInt(); + errorMessages = new String[length]; + for(int i = 0; i < errorMessages.length; i++) + { + length = s.readInt(); + StringBuffer buffer = new StringBuffer(); + + for(int j = 0; j < length; j++) + { + buffer.append(s.readChar()); + } + errorMessages[i] = buffer.toString(); + } + + // read errors + length = s.readInt(); + errors = new int[length]; + for(int i = 0; i < errors.length; i++) + { + errors[i] = s.readInt(); + } + + s.close(); + } + catch(Exception e) + { + throw new RuntimeException("The file \"parser.dat\" is either missing or corrupted."); + } + } +} + +$ + +Macro:TokenIndexHeader +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import $1$.*; +import $2$.*; + +class TokenIndex extends AnalysisAdapter +{ + int index; + +$ + +Macro:TokenIndexBody + + @Override + public void case$0$(@SuppressWarnings("unused") $0$ node) + { + this.index = $1$; + } + +$ + +Macro:TokenIndexTail + + @Override + public void caseEOF(@SuppressWarnings("unused") EOF node) + { + this.index = $0$; + } +} + +$ + +Macro:ParserException +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import $1$.*; + +@SuppressWarnings("serial") +public class ParserException extends Exception +{ + Token token; + + public ParserException(@SuppressWarnings("hiding") Token token, String message) + { + super(message); + this.token = token; + } + + public Token getToken() + { + return this.token; + } +} + +$ + +Macro:State +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import java.util.ArrayList; + +final class State +{ + int state; + ArrayList nodes; + + State(@SuppressWarnings("hiding") int state, @SuppressWarnings("hiding") ArrayList nodes) + { + this.state = state; + this.nodes = nodes; + } +} + +$ diff --git a/src/main/resources/org/sablecc/sablecc/parser/parser.dat b/src/main/resources/org/sablecc/sablecc/parser/parser.dat new file mode 100644 index 0000000000000000000000000000000000000000..f8300a493fcb83f00da2052f6e7b929c8761c61d GIT binary patch literal 20128 zcmZQzU`%CTVBq-w|Nnmm1_nk32tcNpAVLfvni<Ll(JW9lh-QVdK{Okb4WikhY!J-^ zwF9IVW<E$-fPsMlSq@~6B1nRPfk6mO4x|?*C&IwMz>H)j$Q@!(ec}uZ3@~*PXl8)i z2vQ4DDuX5max+YyESen14;&y(3=9kkXmTKNH6$^1sJlS^1YwY$Kw3dG$PXYkh=#cX zM1$M~5(m*BcYxR+8e}hs4WikQ%mtYR!XP;i4Kf472GJlhKx_~VG6Td0(I7KGY!J<g zWEMyd2!rH6G)Nza4WdE%Kx_~V(g$LLXci>>Ape8Zg5*FnNG*sBqCsjwY!D5LFHo3( z;vFOpk^|8oc@P^!!_ost9Vo0pVlX*IBzqmu(g4UzK9E8N1_m<*1_lrx#5D({Z6tjS zNO1+Sqn&|)0TkaLwN^-Spg0mnGRGE84wME3L7EsC80^sO_=uzyWJe29ngr>C`4MCX za(V^%30V%5eqnYvqS^5k$qtY?Qb=|<A%zXd{w@Xv23+|A7B3((KzRZdZZ1gXf$}1< zI#77Q+~tO3wmX^||01~&<c{@7W`fK>_A4l^Iica{#lXOToZdlh1Eq72G>8VJQxF?O zgVG#`4WdD53B(4`$ms?-y@S+&^nuiYXb>O72GJmWAU23b){mUtL2d-81*rqkAhjSi zh(^`}3onqrL16`w$EFSz1|W5y@(0-r<n#`Te`J4v%mcX}WG09Pxdp@q(I7bx8$=_U zhwKk71_lO@T97&r4N?nYgJ@(u$o>GO1CTs6b;$luVqjoEHUrroptOnX4jwYx0m?(f zxI+bxJ3#3h*>9k{MvR#nc+B)bOYa7F)CQpCl>{Wcp!5zZ!$9E-!g*+F8`1dhk@7o8 zuO$Nm1Gcg-AI%O>c?U{!AUg`t%>0a`7L+zS(8@{VIBi2~N6dlN-ym~~85kHq@daX+ zAm#s31_lODIsu87F)%PFgBT194CM?A44`-eaVr=Y7*s(F1_p*oH1~aCU|@iyBaoj# zWhbaC1t|xG52$<rv6~ne800|=1_p*^I=K^;7eMX;rFT&N2RQ*0hREUe4b4x}kis0K z*A=P$=|n3Nw=*y>fbtH=Tu}MW3t})ZFmxk@eGgLE+=~?UeQ5T8%57K}O-GXhrD>S^ zXP~+FADUWFxeZHCGeP+pson*Z2cU8a<V+9^Dsw<=5REI}!QvN`{<uNrfiysATzZi6 zG^qZ@r4ANHAhSVf59B_O@gN#Gj+~Lw8AvTCoI!2|sRhxv%tv;IC@Ahg8lW`D4iFba zBfA5X)<I%0Ib?T$(gL!Xl2EfiYC)`x7SCZ00L6Dj^celx_QHV`fD6Vbv2RNjEX z1LPhM4RRBR4Wg0VhU^DWn*=0}O&ziyK<#T}Gmygt)c!y=6VwhO#!M|deg&mtWc!Wq zs0~63mn5XJ7!;<UHWe}M(ZOSf4_Z8#;87cb=AINZy%u=%Mxg1<K;svn@j>M&a$JDQ zT4eqQH1(h|3|amQQh5w2??810sEq+i4<I(R>J8*RE<Ng|#c2LsipF1t#$S%cUxXBA zpm3=|ss|1s$$`=rsGJ3*F;JKtMl<I(S{|Lpz`y`%=YZ56V_;wa<rNV7I0FNNG>E~# zz;FW1j0I@?g-CG*vVSg8eM8MSLry3CNPY%|2PmDv>Y3AMa-cK`lRJav_U}k}6J$;+ z0|NuB&2Sc}eFHKdR;GZ|f!a4Pb?5P@1N9|g{illz3=DG6FujBpX7osd==C_LjQ}d6 zK~B1g7G|I}15EB3njEMN0SnLTXyFHHQ^48{H;~#FH__7FZ6ebhtjq<4IVjFyVF}U? zlLMu>Ees3{urz-MEsl4C>P4h>#|{$PN%xWb0cs~9r$f*<8LUkLa^n;{X2Zhl5n6ao zMKb>hnp=0`F%MQQg5m>IZ-U|x-L0@bGstbA_$Q`)2us(`k=zCHH_R+hcvG{j2`aB( z?a5cDamNViTO-HwGbA^G^ufX&<R*S-I}j8O#I`p;ekG<ZR>xCEg4)WkvH|1{P`OEr znc8^F^hQb}ATy2es0~I9GlpcOJPFbZ>h}=i9$h?k_@cST6pz|aH1~kUl#$~Q)EC9o zc8f&Qn~BB;^+}P#8dRPV<2OA#?)5|S8>pX+%Y9*J?ny(_3+g}P(i?@QHw%qlgl3iv z9yiCJ>CHjogZkCT<rJvj3=20<S+E~b{xX8n2&nG>G6FP~h8$O*x*n9TKysiy8cYsk z#z6)K22ei+BnQfG$o7HiQF^zrexilnETlRCy&bd$<Y=TiVKo|m6&im&8vhTPU6awq z6p+ILRK6qgCm`idP&l4Lv^l`#9Vowo$}muy16kihG&lS}<AdsKdW1Q08n}#Thcbft z<H%|33X&YC-T~!RkiS4}A7p=l>O5rrQ>3s3g%7BW0qVDdybEfR!2Af31GO<g<CY*f zP&x&<0mKHi6F_!?>;tuPKz(!&8x%&+dXo`U=YYz8kb009w0>p;*@f&!P}>Ej4n!ln z6;$6M^EaT?-;~yqNM?icDa>7<Ji8SseS_LOFgZ}TfZT=L4ns1BVGo)ccTw2JK(2#9 z?jWW=f$Y}Dh&r7S)P_Sg?=GU8Vj#AEvKJJgh`bF7Dh6c#Z$k1vD6C!(>3>k%gNz2H zV`y4o0JV#d{qhni&4a=pxy|&NNPD1dIY!X@2eLg#eqaQpd01Wpc@S(DD1n3ghE{LD z+y_#pk0ys?CWAjxz5}TR&6DA(%fdkcfe2%UbTqxzc<hNr)0>UP2lW||-3*#%!{v@x zG`+cKe9)LOvL8WX#>i%a=IL;m9fxKX`j|Utj2hW&P@f!`UxTK9EgF9vQXi0+fq@Z} z7D43@C>lXwK&`P3SbhT80jk4^8DmHG#}YJm&qm|_LgRz_K*;(hp~<6<8H4(a$m&7; z8CV>F+zcwaLFGBf7*IP7Sq@Ymfbt1Q4wSZ$<v{fTH2*My=3S8OI0?!p(DVzk15_7) z@)XD%(AXZXx&u@<fYgB6<1n*9V{gc2gW6UwcYyNIQN-K}BWSD*Ni8_eVQN9{0JW!J z=7QRiNOc_}s9b=#5#%>=>pD>0gxLY|50ZNrZh<@p4HuBxx1sVGLG43i_4`oe86KeZ z^Y4*Sem_Jrb2A!$BT`ud3NujrL;b@5s;iObMBflu=EC%&mFJA0yaG#m_DJ@E!Uj}t zfa)ud^FVV=$o9Uaz+RBqAiHptOYtBJk>Ut6hld;|p!qUnel?o<S~PwglD|OV2^x0> zr3;WU(3~i8`ULe6VRE4P2V{FdVTa5I)$1_5AU}cHgP{BhG8Z&P50eAg37ThsmUoPx z`6XmIP=18Q4@N!)wd-MOL3V)J(l9$fc?~89vIEp-g}EKQe|-uuhR29Jwhqz<ss~~A zBiE52IglMNIrRBk&=@MrevsQh?H6RXA&1ogP@o{<lo3=;Bg=!vjF8jUJ2KK2vU#Af z9a^<bK;;s$zd>yx<a~ncj(SvoGps=4uS83mpmYNZZ}fQ$&=@9ic?n8Kl$4jCvKZtX z(0B&SPEh)R`3)5Rp!qUbx<#KWxd76Ph*O3mpz$dvAEXzQ&S35XrEy$!4$N+}dWI3y z=Z3ijl)gaY-q5}yN*V^qfyStDr9Ds|4mnQH$NSO8<UsC3Ru38<M&^UY1(4kZ>c7F< z1sb=2$$`QE)Q*IOGpJlcjz3U%!or7~`VM9;XdMMC3_<aS>{hhCC?jYr30WRAW)EAx z2XZgS{gk)~hdUTSWj!ohK=B3Y*CK}*vYSBjJ;;2}oCZuU$c><RSeV~IbA8BaLG>dN zpAocH4~fqJn)3jyD}sq3%Y(*ZVd9|n63k9e83-EF1I-1(#6V#LQV;SkObp~EP#XqR zx53(^pt1s_4ph&A^nk`$L3)tOXHcAh$`4R|12YTMh5?O_fyT^WX$F)oL1uyG?m=dO z*5!cA2i0dFGeP+cWDlsE2H67|j|15QntOqn3mOLljo*Ui_+fqp&56PKTA+1%pt&DV z-Uih*AR49@H0E`hfdL$*0?>R8YP*8m1X{lWauaCo9polZJqmI!s9g$j8)$qL<TlWp zI>`N?vJK=$P+tk;4^UqO<PT7Mg4_(6V*~jIG(HFN4`}`n<R8%Z1IRz1b`Q*5p!|J> zfq@a^7FZnu>Z^d_88kly8Y=|lS<qS(P#t}VfdSmVgy{#BTSplfP|_%<O>vlk0i0i8 z>OlP+&{|4RT?z{?P+J4km)Q^L-!Ovw0Fwi?J3w*=7#KkH9U~}AU||lb7hrA$wbemw z3sBqi5d#AwD1M$WFfht8Fo4Dj7(x9*s6KFeS^*mNpz;nB_MkNsps)wc?}Ne~)Q13t zJ*dqA3KLjc9yAUNiUZL6Jtz)9<vu9hKxGstE<kx76c?a!3KWl^d<OClXnY&wc2FM} z6rZ4RT~Hi>=2k&*1ezZO#V=?M7!+5axm{2^gX%U=JcGs}L2(Ca*Mj03)ZPWfH>m9m zif_>P3@A=PZAwtQgVuI|;vKZ!2^8<3HAA3y2hHuiVPIec`4<)^ps@<j*Z`=Wf`$<T zs9uE0gXYvg{V`A-4HE;6x!hx5U<Bm_m>6ix@(u$7BWP>~mUltpk)XaEsLc;rrvw_e zd&t1R2+A)|HH@I~@*4~cj3NvSp#BS^4FdyX3<CorXiWsvJ&d4s8Ppy|GX@4w-Ngu+ z2Y`wBGB7auF)%QK!U$%rB?AMa2?GP87Xt&M6$1lfAOi!VKLZ0JDEwgh3>g?0jTjgh zk^IgGnyZ1yhchrRMldiig5nV-7R$iE7{|cCh&+b^^5ZK821Z2&21W-64PT228utbH z9W*Zm>bHPsP`}_A0|O%{?SN>|7z0Qg>R$#>|Cke+MnPl4AU>$A3<@Vv1_sc$B%?Vr zyg+;p1_nkD?ZdzT76-W*#0P~Vs7!T$ngyyOLFpZ|HU^a5LGw$X^bYD5gVH;wjR8vU zpmqc(Z-BxbRQ7<{w4ihknnwbqdr+K#+zzULL1_sT7ohYH8fyWie^7l2O8=lZ1m!7E zSb_2ZXf6bl4?t@~KzR%_cLT}~pz$40UIWchfbtq>j0TiHKx68l`~h0q0LmYraRyKx z1g(t#<r7d_5R^|qWAUIo2^ymZ<rmO63Mg-a#!o<b6SRgHlr}))dZ73R%>{$<DrkHZ zl#f7Tu%J8(n)e08HE2#1l&?VZ!l1kh8V?2KUC_88DDQ&$w4nS3YGZ@)8)(f6C@+K7 zaD(z4XdNUdPlMK~fbukG-8Cp5g4Pm%@-}E(9+bC1^AVuD4H_Q-<xkL@0Vt1y)<A>u zIB2aLD362Ykat11TY&N}DE{6uFff9`{5=B$BPh&2F)%QK!u%Tp10yKRe={&JYD4lm zBdD%|re6looCj!p1~k?PO>f{nEL5J+k%58HiGhI;6xT2@WoWtvg)vkQ1E@ZSu|ah< zj18)DVQf%23^juRR40P!KTw?rlLw7^z}TRA0mcTEN3gyJDDQys7bx$5=BGh<2b9-T zAo+~Z4(c{gdW7i*jVVCcpfUwEwhJmF;A~L5L)9>V!UM_%`JDmOr;TGsWvE~%U`S<1 zW+-9EWXNMkXRu;WU{GfWU`S+0X2@npWJqU7Wl(3(0gDDRlrSVRlrW?+6vM?l7*ZK> zz-AO7iH0!bGh{QQGUOqNc`~Fk<T2zk6fvYSq`>tDFcdN5Go&z-Lfw#$qQ{XTiJ_RG zgrNxRo)V}oR|bCuP#;JThx-c{vKi7D6c{oYKq;IThboAy5Dr;&hH9v75Ou;h)uH;8 zfdRM5V1`PDJa8CRFo4oE9}Y8N{tLz-ug);oVgi&3u%{$!E=3J7NZO))>afEZdi1g1 z1gHJf_p2sOyC}(DQaDY;pD%Ie06l1)QfIIR=K$O)LGqB4p#xTlE3d#z!YywL*6)MU zFZ55Lpb`b-H&{Nm#pyQcr4-ci4B2+vB_J#gK<>p?u7N@rWFo{4(E2`H^$PZM12P|^ z9~K_C%5`;y5OD1Qs*xBNoN<O4%-!k?(eU)90cX`fSuk6Z88R3W8H&JlTne}@RA4|B z%K+PhDh8>OAT=ffgCtl*0a!0;Jz5L33si%GFsN?TWv~OMNZe&6aqd@V(1)5%J)daf z^hpTRE>PP5<`Zo0gw>kr49MZkz`&2wWLS7u;#7edi`4Tm?o@<nt2%=wJQR?92THrh zDTcgMl!nv)*ups$?h-`GMz~HJE~^V?*~3{{a2CuLv`9-iIQ^r?fLafL!VfvG4t~GM z;`AFLt`M<-8p;d|zC`FIF7?qO-eM?r9U}G7JIy7M<aT1y8NGdhyH$i*pWv&L5$RAL zT-)GoAA#~BK9eBjGboRON?is9dz@iRdL4oA4{>P*;sV^^gYY#d&oM9<(8R4Evk~DT zPJ$f}_bZa11G!v;g%-pVT<tcHEXZ}R))em0LWDV}mcZAJK`yb;b>U7~pc0UQ0e7Ax zHoai0;SlW%Sg0Uc9JDAEar+Wfir`CWehjG$<?tHUkD-(yham^f#})>NvLEI*P@IDH zF5_xfgVcfc3S*ZiwQYjWCM$4hVudpWQ{r1tdI6<ebq0`sAS_Vt55$6mfHINxVhdGJ zJRwZNU5b(J15gPHG8s9q684K4PQPGtJ)&eoqz=?_2zNe5xDS+*@Wn1fUIM4f5GKJw z6Vw*~jb-7s9bF~vGMV&{M}!3|ydmjC4yO-L?Z6Cah<<9O4ul&KApvtO?v#!@JP~?9 zd4qvLn@GQsQu2U90elV;XdNbKE*`Yz4TM4KGePTeKy1+33(#5t(7ZipjvO@a0-AFH z&9{K&T0nB3xfYN-Xs!h`Hv?Kn2AVeqVUQUhK4`rshz+7a^W31dB%nDR5C)CA<1!nY zedzWhy9MSZkh?&B0=Wz1J`e`k4{{?2gUki3a|XE)G}i~31BAH~WFE*Lp!q$}*gr@d z<W7)&kUn(#(fJ_#Fn7Rckb8(#hf6=QSs?R3euDWA<R=gYtselbr-03eg61GV7{mwp z3ATn1G!F)v0|SYJ=EgvNgJIAd1Pp`b#Xw;LauaC2282QCK;;2wz6N9_Xubx7LE#0O zvjNS=fz*Kbp!qTo4GKfhoEZpHI~+i6gM|%@289nY8yg=a2AaRqX8_gh3=E*O0169G z7=f@M0|NsLgTz4?lvY4t1M(j-4NBLb^aKhIP?&+_K^Qa_37QK8%|(L329%CK;Q<OS z5C)|$5DgLog(pZ4hz5y))Puqe6ow#kL25wZM~Q#Y!vqutAPh=3FbtY61*Hp67=SR$ zpCC7Y{0YJ!HfaAC$i1L-gP^rBAUA{N(?I?OiGyg6n?d3*4Du7me;^v<H&A$h)PmLk zgUke}1F><r6XaG<n1V3K9iX%ZTO$K92jmveIth?GXg(Sw2Erh5klR4!gWLtOA7l?G zJdxc9G9To35C-W3%>#ng@qlQMc_4E@YhXca5C+)=T3-SZ2bm4RAhjSq==>AVyf8>V YNG%M5<}pEXAPiCm5(lXR@j=)Q0B=Xf%>V!Z literal 0 HcmV?d00001 diff --git a/src/main/resources/org/sablecc/sablecc/productions.txt b/src/main/resources/org/sablecc/sablecc/productions.txt new file mode 100644 index 0000000..fae6241 --- /dev/null +++ b/src/main/resources/org/sablecc/sablecc/productions.txt @@ -0,0 +1,18 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +Macro:Production +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +public abstract class $1$ extends Node +{ + // Empty body +} + +$ diff --git a/src/main/resources/org/sablecc/sablecc/tokens.txt b/src/main/resources/org/sablecc/sablecc/tokens.txt new file mode 100644 index 0000000..e1fbe0d --- /dev/null +++ b/src/main/resources/org/sablecc/sablecc/tokens.txt @@ -0,0 +1,91 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +// 0 : xxx.node +// 1 : xxx.analysis +// 2 : Txxx +Macro:VariableTextToken +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import $1$.*; + +@SuppressWarnings("nls") +public final class $2$ extends Token +{ + public $2$(String text) + { + setText(text); + } + + public $2$(String text, int line, int pos) + { + setText(text); + setLine(line); + setPos(pos); + } + + @Override + public Object clone() + { + return new $2$(getText(), getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).case$2$(this); + } +} + +$ + +// 0 : xxx.node +// 1 : xxx.analysis +// 2 : Txxx +// 3 : xxx +Macro:FixedTextToken +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import $1$.*; + +@SuppressWarnings("nls") +public final class $2$ extends Token +{ + public $2$() + { + super.setText("$3$"); + } + + public $2$(int line, int pos) + { + super.setText("$3$"); + setLine(line); + setPos(pos); + } + + @Override + public Object clone() + { + return new $2$(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).case$2$(this); + } + + @Override + public void setText(@SuppressWarnings("unused") String text) + { + throw new RuntimeException("Cannot change $2$ text."); + } +} + +$ diff --git a/src/main/resources/org/sablecc/sablecc/utils.txt b/src/main/resources/org/sablecc/sablecc/utils.txt new file mode 100644 index 0000000..05385e3 --- /dev/null +++ b/src/main/resources/org/sablecc/sablecc/utils.txt @@ -0,0 +1,350 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * This file is part of SableCC. * + * See the file "LICENSE" for copyright information and the * + * terms and conditions for copying, distribution and * + * modification of SableCC. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +Macro:Start +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import $1$.*; + +@SuppressWarnings("nls") +public final class Start extends Node +{ + private $2$ _$3$_; + private EOF _eof_; + + public Start() + { + // Empty body + } + + public Start( + @SuppressWarnings("hiding") $2$ _$3$_, + @SuppressWarnings("hiding") EOF _eof_) + { + set$2$(_$3$_); + setEOF(_eof_); + } + + @Override + public Object clone() + { + return new Start( + cloneNode(this._$3$_), + cloneNode(this._eof_)); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseStart(this); + } + + public $2$ get$2$() + { + return this._$3$_; + } + + public void set$2$($2$ node) + { + if(this._$3$_ != null) + { + this._$3$_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + this._$3$_ = node; + } + + public EOF getEOF() + { + return this._eof_; + } + + public void setEOF(EOF node) + { + if(this._eof_ != null) + { + this._eof_.parent(null); + } + + if(node != null) + { + if(node.parent() != null) + { + node.parent().removeChild(node); + } + + node.parent(this); + } + + this._eof_ = node; + } + + @Override + void removeChild(Node child) + { + if(this._$3$_ == child) + { + this._$3$_ = null; + return; + } + + if(this._eof_ == child) + { + this._eof_ = null; + return; + } + + throw new RuntimeException("Not a child."); + } + + @Override + void replaceChild(Node oldChild, Node newChild) + { + if(this._$3$_ == oldChild) + { + set$2$(($2$) newChild); + return; + } + + if(this._eof_ == oldChild) + { + setEOF((EOF) newChild); + return; + } + + throw new RuntimeException("Not a child."); + } + + @Override + public String toString() + { + return "" + + toString(this._$3$_) + + toString(this._eof_); + } +} + +$ + +Macro:EOF +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import $1$.*; + +@SuppressWarnings("nls") +public final class EOF extends Token +{ + public EOF() + { + setText(""); + } + + public EOF(int line, int pos) + { + setText(""); + setLine(line); + setPos(pos); + } + + @Override + public Object clone() + { + return new EOF(getLine(), getPos()); + } + + public void apply(Switch sw) + { + ((Analysis) sw).caseEOF(this); + } +} + +$ + +Macro:Token +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import de.hhu.stups.sablecc.patch.IToken; + + +@SuppressWarnings("nls") +public abstract class Token extends Node implements IToken +{ + private String text; + private int line; + private int pos; + + public String getText() + { + return this.text; + } + + public void setText(@SuppressWarnings("hiding") String text) + { + this.text = text; + } + + public int getLine() + { + return this.line; + } + + public void setLine(@SuppressWarnings("hiding") int line) + { + this.line = line; + } + + public int getPos() + { + return this.pos; + } + + public void setPos(@SuppressWarnings("hiding") int pos) + { + this.pos = pos; + } + + @Override + public String toString() + { + return this.text + " "; + } + + @Override + void removeChild(@SuppressWarnings("unused") Node child) + { + throw new RuntimeException("Not a child."); + } + + @Override + void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) + { + throw new RuntimeException("Not a child."); + } +} + +$ + +Macro:Node +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +import java.util.*; +import de.hhu.stups.sablecc.patch.PositionedNode; + +@SuppressWarnings("nls") +public abstract class Node extends PositionedNode implements Switchable, Cloneable +{ + private Node parent; + + @Override + public abstract Object clone(); + + public Node parent() + { + return this.parent; + } + + void parent(@SuppressWarnings("hiding") Node parent) + { + this.parent = parent; + } + + abstract void removeChild(Node child); + abstract void replaceChild(Node oldChild, Node newChild); + + public void replaceBy(Node node) + { + this.parent.replaceChild(this, node); + } + + protected String toString(Node node) + { + if(node != null) + { + return node.toString(); + } + + return ""; + } + + protected String toString(List list) + { + StringBuffer s = new StringBuffer(); + + for(Iterator i = list.iterator(); i.hasNext();) + { + s.append(i.next()); + } + + return s.toString(); + } + + @SuppressWarnings("unchecked") + protected <T extends Node> T cloneNode(T node) + { + if(node != null) + { + return (T) node.clone(); + } + + return null; + } + + protected <T> List<T> cloneList(List<T> list) + { + List<T> clone = new LinkedList<T>(); + + for(T n : list) + { + clone.add(n); + } + + return clone; + } +} + +$ + +Macro:Switch +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +public interface Switch +{ + // Empty body +} + +$ + +Macro:Switchable +/* This file was generated by SableCC (http://www.sablecc.org/). */ + +package $0$; + +public interface Switchable +{ + void apply(Switch sw); +} + +$ diff --git a/src/main/resources/patchfiles/IParser.txt b/src/main/resources/patchfiles/IParser.txt new file mode 100644 index 0000000..a5d25de --- /dev/null +++ b/src/main/resources/patchfiles/IParser.txt @@ -0,0 +1,14 @@ +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.hhu.stups.sablecc.patch; + +import java.util.Map; + + +public interface IParser { + public Map<PositionedNode, SourcecodeRange> getMapping(); +} diff --git a/src/main/resources/patchfiles/IToken.txt b/src/main/resources/patchfiles/IToken.txt new file mode 100644 index 0000000..65c0aff --- /dev/null +++ b/src/main/resources/patchfiles/IToken.txt @@ -0,0 +1,23 @@ +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.hhu.stups.sablecc.patch; + + +public interface IToken { + + public String getText(); + + public void setText(String text); + + public int getLine(); + + public void setLine(int line); + + public int getPos(); + + public void setPos(int pos); +} diff --git a/src/main/resources/patchfiles/ITokenListContainer.txt b/src/main/resources/patchfiles/ITokenListContainer.txt new file mode 100644 index 0000000..8d72be4 --- /dev/null +++ b/src/main/resources/patchfiles/ITokenListContainer.txt @@ -0,0 +1,13 @@ +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.hhu.stups.sablecc.patch; + +import java.util.List; + +public interface ITokenListContainer { + public List<IToken> getTokenList(); +} \ No newline at end of file diff --git a/src/main/resources/patchfiles/PositionedNode.txt b/src/main/resources/patchfiles/PositionedNode.txt new file mode 100644 index 0000000..7072ca6 --- /dev/null +++ b/src/main/resources/patchfiles/PositionedNode.txt @@ -0,0 +1,47 @@ +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.hhu.stups.sablecc.patch; + +public class PositionedNode { + private SourcePosition startPos; + private SourcePosition endPos; + + public SourcePosition getStartPos() { + /* + * Special treatment for tokens because they don't get a position in the + * PositionAspect + */ + if (this instanceof IToken) { + final IToken token = (IToken) this; + return new SourcePosition(token.getLine(), token.getPos()); + } + + return startPos; + } + + public SourcePosition getEndPos() { + /* + * Special treatment for tokens because they don't get a position in the + * PositionAspect + */ + if (this instanceof IToken) { + final IToken token = (IToken) this; + return new SourcePosition(token.getLine(), token.getPos() + + token.getText().length()); + } + + return endPos; + } + + public void setStartPos(final SourcePosition startPos) { + this.startPos = startPos; + } + + public void setEndPos(final SourcePosition endPos) { + this.endPos = endPos; + } +} diff --git a/src/main/resources/patchfiles/SourcePosition.txt b/src/main/resources/patchfiles/SourcePosition.txt new file mode 100644 index 0000000..ef6cd9c --- /dev/null +++ b/src/main/resources/patchfiles/SourcePosition.txt @@ -0,0 +1,27 @@ +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.hhu.stups.sablecc.patch; + +public class SourcePosition { + + private final int line; + + private final int pos; + + public SourcePosition(final int line, final int pos) { + this.line = line; + this.pos = pos; + } + + public int getLine() { + return line; + } + + public int getPos() { + return pos; + } +} diff --git a/src/main/resources/patchfiles/SourcePositions.txt b/src/main/resources/patchfiles/SourcePositions.txt new file mode 100644 index 0000000..eabac62 --- /dev/null +++ b/src/main/resources/patchfiles/SourcePositions.txt @@ -0,0 +1,434 @@ +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.hhu.stups.sablecc.patch; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +public class SourcePositions { + private final List<IToken> tokenList; + private final Map<PositionedNode, SourcecodeRange> positions; + + public SourcePositions(final List<IToken> tokenList, + final Map<PositionedNode, SourcecodeRange> positions) { + this.tokenList = tokenList; + this.positions = positions; + } + + /** + * Returns the {@link SourcecodeRange} of this {@link PositionedNode} or + * <code>null</code> if no {@link SourcecodeRange} is available. + * + * @param node + * @return + */ + public SourcecodeRange getSourcecodeRange(final PositionedNode node) { + return positions.get(node); + } + + /** + * Returns the line in which this {@link PositionedNode} begins. The value + * <code>0</code> is returned if no sourcecode range is available for this + * {@link PositionedNode}. + * + * @param node + * @return + */ + public int getBeginLine(final PositionedNode node) { + if (node instanceof IToken) { + return ((IToken) node).getLine(); + } + + return getBeginLine(getSourcecodeRange(node)); + } + + public int getBeginLine(final SourcecodeRange range) { + if (range != null) { + return tokenList.get(range.getBeginIndex()).getLine(); + } else { + return 0; + } + } + + /** + * Returns the column of the first character of this {@link PositionedNode}, + * i.e. the begin column. The value <code>0</code> is returned if no + * sourcecode range is available for this {@link PositionedNode}. + * + * @param node + * @return + */ + public int getBeginColumn(final PositionedNode node) { + if (node instanceof IToken) { + return ((IToken) node).getPos(); + } + + return getBeginColumn(getSourcecodeRange(node)); + } + + public int getBeginColumn(final SourcecodeRange range) { + if (range != null) { + return tokenList.get(range.getBeginIndex()).getPos(); + } else { + return 0; + } + } + + /** + * Returns the line in which the {@link PositionedNode} ends. The value + * <code>0</code> is returned if no sourcecode range is available for this + * {@link PositionedNode}. + * + * @param node + * @return + */ + public int getEndLine(final PositionedNode node) { + // TODO handle multi line comments + /* + * if (node instanceof TComment) { final TComment comment = (TComment) + * node; return comment.getLine() + countLineBreaks(comment); } + */ + + if (node instanceof IToken) { + return ((IToken) node).getLine(); + } + + return getEndLine(getSourcecodeRange(node)); + } + + private int getEndLine(final SourcecodeRange range) { + if (range != null) { + return tokenList.get(range.getEndIndex()).getLine(); + } else { + return 0; + } + } + + // private int countLineBreaks(final PositionedNode node) { + // final char[] text = getNodeString(node).toCharArray(); + // int count = 0; + // + // for (int i = 0; i < text.length; i++) { + // if (text[i] == '\n' || text[i] == '\r') { + // count++; + // } + // } + // + // return count; + // } + + /** + * Returns the last column of this {@link PositionedNode}, i.e. the column + * of the last character of the {@link PositionedNode}. The value + * <code>0</code> is returned if no sourcecode range is available for this + * {@link PositionedNode}. + * + * @param node + * @return + */ + public int getEndColumn(final PositionedNode node) { + // TODO handle multi line comments + /* + * if (node instanceof TComment) { return getEndColumn((TComment) node); + * } + */ + + if (node instanceof IToken) { + final IToken token = (IToken) node; + return token.getPos() + token.getText().length() - 1; + } + + return getEndColumn(getSourcecodeRange(node)); + } + + private int getEndColumn(final SourcecodeRange range) { + if (range != null) { + final IToken token = tokenList.get(range.getEndIndex()); + return token.getPos() + token.getText().length() - 1; + } else { + return 0; + } + } + + /* + * private int getEndColumn(final TComment commentToken) { final String + * asString = commentToken.getText(); final StringTokenizer tokenizer = new + * StringTokenizer(asString, "\n\r"); + * + * // multi line comment if (tokenizer.countTokens() > 1) { String line = + * null; while (tokenizer.hasMoreTokens()) { line = tokenizer.nextToken(); } + * + * if (line == null) { return 0; } + * + * return line.length(); } // single line comment else { return + * commentToken.getPos() + asString.length(); } } + */ + + /** + * Returns the array of {@link IToken}s belonging to this + * {@link PositionedNode}. The array may be empty, if no sourcecode range + * can be determined for this {@link PositionedNode}. + * + * @param node + * @return + */ + public IToken[] getTokens(final PositionedNode node) { + if (node instanceof IToken) { + return new IToken[] { (IToken) node }; + } + + final SourcecodeRange range = getSourcecodeRange(node); + + if (range != null) { + final int beginIndex = range.getBeginIndex(); + final int endIndex = range.getEndIndex(); + final IToken[] result = new IToken[endIndex - beginIndex + 1]; + + for (int i = 0; i + beginIndex <= endIndex; i++) { + result[i] = tokenList.get(i + beginIndex); + } + + return result; + } else { + return new IToken[0]; + } + } + + public String getNodeString(final PositionedNode node) { + // TODO handle comments + /* + * if (node instanceof TComment) { return ((TComment) node).getText(); } + */ + + return getRangeString(getSourcecodeRange(node)); + } + + public String getRangeString(final SourcecodeRange range) { + final StringBuilder buffer = new StringBuilder(); + + if (range != null) { + final int beginIndex = range.getBeginIndex(); + final int endIndex = range.getEndIndex(); + + for (int i = beginIndex; i <= endIndex; i++) { + buffer.append(tokenList.get(i).getText()); + } + } + + return buffer.toString(); + } + + // TODO handle comments + /* + * + * public IToken getCommentBefore(final PositionedNode node) { final + * SourcecodeRange range = getSourcecodeRange(node); final int beginIndex = + * range.getBeginIndex(); if (beginIndex > 0) { final IToken token = + * tokenList.get(beginIndex - 1); if (token instanceof TComment) { return + * token; } else { return null; } } else { return null; } } + * + * public IToken getCommentAfter(final PositionedNode node) { final + * SourcecodeRange range = getSourcecodeRange(node); final int endIndex = + * range.getEndIndex(); if (endIndex < tokenList.size() - 1) { final IToken + * token = tokenList.get(endIndex + 1); if (token instanceof TComment) { + * return token; } else { return null; } } else { return null; } } public + * IToken[] getIncludedComments(final PositionedNode node) { final + * SourcecodeRange range = getSourcecodeRange(node); + * + * if (range != null) { final int beginIndex = range.getBeginIndex(); final + * int endIndex = range.getEndIndex(); final List<IToken> comments = new + * ArrayList<IToken>(); + * + * for (int i = 0; i + beginIndex <= endIndex; i++) { final IToken token = + * tokenList.get(i + beginIndex); if (token instanceof TComment) { + * comments.add(token); } } + * + * return comments.toArray(new IToken[comments.size()]); } else { return new + * IToken[0]; } } + */ + + public List<IToken> getTokenList() { + return tokenList; + } + + public void replaceMapping(final PositionedNode origNode, + final PositionedNode newNode) { + final SourcecodeRange sourcecodeRange = positions.remove(origNode); + + if (sourcecodeRange != null) { + positions.put(newNode, sourcecodeRange); + } + } + + public PositionedNode getSurroundingNode(final int index) { + if (index < 0 || index >= tokenList.size()) { + return null; + } + + PositionedNode bestNode = null; + int bestBeginIndex = 0; + int bestEndIndex = tokenList.size() - 1; + + // TODO find better solution than searching all? + for (final Iterator<PositionedNode> iterator = positions.keySet() + .iterator(); iterator.hasNext();) { + final PositionedNode node = iterator.next(); + final SourcecodeRange range = positions.get(node); + + final int beginIndex = range.getBeginIndex(); + final int endIndex = range.getEndIndex(); + + if (beginIndex <= index && endIndex >= index + && beginIndex >= bestBeginIndex && endIndex <= bestEndIndex) { + bestNode = node; + bestBeginIndex = beginIndex; + bestEndIndex = endIndex; + } + } + + return bestNode; + } + + /** + * <p> + * Finds the index of the token that belongs to the position. + * </p> + * <p> + * If no token list is available <code>-1</code> is returned. For + * <code>line < 0</code> the index <code>0</code> is returned. If + * <code>line >= 1 && column < 0</code> the line number is returned. + * </p> + * <p> + * If the line matches but the requested column is beyond the max. length of + * the line, the last token of this line is returned. The last token of all + * tokens (EOF) is chosen if the requested positions is beyond the + * absolutely last token. + * </p> + * <p> + * <b>Attention</b>: Line and column counting starts at 1! + * </p> + * + * @param line + * line of the position + * @param column + * column of the position + * @return Index in {@link #tokenList} + */ + public int getTokenforPosition(final int line, final int column) { + // Sort out nonsense input + if (tokenList.size() == 0) { + return -1; + } + if (line < 1) { + return 0; + } + if (column < 1) { + return line; + } + + /* + * Shortcut for special case: Position beyond last token + */ + final IToken lastToken = tokenList.get(tokenList.size() - 1); + if (line > lastToken.getLine() + || (line == lastToken.getLine() && column > lastToken.getPos() + + lastToken.getText().length())) { + return tokenList.size() - 1; + } + + int result = -1; + int left = 0; + int right = tokenList.size() - 1; + + while (left <= right && result < 0) { + if (left != right) { + final int currentIndex = left + (right - left) / 2; + + final int lineDiff = line + - tokenList.get(currentIndex).getLine(); + + if (lineDiff > 0) { + // continue in right half + left = Math.min(currentIndex + 1, right); + } else if (lineDiff < 0) { + // continue in left half + right = Math.max(currentIndex - 1, left); + } else { + // we are in the correct line now, switch to linear search + IToken token = tokenList.get(currentIndex); + result = currentIndex; + + final int compare = compareTokenColumn(token, column); + + // move left + if (compare < 0) { + while (compareTokenColumn(token, column) < 0) { + result--; + + if (result < 0) { + break; + } + + token = tokenList.get(result); + } + } + // move right + else if (compare > 0) { + while (compareTokenColumn(token, column) > 0) { + result++; + + if (result > tokenList.size() - 1) { + result = tokenList.size() - 1; + break; + } + + token = tokenList.get(result); + + /* + * Only move as long as line end is not reached. + * This happens when queried for column beyond max + * column of this line. Then we return the index of + * the last token in this line. + */ + if (token.getLine() > line) { + result--; + break; + } + } + } + } + } else { + result = left; + } + } + + return result; + } + + /** + * Compares the token position (within line only) with the column. + * + * @param token + * @param column + * @return <code>-1</code> if <code>column < beginColumn</code>, + * <code>1</code> if <code>endColumn < column</code> or + * <code>0</code> if the column is within the range of the token. + */ + private int compareTokenColumn(final IToken token, final int column) { + final int beginColumn = token.getPos(); + final int endColumn = beginColumn + token.getText().length() - 1; + + if (column < beginColumn) { + return -1; + } else if (endColumn < column) { + return 1; + } else { + return 0; + } + } +} diff --git a/src/main/resources/patchfiles/SourcecodeRange.txt b/src/main/resources/patchfiles/SourcecodeRange.txt new file mode 100644 index 0000000..629befb --- /dev/null +++ b/src/main/resources/patchfiles/SourcecodeRange.txt @@ -0,0 +1,30 @@ +/** + * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, + * Heinrich Heine Universitaet Duesseldorf + * This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) + * */ + +package de.hhu.stups.sablecc.patch; + +public class SourcecodeRange { + private final int beginIndex; + private final int endIndex; + + public SourcecodeRange(final int beginIndex, final int endIndex) { + this.beginIndex = beginIndex; + this.endIndex = endIndex; + } + + public int getBeginIndex() { + return beginIndex; + } + + public int getEndIndex() { + return endIndex; + } + + @Override + public String toString() { + return "(" + beginIndex + "/" + endIndex + ")"; + } +} -- GitLab