expressir 1.2.4 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +200 -21
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- data/README.adoc +8 -0
- data/Rakefile +4 -1
- data/bin/console +0 -1
- data/bin/rspec +3 -3
- data/exe/expressir +4 -2
- data/exe/format +1 -1
- data/exe/format-test +25 -25
- data/exe/generate-parser +16 -13
- data/expressir.gemspec +12 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
- data/ext/express-parser/antlrgen/Express.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
- data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
- data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
- data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
- data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
- data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
- data/ext/express-parser/express_parser.cpp +294 -86
- data/ext/express-parser/extconf.rb +13 -12
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +3 -4
- data/lib/expressir/express/visitor.rb +7 -5
- data/lib/expressir/model.rb +78 -78
- data/lib/expressir/version.rb +1 -1
- data/rakelib/antlr4-native.rake +161 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +17 -2
- data/spec/expressir/express/cache_spec.rb +23 -5
- data/spec/expressir/express/formatter_spec.rb +54 -8
- data/spec/expressir/express/parser_spec.rb +47 -11
- data/spec/expressir/model/model_element_spec.rb +198 -146
- data/spec/spec_helper.rb +7 -0
- metadata +81 -93
- data/demo.rb +0 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
- data/original/examples/employment/eclipse/.project +0 -17
- data/original/examples/employment/eclipse/Export/Employment.png +0 -0
- data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
- data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
- data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
- data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
- data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
- data/original/examples/employment/eclipse/readme.txt +0 -7
- data/original/examples/employment/employment_schema.exp +0 -33
- data/original/examples/employment/employment_schema.rb +0 -232
- data/original/examples/employment/employment_schema.xml +0 -93
- data/original/examples/employment/employment_schema___module.rb +0 -46
- data/original/examples/employment/employment_schema___p28attr.rb +0 -126
- data/original/examples/employment/employment_schema___p28inst.rb +0 -26
- data/original/examples/employment/example_employment_data.xml +0 -1
- data/original/examples/employment/example_employment_data_copy.xml +0 -1
- data/original/examples/employment/example_employment_reader.rb +0 -30
- data/original/examples/employment/example_employment_writer.rb +0 -51
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
- data/original/exp2ruby.rb +0 -525
- data/original/expsm.rb +0 -34
- data/original/mapping_owl.rb +0 -1018
- data/original/mapping_sysml.rb +0 -2281
- data/original/mapping_uml2.rb +0 -599
- data/original/mapping_uml2_eclipse.rb +0 -433
- data/original/reeper.rb +0 -134
- data/spec/expressr_spec.rb +0 -5
@@ -3,7 +3,11 @@
|
|
3
3
|
* can be found in the LICENSE.txt file in the project root.
|
4
4
|
*/
|
5
5
|
|
6
|
+
#include <functional>
|
7
|
+
#include <unordered_set>
|
8
|
+
|
6
9
|
#include "misc/MurmurHash.h"
|
10
|
+
#include "support/Casts.h"
|
7
11
|
#include "support/CPPUtils.h"
|
8
12
|
#include "support/Arrays.h"
|
9
13
|
|
@@ -13,41 +17,109 @@ using namespace antlr4;
|
|
13
17
|
using namespace antlr4::atn;
|
14
18
|
using namespace antlrcpp;
|
15
19
|
|
16
|
-
|
20
|
+
namespace {
|
17
21
|
|
18
|
-
|
19
|
-
|
22
|
+
struct SemanticContextHasher final {
|
23
|
+
size_t operator()(const SemanticContext *semanticContext) const {
|
24
|
+
return semanticContext->hashCode();
|
25
|
+
}
|
26
|
+
};
|
27
|
+
|
28
|
+
struct SemanticContextComparer final {
|
29
|
+
bool operator()(const SemanticContext *lhs, const SemanticContext *rhs) const {
|
30
|
+
return *lhs == *rhs;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
|
34
|
+
template <typename Comparer>
|
35
|
+
void insertSemanticContext(const Ref<const SemanticContext> &semanticContext,
|
36
|
+
std::unordered_set<const SemanticContext*, SemanticContextHasher, SemanticContextComparer> &operandSet,
|
37
|
+
std::vector<Ref<const SemanticContext>> &operandList,
|
38
|
+
Ref<const SemanticContext::PrecedencePredicate> &precedencePredicate,
|
39
|
+
Comparer comparer) {
|
40
|
+
if (semanticContext != nullptr) {
|
41
|
+
if (semanticContext->getContextType() == SemanticContextType::PRECEDENCE) {
|
42
|
+
if (precedencePredicate == nullptr || comparer(downCast<const SemanticContext::PrecedencePredicate*>(semanticContext.get())->precedence, precedencePredicate->precedence)) {
|
43
|
+
precedencePredicate = std::static_pointer_cast<const SemanticContext::PrecedencePredicate>(semanticContext);
|
44
|
+
}
|
45
|
+
} else {
|
46
|
+
auto [existing, inserted] = operandSet.insert(semanticContext.get());
|
47
|
+
if (inserted) {
|
48
|
+
operandList.push_back(semanticContext);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
template <typename Comparer>
|
55
|
+
void insertSemanticContext(Ref<const SemanticContext> &&semanticContext,
|
56
|
+
std::unordered_set<const SemanticContext*, SemanticContextHasher, SemanticContextComparer> &operandSet,
|
57
|
+
std::vector<Ref<const SemanticContext>> &operandList,
|
58
|
+
Ref<const SemanticContext::PrecedencePredicate> &precedencePredicate,
|
59
|
+
Comparer comparer) {
|
60
|
+
if (semanticContext != nullptr) {
|
61
|
+
if (semanticContext->getContextType() == SemanticContextType::PRECEDENCE) {
|
62
|
+
if (precedencePredicate == nullptr || comparer(downCast<const SemanticContext::PrecedencePredicate*>(semanticContext.get())->precedence, precedencePredicate->precedence)) {
|
63
|
+
precedencePredicate = std::static_pointer_cast<const SemanticContext::PrecedencePredicate>(std::move(semanticContext));
|
64
|
+
}
|
65
|
+
} else {
|
66
|
+
auto [existing, inserted] = operandSet.insert(semanticContext.get());
|
67
|
+
if (inserted) {
|
68
|
+
operandList.push_back(std::move(semanticContext));
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
size_t predictOperandCapacity(const Ref<const SemanticContext> &x) {
|
75
|
+
switch (x->getContextType()) {
|
76
|
+
case SemanticContextType::AND:
|
77
|
+
return downCast<const SemanticContext::AND&>(*x).getOperands().size();
|
78
|
+
case SemanticContextType::OR:
|
79
|
+
return downCast<const SemanticContext::OR&>(*x).getOperands().size();
|
80
|
+
default:
|
81
|
+
return 1;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
size_t predictOperandCapacity(const Ref<const SemanticContext> &a, const Ref<const SemanticContext> &b) {
|
86
|
+
return predictOperandCapacity(a) + predictOperandCapacity(b);
|
87
|
+
}
|
20
88
|
|
21
|
-
SemanticContext::Predicate::Predicate(size_t ruleIndex, size_t predIndex, bool isCtxDependent)
|
22
|
-
: ruleIndex(ruleIndex), predIndex(predIndex), isCtxDependent(isCtxDependent) {
|
23
89
|
}
|
24
90
|
|
91
|
+
//------------------ Predicate -----------------------------------------------------------------------------------------
|
25
92
|
|
26
|
-
|
93
|
+
SemanticContext::Predicate::Predicate(size_t ruleIndex, size_t predIndex, bool isCtxDependent)
|
94
|
+
: SemanticContext(SemanticContextType::PREDICATE), ruleIndex(ruleIndex), predIndex(predIndex), isCtxDependent(isCtxDependent) {}
|
95
|
+
|
96
|
+
bool SemanticContext::Predicate::eval(Recognizer *parser, RuleContext *parserCallStack) const {
|
27
97
|
RuleContext *localctx = nullptr;
|
28
|
-
if (isCtxDependent)
|
98
|
+
if (isCtxDependent) {
|
29
99
|
localctx = parserCallStack;
|
100
|
+
}
|
30
101
|
return parser->sempred(localctx, ruleIndex, predIndex);
|
31
102
|
}
|
32
103
|
|
33
104
|
size_t SemanticContext::Predicate::hashCode() const {
|
34
105
|
size_t hashCode = misc::MurmurHash::initialize();
|
106
|
+
hashCode = misc::MurmurHash::update(hashCode, static_cast<size_t>(getContextType()));
|
35
107
|
hashCode = misc::MurmurHash::update(hashCode, ruleIndex);
|
36
108
|
hashCode = misc::MurmurHash::update(hashCode, predIndex);
|
37
109
|
hashCode = misc::MurmurHash::update(hashCode, isCtxDependent ? 1 : 0);
|
38
|
-
hashCode = misc::MurmurHash::finish(hashCode,
|
110
|
+
hashCode = misc::MurmurHash::finish(hashCode, 4);
|
39
111
|
return hashCode;
|
40
112
|
}
|
41
113
|
|
42
|
-
bool SemanticContext::Predicate::
|
43
|
-
if (this == &other)
|
114
|
+
bool SemanticContext::Predicate::equals(const SemanticContext &other) const {
|
115
|
+
if (this == &other) {
|
44
116
|
return true;
|
45
|
-
|
46
|
-
|
47
|
-
if (p == nullptr)
|
117
|
+
}
|
118
|
+
if (getContextType() != other.getContextType()) {
|
48
119
|
return false;
|
49
|
-
|
50
|
-
|
120
|
+
}
|
121
|
+
const Predicate &p = downCast<const Predicate&>(other);
|
122
|
+
return ruleIndex == p.ruleIndex && predIndex == p.predIndex && isCtxDependent == p.isCtxDependent;
|
51
123
|
}
|
52
124
|
|
53
125
|
std::string SemanticContext::Predicate::toString() const {
|
@@ -56,45 +128,36 @@ std::string SemanticContext::Predicate::toString() const {
|
|
56
128
|
|
57
129
|
//------------------ PrecedencePredicate -------------------------------------------------------------------------------
|
58
130
|
|
59
|
-
SemanticContext::PrecedencePredicate::PrecedencePredicate() : precedence(
|
60
|
-
}
|
131
|
+
SemanticContext::PrecedencePredicate::PrecedencePredicate(int precedence) : SemanticContext(SemanticContextType::PRECEDENCE), precedence(precedence) {}
|
61
132
|
|
62
|
-
SemanticContext::PrecedencePredicate::
|
63
|
-
}
|
64
|
-
|
65
|
-
bool SemanticContext::PrecedencePredicate::eval(Recognizer *parser, RuleContext *parserCallStack) {
|
133
|
+
bool SemanticContext::PrecedencePredicate::eval(Recognizer *parser, RuleContext *parserCallStack) const {
|
66
134
|
return parser->precpred(parserCallStack, precedence);
|
67
135
|
}
|
68
136
|
|
69
|
-
Ref<SemanticContext> SemanticContext::PrecedencePredicate::evalPrecedence(Recognizer *parser,
|
70
|
-
RuleContext *parserCallStack) {
|
137
|
+
Ref<const SemanticContext> SemanticContext::PrecedencePredicate::evalPrecedence(Recognizer *parser,
|
138
|
+
RuleContext *parserCallStack) const {
|
71
139
|
if (parser->precpred(parserCallStack, precedence)) {
|
72
140
|
return SemanticContext::NONE;
|
73
141
|
}
|
74
|
-
|
75
|
-
return nullptr;
|
76
|
-
}
|
77
|
-
}
|
78
|
-
|
79
|
-
int SemanticContext::PrecedencePredicate::compareTo(PrecedencePredicate *o) {
|
80
|
-
return precedence - o->precedence;
|
142
|
+
return nullptr;
|
81
143
|
}
|
82
144
|
|
83
145
|
size_t SemanticContext::PrecedencePredicate::hashCode() const {
|
84
|
-
size_t hashCode =
|
85
|
-
hashCode =
|
86
|
-
|
146
|
+
size_t hashCode = misc::MurmurHash::initialize();
|
147
|
+
hashCode = misc::MurmurHash::update(hashCode, static_cast<size_t>(getContextType()));
|
148
|
+
hashCode = misc::MurmurHash::update(hashCode, static_cast<size_t>(precedence));
|
149
|
+
return misc::MurmurHash::finish(hashCode, 2);
|
87
150
|
}
|
88
151
|
|
89
|
-
bool SemanticContext::PrecedencePredicate::
|
90
|
-
if (this == &other)
|
152
|
+
bool SemanticContext::PrecedencePredicate::equals(const SemanticContext &other) const {
|
153
|
+
if (this == &other) {
|
91
154
|
return true;
|
92
|
-
|
93
|
-
|
94
|
-
if (predicate == nullptr)
|
155
|
+
}
|
156
|
+
if (getContextType() != other.getContextType()) {
|
95
157
|
return false;
|
96
|
-
|
97
|
-
|
158
|
+
}
|
159
|
+
const PrecedencePredicate &predicate = downCast<const PrecedencePredicate&>(other);
|
160
|
+
return precedence == predicate.precedence;
|
98
161
|
}
|
99
162
|
|
100
163
|
std::string SemanticContext::PrecedencePredicate::toString() const {
|
@@ -103,61 +166,60 @@ std::string SemanticContext::PrecedencePredicate::toString() const {
|
|
103
166
|
|
104
167
|
//------------------ AND -----------------------------------------------------------------------------------------------
|
105
168
|
|
106
|
-
SemanticContext::AND::AND(Ref<SemanticContext>
|
107
|
-
|
169
|
+
SemanticContext::AND::AND(Ref<const SemanticContext> a, Ref<const SemanticContext> b) : Operator(SemanticContextType::AND) {
|
170
|
+
std::unordered_set<const SemanticContext*, SemanticContextHasher, SemanticContextComparer> operands;
|
171
|
+
Ref<const SemanticContext::PrecedencePredicate> precedencePredicate;
|
108
172
|
|
109
|
-
|
110
|
-
|
111
|
-
|
173
|
+
_opnds.reserve(predictOperandCapacity(a, b) + 1);
|
174
|
+
|
175
|
+
if (a->getContextType() == SemanticContextType::AND) {
|
176
|
+
for (const auto &operand : downCast<const AND*>(a.get())->getOperands()) {
|
177
|
+
insertSemanticContext(operand, operands, _opnds, precedencePredicate, std::less<int>{});
|
112
178
|
}
|
113
179
|
} else {
|
114
|
-
|
180
|
+
insertSemanticContext(std::move(a), operands, _opnds, precedencePredicate, std::less<int>{});
|
115
181
|
}
|
116
182
|
|
117
|
-
if (
|
118
|
-
for (auto operand :
|
119
|
-
|
183
|
+
if (b->getContextType() == SemanticContextType::AND) {
|
184
|
+
for (const auto &operand : downCast<const AND*>(b.get())->getOperands()) {
|
185
|
+
insertSemanticContext(operand, operands, _opnds, precedencePredicate, std::less<int>{});
|
120
186
|
}
|
121
187
|
} else {
|
122
|
-
|
188
|
+
insertSemanticContext(std::move(b), operands, _opnds, precedencePredicate, std::less<int>{});
|
123
189
|
}
|
124
190
|
|
125
|
-
|
126
|
-
|
127
|
-
if (!precedencePredicates.empty()) {
|
191
|
+
if (precedencePredicate != nullptr) {
|
128
192
|
// interested in the transition with the lowest precedence
|
129
|
-
auto
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
auto reduced = std::min_element(precedencePredicates.begin(), precedencePredicates.end(), predicate);
|
134
|
-
operands.insert(*reduced);
|
193
|
+
auto [existing, inserted] = operands.insert(precedencePredicate.get());
|
194
|
+
if (inserted) {
|
195
|
+
_opnds.push_back(std::move(precedencePredicate));
|
196
|
+
}
|
135
197
|
}
|
136
|
-
|
137
|
-
std::copy(operands.begin(), operands.end(), std::back_inserter(opnds));
|
138
198
|
}
|
139
199
|
|
140
|
-
std::vector<Ref<SemanticContext
|
141
|
-
return
|
200
|
+
const std::vector<Ref<const SemanticContext>>& SemanticContext::AND::getOperands() const {
|
201
|
+
return _opnds;
|
142
202
|
}
|
143
203
|
|
144
|
-
bool SemanticContext::AND::
|
145
|
-
if (this == &other)
|
204
|
+
bool SemanticContext::AND::equals(const SemanticContext &other) const {
|
205
|
+
if (this == &other) {
|
146
206
|
return true;
|
147
|
-
|
148
|
-
|
149
|
-
if (context == nullptr)
|
207
|
+
}
|
208
|
+
if (getContextType() != other.getContextType()) {
|
150
209
|
return false;
|
151
|
-
|
152
|
-
|
210
|
+
}
|
211
|
+
const AND &context = downCast<const AND&>(other);
|
212
|
+
return Arrays::equals(getOperands(), context.getOperands());
|
153
213
|
}
|
154
214
|
|
155
215
|
size_t SemanticContext::AND::hashCode() const {
|
156
|
-
|
216
|
+
size_t hash = misc::MurmurHash::initialize();
|
217
|
+
hash = misc::MurmurHash::update(hash, static_cast<size_t>(getContextType()));
|
218
|
+
return misc::MurmurHash::hashCode(getOperands(), hash);
|
157
219
|
}
|
158
220
|
|
159
|
-
bool SemanticContext::AND::eval(Recognizer *parser, RuleContext *parserCallStack) {
|
160
|
-
for (auto opnd :
|
221
|
+
bool SemanticContext::AND::eval(Recognizer *parser, RuleContext *parserCallStack) const {
|
222
|
+
for (const auto &opnd : getOperands()) {
|
161
223
|
if (!opnd->eval(parser, parserCallStack)) {
|
162
224
|
return false;
|
163
225
|
}
|
@@ -165,18 +227,19 @@ bool SemanticContext::AND::eval(Recognizer *parser, RuleContext *parserCallStack
|
|
165
227
|
return true;
|
166
228
|
}
|
167
229
|
|
168
|
-
Ref<SemanticContext> SemanticContext::AND::evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) {
|
230
|
+
Ref<const SemanticContext> SemanticContext::AND::evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) const {
|
169
231
|
bool differs = false;
|
170
|
-
std::vector<Ref<SemanticContext>> operands;
|
171
|
-
for (auto context :
|
172
|
-
|
232
|
+
std::vector<Ref<const SemanticContext>> operands;
|
233
|
+
for (const auto &context : getOperands()) {
|
234
|
+
auto evaluated = context->evalPrecedence(parser, parserCallStack);
|
173
235
|
differs |= (evaluated != context);
|
174
236
|
if (evaluated == nullptr) {
|
175
237
|
// The AND context is false if any element is false.
|
176
238
|
return nullptr;
|
177
|
-
}
|
239
|
+
}
|
240
|
+
if (evaluated != NONE) {
|
178
241
|
// Reduce the result by skipping true elements.
|
179
|
-
operands.push_back(evaluated);
|
242
|
+
operands.push_back(std::move(evaluated));
|
180
243
|
}
|
181
244
|
}
|
182
245
|
|
@@ -189,9 +252,9 @@ Ref<SemanticContext> SemanticContext::AND::evalPrecedence(Recognizer *parser, Ru
|
|
189
252
|
return NONE;
|
190
253
|
}
|
191
254
|
|
192
|
-
Ref<SemanticContext> result = operands[0];
|
255
|
+
Ref<const SemanticContext> result = std::move(operands[0]);
|
193
256
|
for (size_t i = 1; i < operands.size(); ++i) {
|
194
|
-
result = SemanticContext::And(result, operands[i]);
|
257
|
+
result = SemanticContext::And(std::move(result), std::move(operands[i]));
|
195
258
|
}
|
196
259
|
|
197
260
|
return result;
|
@@ -199,7 +262,7 @@ Ref<SemanticContext> SemanticContext::AND::evalPrecedence(Recognizer *parser, Ru
|
|
199
262
|
|
200
263
|
std::string SemanticContext::AND::toString() const {
|
201
264
|
std::string tmp;
|
202
|
-
for (auto var :
|
265
|
+
for (const auto &var : getOperands()) {
|
203
266
|
tmp += var->toString() + " && ";
|
204
267
|
}
|
205
268
|
return tmp;
|
@@ -207,59 +270,60 @@ std::string SemanticContext::AND::toString() const {
|
|
207
270
|
|
208
271
|
//------------------ OR ------------------------------------------------------------------------------------------------
|
209
272
|
|
210
|
-
SemanticContext::OR::OR(Ref<SemanticContext>
|
211
|
-
|
273
|
+
SemanticContext::OR::OR(Ref<const SemanticContext> a, Ref<const SemanticContext> b) : Operator(SemanticContextType::OR) {
|
274
|
+
std::unordered_set<const SemanticContext*, SemanticContextHasher, SemanticContextComparer> operands;
|
275
|
+
Ref<const SemanticContext::PrecedencePredicate> precedencePredicate;
|
276
|
+
|
277
|
+
_opnds.reserve(predictOperandCapacity(a, b) + 1);
|
212
278
|
|
213
|
-
if (
|
214
|
-
for (auto operand :
|
215
|
-
|
279
|
+
if (a->getContextType() == SemanticContextType::OR) {
|
280
|
+
for (const auto &operand : downCast<const OR*>(a.get())->getOperands()) {
|
281
|
+
insertSemanticContext(operand, operands, _opnds, precedencePredicate, std::greater<int>{});
|
216
282
|
}
|
217
283
|
} else {
|
218
|
-
|
284
|
+
insertSemanticContext(std::move(a), operands, _opnds, precedencePredicate, std::greater<int>{});
|
219
285
|
}
|
220
286
|
|
221
|
-
if (
|
222
|
-
for (auto operand :
|
223
|
-
|
287
|
+
if (b->getContextType() == SemanticContextType::OR) {
|
288
|
+
for (const auto &operand : downCast<const OR*>(b.get())->getOperands()) {
|
289
|
+
insertSemanticContext(operand, operands, _opnds, precedencePredicate, std::greater<int>{});
|
224
290
|
}
|
225
291
|
} else {
|
226
|
-
|
292
|
+
insertSemanticContext(std::move(b), operands, _opnds, precedencePredicate, std::greater<int>{});
|
227
293
|
}
|
228
294
|
|
229
|
-
|
230
|
-
if (!precedencePredicates.empty()) {
|
295
|
+
if (precedencePredicate != nullptr) {
|
231
296
|
// interested in the transition with the highest precedence
|
232
|
-
auto
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
operands.insert(*reduced);
|
297
|
+
auto [existing, inserted] = operands.insert(precedencePredicate.get());
|
298
|
+
if (inserted) {
|
299
|
+
_opnds.push_back(std::move(precedencePredicate));
|
300
|
+
}
|
237
301
|
}
|
238
|
-
|
239
|
-
std::copy(operands.begin(), operands.end(), std::back_inserter(opnds));
|
240
302
|
}
|
241
303
|
|
242
|
-
std::vector<Ref<SemanticContext
|
243
|
-
return
|
304
|
+
const std::vector<Ref<const SemanticContext>>& SemanticContext::OR::getOperands() const {
|
305
|
+
return _opnds;
|
244
306
|
}
|
245
307
|
|
246
|
-
bool SemanticContext::OR::
|
247
|
-
if (this == &other)
|
308
|
+
bool SemanticContext::OR::equals(const SemanticContext &other) const {
|
309
|
+
if (this == &other) {
|
248
310
|
return true;
|
249
|
-
|
250
|
-
|
251
|
-
if (context == nullptr)
|
311
|
+
}
|
312
|
+
if (getContextType() != other.getContextType()) {
|
252
313
|
return false;
|
253
|
-
|
254
|
-
|
314
|
+
}
|
315
|
+
const OR &context = downCast<const OR&>(other);
|
316
|
+
return Arrays::equals(getOperands(), context.getOperands());
|
255
317
|
}
|
256
318
|
|
257
319
|
size_t SemanticContext::OR::hashCode() const {
|
258
|
-
|
320
|
+
size_t hash = misc::MurmurHash::initialize();
|
321
|
+
hash = misc::MurmurHash::update(hash, static_cast<size_t>(getContextType()));
|
322
|
+
return misc::MurmurHash::hashCode(getOperands(), hash);
|
259
323
|
}
|
260
324
|
|
261
|
-
bool SemanticContext::OR::eval(Recognizer *parser, RuleContext *parserCallStack) {
|
262
|
-
for (auto opnd :
|
325
|
+
bool SemanticContext::OR::eval(Recognizer *parser, RuleContext *parserCallStack) const {
|
326
|
+
for (const auto &opnd : getOperands()) {
|
263
327
|
if (opnd->eval(parser, parserCallStack)) {
|
264
328
|
return true;
|
265
329
|
}
|
@@ -267,18 +331,19 @@ bool SemanticContext::OR::eval(Recognizer *parser, RuleContext *parserCallStack)
|
|
267
331
|
return false;
|
268
332
|
}
|
269
333
|
|
270
|
-
Ref<SemanticContext> SemanticContext::OR::evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) {
|
334
|
+
Ref<const SemanticContext> SemanticContext::OR::evalPrecedence(Recognizer *parser, RuleContext *parserCallStack) const {
|
271
335
|
bool differs = false;
|
272
|
-
std::vector<Ref<SemanticContext>> operands;
|
273
|
-
for (auto context :
|
274
|
-
|
336
|
+
std::vector<Ref<const SemanticContext>> operands;
|
337
|
+
for (const auto &context : getOperands()) {
|
338
|
+
auto evaluated = context->evalPrecedence(parser, parserCallStack);
|
275
339
|
differs |= (evaluated != context);
|
276
340
|
if (evaluated == NONE) {
|
277
341
|
// The OR context is true if any element is true.
|
278
342
|
return NONE;
|
279
|
-
}
|
343
|
+
}
|
344
|
+
if (evaluated != nullptr) {
|
280
345
|
// Reduce the result by skipping false elements.
|
281
|
-
operands.push_back(evaluated);
|
346
|
+
operands.push_back(std::move(evaluated));
|
282
347
|
}
|
283
348
|
}
|
284
349
|
|
@@ -291,9 +356,9 @@ Ref<SemanticContext> SemanticContext::OR::evalPrecedence(Recognizer *parser, Rul
|
|
291
356
|
return nullptr;
|
292
357
|
}
|
293
358
|
|
294
|
-
Ref<SemanticContext> result = operands[0];
|
359
|
+
Ref<const SemanticContext> result = std::move(operands[0]);
|
295
360
|
for (size_t i = 1; i < operands.size(); ++i) {
|
296
|
-
result = SemanticContext::Or(result, operands[i]);
|
361
|
+
result = SemanticContext::Or(std::move(result), std::move(operands[i]));
|
297
362
|
}
|
298
363
|
|
299
364
|
return result;
|
@@ -301,7 +366,7 @@ Ref<SemanticContext> SemanticContext::OR::evalPrecedence(Recognizer *parser, Rul
|
|
301
366
|
|
302
367
|
std::string SemanticContext::OR::toString() const {
|
303
368
|
std::string tmp;
|
304
|
-
for(auto var :
|
369
|
+
for(const auto &var : getOperands()) {
|
305
370
|
tmp += var->toString() + " || ";
|
306
371
|
}
|
307
372
|
return tmp;
|
@@ -309,20 +374,13 @@ std::string SemanticContext::OR::toString() const {
|
|
309
374
|
|
310
375
|
//------------------ SemanticContext -----------------------------------------------------------------------------------
|
311
376
|
|
312
|
-
const Ref<SemanticContext> SemanticContext::NONE = std::make_shared<Predicate>(INVALID_INDEX, INVALID_INDEX, false);
|
313
|
-
|
314
|
-
SemanticContext::~SemanticContext() {
|
315
|
-
}
|
377
|
+
const Ref<const SemanticContext> SemanticContext::NONE = std::make_shared<Predicate>(INVALID_INDEX, INVALID_INDEX, false);
|
316
378
|
|
317
|
-
|
318
|
-
return !(*this == other);
|
319
|
-
}
|
320
|
-
|
321
|
-
Ref<SemanticContext> SemanticContext::evalPrecedence(Recognizer * /*parser*/, RuleContext * /*parserCallStack*/) {
|
379
|
+
Ref<const SemanticContext> SemanticContext::evalPrecedence(Recognizer * /*parser*/, RuleContext * /*parserCallStack*/) const {
|
322
380
|
return shared_from_this();
|
323
381
|
}
|
324
382
|
|
325
|
-
Ref<SemanticContext> SemanticContext::And(Ref<SemanticContext>
|
383
|
+
Ref<const SemanticContext> SemanticContext::And(Ref<const SemanticContext> a, Ref<const SemanticContext> b) {
|
326
384
|
if (!a || a == NONE) {
|
327
385
|
return b;
|
328
386
|
}
|
@@ -331,15 +389,15 @@ Ref<SemanticContext> SemanticContext::And(Ref<SemanticContext> const& a, Ref<Sem
|
|
331
389
|
return a;
|
332
390
|
}
|
333
391
|
|
334
|
-
Ref<AND> result = std::make_shared<AND>(a, b);
|
335
|
-
if (result->
|
336
|
-
return result->
|
392
|
+
Ref<AND> result = std::make_shared<AND>(std::move(a), std::move(b));
|
393
|
+
if (result->getOperands().size() == 1) {
|
394
|
+
return result->getOperands()[0];
|
337
395
|
}
|
338
396
|
|
339
397
|
return result;
|
340
398
|
}
|
341
399
|
|
342
|
-
Ref<SemanticContext> SemanticContext::Or(Ref<SemanticContext>
|
400
|
+
Ref<const SemanticContext> SemanticContext::Or(Ref<const SemanticContext> a, Ref<const SemanticContext> b) {
|
343
401
|
if (!a) {
|
344
402
|
return b;
|
345
403
|
}
|
@@ -351,27 +409,10 @@ Ref<SemanticContext> SemanticContext::Or(Ref<SemanticContext> const& a, Ref<Sema
|
|
351
409
|
return NONE;
|
352
410
|
}
|
353
411
|
|
354
|
-
Ref<OR> result = std::make_shared<OR>(a, b);
|
355
|
-
if (result->
|
356
|
-
return result->
|
412
|
+
Ref<OR> result = std::make_shared<OR>(std::move(a), std::move(b));
|
413
|
+
if (result->getOperands().size() == 1) {
|
414
|
+
return result->getOperands()[0];
|
357
415
|
}
|
358
416
|
|
359
417
|
return result;
|
360
418
|
}
|
361
|
-
|
362
|
-
std::vector<Ref<SemanticContext::PrecedencePredicate>> SemanticContext::filterPrecedencePredicates(const Set &collection) {
|
363
|
-
std::vector<Ref<SemanticContext::PrecedencePredicate>> result;
|
364
|
-
for (auto context : collection) {
|
365
|
-
if (antlrcpp::is<PrecedencePredicate>(context)) {
|
366
|
-
result.push_back(std::dynamic_pointer_cast<PrecedencePredicate>(context));
|
367
|
-
}
|
368
|
-
}
|
369
|
-
|
370
|
-
return result;
|
371
|
-
}
|
372
|
-
|
373
|
-
|
374
|
-
//------------------ Operator -----------------------------------------------------------------------------------------
|
375
|
-
|
376
|
-
SemanticContext::Operator::~Operator() {
|
377
|
-
}
|