did_parser 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +12 -0
- data/Rakefile +28 -0
- data/did_parser.gemspec +31 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.cpp +10 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.h +167 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.cpp +10 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.h +121 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +23 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +30 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +180 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +79 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +61 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.h +59 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.cpp +25 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.h +36 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +414 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.h +200 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.cpp +11 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.h +37 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +193 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.h +158 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +39 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +74 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.cpp +78 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.h +79 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +15 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.h +35 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +336 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.h +466 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +84 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.h +80 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +64 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +99 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +52 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +32 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.cpp +18 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.h +24 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.cpp +12 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +218 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.cpp +19 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.h +45 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +294 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +196 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +60 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +46 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.cpp +36 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.h +31 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +92 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +88 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.cpp +46 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.h +42 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +668 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +461 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +294 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +173 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +138 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +147 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +53 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.h +38 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +65 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.h +98 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +156 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +159 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +144 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +141 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.cpp +27 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.h +32 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +54 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.h +155 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.cpp +9 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +92 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenFactory.h +30 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.cpp +9 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +85 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.cpp +11 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.h +137 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +425 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +295 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +208 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +117 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +270 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.h +115 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +64 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +177 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.cpp +9 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.h +23 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +98 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +169 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +158 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +132 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +106 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +157 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +232 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +156 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +54 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +48 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +629 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +32 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +33 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +71 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +56 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +139 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNType.h +20 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +29 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +35 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.cpp +16 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.h +68 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +109 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +51 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +27 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +33 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +24 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +23 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +26 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +30 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.cpp +14 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.h +47 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.cpp +14 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.h +70 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.cpp +25 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +227 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +12 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +34 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +31 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +42 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.cpp +15 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.h +43 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +189 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +76 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +67 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +44 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +615 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +199 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +15 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +100 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +111 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +128 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +57 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +43 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +59 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +45 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +75 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +57 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +76 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +43 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +57 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +36 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +53 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +36 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +53 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +43 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +57 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +36 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +51 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +43 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +51 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.cpp +16 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.h +42 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +26 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +22 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +27 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +16 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +25 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.cpp +102 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.h +102 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +1383 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +911 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +29 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +25 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +23 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +35 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +17 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +62 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +24 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +50 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +579 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +225 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +202 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +436 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +179 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +60 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +26 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +31 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +26 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +27 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +33 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +42 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +418 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +233 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +28 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +38 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +86 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +43 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +24 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +37 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +19 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +25 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +24 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +36 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +65 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +21 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +27 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +115 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +96 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +60 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +32 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +59 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +153 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +17 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +22 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +124 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +33 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +61 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +84 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +508 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +190 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +120 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +102 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.cpp +4 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.h +21 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +8 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +16 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +43 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +149 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +76 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +207 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +65 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +161 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +38 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +16 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +129 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +24 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +54 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +43 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +66 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.h +53 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +12 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +111 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.cpp +9 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +39 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeProperty.h +50 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.cpp +9 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +57 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +48 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +55 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +40 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +54 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +32 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +241 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.h +78 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.cpp +9 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +44 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.cpp +69 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +132 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +64 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +105 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +370 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +185 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +77 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.h +117 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.cpp +39 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +86 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.cpp +28 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +51 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +36 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.h +80 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +154 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.h +86 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.cpp +31 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.h +40 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +182 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +47 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.cpp +13 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.h +22 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp +20 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.h +27 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +30 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.h +26 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp +20 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.h +25 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +33 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.h +26 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp +23 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h +23 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.cpp +24 -0
- data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.h +23 -0
- data/ext/did_parser/antlrgen/DIDLexer.cpp +225 -0
- data/ext/did_parser/antlrgen/DIDLexer.h +52 -0
- data/ext/did_parser/antlrgen/DIDLexer.interp +93 -0
- data/ext/did_parser/antlrgen/DIDLexer.tokens +42 -0
- data/ext/did_parser/antlrgen/DIDParser.cpp +2042 -0
- data/ext/did_parser/antlrgen/DIDParser.h +537 -0
- data/ext/did_parser/antlrgen/DIDParser.interp +74 -0
- data/ext/did_parser/antlrgen/DIDParser.tokens +42 -0
- data/ext/did_parser/antlrgen/DIDParserBaseListener.cpp +7 -0
- data/ext/did_parser/antlrgen/DIDParserBaseListener.h +104 -0
- data/ext/did_parser/antlrgen/DIDParserBaseVisitor.cpp +7 -0
- data/ext/did_parser/antlrgen/DIDParserBaseVisitor.h +124 -0
- data/ext/did_parser/antlrgen/DIDParserListener.cpp +7 -0
- data/ext/did_parser/antlrgen/DIDParserListener.h +97 -0
- data/ext/did_parser/antlrgen/DIDParserVisitor.cpp +7 -0
- data/ext/did_parser/antlrgen/DIDParserVisitor.h +76 -0
- data/ext/did_parser/did_parser.cpp +2996 -0
- data/ext/did_parser/extconf.rb +38 -0
- data/lib/did_parser/version.rb +3 -0
- data/lib/did_parser.rb +2 -0
- metadata +382 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "support/Any.h"
|
|
9
|
+
#include "tree/ParseTreeType.h"
|
|
10
|
+
|
|
11
|
+
namespace antlr4 {
|
|
12
|
+
namespace tree {
|
|
13
|
+
|
|
14
|
+
/// An interface to access the tree of <seealso cref="RuleContext"/> objects created
|
|
15
|
+
/// during a parse that makes the data structure look like a simple parse tree.
|
|
16
|
+
/// This node represents both internal nodes, rule invocations,
|
|
17
|
+
/// and leaf nodes, token matches.
|
|
18
|
+
///
|
|
19
|
+
/// The payload is either a <seealso cref="Token"/> or a <seealso cref="RuleContext"/> object.
|
|
20
|
+
// ml: This class unites 4 Java classes: RuleNode, ParseTree, SyntaxTree and Tree.
|
|
21
|
+
class ANTLR4CPP_PUBLIC ParseTree {
|
|
22
|
+
public:
|
|
23
|
+
ParseTree(ParseTree const&) = delete;
|
|
24
|
+
|
|
25
|
+
virtual ~ParseTree() = default;
|
|
26
|
+
|
|
27
|
+
ParseTree& operator=(ParseTree const&) = delete;
|
|
28
|
+
|
|
29
|
+
/// The parent of this node. If the return value is null, then this
|
|
30
|
+
/// node is the root of the tree.
|
|
31
|
+
ParseTree *parent = nullptr;
|
|
32
|
+
|
|
33
|
+
/// If we are debugging or building a parse tree for a visitor,
|
|
34
|
+
/// we need to track all of the tokens and rule invocations associated
|
|
35
|
+
/// with this rule's context. This is empty for parsing w/o tree constr.
|
|
36
|
+
/// operation because we don't the need to track the details about
|
|
37
|
+
/// how we parse this rule.
|
|
38
|
+
// ml: memory is not managed here, but by the owning class. This is just for the structure.
|
|
39
|
+
std::vector<ParseTree *> children;
|
|
40
|
+
|
|
41
|
+
/// Print out a whole tree, not just a node, in LISP format
|
|
42
|
+
/// {@code (root child1 .. childN)}. Print just a node if this is a leaf.
|
|
43
|
+
virtual std::string toStringTree(bool pretty = false) = 0;
|
|
44
|
+
virtual std::string toString() = 0;
|
|
45
|
+
|
|
46
|
+
/// Specialize toStringTree so that it can print out more information
|
|
47
|
+
/// based upon the parser.
|
|
48
|
+
virtual std::string toStringTree(Parser *parser, bool pretty = false) = 0;
|
|
49
|
+
|
|
50
|
+
virtual bool operator == (const ParseTree &other) const;
|
|
51
|
+
|
|
52
|
+
/// The <seealso cref="ParseTreeVisitor"/> needs a double dispatch method.
|
|
53
|
+
// ml: This has been changed to use Any instead of a template parameter, to avoid the need of a virtual template function.
|
|
54
|
+
virtual std::any accept(ParseTreeVisitor *visitor) = 0;
|
|
55
|
+
|
|
56
|
+
/// Return the combined text of all leaf nodes. Does not get any
|
|
57
|
+
/// off-channel tokens (if any) so won't return whitespace and
|
|
58
|
+
/// comments if they are sent to parser on hidden channel.
|
|
59
|
+
virtual std::string getText() = 0;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Return an {@link Interval} indicating the index in the
|
|
63
|
+
* {@link TokenStream} of the first and last token associated with this
|
|
64
|
+
* subtree. If this node is a leaf, then the interval represents a single
|
|
65
|
+
* token and has interval i..i for token index i.
|
|
66
|
+
*
|
|
67
|
+
* <p>An interval of i..i-1 indicates an empty interval at position
|
|
68
|
+
* i in the input stream, where 0 <= i <= the size of the input
|
|
69
|
+
* token stream. Currently, the code base can only have i=0..n-1 but
|
|
70
|
+
* in concept one could have an empty interval after EOF. </p>
|
|
71
|
+
*
|
|
72
|
+
* <p>If source interval is unknown, this returns {@link Interval#INVALID}.</p>
|
|
73
|
+
*
|
|
74
|
+
* <p>As a weird special case, the source interval for rules matched after
|
|
75
|
+
* EOF is unspecified.</p>
|
|
76
|
+
*/
|
|
77
|
+
virtual misc::Interval getSourceInterval() = 0;
|
|
78
|
+
|
|
79
|
+
ParseTreeType getTreeType() const { return _treeType; }
|
|
80
|
+
|
|
81
|
+
protected:
|
|
82
|
+
explicit ParseTree(ParseTreeType treeType) : _treeType(treeType) {}
|
|
83
|
+
|
|
84
|
+
private:
|
|
85
|
+
const ParseTreeType _treeType;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// A class to help managing ParseTree instances without the need of a shared_ptr.
|
|
89
|
+
class ANTLR4CPP_PUBLIC ParseTreeTracker {
|
|
90
|
+
public:
|
|
91
|
+
template<typename T, typename ... Args>
|
|
92
|
+
T* createInstance(Args&& ... args) {
|
|
93
|
+
static_assert(std::is_base_of<ParseTree, T>::value, "Argument must be a parse tree type");
|
|
94
|
+
T* result = new T(args...);
|
|
95
|
+
_allocated.push_back(result);
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
void reset() {
|
|
100
|
+
for (auto * entry : _allocated)
|
|
101
|
+
delete entry;
|
|
102
|
+
_allocated.clear();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private:
|
|
106
|
+
std::vector<ParseTree *> _allocated;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
} // namespace tree
|
|
111
|
+
} // namespace antlr4
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#include "ParseTreeListener.h"
|
|
7
|
+
|
|
8
|
+
antlr4::tree::ParseTreeListener::~ParseTreeListener() {
|
|
9
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "antlr4-common.h"
|
|
9
|
+
|
|
10
|
+
namespace antlr4 {
|
|
11
|
+
namespace tree {
|
|
12
|
+
|
|
13
|
+
/** This interface describes the minimal core of methods triggered
|
|
14
|
+
* by {@link ParseTreeWalker}. E.g.,
|
|
15
|
+
*
|
|
16
|
+
* ParseTreeWalker walker = new ParseTreeWalker();
|
|
17
|
+
* walker.walk(myParseTreeListener, myParseTree); <-- triggers events in your listener
|
|
18
|
+
*
|
|
19
|
+
* If you want to trigger events in multiple listeners during a single
|
|
20
|
+
* tree walk, you can use the ParseTreeDispatcher object available at
|
|
21
|
+
*
|
|
22
|
+
* https://github.com/antlr/antlr4/issues/841
|
|
23
|
+
*/
|
|
24
|
+
class ANTLR4CPP_PUBLIC ParseTreeListener {
|
|
25
|
+
public:
|
|
26
|
+
virtual ~ParseTreeListener();
|
|
27
|
+
|
|
28
|
+
virtual void visitTerminal(TerminalNode *node) = 0;
|
|
29
|
+
virtual void visitErrorNode(ErrorNode *node) = 0;
|
|
30
|
+
virtual void enterEveryRule(ParserRuleContext *ctx) = 0;
|
|
31
|
+
virtual void exitEveryRule(ParserRuleContext *ctx) = 0;
|
|
32
|
+
|
|
33
|
+
bool operator == (const ParseTreeListener &other) {
|
|
34
|
+
return this == &other;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
} // namespace tree
|
|
39
|
+
} // namespace antlr4
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "antlr4-common.h"
|
|
9
|
+
|
|
10
|
+
namespace antlr4 {
|
|
11
|
+
namespace tree {
|
|
12
|
+
|
|
13
|
+
/// <summary>
|
|
14
|
+
/// Associate a property with a parse tree node. Useful with parse tree listeners
|
|
15
|
+
/// that need to associate values with particular tree nodes, kind of like
|
|
16
|
+
/// specifying a return value for the listener event method that visited a
|
|
17
|
+
/// particular node. Example:
|
|
18
|
+
///
|
|
19
|
+
/// <pre>
|
|
20
|
+
/// ParseTreeProperty<Integer> values = new ParseTreeProperty<Integer>();
|
|
21
|
+
/// values.put(tree, 36);
|
|
22
|
+
/// int x = values.get(tree);
|
|
23
|
+
/// values.removeFrom(tree);
|
|
24
|
+
/// </pre>
|
|
25
|
+
///
|
|
26
|
+
/// You would make one decl (values here) in the listener and use lots of times
|
|
27
|
+
/// in your event methods.
|
|
28
|
+
/// </summary>
|
|
29
|
+
template<typename V>
|
|
30
|
+
class ANTLR4CPP_PUBLIC ParseTreeProperty {
|
|
31
|
+
public:
|
|
32
|
+
virtual ~ParseTreeProperty() {}
|
|
33
|
+
virtual V get(ParseTree *node) {
|
|
34
|
+
return _annotations[node];
|
|
35
|
+
}
|
|
36
|
+
virtual void put(ParseTree *node, V value) {
|
|
37
|
+
_annotations[node] = value;
|
|
38
|
+
}
|
|
39
|
+
virtual V removeFrom(ParseTree *node) {
|
|
40
|
+
auto value = _annotations[node];
|
|
41
|
+
_annotations.erase(node);
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected:
|
|
46
|
+
std::map<ParseTree*, V> _annotations;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
} // namespace tree
|
|
50
|
+
} // namespace antlr4
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include <cstddef>
|
|
9
|
+
|
|
10
|
+
#include "antlr4-common.h"
|
|
11
|
+
|
|
12
|
+
namespace antlr4 {
|
|
13
|
+
namespace tree {
|
|
14
|
+
|
|
15
|
+
enum class ParseTreeType : size_t {
|
|
16
|
+
TERMINAL = 1,
|
|
17
|
+
ERROR = 2,
|
|
18
|
+
RULE = 3,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
} // namespace tree
|
|
22
|
+
} // namespace antlr4
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#include "ParseTreeVisitor.h"
|
|
7
|
+
|
|
8
|
+
antlr4::tree::ParseTreeVisitor::~ParseTreeVisitor() {
|
|
9
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "support/Any.h"
|
|
9
|
+
|
|
10
|
+
namespace antlr4 {
|
|
11
|
+
namespace tree {
|
|
12
|
+
|
|
13
|
+
/// <summary>
|
|
14
|
+
/// This interface defines the basic notion of a parse tree visitor. Generated
|
|
15
|
+
/// visitors implement this interface and the {@code XVisitor} interface for
|
|
16
|
+
/// grammar {@code X}.
|
|
17
|
+
/// </summary>
|
|
18
|
+
/// @param <T> The return type of the visit operation. Use <seealso cref="Void"/> for
|
|
19
|
+
/// operations with no return type. </param>
|
|
20
|
+
// ml: no template parameter here, to avoid the need for virtual template functions. Instead we have our Any class.
|
|
21
|
+
class ANTLR4CPP_PUBLIC ParseTreeVisitor {
|
|
22
|
+
public:
|
|
23
|
+
virtual ~ParseTreeVisitor();
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
/// Visit a parse tree, and return a user-defined result of the operation.
|
|
27
|
+
/// </summary>
|
|
28
|
+
/// <param name="tree"> The <seealso cref="ParseTree"/> to visit. </param>
|
|
29
|
+
/// <returns> The result of visiting the parse tree. </returns>
|
|
30
|
+
virtual std::any visit(ParseTree *tree) = 0;
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
/// Visit the children of a node, and return a user-defined result of the
|
|
34
|
+
/// operation.
|
|
35
|
+
/// </summary>
|
|
36
|
+
/// <param name="node"> The <seealso cref="ParseTree"/> whose children should be visited. </param>
|
|
37
|
+
/// <returns> The result of visiting the children of the node. </returns>
|
|
38
|
+
virtual std::any visitChildren(ParseTree *node) = 0;
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
/// Visit a terminal node, and return a user-defined result of the operation.
|
|
42
|
+
/// </summary>
|
|
43
|
+
/// <param name="node"> The <seealso cref="TerminalNode"/> to visit. </param>
|
|
44
|
+
/// <returns> The result of visiting the node. </returns>
|
|
45
|
+
virtual std::any visitTerminal(TerminalNode *node) = 0;
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Visit an error node, and return a user-defined result of the operation.
|
|
49
|
+
/// </summary>
|
|
50
|
+
/// <param name="node"> The <seealso cref="ErrorNode"/> to visit. </param>
|
|
51
|
+
/// <returns> The result of visiting the node. </returns>
|
|
52
|
+
virtual std::any visitErrorNode(ErrorNode *node) = 0;
|
|
53
|
+
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace tree
|
|
57
|
+
} // namespace antlr4
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#include "tree/ErrorNode.h"
|
|
7
|
+
#include "ParserRuleContext.h"
|
|
8
|
+
#include "tree/ParseTreeListener.h"
|
|
9
|
+
#include "support/CPPUtils.h"
|
|
10
|
+
#include "support/Casts.h"
|
|
11
|
+
|
|
12
|
+
#include "tree/IterativeParseTreeWalker.h"
|
|
13
|
+
#include "tree/ParseTreeWalker.h"
|
|
14
|
+
|
|
15
|
+
using namespace antlr4::tree;
|
|
16
|
+
using namespace antlrcpp;
|
|
17
|
+
|
|
18
|
+
static IterativeParseTreeWalker defaultWalker;
|
|
19
|
+
ParseTreeWalker &ParseTreeWalker::DEFAULT = defaultWalker;
|
|
20
|
+
|
|
21
|
+
void ParseTreeWalker::walk(ParseTreeListener *listener, ParseTree *t) const {
|
|
22
|
+
if (ErrorNode::is(*t)) {
|
|
23
|
+
listener->visitErrorNode(downCast<ErrorNode*>(t));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (TerminalNode::is(*t)) {
|
|
27
|
+
listener->visitTerminal(downCast<TerminalNode*>(t));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
enterRule(listener, t);
|
|
32
|
+
for (auto &child : t->children) {
|
|
33
|
+
walk(listener, child);
|
|
34
|
+
}
|
|
35
|
+
exitRule(listener, t);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
void ParseTreeWalker::enterRule(ParseTreeListener *listener, ParseTree *r) const {
|
|
39
|
+
auto *ctx = downCast<ParserRuleContext*>(r);
|
|
40
|
+
listener->enterEveryRule(ctx);
|
|
41
|
+
ctx->enterRule(listener);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void ParseTreeWalker::exitRule(ParseTreeListener *listener, ParseTree *r) const {
|
|
45
|
+
auto *ctx = downCast<ParserRuleContext*>(r);
|
|
46
|
+
ctx->exitRule(listener);
|
|
47
|
+
listener->exitEveryRule(ctx);
|
|
48
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "antlr4-common.h"
|
|
9
|
+
|
|
10
|
+
namespace antlr4 {
|
|
11
|
+
namespace tree {
|
|
12
|
+
|
|
13
|
+
class ANTLR4CPP_PUBLIC ParseTreeWalker {
|
|
14
|
+
public:
|
|
15
|
+
static ParseTreeWalker &DEFAULT;
|
|
16
|
+
|
|
17
|
+
virtual ~ParseTreeWalker() = default;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* <summary>
|
|
21
|
+
* Performs a walk on the given parse tree starting at the root and going down recursively
|
|
22
|
+
* with depth-first search. On each node, <seealso cref="ParseTreeWalker#enterRule"/> is called before
|
|
23
|
+
* recursively walking down into child nodes, then
|
|
24
|
+
* <seealso cref="ParseTreeWalker#exitRule"/> is called after the recursive call to wind up.
|
|
25
|
+
* </summary>
|
|
26
|
+
* <param name='listener'> The listener used by the walker to process grammar rules </param>
|
|
27
|
+
* <param name='t'> The parse tree to be walked on </param>
|
|
28
|
+
*/
|
|
29
|
+
virtual void walk(ParseTreeListener *listener, ParseTree *t) const;
|
|
30
|
+
|
|
31
|
+
protected:
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* <summary>
|
|
35
|
+
* Enters a grammar rule by first triggering the generic event <seealso cref="ParseTreeListener#enterEveryRule"/>
|
|
36
|
+
* then by triggering the event specific to the given parse tree node
|
|
37
|
+
* </summary>
|
|
38
|
+
* <param name='listener'> The listener responding to the trigger events </param>
|
|
39
|
+
* <param name='r'> The grammar rule containing the rule context </param>
|
|
40
|
+
*/
|
|
41
|
+
virtual void enterRule(ParseTreeListener *listener, ParseTree *r) const;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* <summary>
|
|
45
|
+
* Exits a grammar rule by first triggering the event specific to the given parse tree node
|
|
46
|
+
* then by triggering the generic event <seealso cref="ParseTreeListener#exitEveryRule"/>
|
|
47
|
+
* </summary>
|
|
48
|
+
* <param name='listener'> The listener responding to the trigger events </param>
|
|
49
|
+
* <param name='r'> The grammar rule containing the rule context </param>
|
|
50
|
+
*/
|
|
51
|
+
virtual void exitRule(ParseTreeListener *listener, ParseTree *r) const;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace tree
|
|
55
|
+
} // namespace antlr4
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "tree/ParseTree.h"
|
|
9
|
+
|
|
10
|
+
namespace antlr4 {
|
|
11
|
+
namespace tree {
|
|
12
|
+
|
|
13
|
+
class ANTLR4CPP_PUBLIC TerminalNode : public ParseTree {
|
|
14
|
+
public:
|
|
15
|
+
static bool is(const tree::ParseTree &parseTree) {
|
|
16
|
+
const auto treeType = parseTree.getTreeType();
|
|
17
|
+
return treeType == ParseTreeType::TERMINAL || treeType == ParseTreeType::ERROR;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static bool is(const tree::ParseTree *parseTree) { return parseTree != nullptr && is(*parseTree); }
|
|
21
|
+
|
|
22
|
+
virtual Token* getSymbol() const = 0;
|
|
23
|
+
|
|
24
|
+
/** Set the parent for this leaf node.
|
|
25
|
+
*
|
|
26
|
+
* Technically, this is not backward compatible as it changes
|
|
27
|
+
* the interface but no one was able to create custom
|
|
28
|
+
* TerminalNodes anyway so I'm adding as it improves internal
|
|
29
|
+
* code quality.
|
|
30
|
+
*
|
|
31
|
+
* @since 4.7
|
|
32
|
+
*/
|
|
33
|
+
virtual void setParent(RuleContext *parent) = 0;
|
|
34
|
+
|
|
35
|
+
protected:
|
|
36
|
+
using ParseTree::ParseTree;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
} // namespace tree
|
|
40
|
+
} // namespace antlr4
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#include "misc/Interval.h"
|
|
7
|
+
#include "Token.h"
|
|
8
|
+
#include "RuleContext.h"
|
|
9
|
+
#include "tree/ParseTreeVisitor.h"
|
|
10
|
+
|
|
11
|
+
#include "tree/TerminalNodeImpl.h"
|
|
12
|
+
|
|
13
|
+
using namespace antlr4;
|
|
14
|
+
using namespace antlr4::tree;
|
|
15
|
+
|
|
16
|
+
Token* TerminalNodeImpl::getSymbol() const {
|
|
17
|
+
return symbol;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void TerminalNodeImpl::setParent(RuleContext *parent_) {
|
|
21
|
+
this->parent = parent_;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
misc::Interval TerminalNodeImpl::getSourceInterval() {
|
|
25
|
+
if (symbol == nullptr) {
|
|
26
|
+
return misc::Interval::INVALID;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
size_t tokenIndex = symbol->getTokenIndex();
|
|
30
|
+
return misc::Interval(tokenIndex, tokenIndex);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
std::any TerminalNodeImpl::accept(ParseTreeVisitor *visitor) {
|
|
34
|
+
return visitor->visitTerminal(this);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
std::string TerminalNodeImpl::getText() {
|
|
38
|
+
return symbol->getText();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
std::string TerminalNodeImpl::toStringTree(Parser * /*parser*/, bool /*pretty*/) {
|
|
42
|
+
return toString();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
std::string TerminalNodeImpl::toString() {
|
|
46
|
+
if (symbol->getType() == Token::EOF) {
|
|
47
|
+
return "<EOF>";
|
|
48
|
+
}
|
|
49
|
+
return symbol->getText();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
std::string TerminalNodeImpl::toStringTree(bool /*pretty*/) {
|
|
53
|
+
return toString();
|
|
54
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "tree/TerminalNode.h"
|
|
9
|
+
|
|
10
|
+
namespace antlr4 {
|
|
11
|
+
namespace tree {
|
|
12
|
+
|
|
13
|
+
class ANTLR4CPP_PUBLIC TerminalNodeImpl : public TerminalNode {
|
|
14
|
+
public:
|
|
15
|
+
Token *symbol;
|
|
16
|
+
|
|
17
|
+
explicit TerminalNodeImpl(Token *symbol) : TerminalNode(ParseTreeType::TERMINAL), symbol(symbol) {}
|
|
18
|
+
|
|
19
|
+
virtual Token* getSymbol() const override;
|
|
20
|
+
virtual void setParent(RuleContext *parent) override;
|
|
21
|
+
virtual misc::Interval getSourceInterval() override;
|
|
22
|
+
|
|
23
|
+
virtual std::any accept(ParseTreeVisitor *visitor) override;
|
|
24
|
+
|
|
25
|
+
virtual std::string getText() override;
|
|
26
|
+
virtual std::string toStringTree(Parser *parser, bool pretty = false) override;
|
|
27
|
+
virtual std::string toString() override;
|
|
28
|
+
virtual std::string toStringTree(bool pretty = false) override;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // namespace tree
|
|
32
|
+
} // namespace antlr4
|