expressir 1.2.3 → 1.2.6
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 +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +223 -31
- data/.gitignore +7 -1
- 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 +11 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -9
- 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 +19 -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 +51 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +1 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +9 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +43 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +16 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +1 -1
- 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 +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +2 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +9 -9
- 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/ListTokenSource.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +51 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +1 -7
- 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 +20 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +21 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +4 -4
- 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 +12 -17
- 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 +7 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +4 -2
- 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 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -58
- 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 +6 -57
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +35 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +29 -36
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +36 -27
- 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 -464
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -62
- 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 +42 -36
- 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 -108
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +10 -43
- 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 +17 -28
- 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 +169 -152
- 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 +87 -116
- 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 +11 -23
- 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 +2 -9
- 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 +15 -28
- 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 +35 -9
- 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.cpp +2 -2
- 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 +13 -54
- 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 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -40
- 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 +14 -5
- 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 +30 -6
- 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/Trees.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +1 -1
- 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/XPath.cpp +1 -1
- 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/src/tree/xpath/XPathRuleElement.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +1 -1
- 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 +165 -101
- data/ext/express-parser/extconf.rb +14 -14
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +17 -15
- data/lib/expressir/express/visitor.rb +7 -3
- 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 +79 -91
- 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
@@ -13,13 +13,16 @@ namespace atn {
|
|
13
13
|
/// TODO: make all transitions sets? no, should remove set edges.
|
14
14
|
class ANTLR4CPP_PUBLIC AtomTransition final : public Transition {
|
15
15
|
public:
|
16
|
+
static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::ATOM; }
|
17
|
+
|
18
|
+
static bool is(const Transition *transition) { return transition != nullptr && is(*transition); }
|
19
|
+
|
16
20
|
/// The token type or character value; or, signifies special label.
|
21
|
+
/// TODO: rename this to label
|
17
22
|
const size_t _label;
|
18
23
|
|
19
24
|
AtomTransition(ATNState *target, size_t label);
|
20
25
|
|
21
|
-
virtual SerializationType getSerializationType() const override;
|
22
|
-
|
23
26
|
virtual misc::IntervalSet label() const override;
|
24
27
|
virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override;
|
25
28
|
|
@@ -12,10 +12,12 @@ namespace antlr4 {
|
|
12
12
|
namespace atn {
|
13
13
|
|
14
14
|
class ANTLR4CPP_PUBLIC BasicBlockStartState final : public BlockStartState {
|
15
|
-
|
16
15
|
public:
|
17
|
-
|
16
|
+
static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BLOCK_START; }
|
17
|
+
|
18
|
+
static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
|
18
19
|
|
20
|
+
BasicBlockStartState() : BlockStartState(ATNStateType::BLOCK_START) {}
|
19
21
|
};
|
20
22
|
|
21
23
|
} // namespace atn
|
@@ -11,10 +11,12 @@ namespace antlr4 {
|
|
11
11
|
namespace atn {
|
12
12
|
|
13
13
|
class ANTLR4CPP_PUBLIC BasicState final : public ATNState {
|
14
|
-
|
15
14
|
public:
|
16
|
-
|
15
|
+
static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BASIC; }
|
16
|
+
|
17
|
+
static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
|
17
18
|
|
19
|
+
BasicState() : ATNState(ATNStateType::BASIC) {}
|
18
20
|
};
|
19
21
|
|
20
22
|
} // namespace atn
|
@@ -13,11 +13,13 @@ namespace atn {
|
|
13
13
|
/// Terminal node of a simple {@code (a|b|c)} block.
|
14
14
|
class ANTLR4CPP_PUBLIC BlockEndState final : public ATNState {
|
15
15
|
public:
|
16
|
-
|
16
|
+
static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BLOCK_END; }
|
17
|
+
|
18
|
+
static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
|
17
19
|
|
18
|
-
|
20
|
+
BlockStartState *startState = nullptr;
|
19
21
|
|
20
|
-
|
22
|
+
BlockEndState() : ATNState(ATNStateType::BLOCK_END) {}
|
21
23
|
};
|
22
24
|
|
23
25
|
} // namespace atn
|
@@ -13,8 +13,17 @@ namespace atn {
|
|
13
13
|
/// The start of a regular {@code (...)} block.
|
14
14
|
class ANTLR4CPP_PUBLIC BlockStartState : public DecisionState {
|
15
15
|
public:
|
16
|
-
|
16
|
+
static bool is(const ATNState &atnState) {
|
17
|
+
const auto stateType = atnState.getStateType();
|
18
|
+
return stateType >= ATNStateType::BLOCK_START && stateType <= ATNStateType::STAR_BLOCK_START;
|
19
|
+
}
|
20
|
+
|
21
|
+
static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
|
22
|
+
|
17
23
|
BlockEndState *endState = nullptr;
|
24
|
+
|
25
|
+
protected:
|
26
|
+
using DecisionState::DecisionState;
|
18
27
|
};
|
19
28
|
|
20
29
|
} // namespace atn
|
@@ -218,7 +218,7 @@ namespace atn {
|
|
218
218
|
/// statistics for a particular decision.
|
219
219
|
/// </summary>
|
220
220
|
/// <param name="decision"> The decision number </param>
|
221
|
-
DecisionInfo(size_t decision);
|
221
|
+
explicit DecisionInfo(size_t decision);
|
222
222
|
|
223
223
|
std::string toString() const;
|
224
224
|
};
|
@@ -12,18 +12,22 @@ namespace atn {
|
|
12
12
|
|
13
13
|
class ANTLR4CPP_PUBLIC DecisionState : public ATNState {
|
14
14
|
public:
|
15
|
-
|
16
|
-
|
15
|
+
static bool is(const ATNState &atnState) {
|
16
|
+
const auto stateType = atnState.getStateType();
|
17
|
+
return (stateType >= ATNStateType::BLOCK_START && stateType <= ATNStateType::TOKEN_START) ||
|
18
|
+
stateType == ATNStateType::PLUS_LOOP_BACK ||
|
19
|
+
stateType == ATNStateType::STAR_LOOP_ENTRY;
|
20
|
+
}
|
17
21
|
|
18
|
-
|
19
|
-
void InitializeInstanceFields();
|
22
|
+
static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); }
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
InitializeInstanceFields();
|
24
|
-
}
|
24
|
+
int decision = -1;
|
25
|
+
bool nonGreedy = false;
|
25
26
|
|
26
27
|
virtual std::string toString() const override;
|
28
|
+
|
29
|
+
protected:
|
30
|
+
using ATNState::ATNState;
|
27
31
|
};
|
28
32
|
|
29
33
|
} // namespace atn
|
@@ -11,17 +11,13 @@ EpsilonTransition::EpsilonTransition(ATNState *target) : EpsilonTransition(targe
|
|
11
11
|
}
|
12
12
|
|
13
13
|
EpsilonTransition::EpsilonTransition(ATNState *target, size_t outermostPrecedenceReturn)
|
14
|
-
: Transition(target), _outermostPrecedenceReturn(outermostPrecedenceReturn) {
|
14
|
+
: Transition(TransitionType::EPSILON, target), _outermostPrecedenceReturn(outermostPrecedenceReturn) {
|
15
15
|
}
|
16
16
|
|
17
|
-
size_t EpsilonTransition::outermostPrecedenceReturn() {
|
17
|
+
size_t EpsilonTransition::outermostPrecedenceReturn() const {
|
18
18
|
return _outermostPrecedenceReturn;
|
19
19
|
}
|
20
20
|
|
21
|
-
Transition::SerializationType EpsilonTransition::getSerializationType() const {
|
22
|
-
return EPSILON;
|
23
|
-
}
|
24
|
-
|
25
21
|
bool EpsilonTransition::isEpsilon() const {
|
26
22
|
return true;
|
27
23
|
}
|
@@ -12,7 +12,11 @@ namespace atn {
|
|
12
12
|
|
13
13
|
class ANTLR4CPP_PUBLIC EpsilonTransition final : public Transition {
|
14
14
|
public:
|
15
|
-
|
15
|
+
static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::EPSILON; }
|
16
|
+
|
17
|
+
static bool is(const Transition *transition) { return transition != nullptr && is(*transition); }
|
18
|
+
|
19
|
+
explicit EpsilonTransition(ATNState *target);
|
16
20
|
EpsilonTransition(ATNState *target, size_t outermostPrecedenceReturn);
|
17
21
|
|
18
22
|
/**
|
@@ -23,8 +27,7 @@ namespace atn {
|
|
23
27
|
* @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet)
|
24
28
|
* @since 4.4.1
|
25
29
|
*/
|
26
|
-
size_t outermostPrecedenceReturn();
|
27
|
-
virtual SerializationType getSerializationType() const override;
|
30
|
+
size_t outermostPrecedenceReturn() const;
|
28
31
|
|
29
32
|
virtual bool isEpsilon() const override;
|
30
33
|
virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override;
|
@@ -7,12 +7,10 @@
|
|
7
7
|
#include "atn/Transition.h"
|
8
8
|
#include "atn/RuleTransition.h"
|
9
9
|
#include "atn/SingletonPredictionContext.h"
|
10
|
-
#include "atn/AbstractPredicateTransition.h"
|
11
10
|
#include "atn/WildcardTransition.h"
|
12
11
|
#include "atn/NotSetTransition.h"
|
13
12
|
#include "misc/IntervalSet.h"
|
14
13
|
#include "atn/ATNConfig.h"
|
15
|
-
#include "atn/EmptyPredictionContext.h"
|
16
14
|
|
17
15
|
#include "support/CPPUtils.h"
|
18
16
|
|
@@ -22,10 +20,140 @@ using namespace antlr4;
|
|
22
20
|
using namespace antlr4::atn;
|
23
21
|
using namespace antlrcpp;
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
namespace {
|
24
|
+
|
25
|
+
struct ATNConfigHasher final {
|
26
|
+
size_t operator()(const ATNConfig& atn_config) const {
|
27
|
+
return atn_config.hashCode();
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
struct ATNConfigComparer final {
|
32
|
+
bool operator()(const ATNConfig& lhs, const ATNConfig& rhs) const {
|
33
|
+
return lhs == rhs;
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
class LL1AnalyzerImpl final {
|
38
|
+
public:
|
39
|
+
LL1AnalyzerImpl(const ATN& atn, misc::IntervalSet& look, bool seeThruPreds, bool addEOF) : _atn(atn), _look(look), _seeThruPreds(seeThruPreds), _addEOF(addEOF) {}
|
40
|
+
|
41
|
+
/// <summary>
|
42
|
+
/// Compute set of tokens that can follow {@code s} in the ATN in the
|
43
|
+
/// specified {@code ctx}.
|
44
|
+
/// <p/>
|
45
|
+
/// If {@code ctx} is {@code null} and {@code stopState} or the end of the
|
46
|
+
/// rule containing {@code s} is reached, <seealso cref="Token#EPSILON"/> is added to
|
47
|
+
/// the result set. If {@code ctx} is not {@code null} and {@code addEOF} is
|
48
|
+
/// {@code true} and {@code stopState} or the end of the outermost rule is
|
49
|
+
/// reached, <seealso cref="Token#EOF"/> is added to the result set.
|
50
|
+
/// </summary>
|
51
|
+
/// <param name="s"> the ATN state. </param>
|
52
|
+
/// <param name="stopState"> the ATN state to stop at. This can be a
|
53
|
+
/// <seealso cref="BlockEndState"/> to detect epsilon paths through a closure. </param>
|
54
|
+
/// <param name="ctx"> The outer context, or {@code null} if the outer context should
|
55
|
+
/// not be used. </param>
|
56
|
+
/// <param name="look"> The result lookahead set. </param>
|
57
|
+
/// <param name="lookBusy"> A set used for preventing epsilon closures in the ATN
|
58
|
+
/// from causing a stack overflow. Outside code should pass
|
59
|
+
/// {@code new HashSet<ATNConfig>} for this argument. </param>
|
60
|
+
/// <param name="calledRuleStack"> A set used for preventing left recursion in the
|
61
|
+
/// ATN from causing a stack overflow. Outside code should pass
|
62
|
+
/// {@code new BitSet()} for this argument. </param>
|
63
|
+
/// <param name="seeThruPreds"> {@code true} to true semantic predicates as
|
64
|
+
/// implicitly {@code true} and "see through them", otherwise {@code false}
|
65
|
+
/// to treat semantic predicates as opaque and add <seealso cref="#HIT_PRED"/> to the
|
66
|
+
/// result if one is encountered. </param>
|
67
|
+
/// <param name="addEOF"> Add <seealso cref="Token#EOF"/> to the result if the end of the
|
68
|
+
/// outermost context is reached. This parameter has no effect if {@code ctx}
|
69
|
+
/// is {@code null}. </param>
|
70
|
+
void LOOK(ATNState *s, ATNState *stopState, Ref<const PredictionContext> const& ctx) {
|
71
|
+
if (!_lookBusy.insert(ATNConfig(s, 0, ctx)).second) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
|
75
|
+
// ml: s can never be null, hence no need to check if stopState is != null.
|
76
|
+
if (s == stopState) {
|
77
|
+
if (ctx == nullptr) {
|
78
|
+
_look.add(Token::EPSILON);
|
79
|
+
return;
|
80
|
+
} else if (ctx->isEmpty() && _addEOF) {
|
81
|
+
_look.add(Token::EOF);
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
if (s->getStateType() == ATNStateType::RULE_STOP) {
|
87
|
+
if (ctx == nullptr) {
|
88
|
+
_look.add(Token::EPSILON);
|
89
|
+
return;
|
90
|
+
} else if (ctx->isEmpty() && _addEOF) {
|
91
|
+
_look.add(Token::EOF);
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
|
95
|
+
if (ctx != PredictionContext::EMPTY) {
|
96
|
+
bool removed = _calledRuleStack.test(s->ruleIndex);
|
97
|
+
_calledRuleStack[s->ruleIndex] = false;
|
98
|
+
// run thru all possible stack tops in ctx
|
99
|
+
for (size_t i = 0; i < ctx->size(); i++) {
|
100
|
+
ATNState *returnState = _atn.states[ctx->getReturnState(i)];
|
101
|
+
LOOK(returnState, stopState, ctx->getParent(i));
|
102
|
+
}
|
103
|
+
if (removed) {
|
104
|
+
_calledRuleStack.set(s->ruleIndex);
|
105
|
+
}
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
size_t n = s->transitions.size();
|
111
|
+
for (size_t i = 0; i < n; i++) {
|
112
|
+
const Transition *t = s->transitions[i].get();
|
113
|
+
const auto tType = t->getTransitionType();
|
114
|
+
|
115
|
+
if (tType == TransitionType::RULE) {
|
116
|
+
if (_calledRuleStack[(static_cast<const RuleTransition*>(t))->target->ruleIndex]) {
|
117
|
+
continue;
|
118
|
+
}
|
119
|
+
|
120
|
+
Ref<const PredictionContext> newContext = SingletonPredictionContext::create(ctx, (static_cast<const RuleTransition*>(t))->followState->stateNumber);
|
121
|
+
|
122
|
+
_calledRuleStack.set((static_cast<const RuleTransition*>(t))->target->ruleIndex);
|
123
|
+
LOOK(t->target, stopState, newContext);
|
124
|
+
_calledRuleStack[(static_cast<const RuleTransition*>(t))->target->ruleIndex] = false;
|
125
|
+
|
126
|
+
} else if (tType == TransitionType::PREDICATE || tType == TransitionType::PRECEDENCE) {
|
127
|
+
if (_seeThruPreds) {
|
128
|
+
LOOK(t->target, stopState, ctx);
|
129
|
+
} else {
|
130
|
+
_look.add(LL1Analyzer::HIT_PRED);
|
131
|
+
}
|
132
|
+
} else if (t->isEpsilon()) {
|
133
|
+
LOOK(t->target, stopState, ctx);
|
134
|
+
} else if (tType == TransitionType::WILDCARD) {
|
135
|
+
_look.addAll(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
|
136
|
+
} else {
|
137
|
+
misc::IntervalSet set = t->label();
|
138
|
+
if (!set.isEmpty()) {
|
139
|
+
if (tType == TransitionType::NOT_SET) {
|
140
|
+
set = set.complement(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
|
141
|
+
}
|
142
|
+
_look.addAll(set);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
private:
|
149
|
+
const ATN& _atn;
|
150
|
+
misc::IntervalSet& _look;
|
151
|
+
antlrcpp::BitSet _calledRuleStack;
|
152
|
+
std::unordered_set<ATNConfig, ATNConfigHasher, ATNConfigComparer> _lookBusy;
|
153
|
+
bool _seeThruPreds;
|
154
|
+
bool _addEOF;
|
155
|
+
};
|
27
156
|
|
28
|
-
LL1Analyzer::~LL1Analyzer() {
|
29
157
|
}
|
30
158
|
|
31
159
|
std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) const {
|
@@ -37,16 +165,11 @@ std::vector<misc::IntervalSet> LL1Analyzer::getDecisionLookahead(ATNState *s) co
|
|
37
165
|
|
38
166
|
look.resize(s->transitions.size()); // Fills all interval sets with defaults.
|
39
167
|
for (size_t alt = 0; alt < s->transitions.size(); alt++) {
|
40
|
-
|
41
|
-
|
42
|
-
ATNConfig::Set lookBusy;
|
43
|
-
antlrcpp::BitSet callRuleStack;
|
44
|
-
_LOOK(s->transitions[alt]->target, nullptr, PredictionContext::EMPTY,
|
45
|
-
look[alt], lookBusy, callRuleStack, seeThruPreds, false);
|
46
|
-
|
168
|
+
LL1AnalyzerImpl impl(_atn, look[alt], false, false);
|
169
|
+
impl.LOOK(s->transitions[alt]->target, nullptr, PredictionContext::EMPTY);
|
47
170
|
// Wipe out lookahead for this alternative if we found nothing
|
48
171
|
// or we had a predicate when we !seeThruPreds
|
49
|
-
if (look[alt].size() == 0 || look[alt].contains(HIT_PRED)) {
|
172
|
+
if (look[alt].size() == 0 || look[alt].contains(LL1Analyzer::HIT_PRED)) {
|
50
173
|
look[alt].clear();
|
51
174
|
}
|
52
175
|
}
|
@@ -58,101 +181,9 @@ misc::IntervalSet LL1Analyzer::LOOK(ATNState *s, RuleContext *ctx) const {
|
|
58
181
|
}
|
59
182
|
|
60
183
|
misc::IntervalSet LL1Analyzer::LOOK(ATNState *s, ATNState *stopState, RuleContext *ctx) const {
|
184
|
+
Ref<const PredictionContext> lookContext = ctx != nullptr ? PredictionContext::fromRuleContext(_atn, ctx) : nullptr;
|
61
185
|
misc::IntervalSet r;
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
ATNConfig::Set lookBusy;
|
66
|
-
antlrcpp::BitSet callRuleStack;
|
67
|
-
_LOOK(s, stopState, lookContext, r, lookBusy, callRuleStack, seeThruPreds, true);
|
68
|
-
|
186
|
+
LL1AnalyzerImpl impl(_atn, r, true, true);
|
187
|
+
impl.LOOK(s, stopState, lookContext);
|
69
188
|
return r;
|
70
189
|
}
|
71
|
-
|
72
|
-
void LL1Analyzer::_LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext> const& ctx, misc::IntervalSet &look,
|
73
|
-
ATNConfig::Set &lookBusy, antlrcpp::BitSet &calledRuleStack, bool seeThruPreds, bool addEOF) const {
|
74
|
-
|
75
|
-
Ref<ATNConfig> c = std::make_shared<ATNConfig>(s, 0, ctx);
|
76
|
-
|
77
|
-
if (lookBusy.count(c) > 0) // Keep in mind comparison is based on members of the class, not the actual instance.
|
78
|
-
return;
|
79
|
-
|
80
|
-
lookBusy.insert(c);
|
81
|
-
|
82
|
-
// ml: s can never be null, hence no need to check if stopState is != null.
|
83
|
-
if (s == stopState) {
|
84
|
-
if (ctx == nullptr) {
|
85
|
-
look.add(Token::EPSILON);
|
86
|
-
return;
|
87
|
-
} else if (ctx->isEmpty() && addEOF) {
|
88
|
-
look.add(Token::EOF);
|
89
|
-
return;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
if (s->getStateType() == ATNState::RULE_STOP) {
|
94
|
-
if (ctx == nullptr) {
|
95
|
-
look.add(Token::EPSILON);
|
96
|
-
return;
|
97
|
-
} else if (ctx->isEmpty() && addEOF) {
|
98
|
-
look.add(Token::EOF);
|
99
|
-
return;
|
100
|
-
}
|
101
|
-
|
102
|
-
if (ctx != PredictionContext::EMPTY) {
|
103
|
-
// run thru all possible stack tops in ctx
|
104
|
-
for (size_t i = 0; i < ctx->size(); i++) {
|
105
|
-
ATNState *returnState = _atn.states[ctx->getReturnState(i)];
|
106
|
-
|
107
|
-
bool removed = calledRuleStack.test(returnState->ruleIndex);
|
108
|
-
auto onExit = finally([removed, &calledRuleStack, returnState] {
|
109
|
-
if (removed) {
|
110
|
-
calledRuleStack.set(returnState->ruleIndex);
|
111
|
-
}
|
112
|
-
});
|
113
|
-
|
114
|
-
calledRuleStack[returnState->ruleIndex] = false;
|
115
|
-
_LOOK(returnState, stopState, ctx->getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
|
116
|
-
}
|
117
|
-
return;
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
size_t n = s->transitions.size();
|
122
|
-
for (size_t i = 0; i < n; i++) {
|
123
|
-
Transition *t = s->transitions[i];
|
124
|
-
|
125
|
-
if (t->getSerializationType() == Transition::RULE) {
|
126
|
-
if (calledRuleStack[(static_cast<RuleTransition*>(t))->target->ruleIndex]) {
|
127
|
-
continue;
|
128
|
-
}
|
129
|
-
|
130
|
-
Ref<PredictionContext> newContext = SingletonPredictionContext::create(ctx, (static_cast<RuleTransition*>(t))->followState->stateNumber);
|
131
|
-
auto onExit = finally([t, &calledRuleStack] {
|
132
|
-
calledRuleStack[(static_cast<RuleTransition*>(t))->target->ruleIndex] = false;
|
133
|
-
});
|
134
|
-
|
135
|
-
calledRuleStack.set((static_cast<RuleTransition*>(t))->target->ruleIndex);
|
136
|
-
_LOOK(t->target, stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
|
137
|
-
|
138
|
-
} else if (is<AbstractPredicateTransition *>(t)) {
|
139
|
-
if (seeThruPreds) {
|
140
|
-
_LOOK(t->target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
|
141
|
-
} else {
|
142
|
-
look.add(HIT_PRED);
|
143
|
-
}
|
144
|
-
} else if (t->isEpsilon()) {
|
145
|
-
_LOOK(t->target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
|
146
|
-
} else if (t->getSerializationType() == Transition::WILDCARD) {
|
147
|
-
look.addAll(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
|
148
|
-
} else {
|
149
|
-
misc::IntervalSet set = t->label();
|
150
|
-
if (!set.isEmpty()) {
|
151
|
-
if (is<NotSetTransition*>(t)) {
|
152
|
-
set = set.complement(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
|
153
|
-
}
|
154
|
-
look.addAll(set);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
}
|
158
|
-
}
|
@@ -6,23 +6,20 @@
|
|
6
6
|
#pragma once
|
7
7
|
|
8
8
|
#include "Token.h"
|
9
|
-
#include "support/BitSet.h"
|
10
|
-
#include "atn/PredictionContext.h"
|
11
9
|
#include "atn/ATNConfig.h"
|
10
|
+
#include "atn/PredictionContext.h"
|
11
|
+
#include "support/BitSet.h"
|
12
12
|
|
13
13
|
namespace antlr4 {
|
14
14
|
namespace atn {
|
15
15
|
|
16
|
-
class ANTLR4CPP_PUBLIC LL1Analyzer {
|
16
|
+
class ANTLR4CPP_PUBLIC LL1Analyzer final {
|
17
17
|
public:
|
18
18
|
/// Special value added to the lookahead sets to indicate that we hit
|
19
19
|
/// a predicate during analysis if {@code seeThruPreds==false}.
|
20
|
-
static
|
20
|
+
static constexpr size_t HIT_PRED = Token::INVALID_TYPE;
|
21
21
|
|
22
|
-
const atn::ATN &_atn
|
23
|
-
|
24
|
-
LL1Analyzer(const atn::ATN &atn);
|
25
|
-
virtual ~LL1Analyzer();
|
22
|
+
explicit LL1Analyzer(const atn::ATN &atn) : _atn(atn) {}
|
26
23
|
|
27
24
|
/// <summary>
|
28
25
|
/// Calculates the SLL(1) expected lookahead set for each outgoing transition
|
@@ -33,7 +30,7 @@ namespace atn {
|
|
33
30
|
/// </summary>
|
34
31
|
/// <param name="s"> the ATN state </param>
|
35
32
|
/// <returns> the expected symbols for each outgoing transition of {@code s}. </returns>
|
36
|
-
|
33
|
+
std::vector<misc::IntervalSet> getDecisionLookahead(ATNState *s) const;
|
37
34
|
|
38
35
|
/// <summary>
|
39
36
|
/// Compute set of tokens that can follow {@code s} in the ATN in the
|
@@ -50,7 +47,7 @@ namespace atn {
|
|
50
47
|
/// </param>
|
51
48
|
/// <returns> The set of tokens that can follow {@code s} in the ATN in the
|
52
49
|
/// specified {@code ctx}. </returns>
|
53
|
-
|
50
|
+
misc::IntervalSet LOOK(ATNState *s, RuleContext *ctx) const;
|
54
51
|
|
55
52
|
/// <summary>
|
56
53
|
/// Compute set of tokens that can follow {@code s} in the ATN in the
|
@@ -69,40 +66,10 @@ namespace atn {
|
|
69
66
|
/// </param>
|
70
67
|
/// <returns> The set of tokens that can follow {@code s} in the ATN in the
|
71
68
|
/// specified {@code ctx}. </returns>
|
72
|
-
|
69
|
+
misc::IntervalSet LOOK(ATNState *s, ATNState *stopState, RuleContext *ctx) const;
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
/// specified {@code ctx}.
|
77
|
-
/// <p/>
|
78
|
-
/// If {@code ctx} is {@code null} and {@code stopState} or the end of the
|
79
|
-
/// rule containing {@code s} is reached, <seealso cref="Token#EPSILON"/> is added to
|
80
|
-
/// the result set. If {@code ctx} is not {@code null} and {@code addEOF} is
|
81
|
-
/// {@code true} and {@code stopState} or the end of the outermost rule is
|
82
|
-
/// reached, <seealso cref="Token#EOF"/> is added to the result set.
|
83
|
-
/// </summary>
|
84
|
-
/// <param name="s"> the ATN state. </param>
|
85
|
-
/// <param name="stopState"> the ATN state to stop at. This can be a
|
86
|
-
/// <seealso cref="BlockEndState"/> to detect epsilon paths through a closure. </param>
|
87
|
-
/// <param name="ctx"> The outer context, or {@code null} if the outer context should
|
88
|
-
/// not be used. </param>
|
89
|
-
/// <param name="look"> The result lookahead set. </param>
|
90
|
-
/// <param name="lookBusy"> A set used for preventing epsilon closures in the ATN
|
91
|
-
/// from causing a stack overflow. Outside code should pass
|
92
|
-
/// {@code new HashSet<ATNConfig>} for this argument. </param>
|
93
|
-
/// <param name="calledRuleStack"> A set used for preventing left recursion in the
|
94
|
-
/// ATN from causing a stack overflow. Outside code should pass
|
95
|
-
/// {@code new BitSet()} for this argument. </param>
|
96
|
-
/// <param name="seeThruPreds"> {@code true} to true semantic predicates as
|
97
|
-
/// implicitly {@code true} and "see through them", otherwise {@code false}
|
98
|
-
/// to treat semantic predicates as opaque and add <seealso cref="#HIT_PRED"/> to the
|
99
|
-
/// result if one is encountered. </param>
|
100
|
-
/// <param name="addEOF"> Add <seealso cref="Token#EOF"/> to the result if the end of the
|
101
|
-
/// outermost context is reached. This parameter has no effect if {@code ctx}
|
102
|
-
/// is {@code null}. </param>
|
103
|
-
protected:
|
104
|
-
virtual void _LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext> const& ctx, misc::IntervalSet &look,
|
105
|
-
ATNConfig::Set &lookBusy, antlrcpp::BitSet &calledRuleStack, bool seeThruPreds, bool addEOF) const;
|
71
|
+
private:
|
72
|
+
const atn::ATN &_atn;
|
106
73
|
};
|
107
74
|
|
108
75
|
} // namespace atn
|
@@ -10,44 +10,27 @@
|
|
10
10
|
#include "atn/LexerActionExecutor.h"
|
11
11
|
|
12
12
|
#include "support/CPPUtils.h"
|
13
|
+
#include "support/Casts.h"
|
13
14
|
|
14
15
|
#include "atn/LexerATNConfig.h"
|
15
16
|
|
16
17
|
using namespace antlr4::atn;
|
17
18
|
using namespace antlrcpp;
|
18
19
|
|
19
|
-
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext>
|
20
|
-
|
21
|
-
}
|
20
|
+
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<const PredictionContext> context)
|
21
|
+
: ATNConfig(state, alt, std::move(context)) {}
|
22
22
|
|
23
|
-
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> const
|
24
|
-
|
25
|
-
: ATNConfig(state, alt, context, SemanticContext::NONE), _lexerActionExecutor(lexerActionExecutor),
|
26
|
-
_passedThroughNonGreedyDecision(false) {
|
27
|
-
}
|
23
|
+
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<const PredictionContext> context, Ref<const LexerActionExecutor> lexerActionExecutor)
|
24
|
+
: ATNConfig(state, alt, std::move(context)), _lexerActionExecutor(std::move(lexerActionExecutor)) {}
|
28
25
|
|
29
|
-
LexerATNConfig::LexerATNConfig(
|
30
|
-
|
31
|
-
_passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
|
32
|
-
}
|
26
|
+
LexerATNConfig::LexerATNConfig(LexerATNConfig const& other, ATNState *state)
|
27
|
+
: ATNConfig(other, state), _lexerActionExecutor(other._lexerActionExecutor), _passedThroughNonGreedyDecision(checkNonGreedyDecision(other, state)) {}
|
33
28
|
|
34
|
-
LexerATNConfig::LexerATNConfig(
|
35
|
-
|
36
|
-
_passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
|
37
|
-
}
|
29
|
+
LexerATNConfig::LexerATNConfig(LexerATNConfig const& other, ATNState *state, Ref<const LexerActionExecutor> lexerActionExecutor)
|
30
|
+
: ATNConfig(other, state), _lexerActionExecutor(std::move(lexerActionExecutor)), _passedThroughNonGreedyDecision(checkNonGreedyDecision(other, state)) {}
|
38
31
|
|
39
|
-
LexerATNConfig::LexerATNConfig(
|
40
|
-
|
41
|
-
_passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
|
42
|
-
}
|
43
|
-
|
44
|
-
Ref<LexerActionExecutor> LexerATNConfig::getLexerActionExecutor() const {
|
45
|
-
return _lexerActionExecutor;
|
46
|
-
}
|
47
|
-
|
48
|
-
bool LexerATNConfig::hasPassedThroughNonGreedyDecision() {
|
49
|
-
return _passedThroughNonGreedyDecision;
|
50
|
-
}
|
32
|
+
LexerATNConfig::LexerATNConfig(LexerATNConfig const& other, ATNState *state, Ref<const PredictionContext> context)
|
33
|
+
: ATNConfig(other, state, std::move(context)), _lexerActionExecutor(other._lexerActionExecutor), _passedThroughNonGreedyDecision(checkNonGreedyDecision(other, state)) {}
|
51
34
|
|
52
35
|
size_t LexerATNConfig::hashCode() const {
|
53
36
|
size_t hashCode = misc::MurmurHash::initialize(7);
|
@@ -61,7 +44,7 @@ size_t LexerATNConfig::hashCode() const {
|
|
61
44
|
return hashCode;
|
62
45
|
}
|
63
46
|
|
64
|
-
bool LexerATNConfig::operator
|
47
|
+
bool LexerATNConfig::operator==(const LexerATNConfig& other) const
|
65
48
|
{
|
66
49
|
if (this == &other)
|
67
50
|
return true;
|
@@ -75,10 +58,10 @@ bool LexerATNConfig::operator == (const LexerATNConfig& other) const
|
|
75
58
|
return false;
|
76
59
|
}
|
77
60
|
|
78
|
-
return ATNConfig::operator
|
61
|
+
return ATNConfig::operator==(other);
|
79
62
|
}
|
80
63
|
|
81
|
-
bool LexerATNConfig::checkNonGreedyDecision(
|
82
|
-
return source
|
83
|
-
(is
|
64
|
+
bool LexerATNConfig::checkNonGreedyDecision(LexerATNConfig const& source, ATNState *target) {
|
65
|
+
return source._passedThroughNonGreedyDecision ||
|
66
|
+
(DecisionState::is(target) && downCast<DecisionState*>(target)->nonGreedy);
|
84
67
|
}
|