expressir 1.2.4 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +200 -21
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- data/README.adoc +8 -0
- data/Rakefile +4 -1
- data/bin/console +0 -1
- data/bin/rspec +3 -3
- data/exe/expressir +4 -2
- data/exe/format +1 -1
- data/exe/format-test +25 -25
- data/exe/generate-parser +16 -13
- data/expressir.gemspec +12 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
- data/ext/express-parser/antlrgen/Express.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
- data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
- data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
- data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
- data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
- data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
- data/ext/express-parser/express_parser.cpp +294 -86
- data/ext/express-parser/extconf.rb +13 -12
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +3 -4
- data/lib/expressir/express/visitor.rb +7 -5
- data/lib/expressir/model.rb +78 -78
- data/lib/expressir/version.rb +1 -1
- data/rakelib/antlr4-native.rake +161 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +17 -2
- data/spec/expressir/express/cache_spec.rb +23 -5
- data/spec/expressir/express/formatter_spec.rb +54 -8
- data/spec/expressir/express/parser_spec.rb +47 -11
- data/spec/expressir/model/model_element_spec.rb +198 -146
- data/spec/spec_helper.rb +7 -0
- metadata +81 -93
- data/demo.rb +0 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
- data/original/examples/employment/eclipse/.project +0 -17
- data/original/examples/employment/eclipse/Export/Employment.png +0 -0
- data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
- data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
- data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
- data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
- data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
- data/original/examples/employment/eclipse/readme.txt +0 -7
- data/original/examples/employment/employment_schema.exp +0 -33
- data/original/examples/employment/employment_schema.rb +0 -232
- data/original/examples/employment/employment_schema.xml +0 -93
- data/original/examples/employment/employment_schema___module.rb +0 -46
- data/original/examples/employment/employment_schema___p28attr.rb +0 -126
- data/original/examples/employment/employment_schema___p28inst.rb +0 -26
- data/original/examples/employment/example_employment_data.xml +0 -1
- data/original/examples/employment/example_employment_data_copy.xml +0 -1
- data/original/examples/employment/example_employment_reader.rb +0 -30
- data/original/examples/employment/example_employment_writer.rb +0 -51
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
- data/original/exp2ruby.rb +0 -525
- data/original/expsm.rb +0 -34
- data/original/mapping_owl.rb +0 -1018
- data/original/mapping_sysml.rb +0 -2281
- data/original/mapping_uml2.rb +0 -599
- data/original/mapping_uml2_eclipse.rb +0 -433
- data/original/reeper.rb +0 -134
- data/spec/expressr_spec.rb +0 -5
@@ -7,6 +7,7 @@
|
|
7
7
|
#include "atn/LexerIndexedCustomAction.h"
|
8
8
|
#include "support/CPPUtils.h"
|
9
9
|
#include "support/Arrays.h"
|
10
|
+
#include "support/Casts.h"
|
10
11
|
|
11
12
|
#include "atn/LexerActionExecutor.h"
|
12
13
|
|
@@ -15,48 +16,54 @@ using namespace antlr4::atn;
|
|
15
16
|
using namespace antlr4::misc;
|
16
17
|
using namespace antlrcpp;
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
namespace {
|
20
|
+
|
21
|
+
bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
|
22
|
+
return lhs == rhs || lhs == 0 || rhs == 0;
|
23
|
+
}
|
24
|
+
|
25
|
+
bool lexerActionEqual(const Ref<const LexerAction> &lhs, const Ref<const LexerAction> &rhs) {
|
26
|
+
return *lhs == *rhs;
|
27
|
+
}
|
21
28
|
|
22
|
-
LexerActionExecutor::~LexerActionExecutor() {
|
23
29
|
}
|
24
30
|
|
25
|
-
|
26
|
-
|
31
|
+
LexerActionExecutor::LexerActionExecutor(std::vector<Ref<const LexerAction>> lexerActions)
|
32
|
+
: _lexerActions(std::move(lexerActions)), _hashCode(0) {}
|
33
|
+
|
34
|
+
Ref<const LexerActionExecutor> LexerActionExecutor::append(const Ref<const LexerActionExecutor> &lexerActionExecutor,
|
35
|
+
Ref<const LexerAction> lexerAction) {
|
27
36
|
if (lexerActionExecutor == nullptr) {
|
28
|
-
return std::make_shared<LexerActionExecutor>(std::vector<Ref<LexerAction>>
|
37
|
+
return std::make_shared<LexerActionExecutor>(std::vector<Ref<const LexerAction>>{ std::move(lexerAction) });
|
29
38
|
}
|
30
|
-
|
31
|
-
|
32
|
-
lexerActions.
|
33
|
-
|
39
|
+
std::vector<Ref<const LexerAction>> lexerActions;
|
40
|
+
lexerActions.reserve(lexerActionExecutor->_lexerActions.size() + 1);
|
41
|
+
lexerActions.insert(lexerActions.begin(), lexerActionExecutor->_lexerActions.begin(), lexerActionExecutor->_lexerActions.end());
|
42
|
+
lexerActions.push_back(std::move(lexerAction));
|
43
|
+
return std::make_shared<LexerActionExecutor>(std::move(lexerActions));
|
34
44
|
}
|
35
45
|
|
36
|
-
Ref<LexerActionExecutor> LexerActionExecutor::fixOffsetBeforeMatch(int offset) {
|
37
|
-
std::vector<Ref<LexerAction>> updatedLexerActions;
|
46
|
+
Ref<const LexerActionExecutor> LexerActionExecutor::fixOffsetBeforeMatch(int offset) const {
|
47
|
+
std::vector<Ref<const LexerAction>> updatedLexerActions;
|
38
48
|
for (size_t i = 0; i < _lexerActions.size(); i++) {
|
39
|
-
if (_lexerActions[i]->isPositionDependent() && !is
|
49
|
+
if (_lexerActions[i]->isPositionDependent() && !LexerIndexedCustomAction::is(*_lexerActions[i])) {
|
40
50
|
if (updatedLexerActions.empty()) {
|
41
51
|
updatedLexerActions = _lexerActions; // Make a copy.
|
42
52
|
}
|
43
|
-
|
44
53
|
updatedLexerActions[i] = std::make_shared<LexerIndexedCustomAction>(offset, _lexerActions[i]);
|
45
54
|
}
|
46
55
|
}
|
47
|
-
|
48
56
|
if (updatedLexerActions.empty()) {
|
49
57
|
return shared_from_this();
|
50
58
|
}
|
51
|
-
|
52
|
-
return std::make_shared<LexerActionExecutor>(updatedLexerActions);
|
59
|
+
return std::make_shared<LexerActionExecutor>(std::move(updatedLexerActions));
|
53
60
|
}
|
54
61
|
|
55
|
-
std::vector<Ref<LexerAction
|
62
|
+
const std::vector<Ref<const LexerAction>>& LexerActionExecutor::getLexerActions() const {
|
56
63
|
return _lexerActions;
|
57
64
|
}
|
58
65
|
|
59
|
-
void LexerActionExecutor::execute(Lexer *lexer, CharStream *input, size_t startIndex) {
|
66
|
+
void LexerActionExecutor::execute(Lexer *lexer, CharStream *input, size_t startIndex) const {
|
60
67
|
bool requiresSeek = false;
|
61
68
|
size_t stopIndex = input->index();
|
62
69
|
|
@@ -65,43 +72,40 @@ void LexerActionExecutor::execute(Lexer *lexer, CharStream *input, size_t startI
|
|
65
72
|
input->seek(stopIndex);
|
66
73
|
}
|
67
74
|
});
|
68
|
-
for (auto lexerAction : _lexerActions) {
|
69
|
-
if (is
|
70
|
-
int offset =
|
75
|
+
for (const auto &lexerAction : _lexerActions) {
|
76
|
+
if (LexerIndexedCustomAction::is(*lexerAction)) {
|
77
|
+
int offset = downCast<const LexerIndexedCustomAction&>(*lexerAction).getOffset();
|
71
78
|
input->seek(startIndex + offset);
|
72
|
-
lexerAction = std::static_pointer_cast<LexerIndexedCustomAction>(lexerAction)->getAction();
|
73
79
|
requiresSeek = (startIndex + offset) != stopIndex;
|
74
80
|
} else if (lexerAction->isPositionDependent()) {
|
75
81
|
input->seek(stopIndex);
|
76
82
|
requiresSeek = false;
|
77
83
|
}
|
78
|
-
|
79
84
|
lexerAction->execute(lexer);
|
80
85
|
}
|
81
86
|
}
|
82
87
|
|
83
88
|
size_t LexerActionExecutor::hashCode() const {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
89
|
+
auto hash = _hashCode.load(std::memory_order_relaxed);
|
90
|
+
if (hash == 0) {
|
91
|
+
hash = MurmurHash::initialize();
|
92
|
+
for (const auto &lexerAction : _lexerActions) {
|
93
|
+
hash = MurmurHash::update(hash, lexerAction);
|
94
|
+
}
|
95
|
+
hash = MurmurHash::finish(hash, _lexerActions.size());
|
96
|
+
if (hash == 0) {
|
97
|
+
hash = std::numeric_limits<size_t>::max();
|
98
|
+
}
|
99
|
+
_hashCode.store(hash, std::memory_order_relaxed);
|
90
100
|
}
|
91
|
-
|
92
|
-
return _hashCode == obj._hashCode && Arrays::equals(_lexerActions, obj._lexerActions);
|
93
|
-
}
|
94
|
-
|
95
|
-
bool LexerActionExecutor::operator != (const LexerActionExecutor &obj) const {
|
96
|
-
return !operator==(obj);
|
101
|
+
return hash;
|
97
102
|
}
|
98
103
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
hash = MurmurHash::update(hash, lexerAction);
|
104
|
+
bool LexerActionExecutor::equals(const LexerActionExecutor &other) const {
|
105
|
+
if (this == std::addressof(other)) {
|
106
|
+
return true;
|
103
107
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
108
|
+
return cachedHashCodeEqual(_hashCode.load(std::memory_order_relaxed), other._hashCode.load(std::memory_order_relaxed)) &&
|
109
|
+
_lexerActions.size() == other._lexerActions.size() &&
|
110
|
+
std::equal(_lexerActions.begin(), _lexerActions.end(), other._lexerActions.begin(), lexerActionEqual);
|
107
111
|
}
|
@@ -17,13 +17,12 @@ namespace atn {
|
|
17
17
|
/// <para>The executor tracks position information for position-dependent lexer actions
|
18
18
|
/// efficiently, ensuring that actions appearing only at the end of the rule do
|
19
19
|
/// not cause bloating of the <seealso cref="DFA"/> created for the lexer.</para>
|
20
|
-
class ANTLR4CPP_PUBLIC LexerActionExecutor : public std::enable_shared_from_this<LexerActionExecutor> {
|
20
|
+
class ANTLR4CPP_PUBLIC LexerActionExecutor final : public std::enable_shared_from_this<LexerActionExecutor> {
|
21
21
|
public:
|
22
22
|
/// <summary>
|
23
23
|
/// Constructs an executor for a sequence of <seealso cref="LexerAction"/> actions. </summary>
|
24
24
|
/// <param name="lexerActions"> The lexer actions to execute. </param>
|
25
|
-
LexerActionExecutor(
|
26
|
-
virtual ~LexerActionExecutor();
|
25
|
+
explicit LexerActionExecutor(std::vector<Ref<const LexerAction>> lexerActions);
|
27
26
|
|
28
27
|
/// <summary>
|
29
28
|
/// Creates a <seealso cref="LexerActionExecutor"/> which executes the actions for
|
@@ -39,8 +38,8 @@ namespace atn {
|
|
39
38
|
/// </param>
|
40
39
|
/// <returns> A <seealso cref="LexerActionExecutor"/> for executing the combine actions
|
41
40
|
/// of {@code lexerActionExecutor} and {@code lexerAction}. </returns>
|
42
|
-
static Ref<LexerActionExecutor> append(Ref<LexerActionExecutor>
|
43
|
-
|
41
|
+
static Ref<const LexerActionExecutor> append(const Ref<const LexerActionExecutor> &lexerActionExecutor,
|
42
|
+
Ref<const LexerAction> lexerAction);
|
44
43
|
|
45
44
|
/// <summary>
|
46
45
|
/// Creates a <seealso cref="LexerActionExecutor"/> which encodes the current offset
|
@@ -70,12 +69,12 @@ namespace atn {
|
|
70
69
|
/// </param>
|
71
70
|
/// <returns> A <seealso cref="LexerActionExecutor"/> which stores input stream offsets
|
72
71
|
/// for all position-dependent lexer actions. </returns>
|
73
|
-
|
72
|
+
Ref<const LexerActionExecutor> fixOffsetBeforeMatch(int offset) const;
|
74
73
|
|
75
74
|
/// <summary>
|
76
75
|
/// Gets the lexer actions to be executed by this executor. </summary>
|
77
76
|
/// <returns> The lexer actions to be executed by this executor. </returns>
|
78
|
-
|
77
|
+
const std::vector<Ref<const LexerAction>>& getLexerActions() const;
|
79
78
|
|
80
79
|
/// <summary>
|
81
80
|
/// Execute the actions encapsulated by this executor within the context of a
|
@@ -95,21 +94,35 @@ namespace atn {
|
|
95
94
|
/// <param name="startIndex"> The token start index. This value may be passed to
|
96
95
|
/// <seealso cref="IntStream#seek"/> to set the {@code input} position to the beginning
|
97
96
|
/// of the token. </param>
|
98
|
-
|
97
|
+
void execute(Lexer *lexer, CharStream *input, size_t startIndex) const;
|
99
98
|
|
100
|
-
|
101
|
-
|
102
|
-
|
99
|
+
size_t hashCode() const;
|
100
|
+
|
101
|
+
bool equals(const LexerActionExecutor &other) const;
|
103
102
|
|
104
103
|
private:
|
105
|
-
const std::vector<Ref<LexerAction>> _lexerActions;
|
104
|
+
const std::vector<Ref<const LexerAction>> _lexerActions;
|
105
|
+
mutable std::atomic<size_t> _hashCode;
|
106
|
+
};
|
107
|
+
|
108
|
+
inline bool operator==(const LexerActionExecutor &lhs, const LexerActionExecutor &rhs) {
|
109
|
+
return lhs.equals(rhs);
|
110
|
+
}
|
111
|
+
|
112
|
+
inline bool operator!=(const LexerActionExecutor &lhs, const LexerActionExecutor &rhs) {
|
113
|
+
return !operator==(lhs, rhs);
|
114
|
+
}
|
115
|
+
|
116
|
+
} // namespace atn
|
117
|
+
} // namespace antlr4
|
106
118
|
|
107
|
-
|
108
|
-
/// of the performance-critical <seealso cref="LexerATNConfig#hashCode"/> operation.
|
109
|
-
const size_t _hashCode;
|
119
|
+
namespace std {
|
110
120
|
|
111
|
-
|
121
|
+
template <>
|
122
|
+
struct hash<::antlr4::atn::LexerActionExecutor> {
|
123
|
+
size_t operator()(const ::antlr4::atn::LexerActionExecutor &lexerActionExecutor) const {
|
124
|
+
return lexerActionExecutor.hashCode();
|
125
|
+
}
|
112
126
|
};
|
113
127
|
|
114
|
-
}
|
115
|
-
} // namespace antlr4
|
128
|
+
} // namespace std
|
@@ -20,7 +20,7 @@ namespace atn {
|
|
20
20
|
/// <summary>
|
21
21
|
/// The type of a <seealso cref="LexerChannelAction"/> action.
|
22
22
|
/// </summary>
|
23
|
-
CHANNEL,
|
23
|
+
CHANNEL = 0,
|
24
24
|
/// <summary>
|
25
25
|
/// The type of a <seealso cref="LexerCustomAction"/> action.
|
26
26
|
/// </summary>
|
@@ -49,6 +49,8 @@ namespace atn {
|
|
49
49
|
/// The type of a <seealso cref="LexerTypeAction"/> action.
|
50
50
|
/// </summary>
|
51
51
|
TYPE,
|
52
|
+
|
53
|
+
INDEXED_CUSTOM,
|
52
54
|
};
|
53
55
|
|
54
56
|
} // namespace atn
|
@@ -5,51 +5,39 @@
|
|
5
5
|
|
6
6
|
#include "misc/MurmurHash.h"
|
7
7
|
#include "Lexer.h"
|
8
|
+
#include "support/Casts.h"
|
8
9
|
|
9
10
|
#include "atn/LexerChannelAction.h"
|
10
11
|
|
11
12
|
using namespace antlr4::atn;
|
12
13
|
using namespace antlr4::misc;
|
14
|
+
using namespace antlrcpp;
|
13
15
|
|
14
|
-
LexerChannelAction::LexerChannelAction(int channel)
|
15
|
-
}
|
16
|
-
|
17
|
-
int LexerChannelAction::getChannel() const {
|
18
|
-
return _channel;
|
19
|
-
}
|
20
|
-
|
21
|
-
LexerActionType LexerChannelAction::getActionType() const {
|
22
|
-
return LexerActionType::CHANNEL;
|
23
|
-
}
|
16
|
+
LexerChannelAction::LexerChannelAction(int channel)
|
17
|
+
: LexerAction(LexerActionType::CHANNEL, false), _channel(channel) {}
|
24
18
|
|
25
|
-
|
26
|
-
|
19
|
+
void LexerChannelAction::execute(Lexer *lexer) const {
|
20
|
+
lexer->setChannel(getChannel());
|
27
21
|
}
|
28
22
|
|
29
|
-
|
30
|
-
lexer->setChannel(_channel);
|
31
|
-
}
|
32
|
-
|
33
|
-
size_t LexerChannelAction::hashCode() const {
|
23
|
+
size_t LexerChannelAction::hashCodeImpl() const {
|
34
24
|
size_t hash = MurmurHash::initialize();
|
35
25
|
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
36
|
-
hash = MurmurHash::update(hash,
|
26
|
+
hash = MurmurHash::update(hash, getChannel());
|
37
27
|
return MurmurHash::finish(hash, 2);
|
38
28
|
}
|
39
29
|
|
40
|
-
bool LexerChannelAction::
|
41
|
-
if (
|
30
|
+
bool LexerChannelAction::equals(const LexerAction &other) const {
|
31
|
+
if (this == std::addressof(other)) {
|
42
32
|
return true;
|
43
33
|
}
|
44
|
-
|
45
|
-
const LexerChannelAction *action = dynamic_cast<const LexerChannelAction *>(&obj);
|
46
|
-
if (action == nullptr) {
|
34
|
+
if (getActionType() != other.getActionType()) {
|
47
35
|
return false;
|
48
36
|
}
|
49
|
-
|
50
|
-
return
|
37
|
+
const auto &lexerAction = downCast<const LexerChannelAction&>(other);
|
38
|
+
return getChannel() == lexerAction.getChannel();
|
51
39
|
}
|
52
40
|
|
53
41
|
std::string LexerChannelAction::toString() const {
|
54
|
-
return "channel(" + std::to_string(
|
42
|
+
return "channel(" + std::to_string(getChannel()) + ")";
|
55
43
|
}
|
@@ -22,26 +22,20 @@ namespace atn {
|
|
22
22
|
/// </summary>
|
23
23
|
class ANTLR4CPP_PUBLIC LexerChannelAction final : public LexerAction {
|
24
24
|
public:
|
25
|
+
static bool is(const LexerAction &lexerAction) { return lexerAction.getActionType() == LexerActionType::CHANNEL; }
|
26
|
+
|
27
|
+
static bool is(const LexerAction *lexerAction) { return lexerAction != nullptr && is(*lexerAction); }
|
28
|
+
|
25
29
|
/// <summary>
|
26
30
|
/// Constructs a new {@code channel} action with the specified channel value. </summary>
|
27
31
|
/// <param name="channel"> The channel value to pass to <seealso cref="Lexer#setChannel"/>. </param>
|
28
|
-
LexerChannelAction(int channel);
|
32
|
+
explicit LexerChannelAction(int channel);
|
29
33
|
|
30
34
|
/// <summary>
|
31
35
|
/// Gets the channel to use for the <seealso cref="Token"/> created by the lexer.
|
32
36
|
/// </summary>
|
33
37
|
/// <returns> The channel to use for the <seealso cref="Token"/> created by the lexer. </returns>
|
34
|
-
int getChannel() const;
|
35
|
-
|
36
|
-
/// <summary>
|
37
|
-
/// {@inheritDoc} </summary>
|
38
|
-
/// <returns> This method returns <seealso cref="LexerActionType#CHANNEL"/>. </returns>
|
39
|
-
virtual LexerActionType getActionType() const override;
|
40
|
-
|
41
|
-
/// <summary>
|
42
|
-
/// {@inheritDoc} </summary>
|
43
|
-
/// <returns> This method returns {@code false}. </returns>
|
44
|
-
virtual bool isPositionDependent() const override;
|
38
|
+
int getChannel() const { return _channel; }
|
45
39
|
|
46
40
|
/// <summary>
|
47
41
|
/// {@inheritDoc}
|
@@ -49,11 +43,13 @@ namespace atn {
|
|
49
43
|
/// <para>This action is implemented by calling <seealso cref="Lexer#setChannel"/> with the
|
50
44
|
/// value provided by <seealso cref="#getChannel"/>.</para>
|
51
45
|
/// </summary>
|
52
|
-
|
46
|
+
void execute(Lexer *lexer) const override;
|
47
|
+
|
48
|
+
bool equals(const LexerAction &other) const override;
|
49
|
+
std::string toString() const override;
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
virtual std::string toString() const override;
|
51
|
+
protected:
|
52
|
+
size_t hashCodeImpl() const override;
|
57
53
|
|
58
54
|
private:
|
59
55
|
const int _channel;
|
@@ -4,59 +4,42 @@
|
|
4
4
|
*/
|
5
5
|
|
6
6
|
#include "misc/MurmurHash.h"
|
7
|
-
#include "support/CPPUtils.h"
|
8
7
|
#include "Lexer.h"
|
8
|
+
#include "support/Casts.h"
|
9
9
|
|
10
10
|
#include "atn/LexerCustomAction.h"
|
11
11
|
|
12
12
|
using namespace antlr4;
|
13
13
|
using namespace antlr4::atn;
|
14
14
|
using namespace antlr4::misc;
|
15
|
+
using namespace antlrcpp;
|
15
16
|
|
16
|
-
LexerCustomAction::LexerCustomAction(size_t ruleIndex, size_t actionIndex)
|
17
|
-
}
|
18
|
-
|
19
|
-
size_t LexerCustomAction::getRuleIndex() const {
|
20
|
-
return _ruleIndex;
|
21
|
-
}
|
17
|
+
LexerCustomAction::LexerCustomAction(size_t ruleIndex, size_t actionIndex)
|
18
|
+
: LexerAction(LexerActionType::CUSTOM, true), _ruleIndex(ruleIndex), _actionIndex(actionIndex) {}
|
22
19
|
|
23
|
-
|
24
|
-
|
20
|
+
void LexerCustomAction::execute(Lexer *lexer) const {
|
21
|
+
lexer->action(nullptr, getRuleIndex(), getActionIndex());
|
25
22
|
}
|
26
23
|
|
27
|
-
|
28
|
-
return LexerActionType::CUSTOM;
|
29
|
-
}
|
30
|
-
|
31
|
-
bool LexerCustomAction::isPositionDependent() const {
|
32
|
-
return true;
|
33
|
-
}
|
34
|
-
|
35
|
-
void LexerCustomAction::execute(Lexer *lexer) {
|
36
|
-
lexer->action(nullptr, _ruleIndex, _actionIndex);
|
37
|
-
}
|
38
|
-
|
39
|
-
size_t LexerCustomAction::hashCode() const {
|
24
|
+
size_t LexerCustomAction::hashCodeImpl() const {
|
40
25
|
size_t hash = MurmurHash::initialize();
|
41
26
|
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
42
|
-
hash = MurmurHash::update(hash,
|
43
|
-
hash = MurmurHash::update(hash,
|
27
|
+
hash = MurmurHash::update(hash, getRuleIndex());
|
28
|
+
hash = MurmurHash::update(hash, getActionIndex());
|
44
29
|
return MurmurHash::finish(hash, 3);
|
45
30
|
}
|
46
31
|
|
47
|
-
bool LexerCustomAction::
|
48
|
-
if (
|
32
|
+
bool LexerCustomAction::equals(const LexerAction &other) const {
|
33
|
+
if (this == std::addressof(other)) {
|
49
34
|
return true;
|
50
35
|
}
|
51
|
-
|
52
|
-
const LexerCustomAction *action = dynamic_cast<const LexerCustomAction *>(&obj);
|
53
|
-
if (action == nullptr) {
|
36
|
+
if (getActionType() != other.getActionType()) {
|
54
37
|
return false;
|
55
38
|
}
|
56
|
-
|
57
|
-
return
|
39
|
+
const auto &lexerAction = downCast<const LexerCustomAction&>(other);
|
40
|
+
return getRuleIndex() == lexerAction.getRuleIndex() && getActionIndex() == lexerAction.getActionIndex();
|
58
41
|
}
|
59
42
|
|
60
43
|
std::string LexerCustomAction::toString() const {
|
61
|
-
return
|
44
|
+
return "custom(" + std::to_string(getRuleIndex()) + ", " + std::to_string(getActionIndex()) + ")";
|
62
45
|
}
|
@@ -26,6 +26,10 @@ namespace atn {
|
|
26
26
|
/// </summary>
|
27
27
|
class ANTLR4CPP_PUBLIC LexerCustomAction final : public LexerAction {
|
28
28
|
public:
|
29
|
+
static bool is(const LexerAction &lexerAction) { return lexerAction.getActionType() == LexerActionType::CUSTOM; }
|
30
|
+
|
31
|
+
static bool is(const LexerAction *lexerAction) { return lexerAction != nullptr && is(*lexerAction); }
|
32
|
+
|
29
33
|
/// <summary>
|
30
34
|
/// Constructs a custom lexer action with the specified rule and action
|
31
35
|
/// indexes.
|
@@ -40,31 +44,13 @@ namespace atn {
|
|
40
44
|
/// Gets the rule index to use for calls to <seealso cref="Recognizer#action"/>.
|
41
45
|
/// </summary>
|
42
46
|
/// <returns> The rule index for the custom action. </returns>
|
43
|
-
size_t getRuleIndex() const;
|
47
|
+
size_t getRuleIndex() const { return _ruleIndex; }
|
44
48
|
|
45
49
|
/// <summary>
|
46
50
|
/// Gets the action index to use for calls to <seealso cref="Recognizer#action"/>.
|
47
51
|
/// </summary>
|
48
52
|
/// <returns> The action index for the custom action. </returns>
|
49
|
-
size_t getActionIndex() const;
|
50
|
-
|
51
|
-
/// <summary>
|
52
|
-
/// {@inheritDoc}
|
53
|
-
/// </summary>
|
54
|
-
/// <returns> This method returns <seealso cref="LexerActionType#CUSTOM"/>. </returns>
|
55
|
-
virtual LexerActionType getActionType() const override;
|
56
|
-
|
57
|
-
/// <summary>
|
58
|
-
/// Gets whether the lexer action is position-dependent. Position-dependent
|
59
|
-
/// actions may have different semantics depending on the <seealso cref="CharStream"/>
|
60
|
-
/// index at the time the action is executed.
|
61
|
-
///
|
62
|
-
/// <para>Custom actions are position-dependent since they may represent a
|
63
|
-
/// user-defined embedded action which makes calls to methods like
|
64
|
-
/// <seealso cref="Lexer#getText"/>.</para>
|
65
|
-
/// </summary>
|
66
|
-
/// <returns> This method returns {@code true}. </returns>
|
67
|
-
virtual bool isPositionDependent() const override;
|
53
|
+
size_t getActionIndex() const { return _actionIndex; }
|
68
54
|
|
69
55
|
/// <summary>
|
70
56
|
/// {@inheritDoc}
|
@@ -72,11 +58,13 @@ namespace atn {
|
|
72
58
|
/// <para>Custom actions are implemented by calling <seealso cref="Lexer#action"/> with the
|
73
59
|
/// appropriate rule and action indexes.</para>
|
74
60
|
/// </summary>
|
75
|
-
|
61
|
+
void execute(Lexer *lexer) const override;
|
62
|
+
|
63
|
+
bool equals(const LexerAction &other) const override;
|
64
|
+
std::string toString() const override;
|
76
65
|
|
77
|
-
|
78
|
-
|
79
|
-
virtual std::string toString() const override;
|
66
|
+
protected:
|
67
|
+
size_t hashCodeImpl() const override;
|
80
68
|
|
81
69
|
private:
|
82
70
|
const size_t _ruleIndex;
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp
CHANGED
@@ -6,58 +6,52 @@
|
|
6
6
|
#include "misc/MurmurHash.h"
|
7
7
|
#include "Lexer.h"
|
8
8
|
#include "support/CPPUtils.h"
|
9
|
+
#include "support/Casts.h"
|
9
10
|
|
10
11
|
#include "atn/LexerIndexedCustomAction.h"
|
11
12
|
|
12
13
|
using namespace antlr4;
|
13
14
|
using namespace antlr4::atn;
|
14
15
|
using namespace antlr4::misc;
|
16
|
+
using namespace antlrcpp;
|
15
17
|
|
16
|
-
|
17
|
-
: _offset(offset), _action(action) {
|
18
|
-
}
|
19
|
-
|
20
|
-
int LexerIndexedCustomAction::getOffset() const {
|
21
|
-
return _offset;
|
22
|
-
}
|
18
|
+
namespace {
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
}
|
20
|
+
bool cachedHashCodeEqual(size_t lhs, size_t rhs) {
|
21
|
+
return lhs == rhs || lhs == 0 || rhs == 0;
|
22
|
+
}
|
27
23
|
|
28
|
-
LexerActionType LexerIndexedCustomAction::getActionType() const {
|
29
|
-
return _action->getActionType();
|
30
24
|
}
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
}
|
26
|
+
LexerIndexedCustomAction::LexerIndexedCustomAction(int offset, Ref<const LexerAction> action)
|
27
|
+
: LexerAction(LexerActionType::INDEXED_CUSTOM, true), _action(std::move(action)), _offset(offset) {}
|
35
28
|
|
36
|
-
void LexerIndexedCustomAction::execute(Lexer *lexer) {
|
29
|
+
void LexerIndexedCustomAction::execute(Lexer *lexer) const {
|
37
30
|
// assume the input stream position was properly set by the calling code
|
38
|
-
|
31
|
+
getAction()->execute(lexer);
|
39
32
|
}
|
40
33
|
|
41
|
-
size_t LexerIndexedCustomAction::
|
34
|
+
size_t LexerIndexedCustomAction::hashCodeImpl() const {
|
42
35
|
size_t hash = MurmurHash::initialize();
|
43
|
-
hash = MurmurHash::update(hash,
|
44
|
-
hash = MurmurHash::update(hash,
|
45
|
-
|
36
|
+
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
37
|
+
hash = MurmurHash::update(hash, getOffset());
|
38
|
+
hash = MurmurHash::update(hash, getAction());
|
39
|
+
return MurmurHash::finish(hash, 3);
|
46
40
|
}
|
47
41
|
|
48
|
-
bool LexerIndexedCustomAction::
|
49
|
-
if (
|
42
|
+
bool LexerIndexedCustomAction::equals(const LexerAction &other) const {
|
43
|
+
if (this == std::addressof(other)) {
|
50
44
|
return true;
|
51
45
|
}
|
52
|
-
|
53
|
-
const LexerIndexedCustomAction *action = dynamic_cast<const LexerIndexedCustomAction *>(&obj);
|
54
|
-
if (action == nullptr) {
|
46
|
+
if (getActionType() != other.getActionType()) {
|
55
47
|
return false;
|
56
48
|
}
|
57
|
-
|
58
|
-
return
|
49
|
+
const auto &lexerAction = downCast<const LexerIndexedCustomAction&>(other);
|
50
|
+
return getOffset() == lexerAction.getOffset() &&
|
51
|
+
cachedHashCodeEqual(cachedHashCode(), lexerAction.cachedHashCode()) &&
|
52
|
+
*getAction() == *lexerAction.getAction();
|
59
53
|
}
|
60
54
|
|
61
55
|
std::string LexerIndexedCustomAction::toString() const {
|
62
|
-
return
|
56
|
+
return "indexedCustom(" + std::to_string(getOffset()) + ", " + getAction()->toString() + ")";
|
63
57
|
}
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h
CHANGED
@@ -26,6 +26,10 @@ namespace atn {
|
|
26
26
|
/// </summary>
|
27
27
|
class ANTLR4CPP_PUBLIC LexerIndexedCustomAction final : public LexerAction {
|
28
28
|
public:
|
29
|
+
static bool is(const LexerAction &lexerAction) { return lexerAction.getActionType() == LexerActionType::INDEXED_CUSTOM; }
|
30
|
+
|
31
|
+
static bool is(const LexerAction *lexerAction) { return lexerAction != nullptr && is(*lexerAction); }
|
32
|
+
|
29
33
|
/// <summary>
|
30
34
|
/// Constructs a new indexed custom action by associating a character offset
|
31
35
|
/// with a <seealso cref="LexerAction"/>.
|
@@ -38,7 +42,7 @@ namespace atn {
|
|
38
42
|
/// executed. </param>
|
39
43
|
/// <param name="action"> The lexer action to execute at a particular offset in the
|
40
44
|
/// input <seealso cref="CharStream"/>. </param>
|
41
|
-
LexerIndexedCustomAction(int offset, Ref<LexerAction>
|
45
|
+
LexerIndexedCustomAction(int offset, Ref<const LexerAction> action);
|
42
46
|
|
43
47
|
/// <summary>
|
44
48
|
/// Gets the location in the input <seealso cref="CharStream"/> at which the lexer
|
@@ -47,34 +51,24 @@ namespace atn {
|
|
47
51
|
/// </summary>
|
48
52
|
/// <returns> The location in the input <seealso cref="CharStream"/> at which the lexer
|
49
53
|
/// action should be executed. </returns>
|
50
|
-
int getOffset() const;
|
54
|
+
int getOffset() const { return _offset; }
|
51
55
|
|
52
56
|
/// <summary>
|
53
57
|
/// Gets the lexer action to execute.
|
54
58
|
/// </summary>
|
55
59
|
/// <returns> A <seealso cref="LexerAction"/> object which executes the lexer action. </returns>
|
56
|
-
Ref<LexerAction
|
57
|
-
|
58
|
-
/// <summary>
|
59
|
-
/// {@inheritDoc}
|
60
|
-
/// </summary>
|
61
|
-
/// <returns> This method returns the result of calling <seealso cref="#getActionType"/>
|
62
|
-
/// on the <seealso cref="LexerAction"/> returned by <seealso cref="#getAction"/>. </returns>
|
63
|
-
virtual LexerActionType getActionType() const override;
|
60
|
+
const Ref<const LexerAction>& getAction() const { return _action; }
|
64
61
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
virtual bool isPositionDependent() const override;
|
62
|
+
void execute(Lexer *lexer) const override;
|
63
|
+
bool equals(const LexerAction &other) const override;
|
64
|
+
std::string toString() const override;
|
69
65
|
|
70
|
-
|
71
|
-
|
72
|
-
virtual bool operator == (const LexerAction &obj) const override;
|
73
|
-
virtual std::string toString() const override;
|
66
|
+
protected:
|
67
|
+
size_t hashCodeImpl() const override;
|
74
68
|
|
75
69
|
private:
|
70
|
+
const Ref<const LexerAction> _action;
|
76
71
|
const int _offset;
|
77
|
-
const Ref<LexerAction> _action;
|
78
72
|
};
|
79
73
|
|
80
74
|
} // namespace atn
|