expressir 1.2.3 → 1.2.6
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 +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
@@ -10,34 +10,34 @@
|
|
10
10
|
namespace antlr4 {
|
11
11
|
namespace atn {
|
12
12
|
|
13
|
-
class ANTLR4CPP_PUBLIC LexerATNConfig : public ATNConfig {
|
13
|
+
class ANTLR4CPP_PUBLIC LexerATNConfig final : public ATNConfig {
|
14
14
|
public:
|
15
|
-
LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext>
|
16
|
-
LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext>
|
15
|
+
LexerATNConfig(ATNState *state, int alt, Ref<const PredictionContext> context);
|
16
|
+
LexerATNConfig(ATNState *state, int alt, Ref<const PredictionContext> context, Ref<const LexerActionExecutor> lexerActionExecutor);
|
17
17
|
|
18
|
-
LexerATNConfig(
|
19
|
-
LexerATNConfig(
|
20
|
-
LexerATNConfig(
|
18
|
+
LexerATNConfig(LexerATNConfig const& other, ATNState *state);
|
19
|
+
LexerATNConfig(LexerATNConfig const& other, ATNState *state, Ref<const LexerActionExecutor> lexerActionExecutor);
|
20
|
+
LexerATNConfig(LexerATNConfig const& other, ATNState *state, Ref<const PredictionContext> context);
|
21
21
|
|
22
22
|
/**
|
23
23
|
* Gets the {@link LexerActionExecutor} capable of executing the embedded
|
24
24
|
* action(s) for the current configuration.
|
25
25
|
*/
|
26
|
-
Ref<LexerActionExecutor
|
27
|
-
bool hasPassedThroughNonGreedyDecision();
|
26
|
+
const Ref<const LexerActionExecutor>& getLexerActionExecutor() const { return _lexerActionExecutor; }
|
27
|
+
bool hasPassedThroughNonGreedyDecision() const { return _passedThroughNonGreedyDecision; }
|
28
28
|
|
29
29
|
virtual size_t hashCode() const override;
|
30
30
|
|
31
|
-
bool operator
|
31
|
+
bool operator==(const LexerATNConfig& other) const;
|
32
32
|
|
33
33
|
private:
|
34
34
|
/**
|
35
35
|
* This is the backing field for {@link #getLexerActionExecutor}.
|
36
36
|
*/
|
37
|
-
const Ref<LexerActionExecutor> _lexerActionExecutor;
|
38
|
-
const bool _passedThroughNonGreedyDecision;
|
37
|
+
const Ref<const LexerActionExecutor> _lexerActionExecutor;
|
38
|
+
const bool _passedThroughNonGreedyDecision = false;
|
39
39
|
|
40
|
-
static bool checkNonGreedyDecision(
|
40
|
+
static bool checkNonGreedyDecision(LexerATNConfig const& source, ATNState *target);
|
41
41
|
};
|
42
42
|
|
43
43
|
} // namespace atn
|
@@ -20,7 +20,6 @@
|
|
20
20
|
#include "dfa/DFAState.h"
|
21
21
|
#include "atn/LexerATNConfig.h"
|
22
22
|
#include "atn/LexerActionExecutor.h"
|
23
|
-
#include "atn/EmptyPredictionContext.h"
|
24
23
|
|
25
24
|
#include "atn/LexerATNSimulator.h"
|
26
25
|
|
@@ -31,25 +30,10 @@ using namespace antlr4;
|
|
31
30
|
using namespace antlr4::atn;
|
32
31
|
using namespace antlrcpp;
|
33
32
|
|
34
|
-
LexerATNSimulator::SimState::~SimState() {
|
35
|
-
}
|
36
|
-
|
37
33
|
void LexerATNSimulator::SimState::reset() {
|
38
|
-
|
39
|
-
line = 0;
|
40
|
-
charPos = INVALID_INDEX;
|
41
|
-
dfaState = nullptr; // Don't delete. It's just a reference.
|
42
|
-
}
|
43
|
-
|
44
|
-
void LexerATNSimulator::SimState::InitializeInstanceFields() {
|
45
|
-
index = INVALID_INDEX;
|
46
|
-
line = 0;
|
47
|
-
charPos = INVALID_INDEX;
|
34
|
+
*this = SimState();
|
48
35
|
}
|
49
36
|
|
50
|
-
int LexerATNSimulator::match_calls = 0;
|
51
|
-
|
52
|
-
|
53
37
|
LexerATNSimulator::LexerATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
|
54
38
|
PredictionContextCache &sharedContextCache)
|
55
39
|
: LexerATNSimulator(nullptr, atn, decisionToDFA, sharedContextCache) {
|
@@ -69,7 +53,6 @@ void LexerATNSimulator::copyState(LexerATNSimulator *simulator) {
|
|
69
53
|
}
|
70
54
|
|
71
55
|
size_t LexerATNSimulator::match(CharStream *input, size_t mode) {
|
72
|
-
match_calls++;
|
73
56
|
_mode = mode;
|
74
57
|
ssize_t mark = input->mark();
|
75
58
|
|
@@ -80,10 +63,15 @@ size_t LexerATNSimulator::match(CharStream *input, size_t mode) {
|
|
80
63
|
_startIndex = input->index();
|
81
64
|
_prevAccept.reset();
|
82
65
|
const dfa::DFA &dfa = _decisionToDFA[mode];
|
83
|
-
|
66
|
+
dfa::DFAState* s0;
|
67
|
+
{
|
68
|
+
std::shared_lock<std::shared_mutex> stateLock(atn._stateMutex);
|
69
|
+
s0 = dfa.s0;
|
70
|
+
}
|
71
|
+
if (s0 == nullptr) {
|
84
72
|
return matchATN(input);
|
85
73
|
} else {
|
86
|
-
return execATN(input,
|
74
|
+
return execATN(input, s0);
|
87
75
|
}
|
88
76
|
}
|
89
77
|
|
@@ -111,10 +99,7 @@ size_t LexerATNSimulator::matchATN(CharStream *input) {
|
|
111
99
|
bool suppressEdge = s0_closure->hasSemanticContext;
|
112
100
|
s0_closure->hasSemanticContext = false;
|
113
101
|
|
114
|
-
dfa::DFAState *next = addDFAState(s0_closure.release());
|
115
|
-
if (!suppressEdge) {
|
116
|
-
_decisionToDFA[_mode].s0 = next;
|
117
|
-
}
|
102
|
+
dfa::DFAState *next = addDFAState(s0_closure.release(), suppressEdge);
|
118
103
|
|
119
104
|
size_t predict = execATN(input, next);
|
120
105
|
|
@@ -182,7 +167,7 @@ size_t LexerATNSimulator::execATN(CharStream *input, dfa::DFAState *ds0) {
|
|
182
167
|
|
183
168
|
dfa::DFAState *LexerATNSimulator::getExistingTargetState(dfa::DFAState *s, size_t t) {
|
184
169
|
dfa::DFAState* retval = nullptr;
|
185
|
-
|
170
|
+
std::shared_lock<std::shared_mutex> edgeLock(atn._edgeMutex);
|
186
171
|
if (t <= MAX_DFA_EDGE) {
|
187
172
|
auto iterator = s->edges.find(t - MIN_DFA_EDGE);
|
188
173
|
#if DEBUG_ATN == 1
|
@@ -194,7 +179,6 @@ dfa::DFAState *LexerATNSimulator::getExistingTargetState(dfa::DFAState *s, size_
|
|
194
179
|
if (iterator != s->edges.end())
|
195
180
|
retval = iterator->second;
|
196
181
|
}
|
197
|
-
_edgeLock.readUnlock();
|
198
182
|
return retval;
|
199
183
|
}
|
200
184
|
|
@@ -209,9 +193,9 @@ dfa::DFAState *LexerATNSimulator::computeTargetState(CharStream *input, dfa::DFA
|
|
209
193
|
if (!reach->hasSemanticContext) {
|
210
194
|
// we got nowhere on t, don't throw out this knowledge; it'd
|
211
195
|
// cause a failover from DFA later.
|
212
|
-
delete reach;
|
213
196
|
addDFAEdge(s, t, ERROR.get());
|
214
197
|
}
|
198
|
+
delete reach;
|
215
199
|
|
216
200
|
// stop when we can't match any more char
|
217
201
|
return ERROR.get();
|
@@ -223,8 +207,7 @@ dfa::DFAState *LexerATNSimulator::computeTargetState(CharStream *input, dfa::DFA
|
|
223
207
|
|
224
208
|
size_t LexerATNSimulator::failOrAccept(CharStream *input, ATNConfigSet *reach, size_t t) {
|
225
209
|
if (_prevAccept.dfaState != nullptr) {
|
226
|
-
|
227
|
-
accept(input, lexerActionExecutor, _startIndex, _prevAccept.index, _prevAccept.line, _prevAccept.charPos);
|
210
|
+
accept(input, _prevAccept.dfaState->lexerActionExecutor, _startIndex, _prevAccept.index, _prevAccept.line, _prevAccept.charPos);
|
228
211
|
return _prevAccept.dfaState->prediction;
|
229
212
|
} else {
|
230
213
|
// if no accept and EOF is first char, return EOF
|
@@ -241,7 +224,7 @@ void LexerATNSimulator::getReachableConfigSet(CharStream *input, ATNConfigSet *c
|
|
241
224
|
// than a config that already reached an accept state for the same rule
|
242
225
|
size_t skipAlt = ATN::INVALID_ALT_NUMBER;
|
243
226
|
|
244
|
-
for (auto c : closure_->configs) {
|
227
|
+
for (const auto &c : closure_->configs) {
|
245
228
|
bool currentAltReachedAcceptState = c->alt == skipAlt;
|
246
229
|
if (currentAltReachedAcceptState && (std::static_pointer_cast<LexerATNConfig>(c))->hasPassedThroughNonGreedyDecision()) {
|
247
230
|
continue;
|
@@ -253,17 +236,17 @@ void LexerATNSimulator::getReachableConfigSet(CharStream *input, ATNConfigSet *c
|
|
253
236
|
|
254
237
|
size_t n = c->state->transitions.size();
|
255
238
|
for (size_t ti = 0; ti < n; ti++) { // for each transition
|
256
|
-
Transition *trans = c->state->transitions[ti];
|
239
|
+
const Transition *trans = c->state->transitions[ti].get();
|
257
240
|
ATNState *target = getReachableTarget(trans, (int)t);
|
258
241
|
if (target != nullptr) {
|
259
|
-
|
242
|
+
auto lexerActionExecutor = downCast<const LexerATNConfig&>(*c).getLexerActionExecutor();
|
260
243
|
if (lexerActionExecutor != nullptr) {
|
261
244
|
lexerActionExecutor = lexerActionExecutor->fixOffsetBeforeMatch((int)input->index() - (int)_startIndex);
|
262
245
|
}
|
263
246
|
|
264
247
|
bool treatEofAsEpsilon = t == Token::EOF;
|
265
|
-
Ref<LexerATNConfig> config = std::make_shared<LexerATNConfig>(
|
266
|
-
target, lexerActionExecutor);
|
248
|
+
Ref<LexerATNConfig> config = std::make_shared<LexerATNConfig>(downCast<const LexerATNConfig&>(*c),
|
249
|
+
target, std::move(lexerActionExecutor));
|
267
250
|
|
268
251
|
if (closure(input, config, reach, currentAltReachedAcceptState, true, treatEofAsEpsilon)) {
|
269
252
|
// any remaining configs for this alt have a lower priority than
|
@@ -276,7 +259,7 @@ void LexerATNSimulator::getReachableConfigSet(CharStream *input, ATNConfigSet *c
|
|
276
259
|
}
|
277
260
|
}
|
278
261
|
|
279
|
-
void LexerATNSimulator::accept(CharStream *input, const Ref<LexerActionExecutor> &lexerActionExecutor, size_t /*startIndex*/,
|
262
|
+
void LexerATNSimulator::accept(CharStream *input, const Ref<const LexerActionExecutor> &lexerActionExecutor, size_t /*startIndex*/,
|
280
263
|
size_t index, size_t line, size_t charPos) {
|
281
264
|
#if DEBUG_ATN == 1
|
282
265
|
std::cout << "ACTION ";
|
@@ -293,7 +276,7 @@ void LexerATNSimulator::accept(CharStream *input, const Ref<LexerActionExecutor>
|
|
293
276
|
}
|
294
277
|
}
|
295
278
|
|
296
|
-
atn::ATNState *LexerATNSimulator::getReachableTarget(Transition *trans, size_t t) {
|
279
|
+
atn::ATNState *LexerATNSimulator::getReachableTarget(const Transition *trans, size_t t) {
|
297
280
|
if (trans->matches(t, Lexer::MIN_CHAR_VALUE, Lexer::MAX_CHAR_VALUE)) {
|
298
281
|
return trans->target;
|
299
282
|
}
|
@@ -302,7 +285,7 @@ atn::ATNState *LexerATNSimulator::getReachableTarget(Transition *trans, size_t t
|
|
302
285
|
}
|
303
286
|
|
304
287
|
std::unique_ptr<ATNConfigSet> LexerATNSimulator::computeStartState(CharStream *input, ATNState *p) {
|
305
|
-
Ref<PredictionContext> initialContext = PredictionContext::EMPTY; // ml: the purpose of this assignment is unclear
|
288
|
+
Ref<const PredictionContext> initialContext = PredictionContext::EMPTY; // ml: the purpose of this assignment is unclear
|
306
289
|
std::unique_ptr<ATNConfigSet> configs(new OrderedATNConfigSet());
|
307
290
|
for (size_t i = 0; i < p->transitions.size(); i++) {
|
308
291
|
ATNState *target = p->transitions[i]->target;
|
@@ -319,7 +302,7 @@ bool LexerATNSimulator::closure(CharStream *input, const Ref<LexerATNConfig> &co
|
|
319
302
|
std::cout << "closure(" << config->toString(true) << ")" << std::endl;
|
320
303
|
#endif
|
321
304
|
|
322
|
-
if (
|
305
|
+
if (config->state != nullptr && config->state->getStateType() == ATNStateType::RULE_STOP) {
|
323
306
|
#if DEBUG_ATN == 1
|
324
307
|
if (_recog != nullptr) {
|
325
308
|
std::cout << "closure at " << _recog->getRuleNames()[config->state->ruleIndex] << " rule stop " << config << std::endl;
|
@@ -333,7 +316,7 @@ bool LexerATNSimulator::closure(CharStream *input, const Ref<LexerATNConfig> &co
|
|
333
316
|
configs->add(config);
|
334
317
|
return true;
|
335
318
|
} else {
|
336
|
-
configs->add(std::make_shared<LexerATNConfig>(config, config->state, PredictionContext::EMPTY));
|
319
|
+
configs->add(std::make_shared<LexerATNConfig>(*config, config->state, PredictionContext::EMPTY));
|
337
320
|
currentAltReachedAcceptState = true;
|
338
321
|
}
|
339
322
|
}
|
@@ -341,9 +324,9 @@ bool LexerATNSimulator::closure(CharStream *input, const Ref<LexerATNConfig> &co
|
|
341
324
|
if (config->context != nullptr && !config->context->isEmpty()) {
|
342
325
|
for (size_t i = 0; i < config->context->size(); i++) {
|
343
326
|
if (config->context->getReturnState(i) != PredictionContext::EMPTY_RETURN_STATE) {
|
344
|
-
|
327
|
+
Ref<const PredictionContext> newContext = config->context->getParent(i); // "pop" return state
|
345
328
|
ATNState *returnState = atn.states[config->context->getReturnState(i)];
|
346
|
-
Ref<LexerATNConfig> c = std::make_shared<LexerATNConfig>(config, returnState, newContext
|
329
|
+
Ref<LexerATNConfig> c = std::make_shared<LexerATNConfig>(*config, returnState, newContext);
|
347
330
|
currentAltReachedAcceptState = closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
|
348
331
|
}
|
349
332
|
}
|
@@ -361,7 +344,7 @@ bool LexerATNSimulator::closure(CharStream *input, const Ref<LexerATNConfig> &co
|
|
361
344
|
|
362
345
|
ATNState *p = config->state;
|
363
346
|
for (size_t i = 0; i < p->transitions.size(); i++) {
|
364
|
-
Transition *t = p->transitions[i];
|
347
|
+
const Transition *t = p->transitions[i].get();
|
365
348
|
Ref<LexerATNConfig> c = getEpsilonTarget(input, config, t, configs, speculative, treatEofAsEpsilon);
|
366
349
|
if (c != nullptr) {
|
367
350
|
currentAltReachedAcceptState = closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
|
@@ -371,22 +354,22 @@ bool LexerATNSimulator::closure(CharStream *input, const Ref<LexerATNConfig> &co
|
|
371
354
|
return currentAltReachedAcceptState;
|
372
355
|
}
|
373
356
|
|
374
|
-
Ref<LexerATNConfig> LexerATNSimulator::getEpsilonTarget(CharStream *input, const Ref<LexerATNConfig> &config, Transition *t,
|
357
|
+
Ref<LexerATNConfig> LexerATNSimulator::getEpsilonTarget(CharStream *input, const Ref<LexerATNConfig> &config, const Transition *t,
|
375
358
|
ATNConfigSet *configs, bool speculative, bool treatEofAsEpsilon) {
|
376
359
|
|
377
360
|
Ref<LexerATNConfig> c = nullptr;
|
378
|
-
switch (t->
|
379
|
-
case
|
380
|
-
RuleTransition *ruleTransition = static_cast<RuleTransition*>(t);
|
381
|
-
Ref<PredictionContext> newContext = SingletonPredictionContext::create(config->context, ruleTransition->followState->stateNumber);
|
382
|
-
c = std::make_shared<LexerATNConfig>(config, t->target, newContext);
|
361
|
+
switch (t->getTransitionType()) {
|
362
|
+
case TransitionType::RULE: {
|
363
|
+
const RuleTransition *ruleTransition = static_cast<const RuleTransition*>(t);
|
364
|
+
Ref<const PredictionContext> newContext = SingletonPredictionContext::create(config->context, ruleTransition->followState->stateNumber);
|
365
|
+
c = std::make_shared<LexerATNConfig>(*config, t->target, newContext);
|
383
366
|
break;
|
384
367
|
}
|
385
368
|
|
386
|
-
case
|
369
|
+
case TransitionType::PRECEDENCE:
|
387
370
|
throw UnsupportedOperationException("Precedence predicates are not supported in lexers.");
|
388
371
|
|
389
|
-
case
|
372
|
+
case TransitionType::PREDICATE: {
|
390
373
|
/* Track traversing semantic predicates. If we traverse,
|
391
374
|
we cannot add a DFA state for this "reach" computation
|
392
375
|
because the DFA would not test the predicate again in the
|
@@ -405,20 +388,20 @@ Ref<LexerATNConfig> LexerATNSimulator::getEpsilonTarget(CharStream *input, const
|
|
405
388
|
states reached by traversing predicates. Since this is when we
|
406
389
|
test them, we cannot cash the DFA state target of ID.
|
407
390
|
*/
|
408
|
-
PredicateTransition *pt = static_cast<PredicateTransition*>(t);
|
391
|
+
const PredicateTransition *pt = static_cast<const PredicateTransition*>(t);
|
409
392
|
|
410
393
|
#if DEBUG_ATN == 1
|
411
|
-
std::cout << "EVAL rule " << pt->
|
394
|
+
std::cout << "EVAL rule " << pt->getRuleIndex() << ":" << pt->getPredIndex() << std::endl;
|
412
395
|
#endif
|
413
396
|
|
414
397
|
configs->hasSemanticContext = true;
|
415
|
-
if (evaluatePredicate(input, pt->
|
416
|
-
c = std::make_shared<LexerATNConfig>(config, t->target);
|
398
|
+
if (evaluatePredicate(input, pt->getRuleIndex(), pt->getPredIndex(), speculative)) {
|
399
|
+
c = std::make_shared<LexerATNConfig>(*config, t->target);
|
417
400
|
}
|
418
401
|
break;
|
419
402
|
}
|
420
403
|
|
421
|
-
case
|
404
|
+
case TransitionType::ACTION:
|
422
405
|
if (config->context == nullptr|| config->context->hasEmptyPath()) {
|
423
406
|
// execute actions anywhere in the start rule for a token.
|
424
407
|
//
|
@@ -432,27 +415,27 @@ Ref<LexerATNConfig> LexerATNSimulator::getEpsilonTarget(CharStream *input, const
|
|
432
415
|
// getEpsilonTarget to return two configurations, so
|
433
416
|
// additional modifications are needed before we can support
|
434
417
|
// the split operation.
|
435
|
-
|
436
|
-
atn.lexerActions[static_cast<ActionTransition *>(t)->actionIndex]);
|
437
|
-
c = std::make_shared<LexerATNConfig>(config, t->target, lexerActionExecutor);
|
418
|
+
auto lexerActionExecutor = LexerActionExecutor::append(config->getLexerActionExecutor(),
|
419
|
+
atn.lexerActions[static_cast<const ActionTransition *>(t)->actionIndex]);
|
420
|
+
c = std::make_shared<LexerATNConfig>(*config, t->target, std::move(lexerActionExecutor));
|
438
421
|
break;
|
439
422
|
}
|
440
423
|
else {
|
441
424
|
// ignore actions in referenced rules
|
442
|
-
c = std::make_shared<LexerATNConfig>(config, t->target);
|
425
|
+
c = std::make_shared<LexerATNConfig>(*config, t->target);
|
443
426
|
break;
|
444
427
|
}
|
445
428
|
|
446
|
-
case
|
447
|
-
c = std::make_shared<LexerATNConfig>(config, t->target);
|
429
|
+
case TransitionType::EPSILON:
|
430
|
+
c = std::make_shared<LexerATNConfig>(*config, t->target);
|
448
431
|
break;
|
449
432
|
|
450
|
-
case
|
451
|
-
case
|
452
|
-
case
|
433
|
+
case TransitionType::ATOM:
|
434
|
+
case TransitionType::RANGE:
|
435
|
+
case TransitionType::SET:
|
453
436
|
if (treatEofAsEpsilon) {
|
454
437
|
if (t->matches(Token::EOF, Lexer::MIN_CHAR_VALUE, Lexer::MAX_CHAR_VALUE)) {
|
455
|
-
c = std::make_shared<LexerATNConfig>(config, t->target);
|
438
|
+
c = std::make_shared<LexerATNConfig>(*config, t->target);
|
456
439
|
break;
|
457
440
|
}
|
458
441
|
}
|
@@ -530,12 +513,15 @@ void LexerATNSimulator::addDFAEdge(dfa::DFAState *p, size_t t, dfa::DFAState *q)
|
|
530
513
|
return;
|
531
514
|
}
|
532
515
|
|
533
|
-
|
516
|
+
std::unique_lock<std::shared_mutex> edgeLock(atn._edgeMutex);
|
534
517
|
p->edges[t - MIN_DFA_EDGE] = q; // connect
|
535
|
-
_edgeLock.writeUnlock();
|
536
518
|
}
|
537
519
|
|
538
520
|
dfa::DFAState *LexerATNSimulator::addDFAState(ATNConfigSet *configs) {
|
521
|
+
return addDFAState(configs, true);
|
522
|
+
}
|
523
|
+
|
524
|
+
dfa::DFAState *LexerATNSimulator::addDFAState(ATNConfigSet *configs, bool suppressEdge) {
|
539
525
|
/* the lexer evaluates predicates on-the-fly; by this point configs
|
540
526
|
* should not contain any configurations with unevaluated predicates.
|
541
527
|
*/
|
@@ -543,8 +529,8 @@ dfa::DFAState *LexerATNSimulator::addDFAState(ATNConfigSet *configs) {
|
|
543
529
|
|
544
530
|
dfa::DFAState *proposed = new dfa::DFAState(std::unique_ptr<ATNConfigSet>(configs)); /* mem-check: managed by the DFA or deleted below */
|
545
531
|
Ref<ATNConfig> firstConfigWithRuleStopState = nullptr;
|
546
|
-
for (auto &c : configs->configs) {
|
547
|
-
if (is
|
532
|
+
for (const auto &c : configs->configs) {
|
533
|
+
if (RuleStopState::is(c->state)) {
|
548
534
|
firstConfigWithRuleStopState = c;
|
549
535
|
break;
|
550
536
|
}
|
@@ -552,28 +538,29 @@ dfa::DFAState *LexerATNSimulator::addDFAState(ATNConfigSet *configs) {
|
|
552
538
|
|
553
539
|
if (firstConfigWithRuleStopState != nullptr) {
|
554
540
|
proposed->isAcceptState = true;
|
555
|
-
proposed->lexerActionExecutor =
|
541
|
+
proposed->lexerActionExecutor = downCast<const LexerATNConfig&>(*firstConfigWithRuleStopState).getLexerActionExecutor();
|
556
542
|
proposed->prediction = atn.ruleToTokenType[firstConfigWithRuleStopState->state->ruleIndex];
|
557
543
|
}
|
558
544
|
|
559
545
|
dfa::DFA &dfa = _decisionToDFA[_mode];
|
560
546
|
|
561
|
-
|
562
|
-
|
563
|
-
auto
|
564
|
-
if (
|
547
|
+
{
|
548
|
+
std::unique_lock<std::shared_mutex> stateLock(atn._stateMutex);
|
549
|
+
auto [existing, inserted] = dfa.states.insert(proposed);
|
550
|
+
if (!inserted) {
|
565
551
|
delete proposed;
|
566
|
-
|
567
|
-
|
552
|
+
proposed = *existing;
|
553
|
+
} else {
|
554
|
+
// Previously we did a lookup, then set fields, then inserted. It was `dfa.states.size()`,
|
555
|
+
// since we already inserted we need to subtract one.
|
556
|
+
proposed->stateNumber = static_cast<int>(dfa.states.size() - 1);
|
557
|
+
proposed->configs->setReadonly(true);
|
558
|
+
}
|
559
|
+
if (!suppressEdge) {
|
560
|
+
dfa.s0 = proposed;
|
568
561
|
}
|
569
562
|
}
|
570
563
|
|
571
|
-
proposed->stateNumber = (int)dfa.states.size();
|
572
|
-
proposed->configs->setReadonly(true);
|
573
|
-
|
574
|
-
dfa.states.insert(proposed);
|
575
|
-
_stateLock.writeUnlock();
|
576
|
-
|
577
564
|
return proposed;
|
578
565
|
}
|
579
566
|
|
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
#pragma once
|
7
7
|
|
8
|
+
#include <atomic>
|
9
|
+
|
8
10
|
#include "atn/ATNSimulator.h"
|
9
11
|
#include "atn/LexerATNConfig.h"
|
10
12
|
#include "atn/ATNConfigSet.h"
|
@@ -15,31 +17,18 @@ namespace atn {
|
|
15
17
|
/// "dup" of ParserInterpreter
|
16
18
|
class ANTLR4CPP_PUBLIC LexerATNSimulator : public ATNSimulator {
|
17
19
|
protected:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
size_t index;
|
24
|
-
size_t line;
|
25
|
-
size_t charPos;
|
26
|
-
dfa::DFAState *dfaState;
|
27
|
-
virtual void reset();
|
28
|
-
friend class LexerATNSimulator;
|
29
|
-
|
30
|
-
private:
|
31
|
-
void InitializeInstanceFields();
|
32
|
-
|
33
|
-
public:
|
34
|
-
SimState() {
|
35
|
-
InitializeInstanceFields();
|
36
|
-
}
|
37
|
-
};
|
20
|
+
struct ANTLR4CPP_PUBLIC SimState final {
|
21
|
+
size_t index = INVALID_INDEX;
|
22
|
+
size_t line = 0;
|
23
|
+
size_t charPos = INVALID_INDEX;
|
24
|
+
dfa::DFAState *dfaState = nullptr;
|
38
25
|
|
26
|
+
void reset();
|
27
|
+
};
|
39
28
|
|
40
29
|
public:
|
41
|
-
static
|
42
|
-
static
|
30
|
+
static constexpr size_t MIN_DFA_EDGE = 0;
|
31
|
+
static constexpr size_t MAX_DFA_EDGE = 127; // forces unicode to stay in ATN
|
43
32
|
|
44
33
|
protected:
|
45
34
|
/// <summary>
|
@@ -82,11 +71,9 @@ namespace atn {
|
|
82
71
|
SimState _prevAccept;
|
83
72
|
|
84
73
|
public:
|
85
|
-
static int match_calls;
|
86
|
-
|
87
74
|
LexerATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA, PredictionContextCache &sharedContextCache);
|
88
75
|
LexerATNSimulator(Lexer *recog, const ATN &atn, std::vector<dfa::DFA> &decisionToDFA, PredictionContextCache &sharedContextCache);
|
89
|
-
virtual ~LexerATNSimulator
|
76
|
+
virtual ~LexerATNSimulator() = default;
|
90
77
|
|
91
78
|
virtual void copyState(LexerATNSimulator *simulator);
|
92
79
|
virtual size_t match(CharStream *input, size_t mode);
|
@@ -133,10 +120,10 @@ namespace atn {
|
|
133
120
|
void getReachableConfigSet(CharStream *input, ATNConfigSet *closure_, // closure_ as we have a closure() already
|
134
121
|
ATNConfigSet *reach, size_t t);
|
135
122
|
|
136
|
-
virtual void accept(CharStream *input, const Ref<LexerActionExecutor> &lexerActionExecutor, size_t startIndex, size_t index,
|
123
|
+
virtual void accept(CharStream *input, const Ref<const LexerActionExecutor> &lexerActionExecutor, size_t startIndex, size_t index,
|
137
124
|
size_t line, size_t charPos);
|
138
125
|
|
139
|
-
virtual ATNState *getReachableTarget(Transition *trans, size_t t);
|
126
|
+
virtual ATNState *getReachableTarget(const Transition *trans, size_t t);
|
140
127
|
|
141
128
|
virtual std::unique_ptr<ATNConfigSet> computeStartState(CharStream *input, ATNState *p);
|
142
129
|
|
@@ -153,7 +140,7 @@ namespace atn {
|
|
153
140
|
bool currentAltReachedAcceptState, bool speculative, bool treatEofAsEpsilon);
|
154
141
|
|
155
142
|
// side-effect: can alter configs.hasSemanticContext
|
156
|
-
virtual Ref<LexerATNConfig> getEpsilonTarget(CharStream *input, const Ref<LexerATNConfig> &config, Transition *t,
|
143
|
+
virtual Ref<LexerATNConfig> getEpsilonTarget(CharStream *input, const Ref<LexerATNConfig> &config, const Transition *t,
|
157
144
|
ATNConfigSet *configs, bool speculative, bool treatEofAsEpsilon);
|
158
145
|
|
159
146
|
/// <summary>
|
@@ -190,6 +177,8 @@ namespace atn {
|
|
190
177
|
/// </summary>
|
191
178
|
virtual dfa::DFAState *addDFAState(ATNConfigSet *configs);
|
192
179
|
|
180
|
+
virtual dfa::DFAState *addDFAState(ATNConfigSet *configs, bool suppressEdge);
|
181
|
+
|
193
182
|
public:
|
194
183
|
dfa::DFA& getDFA(size_t mode);
|
195
184
|
|
@@ -1,9 +1,15 @@
|
|
1
|
-
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
|
2
|
-
* Use of this file is governed by the BSD 3-clause license that
|
3
|
-
* can be found in the LICENSE.txt file in the project root.
|
4
|
-
*/
|
5
|
-
|
6
1
|
#include "LexerAction.h"
|
7
2
|
|
8
|
-
antlr4::atn
|
3
|
+
using namespace antlr4::atn;
|
4
|
+
|
5
|
+
size_t LexerAction::hashCode() const {
|
6
|
+
auto hash = cachedHashCode();
|
7
|
+
if (hash == 0) {
|
8
|
+
hash = hashCodeImpl();
|
9
|
+
if (hash == 0) {
|
10
|
+
hash = std::numeric_limits<size_t>::max();
|
11
|
+
}
|
12
|
+
_hashCode.store(hash, std::memory_order_relaxed);
|
13
|
+
}
|
14
|
+
return hash;
|
9
15
|
}
|
@@ -21,13 +21,17 @@ namespace atn {
|
|
21
21
|
/// </summary>
|
22
22
|
class ANTLR4CPP_PUBLIC LexerAction {
|
23
23
|
public:
|
24
|
-
virtual ~LexerAction();
|
24
|
+
virtual ~LexerAction() = default;
|
25
25
|
|
26
26
|
/// <summary>
|
27
27
|
/// Gets the serialization type of the lexer action.
|
28
28
|
/// </summary>
|
29
29
|
/// <returns> The serialization type of the lexer action. </returns>
|
30
|
-
|
30
|
+
///
|
31
|
+
/// IMPORTANT: Unlike Java, this returns LexerActionType::INDEXED_CUSTOM for instances of
|
32
|
+
/// LexerIndexedCustomAction. If you need the wrapped action type, use
|
33
|
+
/// LexerIndexedCustomAction::getAction()->getActionType().
|
34
|
+
LexerActionType getActionType() const { return _actionType; }
|
31
35
|
|
32
36
|
/// <summary>
|
33
37
|
/// Gets whether the lexer action is position-dependent. Position-dependent
|
@@ -42,7 +46,7 @@ namespace atn {
|
|
42
46
|
/// <returns> {@code true} if the lexer action semantics can be affected by the
|
43
47
|
/// position of the input <seealso cref="CharStream"/> at the time it is executed;
|
44
48
|
/// otherwise, {@code false}. </returns>
|
45
|
-
|
49
|
+
bool isPositionDependent() const { return _positionDependent; }
|
46
50
|
|
47
51
|
/// <summary>
|
48
52
|
/// Execute the lexer action in the context of the specified <seealso cref="Lexer"/>.
|
@@ -51,16 +55,46 @@ namespace atn {
|
|
51
55
|
/// positioned correctly prior to calling this method.</para>
|
52
56
|
/// </summary>
|
53
57
|
/// <param name="lexer"> The lexer instance. </param>
|
54
|
-
virtual void execute(Lexer *lexer) = 0;
|
58
|
+
virtual void execute(Lexer *lexer) const = 0;
|
55
59
|
|
56
|
-
|
57
|
-
|
58
|
-
virtual bool
|
59
|
-
return !(*this == obj);
|
60
|
-
}
|
60
|
+
size_t hashCode() const;
|
61
|
+
|
62
|
+
virtual bool equals(const LexerAction &other) const = 0;
|
61
63
|
|
62
64
|
virtual std::string toString() const = 0;
|
65
|
+
|
66
|
+
protected:
|
67
|
+
LexerAction(LexerActionType actionType, bool positionDependent)
|
68
|
+
: _actionType(actionType), _hashCode(0), _positionDependent(positionDependent) {}
|
69
|
+
|
70
|
+
virtual size_t hashCodeImpl() const = 0;
|
71
|
+
|
72
|
+
size_t cachedHashCode() const { return _hashCode.load(std::memory_order_relaxed); }
|
73
|
+
|
74
|
+
private:
|
75
|
+
const LexerActionType _actionType;
|
76
|
+
mutable std::atomic<size_t> _hashCode;
|
77
|
+
const bool _positionDependent;
|
78
|
+
};
|
79
|
+
|
80
|
+
inline bool operator==(const LexerAction &lhs, const LexerAction &rhs) {
|
81
|
+
return lhs.equals(rhs);
|
82
|
+
}
|
83
|
+
|
84
|
+
inline bool operator!=(const LexerAction &lhs, const LexerAction &rhs) {
|
85
|
+
return !operator==(lhs, rhs);
|
86
|
+
}
|
87
|
+
|
88
|
+
} // namespace atn
|
89
|
+
} // namespace antlr4
|
90
|
+
|
91
|
+
namespace std {
|
92
|
+
|
93
|
+
template <>
|
94
|
+
struct hash<::antlr4::atn::LexerAction> {
|
95
|
+
size_t operator()(const ::antlr4::atn::LexerAction &lexerAction) const {
|
96
|
+
return lexerAction.hashCode();
|
97
|
+
}
|
63
98
|
};
|
64
99
|
|
65
|
-
}
|
66
|
-
} // namespace antlr4
|
100
|
+
} // namespace std
|