expressir 1.2.4 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +200 -21
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- data/README.adoc +8 -0
- data/Rakefile +4 -1
- data/bin/console +0 -1
- data/bin/rspec +3 -3
- data/exe/expressir +4 -2
- data/exe/format +1 -1
- data/exe/format-test +25 -25
- data/exe/generate-parser +16 -13
- data/expressir.gemspec +12 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
- data/ext/express-parser/antlrgen/Express.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
- data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
- data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
- data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
- data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
- data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
- data/ext/express-parser/express_parser.cpp +294 -86
- data/ext/express-parser/extconf.rb +13 -12
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +3 -4
- data/lib/expressir/express/visitor.rb +7 -5
- data/lib/expressir/model.rb +78 -78
- data/lib/expressir/version.rb +1 -1
- data/rakelib/antlr4-native.rake +161 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +17 -2
- data/spec/expressir/express/cache_spec.rb +23 -5
- data/spec/expressir/express/formatter_spec.rb +54 -8
- data/spec/expressir/express/parser_spec.rb +47 -11
- data/spec/expressir/model/model_element_spec.rb +198 -146
- data/spec/spec_helper.rb +7 -0
- metadata +81 -93
- data/demo.rb +0 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
- data/original/examples/employment/eclipse/.project +0 -17
- data/original/examples/employment/eclipse/Export/Employment.png +0 -0
- data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
- data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
- data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
- data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
- data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
- data/original/examples/employment/eclipse/readme.txt +0 -7
- data/original/examples/employment/employment_schema.exp +0 -33
- data/original/examples/employment/employment_schema.rb +0 -232
- data/original/examples/employment/employment_schema.xml +0 -93
- data/original/examples/employment/employment_schema___module.rb +0 -46
- data/original/examples/employment/employment_schema___p28attr.rb +0 -126
- data/original/examples/employment/employment_schema___p28inst.rb +0 -26
- data/original/examples/employment/example_employment_data.xml +0 -1
- data/original/examples/employment/example_employment_data_copy.xml +0 -1
- data/original/examples/employment/example_employment_reader.rb +0 -30
- data/original/examples/employment/example_employment_writer.rb +0 -51
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
- data/original/exp2ruby.rb +0 -525
- data/original/expsm.rb +0 -34
- data/original/mapping_owl.rb +0 -1018
- data/original/mapping_sysml.rb +0 -2281
- data/original/mapping_uml2.rb +0 -599
- data/original/mapping_uml2_eclipse.rb +0 -433
- data/original/reeper.rb +0 -134
- data/spec/expressr_spec.rb +0 -5
@@ -28,10 +28,25 @@
|
|
28
28
|
|
29
29
|
using namespace antlr4;
|
30
30
|
using namespace antlr4::atn;
|
31
|
-
|
32
31
|
using namespace antlrcpp;
|
33
32
|
|
34
|
-
|
33
|
+
namespace {
|
34
|
+
|
35
|
+
struct BypassAltsAtnCache final {
|
36
|
+
std::shared_mutex mutex;
|
37
|
+
/// This field maps from the serialized ATN string to the deserialized <seealso cref="ATN"/> with
|
38
|
+
/// bypass alternatives.
|
39
|
+
///
|
40
|
+
/// <seealso cref= ATNDeserializationOptions#isGenerateRuleBypassTransitions() </seealso>
|
41
|
+
std::map<std::vector<int32_t>, std::unique_ptr<const atn::ATN>, std::less<>> map;
|
42
|
+
};
|
43
|
+
|
44
|
+
BypassAltsAtnCache* getBypassAltsAtnCache() {
|
45
|
+
static BypassAltsAtnCache* const instance = new BypassAltsAtnCache();
|
46
|
+
return instance;
|
47
|
+
}
|
48
|
+
|
49
|
+
}
|
35
50
|
|
36
51
|
Parser::TraceListener::TraceListener(Parser *outerInstance_) : outerInstance(outerInstance_) {
|
37
52
|
}
|
@@ -212,27 +227,32 @@ TokenFactory<CommonToken>* Parser::getTokenFactory() {
|
|
212
227
|
return _input->getTokenSource()->getTokenFactory();
|
213
228
|
}
|
214
229
|
|
215
|
-
|
216
230
|
const atn::ATN& Parser::getATNWithBypassAlts() {
|
217
|
-
|
231
|
+
auto serializedAtn = getSerializedATN();
|
218
232
|
if (serializedAtn.empty()) {
|
219
233
|
throw UnsupportedOperationException("The current parser does not support an ATN with bypass alternatives.");
|
220
234
|
}
|
221
|
-
|
222
|
-
std::lock_guard<std::mutex> lck(_mutex);
|
223
|
-
|
224
235
|
// XXX: using the entire serialized ATN as key into the map is a big resource waste.
|
225
236
|
// How large can that thing become?
|
226
|
-
|
237
|
+
auto *cache = getBypassAltsAtnCache();
|
227
238
|
{
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
239
|
+
std::shared_lock<std::shared_mutex> lock(cache->mutex);
|
240
|
+
auto existing = cache->map.find(serializedAtn);
|
241
|
+
if (existing != cache->map.end()) {
|
242
|
+
return *existing->second;
|
243
|
+
}
|
233
244
|
}
|
234
245
|
|
235
|
-
|
246
|
+
std::unique_lock<std::shared_mutex> lock(cache->mutex);
|
247
|
+
auto existing = cache->map.find(serializedAtn);
|
248
|
+
if (existing != cache->map.end()) {
|
249
|
+
return *existing->second;
|
250
|
+
}
|
251
|
+
atn::ATNDeserializationOptions deserializationOptions;
|
252
|
+
deserializationOptions.setGenerateRuleBypassTransitions(true);
|
253
|
+
atn::ATNDeserializer deserializer(deserializationOptions);
|
254
|
+
auto atn = deserializer.deserialize(serializedAtn);
|
255
|
+
return *cache->map.insert(std::make_pair(std::vector<int32_t>(serializedAtn.begin(), serializedAtn.end()), std::move(atn))).first->second;
|
236
256
|
}
|
237
257
|
|
238
258
|
tree::pattern::ParseTreePattern Parser::compileParseTreePattern(const std::string &pattern, int patternRuleIndex) {
|
@@ -328,8 +348,7 @@ void Parser::addContextToParseTree() {
|
|
328
348
|
if (_ctx->parent == nullptr)
|
329
349
|
return;
|
330
350
|
|
331
|
-
|
332
|
-
parent->addChild(_ctx);
|
351
|
+
downCast<ParserRuleContext*>(_ctx->parent)->addChild(_ctx);
|
333
352
|
}
|
334
353
|
|
335
354
|
void Parser::enterRule(ParserRuleContext *localctx, size_t state, size_t /*ruleIndex*/) {
|
@@ -357,7 +376,7 @@ void Parser::exitRule() {
|
|
357
376
|
triggerExitRuleEvent();
|
358
377
|
}
|
359
378
|
setState(_ctx->invokingState);
|
360
|
-
_ctx =
|
379
|
+
_ctx = downCast<ParserRuleContext*>(_ctx->parent);
|
361
380
|
}
|
362
381
|
|
363
382
|
void Parser::enterOuterAlt(ParserRuleContext *localctx, size_t altNum) {
|
@@ -367,7 +386,7 @@ void Parser::enterOuterAlt(ParserRuleContext *localctx, size_t altNum) {
|
|
367
386
|
// that is previous child of parse tree
|
368
387
|
if (_buildParseTrees && _ctx != localctx) {
|
369
388
|
if (_ctx->parent != nullptr) {
|
370
|
-
ParserRuleContext *parent =
|
389
|
+
ParserRuleContext *parent = downCast<ParserRuleContext*>(_ctx->parent);
|
371
390
|
parent->removeLastChild();
|
372
391
|
parent->addChild(localctx);
|
373
392
|
}
|
@@ -423,7 +442,7 @@ void Parser::unrollRecursionContexts(ParserRuleContext *parentctx) {
|
|
423
442
|
if (_parseListeners.size() > 0) {
|
424
443
|
while (_ctx != parentctx) {
|
425
444
|
triggerExitRuleEvent();
|
426
|
-
_ctx =
|
445
|
+
_ctx = downCast<ParserRuleContext*>(_ctx->parent);
|
427
446
|
}
|
428
447
|
} else {
|
429
448
|
_ctx = parentctx;
|
@@ -446,7 +465,7 @@ ParserRuleContext* Parser::getInvokingContext(size_t ruleIndex) {
|
|
446
465
|
}
|
447
466
|
if (p->parent == nullptr)
|
448
467
|
break;
|
449
|
-
p =
|
468
|
+
p = downCast<ParserRuleContext*>(p->parent);
|
450
469
|
}
|
451
470
|
return nullptr;
|
452
471
|
}
|
@@ -484,13 +503,13 @@ bool Parser::isExpectedToken(size_t symbol) {
|
|
484
503
|
|
485
504
|
while (ctx && ctx->invokingState != ATNState::INVALID_STATE_NUMBER && following.contains(Token::EPSILON)) {
|
486
505
|
atn::ATNState *invokingState = atn.states[ctx->invokingState];
|
487
|
-
atn::RuleTransition *rt = static_cast<atn::RuleTransition*>(invokingState->transitions[0]);
|
506
|
+
const atn::RuleTransition *rt = static_cast<const atn::RuleTransition*>(invokingState->transitions[0].get());
|
488
507
|
following = atn.nextTokens(rt->followState);
|
489
508
|
if (following.contains(symbol)) {
|
490
509
|
return true;
|
491
510
|
}
|
492
511
|
|
493
|
-
ctx =
|
512
|
+
ctx = downCast<ParserRuleContext*>(ctx->parent);
|
494
513
|
}
|
495
514
|
|
496
515
|
if (following.contains(Token::EPSILON) && symbol == EOF) {
|
@@ -543,9 +562,10 @@ std::vector<std::string> Parser::getRuleInvocationStack(RuleContext *p) {
|
|
543
562
|
} else {
|
544
563
|
stack.push_back(ruleNames[ruleIndex]);
|
545
564
|
}
|
546
|
-
if (
|
565
|
+
if (!RuleContext::is(run->parent)) {
|
547
566
|
break;
|
548
|
-
|
567
|
+
}
|
568
|
+
run = downCast<RuleContext*>(run->parent);
|
549
569
|
}
|
550
570
|
return stack;
|
551
571
|
}
|
@@ -589,12 +609,12 @@ std::string Parser::getSourceName() {
|
|
589
609
|
}
|
590
610
|
|
591
611
|
atn::ParseInfo Parser::getParseInfo() const {
|
592
|
-
atn::
|
593
|
-
return atn::ParseInfo(
|
612
|
+
atn::ParserATNSimulator *simulator = getInterpreter<atn::ParserATNSimulator>();
|
613
|
+
return atn::ParseInfo(dynamic_cast<atn::ProfilingATNSimulator*>(simulator));
|
594
614
|
}
|
595
615
|
|
596
616
|
void Parser::setProfile(bool profile) {
|
597
|
-
atn::ParserATNSimulator *interp = getInterpreter<atn::
|
617
|
+
atn::ParserATNSimulator *interp = getInterpreter<atn::ParserATNSimulator>();
|
598
618
|
atn::PredictionMode saveMode = interp != nullptr ? interp->getPredictionMode() : atn::PredictionMode::LL;
|
599
619
|
if (profile) {
|
600
620
|
if (!is<atn::ProfilingATNSimulator *>(interp)) {
|
@@ -448,12 +448,6 @@ namespace antlr4 {
|
|
448
448
|
tree::ParseTreeTracker _tracker;
|
449
449
|
|
450
450
|
private:
|
451
|
-
/// This field maps from the serialized ATN string to the deserialized <seealso cref="ATN"/> with
|
452
|
-
/// bypass alternatives.
|
453
|
-
///
|
454
|
-
/// <seealso cref= ATNDeserializationOptions#isGenerateRuleBypassTransitions() </seealso>
|
455
|
-
static std::map<std::vector<uint16_t>, atn::ATN> bypassAltsAtnCache;
|
456
|
-
|
457
451
|
/// When setTrace(true) is called, a reference to the
|
458
452
|
/// TraceListener is stored here so it can be easily removed in a
|
459
453
|
/// later call to setTrace(false). The listener itself is
|
@@ -26,6 +26,7 @@
|
|
26
26
|
#include "tree/ErrorNode.h"
|
27
27
|
|
28
28
|
#include "support/CPPUtils.h"
|
29
|
+
#include "support/Casts.h"
|
29
30
|
|
30
31
|
#include "ParserInterpreter.h"
|
31
32
|
|
@@ -35,19 +36,10 @@ using namespace antlr4::misc;
|
|
35
36
|
|
36
37
|
using namespace antlrcpp;
|
37
38
|
|
38
|
-
ParserInterpreter::ParserInterpreter(const std::string &grammarFileName, const std::vector<std::string>& tokenNames,
|
39
|
-
const std::vector<std::string>& ruleNames, const atn::ATN &atn, TokenStream *input)
|
40
|
-
: ParserInterpreter(grammarFileName, dfa::Vocabulary::fromTokenNames(tokenNames), ruleNames, atn, input) {
|
41
|
-
}
|
42
|
-
|
43
39
|
ParserInterpreter::ParserInterpreter(const std::string &grammarFileName, const dfa::Vocabulary &vocabulary,
|
44
40
|
const std::vector<std::string> &ruleNames, const atn::ATN &atn, TokenStream *input)
|
45
41
|
: Parser(input), _grammarFileName(grammarFileName), _atn(atn), _ruleNames(ruleNames), _vocabulary(vocabulary) {
|
46
42
|
|
47
|
-
for (size_t i = 0; i < atn.maxTokenType; ++i) {
|
48
|
-
_tokenNames.push_back(vocabulary.getDisplayName(i));
|
49
|
-
}
|
50
|
-
|
51
43
|
// init decision DFA
|
52
44
|
for (size_t i = 0; i < atn.getNumberOfDecisions(); ++i) {
|
53
45
|
atn::DecisionState *decisionState = atn.getDecisionState(i);
|
@@ -72,10 +64,6 @@ const atn::ATN& ParserInterpreter::getATN() const {
|
|
72
64
|
return _atn;
|
73
65
|
}
|
74
66
|
|
75
|
-
const std::vector<std::string>& ParserInterpreter::getTokenNames() const {
|
76
|
-
return _tokenNames;
|
77
|
-
}
|
78
|
-
|
79
67
|
const dfa::Vocabulary& ParserInterpreter::getVocabulary() const {
|
80
68
|
return _vocabulary;
|
81
69
|
}
|
@@ -102,7 +90,7 @@ ParserRuleContext* ParserInterpreter::parse(size_t startRuleIndex) {
|
|
102
90
|
while (true) {
|
103
91
|
atn::ATNState *p = getATNState();
|
104
92
|
switch (p->getStateType()) {
|
105
|
-
case atn::
|
93
|
+
case atn::ATNStateType::RULE_STOP :
|
106
94
|
// pop; return from rule
|
107
95
|
if (_ctx->isEmpty()) {
|
108
96
|
if (startRuleStartState->isLeftRecursiveRule) {
|
@@ -161,16 +149,16 @@ atn::ATNState* ParserInterpreter::getATNState() {
|
|
161
149
|
|
162
150
|
void ParserInterpreter::visitState(atn::ATNState *p) {
|
163
151
|
size_t predictedAlt = 1;
|
164
|
-
if (is
|
165
|
-
predictedAlt = visitDecisionState(
|
152
|
+
if (DecisionState::is(p)) {
|
153
|
+
predictedAlt = visitDecisionState(downCast<DecisionState*>(p));
|
166
154
|
}
|
167
155
|
|
168
|
-
atn::Transition *transition = p->transitions[predictedAlt - 1];
|
169
|
-
switch (transition->
|
170
|
-
case atn::
|
171
|
-
if (p->getStateType() ==
|
172
|
-
(
|
173
|
-
!is
|
156
|
+
const atn::Transition *transition = p->transitions[predictedAlt - 1].get();
|
157
|
+
switch (transition->getTransitionType()) {
|
158
|
+
case atn::TransitionType::EPSILON:
|
159
|
+
if (p->getStateType() == ATNStateType::STAR_LOOP_ENTRY &&
|
160
|
+
(downCast<StarLoopEntryState *>(p))->isPrecedenceDecision &&
|
161
|
+
!LoopEndState::is(transition->target)) {
|
174
162
|
// We are at the start of a left recursive rule's (...)* loop
|
175
163
|
// and we're not taking the exit branch of loop.
|
176
164
|
InterpreterRuleContext *localctx = createInterpreterRuleContext(_parentContextStack.top().first,
|
@@ -179,56 +167,56 @@ void ParserInterpreter::visitState(atn::ATNState *p) {
|
|
179
167
|
}
|
180
168
|
break;
|
181
169
|
|
182
|
-
case atn::
|
183
|
-
match(static_cast<int>(static_cast<atn::AtomTransition*>(transition)->_label));
|
170
|
+
case atn::TransitionType::ATOM:
|
171
|
+
match(static_cast<int>(static_cast<const atn::AtomTransition*>(transition)->_label));
|
184
172
|
break;
|
185
173
|
|
186
|
-
case atn::
|
187
|
-
case atn::
|
188
|
-
case atn::
|
174
|
+
case atn::TransitionType::RANGE:
|
175
|
+
case atn::TransitionType::SET:
|
176
|
+
case atn::TransitionType::NOT_SET:
|
189
177
|
if (!transition->matches(static_cast<int>(_input->LA(1)), Token::MIN_USER_TOKEN_TYPE, Lexer::MAX_CHAR_VALUE)) {
|
190
178
|
recoverInline();
|
191
179
|
}
|
192
180
|
matchWildcard();
|
193
181
|
break;
|
194
182
|
|
195
|
-
case atn::
|
183
|
+
case atn::TransitionType::WILDCARD:
|
196
184
|
matchWildcard();
|
197
185
|
break;
|
198
186
|
|
199
|
-
case atn::
|
187
|
+
case atn::TransitionType::RULE:
|
200
188
|
{
|
201
189
|
atn::RuleStartState *ruleStartState = static_cast<atn::RuleStartState*>(transition->target);
|
202
190
|
size_t ruleIndex = ruleStartState->ruleIndex;
|
203
191
|
InterpreterRuleContext *newctx = createInterpreterRuleContext(_ctx, p->stateNumber, ruleIndex);
|
204
192
|
if (ruleStartState->isLeftRecursiveRule) {
|
205
|
-
enterRecursionRule(newctx, ruleStartState->stateNumber, ruleIndex, static_cast<atn::RuleTransition*>(transition)->precedence);
|
193
|
+
enterRecursionRule(newctx, ruleStartState->stateNumber, ruleIndex, static_cast<const atn::RuleTransition*>(transition)->precedence);
|
206
194
|
} else {
|
207
195
|
enterRule(newctx, transition->target->stateNumber, ruleIndex);
|
208
196
|
}
|
209
197
|
}
|
210
198
|
break;
|
211
199
|
|
212
|
-
case atn::
|
200
|
+
case atn::TransitionType::PREDICATE:
|
213
201
|
{
|
214
|
-
atn::PredicateTransition *predicateTransition = static_cast<atn::PredicateTransition*>(transition);
|
215
|
-
if (!sempred(_ctx, predicateTransition->
|
202
|
+
const atn::PredicateTransition *predicateTransition = static_cast<const atn::PredicateTransition*>(transition);
|
203
|
+
if (!sempred(_ctx, predicateTransition->getRuleIndex(), predicateTransition->getPredIndex())) {
|
216
204
|
throw FailedPredicateException(this);
|
217
205
|
}
|
218
206
|
}
|
219
207
|
break;
|
220
208
|
|
221
|
-
case atn::
|
209
|
+
case atn::TransitionType::ACTION:
|
222
210
|
{
|
223
|
-
atn::ActionTransition *actionTransition = static_cast<atn::ActionTransition*>(transition);
|
211
|
+
const atn::ActionTransition *actionTransition = static_cast<const atn::ActionTransition*>(transition);
|
224
212
|
action(_ctx, actionTransition->ruleIndex, actionTransition->actionIndex);
|
225
213
|
}
|
226
214
|
break;
|
227
215
|
|
228
|
-
case atn::
|
216
|
+
case atn::TransitionType::PRECEDENCE:
|
229
217
|
{
|
230
|
-
if (!precpred(_ctx, static_cast<atn::PrecedencePredicateTransition*>(transition)->
|
231
|
-
throw FailedPredicateException(this, "precpred(_ctx, " + std::to_string(static_cast<atn::PrecedencePredicateTransition*>(transition)->
|
218
|
+
if (!precpred(_ctx, static_cast<const atn::PrecedencePredicateTransition*>(transition)->getPrecedence())) {
|
219
|
+
throw FailedPredicateException(this, "precpred(_ctx, " + std::to_string(static_cast<const atn::PrecedencePredicateTransition*>(transition)->getPrecedence()) + ")");
|
232
220
|
}
|
233
221
|
}
|
234
222
|
break;
|
@@ -272,7 +260,7 @@ void ParserInterpreter::visitRuleStopState(atn::ATNState *p) {
|
|
272
260
|
exitRule();
|
273
261
|
}
|
274
262
|
|
275
|
-
atn::RuleTransition *ruleTransition = static_cast<atn::RuleTransition*>(_atn.states[getState()]->transitions[0]);
|
263
|
+
const atn::RuleTransition *ruleTransition = static_cast<const atn::RuleTransition*>(_atn.states[getState()]->transitions[0].get());
|
276
264
|
setState(ruleTransition->followState->stateNumber);
|
277
265
|
}
|
278
266
|
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#include "atn/ATN.h"
|
10
10
|
#include "support/BitSet.h"
|
11
11
|
#include "atn/PredictionContext.h"
|
12
|
+
#include "atn/PredictionContextCache.h"
|
12
13
|
#include "Vocabulary.h"
|
13
14
|
|
14
15
|
namespace antlr4 {
|
@@ -29,9 +30,6 @@ namespace antlr4 {
|
|
29
30
|
/// </summary>
|
30
31
|
class ANTLR4CPP_PUBLIC ParserInterpreter : public Parser {
|
31
32
|
public:
|
32
|
-
// @deprecated
|
33
|
-
ParserInterpreter(const std::string &grammarFileName, const std::vector<std::string>& tokenNames,
|
34
|
-
const std::vector<std::string>& ruleNames, const atn::ATN &atn, TokenStream *input);
|
35
33
|
ParserInterpreter(const std::string &grammarFileName, const dfa::Vocabulary &vocabulary,
|
36
34
|
const std::vector<std::string> &ruleNames, const atn::ATN &atn, TokenStream *input);
|
37
35
|
~ParserInterpreter();
|
@@ -40,9 +38,6 @@ namespace antlr4 {
|
|
40
38
|
|
41
39
|
virtual const atn::ATN& getATN() const override;
|
42
40
|
|
43
|
-
// @deprecated
|
44
|
-
virtual const std::vector<std::string>& getTokenNames() const override;
|
45
|
-
|
46
41
|
virtual const dfa::Vocabulary& getVocabulary() const override;
|
47
42
|
|
48
43
|
virtual const std::vector<std::string>& getRuleNames() const override;
|
@@ -110,7 +105,6 @@ namespace antlr4 {
|
|
110
105
|
|
111
106
|
protected:
|
112
107
|
const std::string _grammarFileName;
|
113
|
-
std::vector<std::string> _tokenNames;
|
114
108
|
const atn::ATN &_atn;
|
115
109
|
|
116
110
|
std::vector<std::string> _ruleNames;
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#include "Parser.h"
|
10
10
|
#include "Token.h"
|
11
11
|
|
12
|
+
#include "support/Casts.h"
|
12
13
|
#include "support/CPPUtils.h"
|
13
14
|
|
14
15
|
#include "ParserRuleContext.h"
|
@@ -39,10 +40,9 @@ void ParserRuleContext::copyFrom(ParserRuleContext *ctx) {
|
|
39
40
|
// copy any error nodes to alt label node
|
40
41
|
if (!ctx->children.empty()) {
|
41
42
|
for (auto *child : ctx->children) {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
children.push_back(errorNode);
|
43
|
+
if (ErrorNode::is(child)) {
|
44
|
+
downCast<ErrorNode*>(child)->setParent(this);
|
45
|
+
children.push_back(child);
|
46
46
|
}
|
47
47
|
}
|
48
48
|
|
@@ -76,39 +76,36 @@ void ParserRuleContext::removeLastChild() {
|
|
76
76
|
}
|
77
77
|
}
|
78
78
|
|
79
|
-
tree::TerminalNode* ParserRuleContext::getToken(size_t ttype, size_t i) {
|
79
|
+
tree::TerminalNode* ParserRuleContext::getToken(size_t ttype, size_t i) const {
|
80
80
|
if (i >= children.size()) {
|
81
81
|
return nullptr;
|
82
82
|
}
|
83
|
-
|
84
83
|
size_t j = 0; // what token with ttype have we found?
|
85
|
-
for (auto *
|
86
|
-
if (is
|
87
|
-
tree::TerminalNode *
|
88
|
-
Token *symbol =
|
84
|
+
for (auto *child : children) {
|
85
|
+
if (TerminalNode::is(child)) {
|
86
|
+
tree::TerminalNode *typedChild = downCast<tree::TerminalNode*>(child);
|
87
|
+
Token *symbol = typedChild->getSymbol();
|
89
88
|
if (symbol->getType() == ttype) {
|
90
89
|
if (j++ == i) {
|
91
|
-
return
|
90
|
+
return typedChild;
|
92
91
|
}
|
93
92
|
}
|
94
93
|
}
|
95
94
|
}
|
96
|
-
|
97
95
|
return nullptr;
|
98
96
|
}
|
99
97
|
|
100
|
-
std::vector<tree::TerminalNode *> ParserRuleContext::getTokens(size_t ttype) {
|
101
|
-
std::vector<tree::TerminalNode
|
102
|
-
for (auto
|
103
|
-
if (is
|
104
|
-
tree::TerminalNode *
|
105
|
-
Token *symbol =
|
98
|
+
std::vector<tree::TerminalNode *> ParserRuleContext::getTokens(size_t ttype) const {
|
99
|
+
std::vector<tree::TerminalNode*> tokens;
|
100
|
+
for (auto *child : children) {
|
101
|
+
if (TerminalNode::is(child)) {
|
102
|
+
tree::TerminalNode *typedChild = downCast<tree::TerminalNode*>(child);
|
103
|
+
Token *symbol = typedChild->getSymbol();
|
106
104
|
if (symbol->getType() == ttype) {
|
107
|
-
tokens.push_back(
|
105
|
+
tokens.push_back(typedChild);
|
108
106
|
}
|
109
107
|
}
|
110
108
|
}
|
111
|
-
|
112
109
|
return tokens;
|
113
110
|
}
|
114
111
|
|
@@ -123,11 +120,11 @@ misc::Interval ParserRuleContext::getSourceInterval() {
|
|
123
120
|
return misc::Interval(start->getTokenIndex(), stop->getTokenIndex());
|
124
121
|
}
|
125
122
|
|
126
|
-
Token* ParserRuleContext::getStart() {
|
123
|
+
Token* ParserRuleContext::getStart() const {
|
127
124
|
return start;
|
128
125
|
}
|
129
126
|
|
130
|
-
Token* ParserRuleContext::getStop() {
|
127
|
+
Token* ParserRuleContext::getStop() const {
|
131
128
|
return stop;
|
132
129
|
}
|
133
130
|
|
@@ -67,7 +67,6 @@ namespace antlr4 {
|
|
67
67
|
|
68
68
|
ParserRuleContext();
|
69
69
|
ParserRuleContext(ParserRuleContext *parent, size_t invokingStateNumber);
|
70
|
-
virtual ~ParserRuleContext() {}
|
71
70
|
|
72
71
|
/** COPY a ctx (I'm deliberately not using copy constructor) to avoid
|
73
72
|
* confusion with creating node with parent. Does not copy children
|
@@ -88,23 +87,22 @@ namespace antlr4 {
|
|
88
87
|
/// Used by enterOuterAlt to toss out a RuleContext previously added as
|
89
88
|
/// we entered a rule. If we have # label, we will need to remove
|
90
89
|
/// generic ruleContext object.
|
91
|
-
|
90
|
+
void removeLastChild();
|
92
91
|
|
93
|
-
|
92
|
+
tree::TerminalNode* getToken(size_t ttype, std::size_t i) const;
|
94
93
|
|
95
|
-
|
94
|
+
std::vector<tree::TerminalNode*> getTokens(size_t ttype) const;
|
96
95
|
|
97
96
|
template<typename T>
|
98
|
-
T* getRuleContext(size_t i) {
|
99
|
-
|
100
|
-
return nullptr;
|
101
|
-
}
|
102
|
-
|
97
|
+
T* getRuleContext(size_t i) const {
|
98
|
+
static_assert(std::is_base_of_v<RuleContext, T>, "T must be derived from RuleContext");
|
103
99
|
size_t j = 0; // what element have we found with ctxType?
|
104
|
-
for (auto
|
105
|
-
if (
|
106
|
-
if (
|
107
|
-
|
100
|
+
for (auto *child : children) {
|
101
|
+
if (RuleContext::is(child)) {
|
102
|
+
if (auto *typedChild = dynamic_cast<T*>(child); typedChild != nullptr) {
|
103
|
+
if (j++ == i) {
|
104
|
+
return typedChild;
|
105
|
+
}
|
108
106
|
}
|
109
107
|
}
|
110
108
|
}
|
@@ -112,14 +110,16 @@ namespace antlr4 {
|
|
112
110
|
}
|
113
111
|
|
114
112
|
template<typename T>
|
115
|
-
std::vector<T
|
116
|
-
std::
|
113
|
+
std::vector<T*> getRuleContexts() const {
|
114
|
+
static_assert(std::is_base_of_v<RuleContext, T>, "T must be derived from RuleContext");
|
115
|
+
std::vector<T*> contexts;
|
117
116
|
for (auto *child : children) {
|
118
|
-
if (
|
119
|
-
|
117
|
+
if (RuleContext::is(child)) {
|
118
|
+
if (auto *typedChild = dynamic_cast<T*>(child); typedChild != nullptr) {
|
119
|
+
contexts.push_back(typedChild);
|
120
|
+
}
|
120
121
|
}
|
121
122
|
}
|
122
|
-
|
123
123
|
return contexts;
|
124
124
|
}
|
125
125
|
|
@@ -130,14 +130,14 @@ namespace antlr4 {
|
|
130
130
|
* Note that the range from start to stop is inclusive, so for rules that do not consume anything
|
131
131
|
* (for example, zero length or error productions) this token may exceed stop.
|
132
132
|
*/
|
133
|
-
|
133
|
+
Token* getStart() const;
|
134
134
|
|
135
135
|
/**
|
136
136
|
* Get the final token in this context.
|
137
137
|
* Note that the range from start to stop is inclusive, so for rules that do not consume anything
|
138
138
|
* (for example, zero length or error productions) this token may precede start.
|
139
139
|
*/
|
140
|
-
|
140
|
+
Token* getStop() const;
|
141
141
|
|
142
142
|
/// <summary>
|
143
143
|
/// Used for rule context info debugging during parse-time, not so much for ATN debugging </summary>
|
@@ -6,11 +6,11 @@
|
|
6
6
|
#include "ConsoleErrorListener.h"
|
7
7
|
#include "RecognitionException.h"
|
8
8
|
#include "support/CPPUtils.h"
|
9
|
-
#include "support/StringUtils.h"
|
10
9
|
#include "Token.h"
|
11
10
|
#include "atn/ATN.h"
|
12
11
|
#include "atn/ATNSimulator.h"
|
13
12
|
#include "support/CPPUtils.h"
|
13
|
+
#include "support/StringUtils.h"
|
14
14
|
|
15
15
|
#include "Vocabulary.h"
|
16
16
|
|
@@ -19,7 +19,7 @@
|
|
19
19
|
using namespace antlr4;
|
20
20
|
using namespace antlr4::atn;
|
21
21
|
|
22
|
-
std::map<const dfa::Vocabulary*, std::map<std::
|
22
|
+
std::map<const dfa::Vocabulary*, std::map<std::string_view, size_t>> Recognizer::_tokenTypeMapCache;
|
23
23
|
std::map<std::vector<std::string>, std::map<std::string, size_t>> Recognizer::_ruleIndexMapCache;
|
24
24
|
|
25
25
|
Recognizer::Recognizer() {
|
@@ -30,31 +30,26 @@ Recognizer::Recognizer() {
|
|
30
30
|
Recognizer::~Recognizer() {
|
31
31
|
}
|
32
32
|
|
33
|
-
|
34
|
-
static dfa::Vocabulary vocabulary = dfa::Vocabulary::fromTokenNames(getTokenNames());
|
35
|
-
return vocabulary;
|
36
|
-
}
|
37
|
-
|
38
|
-
std::map<std::string, size_t> Recognizer::getTokenTypeMap() {
|
33
|
+
std::map<std::string_view, size_t> Recognizer::getTokenTypeMap() {
|
39
34
|
const dfa::Vocabulary& vocabulary = getVocabulary();
|
40
35
|
|
41
36
|
std::lock_guard<std::mutex> lck(_mutex);
|
42
|
-
std::map<std::
|
37
|
+
std::map<std::string_view, size_t> result;
|
43
38
|
auto iterator = _tokenTypeMapCache.find(&vocabulary);
|
44
39
|
if (iterator != _tokenTypeMapCache.end()) {
|
45
40
|
result = iterator->second;
|
46
41
|
} else {
|
47
42
|
for (size_t i = 0; i <= getATN().maxTokenType; ++i) {
|
48
|
-
std::
|
43
|
+
std::string_view literalName = vocabulary.getLiteralName(i);
|
49
44
|
if (!literalName.empty()) {
|
50
45
|
result[literalName] = i;
|
51
46
|
}
|
52
47
|
|
53
|
-
std::
|
48
|
+
std::string_view symbolicName = vocabulary.getSymbolicName(i);
|
54
49
|
if (!symbolicName.empty()) {
|
55
50
|
result[symbolicName] = i;
|
56
51
|
}
|
57
|
-
|
52
|
+
}
|
58
53
|
result["EOF"] = EOF;
|
59
54
|
_tokenTypeMapCache[&vocabulary] = result;
|
60
55
|
}
|
@@ -80,8 +75,8 @@ std::map<std::string, size_t> Recognizer::getRuleIndexMap() {
|
|
80
75
|
return result;
|
81
76
|
}
|
82
77
|
|
83
|
-
size_t Recognizer::getTokenType(
|
84
|
-
const std::map<std::
|
78
|
+
size_t Recognizer::getTokenType(std::string_view tokenName) {
|
79
|
+
const std::map<std::string_view, size_t> &map = getTokenTypeMap();
|
85
80
|
auto iterator = map.find(tokenName);
|
86
81
|
if (iterator == map.end())
|
87
82
|
return Token::INVALID_TYPE;
|
@@ -118,11 +113,13 @@ std::string Recognizer::getTokenErrorDisplay(Token *t) {
|
|
118
113
|
}
|
119
114
|
}
|
120
115
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
116
|
+
std::string result;
|
117
|
+
result.reserve(s.size() + 2);
|
118
|
+
result.push_back('\'');
|
119
|
+
antlrcpp::escapeWhitespace(result, s);
|
120
|
+
result.push_back('\'');
|
121
|
+
result.shrink_to_fit();
|
122
|
+
return result;
|
126
123
|
}
|
127
124
|
|
128
125
|
void Recognizer::addErrorListener(ANTLRErrorListener *listener) {
|
@@ -152,14 +149,6 @@ bool Recognizer::precpred(RuleContext * /*localctx*/, int /*precedence*/) {
|
|
152
149
|
void Recognizer::action(RuleContext * /*localctx*/, size_t /*ruleIndex*/, size_t /*actionIndex*/) {
|
153
150
|
}
|
154
151
|
|
155
|
-
size_t Recognizer::getState() const {
|
156
|
-
return _stateNumber;
|
157
|
-
}
|
158
|
-
|
159
|
-
void Recognizer::setState(size_t atnState) {
|
160
|
-
_stateNumber = atnState;
|
161
|
-
}
|
162
|
-
|
163
152
|
void Recognizer::InitializeInstanceFields() {
|
164
153
|
_stateNumber = ATNState::INVALID_STATE_NUMBER;
|
165
154
|
_interpreter = nullptr;
|