expressir 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +200 -9
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- 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 -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 +207 -75
- data/ext/express-parser/extconf.rb +10 -9
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +2 -2
- 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 +63 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +7 -2
- data/spec/expressir/express/cache_spec.rb +8 -5
- data/spec/expressir/express/formatter_spec.rb +16 -8
- data/spec/expressir/express/parser_spec.rb +17 -11
- data/spec/expressir/model/model_element_spec.rb +154 -146
- 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
|
@@ -5,24 +5,30 @@
|
|
|
5
5
|
|
|
6
6
|
#pragma once
|
|
7
7
|
|
|
8
|
+
#include <atomic>
|
|
9
|
+
|
|
8
10
|
#include "Recognizer.h"
|
|
9
11
|
#include "atn/ATN.h"
|
|
10
12
|
#include "atn/ATNState.h"
|
|
13
|
+
#include "atn/PredictionContextType.h"
|
|
11
14
|
|
|
12
15
|
namespace antlr4 {
|
|
16
|
+
|
|
17
|
+
class RuleContext;
|
|
18
|
+
|
|
13
19
|
namespace atn {
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
class ATN;
|
|
22
|
+
class ArrayPredictionContext;
|
|
23
|
+
class SingletonPredictionContext;
|
|
24
|
+
class PredictionContextCache;
|
|
17
25
|
class PredictionContextMergeCache;
|
|
18
26
|
|
|
19
|
-
typedef std::unordered_set<Ref<PredictionContext>, PredictionContextHasher, PredictionContextComparer> PredictionContextCache;
|
|
20
|
-
|
|
21
27
|
class ANTLR4CPP_PUBLIC PredictionContext {
|
|
22
28
|
public:
|
|
23
29
|
/// Represents $ in local context prediction, which means wildcard.
|
|
24
30
|
/// *+x = *.
|
|
25
|
-
static const Ref<PredictionContext> EMPTY;
|
|
31
|
+
static const Ref<const PredictionContext> EMPTY;
|
|
26
32
|
|
|
27
33
|
/// Represents $ in an array in full context mode, when $
|
|
28
34
|
/// doesn't mean wildcard: $ + x = [$,x]. Here,
|
|
@@ -30,80 +36,13 @@ namespace atn {
|
|
|
30
36
|
// ml: originally Integer.MAX_VALUE, which would be -1 for us, but this is already used in places where
|
|
31
37
|
// -1 is converted to unsigned, so we use a different value here. Any value does the job provided it doesn't
|
|
32
38
|
// conflict with real return states.
|
|
33
|
-
#if __cplusplus >= 201703L
|
|
34
39
|
static constexpr size_t EMPTY_RETURN_STATE = std::numeric_limits<size_t>::max() - 9;
|
|
35
|
-
#else
|
|
36
|
-
enum : size_t {
|
|
37
|
-
EMPTY_RETURN_STATE = static_cast<size_t>(-10), // std::numeric_limits<size_t>::max() - 9; doesn't work in VS 2013
|
|
38
|
-
};
|
|
39
|
-
#endif
|
|
40
|
-
|
|
41
|
-
private:
|
|
42
|
-
#if __cplusplus >= 201703L
|
|
43
|
-
static constexpr size_t INITIAL_HASH = 1;
|
|
44
|
-
#else
|
|
45
|
-
enum : size_t {
|
|
46
|
-
INITIAL_HASH = 1,
|
|
47
|
-
};
|
|
48
|
-
#endif
|
|
49
|
-
|
|
50
|
-
public:
|
|
51
|
-
static size_t globalNodeCount;
|
|
52
|
-
const size_t id;
|
|
53
|
-
|
|
54
|
-
/// <summary>
|
|
55
|
-
/// Stores the computed hash code of this <seealso cref="PredictionContext"/>. The hash
|
|
56
|
-
/// code is computed in parts to match the following reference algorithm.
|
|
57
|
-
///
|
|
58
|
-
/// <pre>
|
|
59
|
-
/// private int referenceHashCode() {
|
|
60
|
-
/// int hash = <seealso cref="MurmurHash#initialize"/>(<seealso cref="#INITIAL_HASH"/>);
|
|
61
|
-
///
|
|
62
|
-
/// for (int i = 0; i < <seealso cref="#size()"/>; i++) {
|
|
63
|
-
/// hash = <seealso cref="MurmurHash#update"/>(hash, <seealso cref="#getParent"/>(i));
|
|
64
|
-
/// }
|
|
65
|
-
///
|
|
66
|
-
/// for (int i = 0; i < <seealso cref="#size()"/>; i++) {
|
|
67
|
-
/// hash = <seealso cref="MurmurHash#update"/>(hash, <seealso cref="#getReturnState"/>(i));
|
|
68
|
-
/// }
|
|
69
|
-
///
|
|
70
|
-
/// hash = <seealso cref="MurmurHash#finish"/>(hash, 2 * <seealso cref="#size()"/>);
|
|
71
|
-
/// return hash;
|
|
72
|
-
/// }
|
|
73
|
-
/// </pre>
|
|
74
|
-
/// </summary>
|
|
75
|
-
const size_t cachedHashCode;
|
|
76
40
|
|
|
77
|
-
protected:
|
|
78
|
-
PredictionContext(size_t cachedHashCode);
|
|
79
|
-
~PredictionContext();
|
|
80
|
-
|
|
81
|
-
public:
|
|
82
|
-
/// Convert a RuleContext tree to a PredictionContext graph.
|
|
83
|
-
/// Return EMPTY if outerContext is empty.
|
|
84
|
-
static Ref<PredictionContext> fromRuleContext(const ATN &atn, RuleContext *outerContext);
|
|
85
|
-
|
|
86
|
-
virtual size_t size() const = 0;
|
|
87
|
-
virtual Ref<PredictionContext> getParent(size_t index) const = 0;
|
|
88
|
-
virtual size_t getReturnState(size_t index) const = 0;
|
|
89
|
-
|
|
90
|
-
virtual bool operator == (const PredictionContext &o) const = 0;
|
|
91
|
-
|
|
92
|
-
/// This means only the EMPTY (wildcard? not sure) context is in set.
|
|
93
|
-
virtual bool isEmpty() const;
|
|
94
|
-
virtual bool hasEmptyPath() const;
|
|
95
|
-
virtual size_t hashCode() const;
|
|
96
|
-
|
|
97
|
-
protected:
|
|
98
|
-
static size_t calculateEmptyHashCode();
|
|
99
|
-
static size_t calculateHashCode(Ref<PredictionContext> parent, size_t returnState);
|
|
100
|
-
static size_t calculateHashCode(const std::vector<Ref<PredictionContext>> &parents,
|
|
101
|
-
const std::vector<size_t> &returnStates);
|
|
102
|
-
|
|
103
|
-
public:
|
|
104
41
|
// dispatch
|
|
105
|
-
static Ref<PredictionContext> merge(
|
|
106
|
-
|
|
42
|
+
static Ref<const PredictionContext> merge(Ref<const PredictionContext> a,
|
|
43
|
+
Ref<const PredictionContext> b,
|
|
44
|
+
bool rootIsWildcard,
|
|
45
|
+
PredictionContextMergeCache *mergeCache);
|
|
107
46
|
|
|
108
47
|
/// <summary>
|
|
109
48
|
/// Merge two <seealso cref="SingletonPredictionContext"/> instances.
|
|
@@ -139,8 +78,10 @@ namespace atn {
|
|
|
139
78
|
/// <param name="rootIsWildcard"> {@code true} if this is a local-context merge,
|
|
140
79
|
/// otherwise false to indicate a full-context merge </param>
|
|
141
80
|
/// <param name="mergeCache"> </param>
|
|
142
|
-
static Ref<PredictionContext> mergeSingletons(const
|
|
143
|
-
|
|
81
|
+
static Ref<const PredictionContext> mergeSingletons(Ref<const SingletonPredictionContext> a,
|
|
82
|
+
Ref<const SingletonPredictionContext> b,
|
|
83
|
+
bool rootIsWildcard,
|
|
84
|
+
PredictionContextMergeCache *mergeCache);
|
|
144
85
|
|
|
145
86
|
/**
|
|
146
87
|
* Handle case where at least one of {@code a} or {@code b} is
|
|
@@ -180,8 +121,9 @@ namespace atn {
|
|
|
180
121
|
* @param rootIsWildcard {@code true} if this is a local-context merge,
|
|
181
122
|
* otherwise false to indicate a full-context merge
|
|
182
123
|
*/
|
|
183
|
-
static Ref<PredictionContext> mergeRoot(const
|
|
184
|
-
|
|
124
|
+
static Ref<const PredictionContext> mergeRoot(Ref<const SingletonPredictionContext> a,
|
|
125
|
+
Ref<const SingletonPredictionContext> b,
|
|
126
|
+
bool rootIsWildcard);
|
|
185
127
|
|
|
186
128
|
/**
|
|
187
129
|
* Merge two {@link ArrayPredictionContext} instances.
|
|
@@ -202,65 +144,82 @@ namespace atn {
|
|
|
202
144
|
* {@link SingletonPredictionContext}.<br>
|
|
203
145
|
* <embed src="images/ArrayMerge_EqualTop.svg" type="image/svg+xml"/></p>
|
|
204
146
|
*/
|
|
205
|
-
static Ref<PredictionContext> mergeArrays(const
|
|
206
|
-
|
|
147
|
+
static Ref<const PredictionContext> mergeArrays(Ref<const ArrayPredictionContext> a,
|
|
148
|
+
Ref<const ArrayPredictionContext> b,
|
|
149
|
+
bool rootIsWildcard,
|
|
150
|
+
PredictionContextMergeCache *mergeCache);
|
|
207
151
|
|
|
208
|
-
|
|
209
|
-
/// Make pass over all M parents; merge any equal() ones.
|
|
210
|
-
/// @returns true if the list has been changed (i.e. duplicates where found).
|
|
211
|
-
static bool combineCommonParents(std::vector<Ref<PredictionContext>> &parents);
|
|
152
|
+
static std::string toDOTString(const Ref<const PredictionContext> &context);
|
|
212
153
|
|
|
213
|
-
|
|
214
|
-
|
|
154
|
+
static Ref<const PredictionContext> getCachedContext(const Ref<const PredictionContext> &context,
|
|
155
|
+
PredictionContextCache &contextCache);
|
|
215
156
|
|
|
216
|
-
static Ref<PredictionContext
|
|
217
|
-
PredictionContextCache &contextCache,
|
|
218
|
-
std::map<Ref<PredictionContext>, Ref<PredictionContext>> &visited);
|
|
157
|
+
static std::vector<Ref<const PredictionContext>> getAllContextNodes(const Ref<const PredictionContext> &context);
|
|
219
158
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
static
|
|
223
|
-
std::vector<Ref<PredictionContext>> &nodes, std::set<PredictionContext *> &visited);
|
|
159
|
+
/// Convert a RuleContext tree to a PredictionContext graph.
|
|
160
|
+
/// Return EMPTY if outerContext is empty.
|
|
161
|
+
static Ref<const PredictionContext> fromRuleContext(const ATN &atn, RuleContext *outerContext);
|
|
224
162
|
|
|
225
|
-
|
|
226
|
-
virtual std::string toString(Recognizer *recog) const;
|
|
163
|
+
PredictionContext(const PredictionContext&) = delete;
|
|
227
164
|
|
|
228
|
-
|
|
229
|
-
std::vector<std::string> toStrings(Recognizer *recognizer, const Ref<PredictionContext> &stop, int currentState);
|
|
230
|
-
};
|
|
165
|
+
virtual ~PredictionContext() = default;
|
|
231
166
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return k->hashCode();
|
|
235
|
-
}
|
|
236
|
-
};
|
|
167
|
+
PredictionContext& operator=(const PredictionContext&) = delete;
|
|
168
|
+
PredictionContext& operator=(PredictionContext&&) = delete;
|
|
237
169
|
|
|
238
|
-
|
|
239
|
-
bool operator () (const Ref<PredictionContext> &lhs, const Ref<PredictionContext> &rhs) const
|
|
240
|
-
{
|
|
241
|
-
if (lhs == rhs) // Object identity.
|
|
242
|
-
return true;
|
|
243
|
-
return (lhs->hashCode() == rhs->hashCode()) && (*lhs == *rhs);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
170
|
+
PredictionContextType getContextType() const { return _contextType; }
|
|
246
171
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
Ref<PredictionContext> const& value);
|
|
251
|
-
Ref<PredictionContext> get(Ref<PredictionContext> const& key1, Ref<PredictionContext> const& key2);
|
|
172
|
+
virtual size_t size() const = 0;
|
|
173
|
+
virtual const Ref<const PredictionContext>& getParent(size_t index) const = 0;
|
|
174
|
+
virtual size_t getReturnState(size_t index) const = 0;
|
|
252
175
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
176
|
+
/// This means only the EMPTY (wildcard? not sure) context is in set.
|
|
177
|
+
virtual bool isEmpty() const = 0;
|
|
178
|
+
bool hasEmptyPath() const;
|
|
256
179
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
PredictionContextHasher, PredictionContextComparer> _data;
|
|
180
|
+
size_t hashCode() const;
|
|
181
|
+
|
|
182
|
+
virtual bool equals(const PredictionContext &other) const = 0;
|
|
261
183
|
|
|
184
|
+
virtual std::string toString() const = 0;
|
|
185
|
+
|
|
186
|
+
std::vector<std::string> toStrings(Recognizer *recognizer, int currentState) const;
|
|
187
|
+
std::vector<std::string> toStrings(Recognizer *recognizer,
|
|
188
|
+
const Ref<const PredictionContext> &stop,
|
|
189
|
+
int currentState) const;
|
|
190
|
+
|
|
191
|
+
protected:
|
|
192
|
+
explicit PredictionContext(PredictionContextType contextType);
|
|
193
|
+
|
|
194
|
+
PredictionContext(PredictionContext&& other);
|
|
195
|
+
|
|
196
|
+
virtual size_t hashCodeImpl() const = 0;
|
|
197
|
+
|
|
198
|
+
size_t cachedHashCode() const { return _hashCode.load(std::memory_order_relaxed); }
|
|
199
|
+
|
|
200
|
+
private:
|
|
201
|
+
const PredictionContextType _contextType;
|
|
202
|
+
mutable std::atomic<size_t> _hashCode;
|
|
262
203
|
};
|
|
263
204
|
|
|
264
|
-
|
|
265
|
-
|
|
205
|
+
inline bool operator==(const PredictionContext &lhs, const PredictionContext &rhs) {
|
|
206
|
+
return lhs.equals(rhs);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
inline bool operator!=(const PredictionContext &lhs, const PredictionContext &rhs) {
|
|
210
|
+
return !operator==(lhs, rhs);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
} // namespace atn
|
|
214
|
+
} // namespace antlr4
|
|
215
|
+
|
|
216
|
+
namespace std {
|
|
217
|
+
|
|
218
|
+
template <>
|
|
219
|
+
struct hash<::antlr4::atn::PredictionContext> {
|
|
220
|
+
size_t operator()(const ::antlr4::atn::PredictionContext &predictionContext) const {
|
|
221
|
+
return predictionContext.hashCode();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
266
224
|
|
|
225
|
+
} // namespace std
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright 2012-2022 The ANTLR Project
|
|
2
|
+
//
|
|
3
|
+
// Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
4
|
+
// provided that the following conditions are met:
|
|
5
|
+
//
|
|
6
|
+
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
7
|
+
// and the following disclaimer.
|
|
8
|
+
//
|
|
9
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
|
10
|
+
// conditions and the following disclaimer in the documentation and/or other materials provided
|
|
11
|
+
// with the distribution.
|
|
12
|
+
//
|
|
13
|
+
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to
|
|
14
|
+
// endorse or promote products derived from this software without specific prior written
|
|
15
|
+
// permission.
|
|
16
|
+
//
|
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
|
18
|
+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
20
|
+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21
|
+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
22
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
23
|
+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
|
24
|
+
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
#include "atn/PredictionContextCache.h"
|
|
27
|
+
|
|
28
|
+
using namespace antlr4::atn;
|
|
29
|
+
|
|
30
|
+
void PredictionContextCache::put(const Ref<const PredictionContext> &value) {
|
|
31
|
+
assert(value);
|
|
32
|
+
|
|
33
|
+
_data.insert(value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Ref<const PredictionContext> PredictionContextCache::get(
|
|
37
|
+
const Ref<const PredictionContext> &value) const {
|
|
38
|
+
assert(value);
|
|
39
|
+
|
|
40
|
+
auto iterator = _data.find(value);
|
|
41
|
+
if (iterator == _data.end()) {
|
|
42
|
+
return nullptr;
|
|
43
|
+
}
|
|
44
|
+
return *iterator;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
size_t PredictionContextCache::PredictionContextHasher::operator()(
|
|
48
|
+
const Ref<const PredictionContext> &predictionContext) const {
|
|
49
|
+
return predictionContext->hashCode();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
bool PredictionContextCache::PredictionContextComparer::operator()(
|
|
53
|
+
const Ref<const PredictionContext> &lhs,
|
|
54
|
+
const Ref<const PredictionContext> &rhs) const {
|
|
55
|
+
return *lhs == *rhs;
|
|
56
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright 2012-2022 The ANTLR Project
|
|
2
|
+
//
|
|
3
|
+
// Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
4
|
+
// provided that the following conditions are met:
|
|
5
|
+
//
|
|
6
|
+
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
7
|
+
// and the following disclaimer.
|
|
8
|
+
//
|
|
9
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
|
10
|
+
// conditions and the following disclaimer in the documentation and/or other materials provided
|
|
11
|
+
// with the distribution.
|
|
12
|
+
//
|
|
13
|
+
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to
|
|
14
|
+
// endorse or promote products derived from this software without specific prior written
|
|
15
|
+
// permission.
|
|
16
|
+
//
|
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
|
18
|
+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
20
|
+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21
|
+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
22
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
23
|
+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
|
24
|
+
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include <unordered_set>
|
|
29
|
+
|
|
30
|
+
#include "atn/PredictionContext.h"
|
|
31
|
+
|
|
32
|
+
namespace antlr4 {
|
|
33
|
+
namespace atn {
|
|
34
|
+
|
|
35
|
+
class ANTLR4CPP_PUBLIC PredictionContextCache final {
|
|
36
|
+
public:
|
|
37
|
+
PredictionContextCache() = default;
|
|
38
|
+
|
|
39
|
+
PredictionContextCache(const PredictionContextCache&) = delete;
|
|
40
|
+
PredictionContextCache(PredictionContextCache&&) = delete;
|
|
41
|
+
|
|
42
|
+
PredictionContextCache& operator=(const PredictionContextCache&) = delete;
|
|
43
|
+
PredictionContextCache& operator=(PredictionContextCache&&) = delete;
|
|
44
|
+
|
|
45
|
+
void put(const Ref<const PredictionContext> &value);
|
|
46
|
+
|
|
47
|
+
Ref<const PredictionContext> get(const Ref<const PredictionContext> &value) const;
|
|
48
|
+
|
|
49
|
+
private:
|
|
50
|
+
struct ANTLR4CPP_PUBLIC PredictionContextHasher final {
|
|
51
|
+
size_t operator()(const Ref<const PredictionContext> &predictionContext) const;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
struct ANTLR4CPP_PUBLIC PredictionContextComparer final {
|
|
55
|
+
bool operator()(const Ref<const PredictionContext> &lhs,
|
|
56
|
+
const Ref<const PredictionContext> &rhs) const;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
std::unordered_set<Ref<const PredictionContext>,
|
|
60
|
+
PredictionContextHasher, PredictionContextComparer> _data;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
} // namespace atn
|
|
64
|
+
} // namespace antlr4
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// Copyright 2012-2022 The ANTLR Project
|
|
2
|
+
//
|
|
3
|
+
// Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
4
|
+
// provided that the following conditions are met:
|
|
5
|
+
//
|
|
6
|
+
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
7
|
+
// and the following disclaimer.
|
|
8
|
+
//
|
|
9
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
|
10
|
+
// conditions and the following disclaimer in the documentation and/or other materials provided
|
|
11
|
+
// with the distribution.
|
|
12
|
+
//
|
|
13
|
+
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to
|
|
14
|
+
// endorse or promote products derived from this software without specific prior written
|
|
15
|
+
// permission.
|
|
16
|
+
//
|
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
|
18
|
+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
20
|
+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21
|
+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
22
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
23
|
+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
|
24
|
+
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
#include "atn/PredictionContextMergeCache.h"
|
|
27
|
+
|
|
28
|
+
#include "misc/MurmurHash.h"
|
|
29
|
+
|
|
30
|
+
using namespace antlr4::atn;
|
|
31
|
+
using namespace antlr4::misc;
|
|
32
|
+
|
|
33
|
+
PredictionContextMergeCache::PredictionContextMergeCache(
|
|
34
|
+
const PredictionContextMergeCacheOptions &options) : _options(options) {}
|
|
35
|
+
|
|
36
|
+
Ref<const PredictionContext> PredictionContextMergeCache::put(
|
|
37
|
+
const Ref<const PredictionContext> &key1,
|
|
38
|
+
const Ref<const PredictionContext> &key2,
|
|
39
|
+
Ref<const PredictionContext> value) {
|
|
40
|
+
assert(key1);
|
|
41
|
+
assert(key2);
|
|
42
|
+
|
|
43
|
+
if (getOptions().getMaxSize() == 0) {
|
|
44
|
+
// Cache is effectively disabled.
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
auto [existing, inserted] = _entries.try_emplace(std::make_pair(key1.get(), key2.get()));
|
|
49
|
+
if (inserted) {
|
|
50
|
+
try {
|
|
51
|
+
existing->second.reset(new Entry());
|
|
52
|
+
} catch (...) {
|
|
53
|
+
_entries.erase(existing);
|
|
54
|
+
throw;
|
|
55
|
+
}
|
|
56
|
+
existing->second->key = std::make_pair(key1, key2);
|
|
57
|
+
existing->second->value = std::move(value);
|
|
58
|
+
pushToFront(existing->second.get());
|
|
59
|
+
} else {
|
|
60
|
+
if (existing->second->value != value) {
|
|
61
|
+
existing->second->value = std::move(value);
|
|
62
|
+
}
|
|
63
|
+
moveToFront(existing->second.get());
|
|
64
|
+
}
|
|
65
|
+
compact(existing->second.get());
|
|
66
|
+
return existing->second->value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Ref<const PredictionContext> PredictionContextMergeCache::get(
|
|
70
|
+
const Ref<const PredictionContext> &key1,
|
|
71
|
+
const Ref<const PredictionContext> &key2) const {
|
|
72
|
+
assert(key1);
|
|
73
|
+
assert(key2);
|
|
74
|
+
|
|
75
|
+
if (getOptions().getMaxSize() == 0) {
|
|
76
|
+
// Cache is effectively disabled.
|
|
77
|
+
return nullptr;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
auto iterator = _entries.find(std::make_pair(key1.get(), key2.get()));
|
|
81
|
+
if (iterator == _entries.end()) {
|
|
82
|
+
return nullptr;
|
|
83
|
+
}
|
|
84
|
+
moveToFront(iterator->second.get());
|
|
85
|
+
return iterator->second->value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
void PredictionContextMergeCache::clear() {
|
|
89
|
+
Container().swap(_entries);
|
|
90
|
+
_head = _tail = nullptr;
|
|
91
|
+
_size = 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
void PredictionContextMergeCache::moveToFront(Entry *entry) const {
|
|
95
|
+
if (entry->prev == nullptr) {
|
|
96
|
+
assert(entry == _head);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
entry->prev->next = entry->next;
|
|
100
|
+
if (entry->next != nullptr) {
|
|
101
|
+
entry->next->prev = entry->prev;
|
|
102
|
+
} else {
|
|
103
|
+
assert(entry == _tail);
|
|
104
|
+
_tail = entry->prev;
|
|
105
|
+
}
|
|
106
|
+
entry->prev = nullptr;
|
|
107
|
+
entry->next = _head;
|
|
108
|
+
_head->prev = entry;
|
|
109
|
+
_head = entry;
|
|
110
|
+
assert(entry->prev == nullptr);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void PredictionContextMergeCache::pushToFront(Entry *entry) {
|
|
114
|
+
++_size;
|
|
115
|
+
entry->prev = nullptr;
|
|
116
|
+
entry->next = _head;
|
|
117
|
+
if (_head != nullptr) {
|
|
118
|
+
_head->prev = entry;
|
|
119
|
+
_head = entry;
|
|
120
|
+
} else {
|
|
121
|
+
assert(entry->next == nullptr);
|
|
122
|
+
_head = entry;
|
|
123
|
+
_tail = entry;
|
|
124
|
+
}
|
|
125
|
+
assert(entry->prev == nullptr);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
void PredictionContextMergeCache::remove(Entry *entry) {
|
|
129
|
+
if (entry->prev != nullptr) {
|
|
130
|
+
entry->prev->next = entry->next;
|
|
131
|
+
} else {
|
|
132
|
+
assert(entry == _head);
|
|
133
|
+
_head = entry->next;
|
|
134
|
+
}
|
|
135
|
+
if (entry->next != nullptr) {
|
|
136
|
+
entry->next->prev = entry->prev;
|
|
137
|
+
} else {
|
|
138
|
+
assert(entry == _tail);
|
|
139
|
+
_tail = entry->prev;
|
|
140
|
+
}
|
|
141
|
+
--_size;
|
|
142
|
+
_entries.erase(std::make_pair(entry->key.first.get(), entry->key.second.get()));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
void PredictionContextMergeCache::compact(const Entry *preserve) {
|
|
146
|
+
Entry *entry = _tail;
|
|
147
|
+
while (entry != nullptr && _size > getOptions().getMaxSize()) {
|
|
148
|
+
Entry *next = entry->prev;
|
|
149
|
+
if (entry != preserve) {
|
|
150
|
+
remove(entry);
|
|
151
|
+
}
|
|
152
|
+
entry = next;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
size_t PredictionContextMergeCache::PredictionContextHasher::operator()(
|
|
157
|
+
const PredictionContextPair &value) const {
|
|
158
|
+
size_t hash = MurmurHash::initialize();
|
|
159
|
+
hash = MurmurHash::update(hash, value.first->hashCode());
|
|
160
|
+
hash = MurmurHash::update(hash, value.second->hashCode());
|
|
161
|
+
return MurmurHash::finish(hash, 2);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
bool PredictionContextMergeCache::PredictionContextComparer::operator()(
|
|
165
|
+
const PredictionContextPair &lhs, const PredictionContextPair &rhs) const {
|
|
166
|
+
return *lhs.first == *rhs.first && *lhs.second == *rhs.second;
|
|
167
|
+
}
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright 2012-2022 The ANTLR Project
|
|
2
|
+
//
|
|
3
|
+
// Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
4
|
+
// provided that the following conditions are met:
|
|
5
|
+
//
|
|
6
|
+
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
7
|
+
// and the following disclaimer.
|
|
8
|
+
//
|
|
9
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
|
10
|
+
// conditions and the following disclaimer in the documentation and/or other materials provided
|
|
11
|
+
// with the distribution.
|
|
12
|
+
//
|
|
13
|
+
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to
|
|
14
|
+
// endorse or promote products derived from this software without specific prior written
|
|
15
|
+
// permission.
|
|
16
|
+
//
|
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
|
18
|
+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
20
|
+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21
|
+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
22
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
23
|
+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
|
24
|
+
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include <unordered_map>
|
|
29
|
+
#include <utility>
|
|
30
|
+
|
|
31
|
+
#include "atn/PredictionContext.h"
|
|
32
|
+
#include "atn/PredictionContextMergeCacheOptions.h"
|
|
33
|
+
|
|
34
|
+
namespace antlr4 {
|
|
35
|
+
namespace atn {
|
|
36
|
+
|
|
37
|
+
class ANTLR4CPP_PUBLIC PredictionContextMergeCache final {
|
|
38
|
+
public:
|
|
39
|
+
PredictionContextMergeCache()
|
|
40
|
+
: PredictionContextMergeCache(PredictionContextMergeCacheOptions()) {}
|
|
41
|
+
|
|
42
|
+
explicit PredictionContextMergeCache(const PredictionContextMergeCacheOptions &options);
|
|
43
|
+
|
|
44
|
+
PredictionContextMergeCache(const PredictionContextMergeCache&) = delete;
|
|
45
|
+
PredictionContextMergeCache(PredictionContextMergeCache&&) = delete;
|
|
46
|
+
|
|
47
|
+
PredictionContextMergeCache& operator=(const PredictionContextMergeCache&) = delete;
|
|
48
|
+
PredictionContextMergeCache& operator=(PredictionContextMergeCache&&) = delete;
|
|
49
|
+
|
|
50
|
+
Ref<const PredictionContext> put(const Ref<const PredictionContext> &key1,
|
|
51
|
+
const Ref<const PredictionContext> &key2,
|
|
52
|
+
Ref<const PredictionContext> value);
|
|
53
|
+
|
|
54
|
+
Ref<const PredictionContext> get(const Ref<const PredictionContext> &key1,
|
|
55
|
+
const Ref<const PredictionContext> &key2) const;
|
|
56
|
+
|
|
57
|
+
const PredictionContextMergeCacheOptions& getOptions() const { return _options; }
|
|
58
|
+
|
|
59
|
+
void clear();
|
|
60
|
+
|
|
61
|
+
private:
|
|
62
|
+
using PredictionContextPair = std::pair<const PredictionContext*, const PredictionContext*>;
|
|
63
|
+
|
|
64
|
+
struct ANTLR4CPP_PUBLIC PredictionContextHasher final {
|
|
65
|
+
size_t operator()(const PredictionContextPair &value) const;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
struct ANTLR4CPP_PUBLIC PredictionContextComparer final {
|
|
69
|
+
bool operator()(const PredictionContextPair &lhs, const PredictionContextPair &rhs) const;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
struct ANTLR4CPP_PUBLIC Entry final {
|
|
73
|
+
std::pair<Ref<const PredictionContext>, Ref<const PredictionContext>> key;
|
|
74
|
+
Ref<const PredictionContext> value;
|
|
75
|
+
Entry *prev = nullptr;
|
|
76
|
+
Entry *next = nullptr;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
void moveToFront(Entry *entry) const;
|
|
80
|
+
|
|
81
|
+
void pushToFront(Entry *entry);
|
|
82
|
+
|
|
83
|
+
void remove(Entry *entry);
|
|
84
|
+
|
|
85
|
+
void compact(const Entry *preserve);
|
|
86
|
+
|
|
87
|
+
using Container = std::unordered_map<PredictionContextPair, std::unique_ptr<Entry>,
|
|
88
|
+
PredictionContextHasher, PredictionContextComparer>;
|
|
89
|
+
|
|
90
|
+
const PredictionContextMergeCacheOptions _options;
|
|
91
|
+
|
|
92
|
+
Container _entries;
|
|
93
|
+
|
|
94
|
+
mutable Entry *_head = nullptr;
|
|
95
|
+
mutable Entry *_tail = nullptr;
|
|
96
|
+
|
|
97
|
+
size_t _size = 0;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
} // namespace atn
|
|
101
|
+
} // namespace antlr4
|