expressir 1.2.3 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +223 -31
- data/.gitignore +7 -1
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- data/README.adoc +8 -0
- data/Rakefile +4 -1
- data/bin/console +0 -1
- data/bin/rspec +3 -3
- data/exe/expressir +4 -2
- data/exe/format +1 -1
- data/exe/format-test +25 -25
- data/exe/generate-parser +16 -13
- data/expressir.gemspec +11 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +19 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +51 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +1 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +9 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +43 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +16 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +2 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +9 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +51 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +20 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +21 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +12 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +7 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -58
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +6 -57
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +35 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +29 -36
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +36 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -464
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -62
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +42 -36
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -108
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +10 -43
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +17 -28
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +169 -152
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +87 -116
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +11 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +2 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +15 -28
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +35 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +13 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -40
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +14 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +30 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
- data/ext/express-parser/antlrgen/Express.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
- data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
- data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
- data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
- data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
- data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
- data/ext/express-parser/express_parser.cpp +165 -101
- data/ext/express-parser/extconf.rb +14 -14
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +17 -15
- data/lib/expressir/express/visitor.rb +7 -3
- data/lib/expressir/model.rb +78 -78
- data/lib/expressir/version.rb +1 -1
- data/rakelib/antlr4-native.rake +161 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +17 -2
- data/spec/expressir/express/cache_spec.rb +23 -5
- data/spec/expressir/express/formatter_spec.rb +54 -8
- data/spec/expressir/express/parser_spec.rb +47 -11
- data/spec/expressir/model/model_element_spec.rb +198 -146
- data/spec/spec_helper.rb +7 -0
- metadata +79 -91
- data/demo.rb +0 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
- data/original/examples/employment/eclipse/.project +0 -17
- data/original/examples/employment/eclipse/Export/Employment.png +0 -0
- data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
- data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
- data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
- data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
- data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
- data/original/examples/employment/eclipse/readme.txt +0 -7
- data/original/examples/employment/employment_schema.exp +0 -33
- data/original/examples/employment/employment_schema.rb +0 -232
- data/original/examples/employment/employment_schema.xml +0 -93
- data/original/examples/employment/employment_schema___module.rb +0 -46
- data/original/examples/employment/employment_schema___p28attr.rb +0 -126
- data/original/examples/employment/employment_schema___p28inst.rb +0 -26
- data/original/examples/employment/example_employment_data.xml +0 -1
- data/original/examples/employment/example_employment_data_copy.xml +0 -1
- data/original/examples/employment/example_employment_reader.rb +0 -30
- data/original/examples/employment/example_employment_writer.rb +0 -51
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
- data/original/exp2ruby.rb +0 -525
- data/original/expsm.rb +0 -34
- data/original/mapping_owl.rb +0 -1018
- data/original/mapping_sysml.rb +0 -2281
- data/original/mapping_uml2.rb +0 -599
- data/original/mapping_uml2_eclipse.rb +0 -433
- data/original/reeper.rb +0 -134
- data/spec/expressr_spec.rb +0 -5
@@ -15,26 +15,31 @@
|
|
15
15
|
using namespace antlr4::atn;
|
16
16
|
using namespace antlrcpp;
|
17
17
|
|
18
|
-
|
19
|
-
InitializeInstanceFields();
|
20
|
-
}
|
18
|
+
namespace {
|
21
19
|
|
22
|
-
ATNConfigSet::ATNConfigSet(const Ref<ATNConfigSet> &old) : ATNConfigSet(old->fullCtx) {
|
23
|
-
addAll(old);
|
24
|
-
uniqueAlt = old->uniqueAlt;
|
25
|
-
conflictingAlts = old->conflictingAlts;
|
26
|
-
hasSemanticContext = old->hasSemanticContext;
|
27
|
-
dipsIntoOuterContext = old->dipsIntoOuterContext;
|
28
20
|
}
|
29
21
|
|
30
|
-
ATNConfigSet
|
22
|
+
ATNConfigSet::ATNConfigSet() : ATNConfigSet(true) {}
|
23
|
+
|
24
|
+
ATNConfigSet::ATNConfigSet(const ATNConfigSet &other)
|
25
|
+
: fullCtx(other.fullCtx), _configLookup(other._configLookup.bucket_count(), ATNConfigHasher{this}, ATNConfigComparer{this}) {
|
26
|
+
addAll(other);
|
27
|
+
uniqueAlt = other.uniqueAlt;
|
28
|
+
conflictingAlts = other.conflictingAlts;
|
29
|
+
hasSemanticContext = other.hasSemanticContext;
|
30
|
+
dipsIntoOuterContext = other.dipsIntoOuterContext;
|
31
31
|
}
|
32
32
|
|
33
|
+
ATNConfigSet::ATNConfigSet(bool fullCtx)
|
34
|
+
: fullCtx(fullCtx), _configLookup(0, ATNConfigHasher{this}, ATNConfigComparer{this}) {}
|
35
|
+
|
33
36
|
bool ATNConfigSet::add(const Ref<ATNConfig> &config) {
|
34
37
|
return add(config, nullptr);
|
35
38
|
}
|
36
39
|
|
37
40
|
bool ATNConfigSet::add(const Ref<ATNConfig> &config, PredictionContextMergeCache *mergeCache) {
|
41
|
+
assert(config);
|
42
|
+
|
38
43
|
if (_readonly) {
|
39
44
|
throw IllegalStateException("This set is readonly");
|
40
45
|
}
|
@@ -45,10 +50,9 @@ bool ATNConfigSet::add(const Ref<ATNConfig> &config, PredictionContextMergeCache
|
|
45
50
|
dipsIntoOuterContext = true;
|
46
51
|
}
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
_configLookup[hash] = config.get();
|
53
|
+
auto existing = _configLookup.find(config.get());
|
54
|
+
if (existing == _configLookup.end()) {
|
55
|
+
_configLookup.insert(config.get());
|
52
56
|
_cachedHashCode = 0;
|
53
57
|
configs.push_back(config); // track order here
|
54
58
|
|
@@ -57,32 +61,33 @@ bool ATNConfigSet::add(const Ref<ATNConfig> &config, PredictionContextMergeCache
|
|
57
61
|
|
58
62
|
// a previous (s,i,pi,_), merge with it and save result
|
59
63
|
bool rootIsWildcard = !fullCtx;
|
60
|
-
Ref<PredictionContext> merged = PredictionContext::merge(existing->context, config->context, rootIsWildcard, mergeCache);
|
64
|
+
Ref<const PredictionContext> merged = PredictionContext::merge((*existing)->context, config->context, rootIsWildcard, mergeCache);
|
61
65
|
// no need to check for existing.context, config.context in cache
|
62
66
|
// since only way to create new graphs is "call rule" and here. We
|
63
67
|
// cache at both places.
|
64
|
-
existing->reachesIntoOuterContext = std::max(existing->reachesIntoOuterContext, config->reachesIntoOuterContext);
|
68
|
+
(*existing)->reachesIntoOuterContext = std::max((*existing)->reachesIntoOuterContext, config->reachesIntoOuterContext);
|
65
69
|
|
66
70
|
// make sure to preserve the precedence filter suppression during the merge
|
67
71
|
if (config->isPrecedenceFilterSuppressed()) {
|
68
|
-
existing->setPrecedenceFilterSuppressed(true);
|
72
|
+
(*existing)->setPrecedenceFilterSuppressed(true);
|
69
73
|
}
|
70
74
|
|
71
|
-
existing->context = merged; // replace context; no need to alt mapping
|
75
|
+
(*existing)->context = std::move(merged); // replace context; no need to alt mapping
|
72
76
|
|
73
77
|
return true;
|
74
78
|
}
|
75
79
|
|
76
|
-
bool ATNConfigSet::addAll(const
|
77
|
-
for (auto &c : other
|
80
|
+
bool ATNConfigSet::addAll(const ATNConfigSet &other) {
|
81
|
+
for (const auto &c : other.configs) {
|
78
82
|
add(c);
|
79
83
|
}
|
80
84
|
return false;
|
81
85
|
}
|
82
86
|
|
83
|
-
std::vector<ATNState*> ATNConfigSet::getStates() {
|
87
|
+
std::vector<ATNState*> ATNConfigSet::getStates() const {
|
84
88
|
std::vector<ATNState*> states;
|
85
|
-
|
89
|
+
states.reserve(configs.size());
|
90
|
+
for (const auto &c : configs) {
|
86
91
|
states.push_back(c->state);
|
87
92
|
}
|
88
93
|
return states;
|
@@ -97,17 +102,18 @@ std::vector<ATNState*> ATNConfigSet::getStates() {
|
|
97
102
|
* @since 4.3
|
98
103
|
*/
|
99
104
|
|
100
|
-
BitSet ATNConfigSet::getAlts() {
|
105
|
+
BitSet ATNConfigSet::getAlts() const {
|
101
106
|
BitSet alts;
|
102
|
-
for (
|
103
|
-
alts.set(config
|
107
|
+
for (const auto &config : configs) {
|
108
|
+
alts.set(config->alt);
|
104
109
|
}
|
105
110
|
return alts;
|
106
111
|
}
|
107
112
|
|
108
|
-
std::vector<Ref<SemanticContext>> ATNConfigSet::getPredicates() {
|
109
|
-
std::vector<Ref<SemanticContext>> preds;
|
110
|
-
|
113
|
+
std::vector<Ref<const SemanticContext>> ATNConfigSet::getPredicates() const {
|
114
|
+
std::vector<Ref<const SemanticContext>> preds;
|
115
|
+
preds.reserve(configs.size());
|
116
|
+
for (const auto &c : configs) {
|
111
117
|
if (c->semanticContext != SemanticContext::NONE) {
|
112
118
|
preds.push_back(c->semanticContext);
|
113
119
|
}
|
@@ -115,23 +121,25 @@ std::vector<Ref<SemanticContext>> ATNConfigSet::getPredicates() {
|
|
115
121
|
return preds;
|
116
122
|
}
|
117
123
|
|
118
|
-
Ref<ATNConfig
|
124
|
+
const Ref<ATNConfig>& ATNConfigSet::get(size_t i) const {
|
119
125
|
return configs[i];
|
120
126
|
}
|
121
127
|
|
122
128
|
void ATNConfigSet::optimizeConfigs(ATNSimulator *interpreter) {
|
129
|
+
assert(interpreter);
|
130
|
+
|
123
131
|
if (_readonly) {
|
124
132
|
throw IllegalStateException("This set is readonly");
|
125
133
|
}
|
126
134
|
if (_configLookup.empty())
|
127
135
|
return;
|
128
136
|
|
129
|
-
for (auto &config : configs) {
|
137
|
+
for (const auto &config : configs) {
|
130
138
|
config->context = interpreter->getCachedContext(config->context);
|
131
139
|
}
|
132
140
|
}
|
133
141
|
|
134
|
-
bool ATNConfigSet::
|
142
|
+
bool ATNConfigSet::equals(const ATNConfigSet &other) const {
|
135
143
|
if (&other == this) {
|
136
144
|
return true;
|
137
145
|
}
|
@@ -147,22 +155,23 @@ bool ATNConfigSet::operator == (const ATNConfigSet &other) {
|
|
147
155
|
return Arrays::equals(configs, other.configs);
|
148
156
|
}
|
149
157
|
|
150
|
-
size_t ATNConfigSet::hashCode() {
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
158
|
+
size_t ATNConfigSet::hashCode() const {
|
159
|
+
size_t cachedHashCode = _cachedHashCode.load(std::memory_order_relaxed);
|
160
|
+
if (!isReadonly() || cachedHashCode == 0) {
|
161
|
+
cachedHashCode = 1;
|
162
|
+
for (const auto &i : configs) {
|
163
|
+
cachedHashCode = 31 * cachedHashCode + i->hashCode(); // Same as Java's list hashCode impl.
|
155
164
|
}
|
165
|
+
_cachedHashCode.store(cachedHashCode, std::memory_order_relaxed);
|
156
166
|
}
|
157
|
-
|
158
|
-
return _cachedHashCode;
|
167
|
+
return cachedHashCode;
|
159
168
|
}
|
160
169
|
|
161
|
-
size_t ATNConfigSet::size() {
|
170
|
+
size_t ATNConfigSet::size() const {
|
162
171
|
return configs.size();
|
163
172
|
}
|
164
173
|
|
165
|
-
bool ATNConfigSet::isEmpty() {
|
174
|
+
bool ATNConfigSet::isEmpty() const {
|
166
175
|
return configs.empty();
|
167
176
|
}
|
168
177
|
|
@@ -175,16 +184,16 @@ void ATNConfigSet::clear() {
|
|
175
184
|
_configLookup.clear();
|
176
185
|
}
|
177
186
|
|
178
|
-
bool ATNConfigSet::isReadonly() {
|
187
|
+
bool ATNConfigSet::isReadonly() const {
|
179
188
|
return _readonly;
|
180
189
|
}
|
181
190
|
|
182
191
|
void ATNConfigSet::setReadonly(bool readonly) {
|
183
192
|
_readonly = readonly;
|
184
|
-
|
193
|
+
LookupContainer(0, ATNConfigHasher{this}, ATNConfigComparer{this}).swap(_configLookup);
|
185
194
|
}
|
186
195
|
|
187
|
-
std::string ATNConfigSet::toString() {
|
196
|
+
std::string ATNConfigSet::toString() const {
|
188
197
|
std::stringstream ss;
|
189
198
|
ss << "[";
|
190
199
|
for (size_t i = 0; i < configs.size(); i++) {
|
@@ -210,19 +219,14 @@ std::string ATNConfigSet::toString() {
|
|
210
219
|
return ss.str();
|
211
220
|
}
|
212
221
|
|
213
|
-
size_t ATNConfigSet::
|
222
|
+
size_t ATNConfigSet::hashCode(const ATNConfig &other) const {
|
214
223
|
size_t hashCode = 7;
|
215
|
-
hashCode = 31 * hashCode +
|
216
|
-
hashCode = 31 * hashCode +
|
217
|
-
hashCode = 31 * hashCode +
|
224
|
+
hashCode = 31 * hashCode + other.state->stateNumber;
|
225
|
+
hashCode = 31 * hashCode + other.alt;
|
226
|
+
hashCode = 31 * hashCode + other.semanticContext->hashCode();
|
218
227
|
return hashCode;
|
219
228
|
}
|
220
229
|
|
221
|
-
|
222
|
-
|
223
|
-
hasSemanticContext = false;
|
224
|
-
dipsIntoOuterContext = false;
|
225
|
-
|
226
|
-
_readonly = false;
|
227
|
-
_cachedHashCode = 0;
|
230
|
+
bool ATNConfigSet::equals(const ATNConfig &lhs, const ATNConfig &rhs) const {
|
231
|
+
return lhs.state->stateNumber == rhs.state->stateNumber && lhs.alt == rhs.alt && *lhs.semanticContext == *rhs.semanticContext;
|
228
232
|
}
|
@@ -5,8 +5,11 @@
|
|
5
5
|
|
6
6
|
#pragma once
|
7
7
|
|
8
|
+
#include <cassert>
|
9
|
+
|
8
10
|
#include "support/BitSet.h"
|
9
11
|
#include "atn/PredictionContext.h"
|
12
|
+
#include "atn/ATNConfig.h"
|
10
13
|
|
11
14
|
namespace antlr4 {
|
12
15
|
namespace atn {
|
@@ -20,7 +23,7 @@ namespace atn {
|
|
20
23
|
|
21
24
|
// TODO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation
|
22
25
|
// TODO: can we track conflicts as they are added to save scanning configs later?
|
23
|
-
size_t uniqueAlt;
|
26
|
+
size_t uniqueAlt = 0;
|
24
27
|
|
25
28
|
/** Currently this is only used when we detect SLL conflict; this does
|
26
29
|
* not necessarily represent the ambiguous alternatives. In fact,
|
@@ -31,20 +34,25 @@ namespace atn {
|
|
31
34
|
|
32
35
|
// Used in parser and lexer. In lexer, it indicates we hit a pred
|
33
36
|
// while computing a closure operation. Don't make a DFA state from this.
|
34
|
-
bool hasSemanticContext;
|
35
|
-
bool dipsIntoOuterContext;
|
37
|
+
bool hasSemanticContext = false;
|
38
|
+
bool dipsIntoOuterContext = false;
|
36
39
|
|
37
40
|
/// Indicates that this configuration set is part of a full context
|
38
41
|
/// LL prediction. It will be used to determine how to merge $. With SLL
|
39
42
|
/// it's a wildcard whereas it is not for LL context merge.
|
40
|
-
const bool fullCtx;
|
43
|
+
const bool fullCtx = true;
|
44
|
+
|
45
|
+
ATNConfigSet();
|
46
|
+
|
47
|
+
ATNConfigSet(const ATNConfigSet &other);
|
41
48
|
|
42
|
-
ATNConfigSet(
|
43
|
-
ATNConfigSet(const Ref<ATNConfigSet> &old);
|
49
|
+
ATNConfigSet(ATNConfigSet&&) = delete;
|
44
50
|
|
45
|
-
|
51
|
+
explicit ATNConfigSet(bool fullCtx);
|
46
52
|
|
47
|
-
virtual
|
53
|
+
virtual ~ATNConfigSet() = default;
|
54
|
+
|
55
|
+
bool add(const Ref<ATNConfig> &config);
|
48
56
|
|
49
57
|
/// <summary>
|
50
58
|
/// Adding a new config means merging contexts with existing configs for
|
@@ -56,9 +64,11 @@ namespace atn {
|
|
56
64
|
/// This method updates <seealso cref="#dipsIntoOuterContext"/> and
|
57
65
|
/// <seealso cref="#hasSemanticContext"/> when necessary.
|
58
66
|
/// </summary>
|
59
|
-
|
67
|
+
bool add(const Ref<ATNConfig> &config, PredictionContextMergeCache *mergeCache);
|
68
|
+
|
69
|
+
bool addAll(const ATNConfigSet &other);
|
60
70
|
|
61
|
-
|
71
|
+
std::vector<ATNState*> getStates() const;
|
62
72
|
|
63
73
|
/**
|
64
74
|
* Gets the complete set of represented alternatives for the configuration
|
@@ -68,43 +78,79 @@ namespace atn {
|
|
68
78
|
*
|
69
79
|
* @since 4.3
|
70
80
|
*/
|
71
|
-
antlrcpp::BitSet getAlts();
|
72
|
-
|
81
|
+
antlrcpp::BitSet getAlts() const;
|
82
|
+
std::vector<Ref<const SemanticContext>> getPredicates() const;
|
83
|
+
|
84
|
+
const Ref<ATNConfig>& get(size_t i) const;
|
73
85
|
|
74
|
-
|
86
|
+
void optimizeConfigs(ATNSimulator *interpreter);
|
75
87
|
|
76
|
-
|
88
|
+
size_t size() const;
|
89
|
+
bool isEmpty() const;
|
90
|
+
void clear();
|
91
|
+
bool isReadonly() const;
|
92
|
+
void setReadonly(bool readonly);
|
93
|
+
|
94
|
+
virtual size_t hashCode() const;
|
95
|
+
|
96
|
+
virtual bool equals(const ATNConfigSet &other) const;
|
97
|
+
|
98
|
+
virtual std::string toString() const;
|
99
|
+
|
100
|
+
private:
|
101
|
+
struct ATNConfigHasher final {
|
102
|
+
const ATNConfigSet* atnConfigSet;
|
77
103
|
|
78
|
-
|
104
|
+
size_t operator()(const ATNConfig *other) const {
|
105
|
+
assert(other != nullptr);
|
106
|
+
return atnConfigSet->hashCode(*other);
|
107
|
+
}
|
108
|
+
};
|
79
109
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
110
|
+
struct ATNConfigComparer final {
|
111
|
+
const ATNConfigSet* atnConfigSet;
|
112
|
+
|
113
|
+
bool operator()(const ATNConfig *lhs, const ATNConfig *rhs) const {
|
114
|
+
assert(lhs != nullptr);
|
115
|
+
assert(rhs != nullptr);
|
116
|
+
return atnConfigSet->equals(*lhs, *rhs);
|
117
|
+
}
|
118
|
+
};
|
119
|
+
|
120
|
+
mutable std::atomic<size_t> _cachedHashCode = 0;
|
88
121
|
|
89
|
-
protected:
|
90
122
|
/// Indicates that the set of configurations is read-only. Do not
|
91
123
|
/// allow any code to manipulate the set; DFA states will point at
|
92
124
|
/// the sets and they must not change. This does not protect the other
|
93
125
|
/// fields; in particular, conflictingAlts is set after
|
94
126
|
/// we've made this readonly.
|
95
|
-
bool _readonly;
|
127
|
+
bool _readonly = false;
|
96
128
|
|
97
|
-
virtual size_t
|
129
|
+
virtual size_t hashCode(const ATNConfig &atnConfig) const;
|
98
130
|
|
99
|
-
|
100
|
-
|
131
|
+
virtual bool equals(const ATNConfig &lhs, const ATNConfig &rhs) const;
|
132
|
+
|
133
|
+
using LookupContainer = std::unordered_set<ATNConfig*, ATNConfigHasher, ATNConfigComparer>;
|
101
134
|
|
102
135
|
/// All configs but hashed by (s, i, _, pi) not including context. Wiped out
|
103
136
|
/// when we go readonly as this set becomes a DFA state.
|
104
|
-
|
105
|
-
|
106
|
-
void InitializeInstanceFields();
|
137
|
+
LookupContainer _configLookup;
|
107
138
|
};
|
108
139
|
|
140
|
+
inline bool operator==(const ATNConfigSet &lhs, const ATNConfigSet &rhs) { return lhs.equals(rhs); }
|
141
|
+
|
142
|
+
inline bool operator!=(const ATNConfigSet &lhs, const ATNConfigSet &rhs) { return !operator==(lhs, rhs); }
|
143
|
+
|
109
144
|
} // namespace atn
|
110
145
|
} // namespace antlr4
|
146
|
+
|
147
|
+
namespace std {
|
148
|
+
|
149
|
+
template <>
|
150
|
+
struct hash<::antlr4::atn::ATNConfigSet> {
|
151
|
+
size_t operator()(const ::antlr4::atn::ATNConfigSet &atnConfigSet) const {
|
152
|
+
return atnConfigSet.hashCode();
|
153
|
+
}
|
154
|
+
};
|
155
|
+
|
156
|
+
} // namespace std
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp
CHANGED
@@ -4,61 +4,51 @@
|
|
4
4
|
*/
|
5
5
|
|
6
6
|
#include "atn/ATNDeserializationOptions.h"
|
7
|
+
#include "Exceptions.h"
|
7
8
|
|
9
|
+
#include <memory>
|
10
|
+
#include <mutex>
|
11
|
+
|
12
|
+
using namespace antlr4;
|
8
13
|
using namespace antlr4::atn;
|
9
14
|
|
10
|
-
|
15
|
+
namespace {
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
}
|
17
|
+
std::once_flag defaultATNDeserializationOptionsOnceFlag;
|
18
|
+
std::unique_ptr<ATNDeserializationOptions> defaultATNDeserializationOptions;
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
this->generateRuleBypassTransitions = options->generateRuleBypassTransitions;
|
20
|
+
void initializeDefaultATNDeserializationOptions() {
|
21
|
+
defaultATNDeserializationOptions.reset(new ATNDeserializationOptions());
|
19
22
|
}
|
20
23
|
|
21
|
-
ATNDeserializationOptions::~ATNDeserializationOptions() {
|
22
24
|
}
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
}
|
26
|
+
ATNDeserializationOptions::ATNDeserializationOptions(ATNDeserializationOptions *options)
|
27
|
+
: _readOnly(false), _verifyATN(options->_verifyATN),
|
28
|
+
_generateRuleBypassTransitions(options->_generateRuleBypassTransitions) {}
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() {
|
31
|
+
std::call_once(defaultATNDeserializationOptionsOnceFlag,
|
32
|
+
initializeDefaultATNDeserializationOptions);
|
33
|
+
return *defaultATNDeserializationOptions;
|
30
34
|
}
|
31
35
|
|
32
36
|
void ATNDeserializationOptions::makeReadOnly() {
|
33
|
-
|
34
|
-
}
|
35
|
-
|
36
|
-
bool ATNDeserializationOptions::isVerifyATN() {
|
37
|
-
return verifyATN;
|
37
|
+
_readOnly = true;
|
38
38
|
}
|
39
39
|
|
40
40
|
void ATNDeserializationOptions::setVerifyATN(bool verify) {
|
41
41
|
throwIfReadOnly();
|
42
|
-
|
43
|
-
}
|
44
|
-
|
45
|
-
bool ATNDeserializationOptions::isGenerateRuleBypassTransitions() {
|
46
|
-
return generateRuleBypassTransitions;
|
42
|
+
_verifyATN = verify;
|
47
43
|
}
|
48
44
|
|
49
45
|
void ATNDeserializationOptions::setGenerateRuleBypassTransitions(bool generate) {
|
50
46
|
throwIfReadOnly();
|
51
|
-
|
47
|
+
_generateRuleBypassTransitions = generate;
|
52
48
|
}
|
53
49
|
|
54
|
-
void ATNDeserializationOptions::throwIfReadOnly() {
|
50
|
+
void ATNDeserializationOptions::throwIfReadOnly() const {
|
55
51
|
if (isReadOnly()) {
|
56
|
-
throw "
|
52
|
+
throw IllegalStateException("ATNDeserializationOptions is read only.");
|
57
53
|
}
|
58
54
|
}
|
59
|
-
|
60
|
-
void ATNDeserializationOptions::InitializeInstanceFields() {
|
61
|
-
readOnly = false;
|
62
|
-
verifyATN = true;
|
63
|
-
generateRuleBypassTransitions = false;
|
64
|
-
}
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h
CHANGED
@@ -10,41 +10,39 @@
|
|
10
10
|
namespace antlr4 {
|
11
11
|
namespace atn {
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
class ANTLR4CPP_PUBLIC ATNDeserializationOptions final {
|
14
|
+
public:
|
15
|
+
ATNDeserializationOptions()
|
16
|
+
: _readOnly(false), _verifyATN(true), _generateRuleBypassTransitions(false) {}
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
bool generateRuleBypassTransitions;
|
18
|
+
// TODO: Is this useful? If so we should mark it as explicit, otherwise remove it.
|
19
|
+
ATNDeserializationOptions(ATNDeserializationOptions *options);
|
20
20
|
|
21
|
-
|
22
|
-
ATNDeserializationOptions();
|
23
|
-
ATNDeserializationOptions(ATNDeserializationOptions *options);
|
24
|
-
ATNDeserializationOptions(ATNDeserializationOptions const&) = default;
|
25
|
-
virtual ~ATNDeserializationOptions();
|
26
|
-
ATNDeserializationOptions& operator=(ATNDeserializationOptions const&) = default;
|
21
|
+
ATNDeserializationOptions(const ATNDeserializationOptions&) = default;
|
27
22
|
|
28
|
-
|
23
|
+
ATNDeserializationOptions& operator=(const ATNDeserializationOptions&) = default;
|
29
24
|
|
30
|
-
|
25
|
+
static const ATNDeserializationOptions& getDefaultOptions();
|
31
26
|
|
32
|
-
|
27
|
+
bool isReadOnly() const { return _readOnly; }
|
33
28
|
|
34
|
-
|
29
|
+
void makeReadOnly();
|
35
30
|
|
36
|
-
|
31
|
+
bool isVerifyATN() const { return _verifyATN; }
|
37
32
|
|
38
|
-
|
33
|
+
void setVerifyATN(bool verify);
|
39
34
|
|
40
|
-
|
35
|
+
bool isGenerateRuleBypassTransitions() const { return _generateRuleBypassTransitions; }
|
41
36
|
|
42
|
-
|
43
|
-
virtual void throwIfReadOnly();
|
37
|
+
void setGenerateRuleBypassTransitions(bool generate);
|
44
38
|
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
private:
|
40
|
+
void throwIfReadOnly() const;
|
41
|
+
|
42
|
+
bool _readOnly;
|
43
|
+
bool _verifyATN;
|
44
|
+
bool _generateRuleBypassTransitions;
|
45
|
+
};
|
48
46
|
|
49
47
|
} // namespace atn
|
50
48
|
} // namespace antlr4
|