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
@@ -9,10 +9,7 @@
|
|
9
9
|
|
10
10
|
using namespace antlr4::dfa;
|
11
11
|
|
12
|
-
LexerDFASerializer::LexerDFASerializer(DFA *dfa) : DFASerializer(dfa, Vocabulary
|
13
|
-
}
|
14
|
-
|
15
|
-
LexerDFASerializer::~LexerDFASerializer() {
|
12
|
+
LexerDFASerializer::LexerDFASerializer(const DFA *dfa) : DFASerializer(dfa, Vocabulary()) {
|
16
13
|
}
|
17
14
|
|
18
15
|
std::string LexerDFASerializer::getEdgeLabel(size_t i) const {
|
@@ -10,13 +10,12 @@
|
|
10
10
|
namespace antlr4 {
|
11
11
|
namespace dfa {
|
12
12
|
|
13
|
-
class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer {
|
13
|
+
class ANTLR4CPP_PUBLIC LexerDFASerializer final : public DFASerializer {
|
14
14
|
public:
|
15
|
-
LexerDFASerializer(DFA *dfa);
|
16
|
-
virtual ~LexerDFASerializer();
|
15
|
+
explicit LexerDFASerializer(const DFA *dfa);
|
17
16
|
|
18
17
|
protected:
|
19
|
-
|
18
|
+
std::string getEdgeLabel(size_t i) const override;
|
20
19
|
};
|
21
20
|
|
22
21
|
} // namespace atn
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp
CHANGED
@@ -101,7 +101,7 @@ InterpreterData InterpreterDataReader::parseFile(std::string const& fileName) {
|
|
101
101
|
};
|
102
102
|
}
|
103
103
|
|
104
|
-
std::vector<
|
104
|
+
std::vector<int32_t> serializedATN;
|
105
105
|
|
106
106
|
std::getline(input, line, '\n');
|
107
107
|
assert(line == "atn:");
|
@@ -115,7 +115,7 @@ InterpreterData InterpreterDataReader::parseFile(std::string const& fileName) {
|
|
115
115
|
number = std::strtoul(&value[1], nullptr, 10);
|
116
116
|
else
|
117
117
|
number = std::strtoul(value.c_str(), nullptr, 10);
|
118
|
-
serializedATN.push_back(static_cast<
|
118
|
+
serializedATN.push_back(static_cast<int32_t>(number));
|
119
119
|
}
|
120
120
|
|
121
121
|
ATNDeserializer deserializer;
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h
CHANGED
@@ -6,12 +6,14 @@
|
|
6
6
|
#pragma once
|
7
7
|
|
8
8
|
#include "antlr4-common.h"
|
9
|
+
#include "atn/ATN.h"
|
10
|
+
#include "Vocabulary.h"
|
9
11
|
|
10
12
|
namespace antlr4 {
|
11
13
|
namespace misc {
|
12
14
|
|
13
15
|
struct InterpreterData {
|
14
|
-
atn::ATN atn;
|
16
|
+
std::unique_ptr<atn::ATN> atn;
|
15
17
|
dfa::Vocabulary vocabulary;
|
16
18
|
std::vector<std::string> ruleNames;
|
17
19
|
std::vector<std::string> channels; // Only valid for lexer grammars.
|
@@ -7,35 +7,7 @@
|
|
7
7
|
|
8
8
|
using namespace antlr4::misc;
|
9
9
|
|
10
|
-
|
11
|
-
return static_cast<size_t>(v);
|
12
|
-
}
|
13
|
-
|
14
|
-
ssize_t antlr4::misc::symbolToNumeric(size_t v) {
|
15
|
-
return static_cast<ssize_t>(v);
|
16
|
-
}
|
17
|
-
|
18
|
-
Interval const Interval::INVALID;
|
19
|
-
|
20
|
-
Interval::Interval() : Interval(static_cast<ssize_t>(-1), -2) { // Need an explicit cast here for VS.
|
21
|
-
}
|
22
|
-
|
23
|
-
Interval::Interval(size_t a_, size_t b_) : Interval(symbolToNumeric(a_), symbolToNumeric(b_)) {
|
24
|
-
}
|
25
|
-
|
26
|
-
Interval::Interval(ssize_t a_, ssize_t b_) : a(a_), b(b_) {
|
27
|
-
}
|
28
|
-
|
29
|
-
size_t Interval::length() const {
|
30
|
-
if (b < a) {
|
31
|
-
return 0;
|
32
|
-
}
|
33
|
-
return size_t(b - a + 1);
|
34
|
-
}
|
35
|
-
|
36
|
-
bool Interval::operator == (const Interval &other) const {
|
37
|
-
return a == other.a && b == other.b;
|
38
|
-
}
|
10
|
+
const Interval Interval::INVALID;
|
39
11
|
|
40
12
|
size_t Interval::hashCode() const {
|
41
13
|
size_t hash = 23;
|
@@ -13,11 +13,11 @@ namespace misc {
|
|
13
13
|
// Helpers to convert certain unsigned symbols (e.g. Token::EOF) to their original numeric value (e.g. -1)
|
14
14
|
// and vice versa. This is needed mostly for intervals to keep their original order and for toString()
|
15
15
|
// methods to print the original numeric value (e.g. for tests).
|
16
|
-
size_t numericToSymbol(ssize_t v);
|
17
|
-
ssize_t symbolToNumeric(size_t v);
|
16
|
+
constexpr size_t numericToSymbol(ssize_t v) { return static_cast<size_t>(v); }
|
17
|
+
constexpr ssize_t symbolToNumeric(size_t v) { return static_cast<ssize_t>(v); }
|
18
18
|
|
19
19
|
/// An immutable inclusive interval a..b
|
20
|
-
class ANTLR4CPP_PUBLIC Interval {
|
20
|
+
class ANTLR4CPP_PUBLIC Interval final {
|
21
21
|
public:
|
22
22
|
static const Interval INVALID;
|
23
23
|
|
@@ -25,15 +25,17 @@ namespace misc {
|
|
25
25
|
ssize_t a;
|
26
26
|
ssize_t b;
|
27
27
|
|
28
|
-
Interval()
|
29
|
-
|
30
|
-
Interval(
|
28
|
+
constexpr Interval() : Interval(static_cast<ssize_t>(-1), static_cast<ssize_t>(-2)) {}
|
29
|
+
|
30
|
+
constexpr explicit Interval(size_t a_, size_t b_) : Interval(symbolToNumeric(a_), symbolToNumeric(b_)) {}
|
31
|
+
|
32
|
+
constexpr Interval(ssize_t a_, ssize_t b_) : a(a_), b(b_) {}
|
31
33
|
|
32
34
|
/// return number of elements between a and b inclusively. x..x is length 1.
|
33
35
|
/// if b < a, then length is 0. 9..10 has length 2.
|
34
|
-
size_t length() const;
|
36
|
+
constexpr size_t length() const { return b >= a ? static_cast<size_t>(b - a + 1) : 0; }
|
35
37
|
|
36
|
-
bool operator
|
38
|
+
constexpr bool operator==(const Interval &other) const { return a == other.a && b == other.b; }
|
37
39
|
|
38
40
|
size_t hashCode() const;
|
39
41
|
|
@@ -76,8 +78,6 @@ namespace misc {
|
|
76
78
|
Interval intersection(const Interval &other) const;
|
77
79
|
|
78
80
|
std::string toString() const;
|
79
|
-
|
80
|
-
private:
|
81
81
|
};
|
82
82
|
|
83
83
|
} // namespace atn
|
@@ -13,7 +13,7 @@
|
|
13
13
|
using namespace antlr4;
|
14
14
|
using namespace antlr4::misc;
|
15
15
|
|
16
|
-
IntervalSet const IntervalSet::COMPLETE_CHAR_SET =
|
16
|
+
IntervalSet const IntervalSet::COMPLETE_CHAR_SET =
|
17
17
|
IntervalSet::of(Lexer::MIN_CHAR_VALUE, Lexer::MAX_CHAR_VALUE);
|
18
18
|
|
19
19
|
IntervalSet const IntervalSet::EMPTY_SET;
|
@@ -265,18 +265,13 @@ bool IntervalSet::contains(size_t el) const {
|
|
265
265
|
}
|
266
266
|
|
267
267
|
bool IntervalSet::contains(ssize_t el) const {
|
268
|
-
if (_intervals.empty())
|
268
|
+
if (_intervals.empty() || el < _intervals.front().a || el > _intervals.back().b) {
|
269
269
|
return false;
|
270
|
-
|
271
|
-
if (el < _intervals[0].a) // list is sorted and el is before first interval; not here
|
272
|
-
return false;
|
273
|
-
|
274
|
-
for (const auto &interval : _intervals) {
|
275
|
-
if (el >= interval.a && el <= interval.b) {
|
276
|
-
return true; // found in this interval
|
277
|
-
}
|
278
270
|
}
|
279
|
-
|
271
|
+
|
272
|
+
return std::binary_search(_intervals.begin(), _intervals.end(), Interval(el, el), [](const Interval &lhs, const Interval &rhs) {
|
273
|
+
return lhs.b < rhs.a;
|
274
|
+
});
|
280
275
|
}
|
281
276
|
|
282
277
|
bool IntervalSet::isEmpty() const {
|
@@ -306,7 +301,7 @@ ssize_t IntervalSet::getMinElement() const {
|
|
306
301
|
return Token::INVALID_TYPE;
|
307
302
|
}
|
308
303
|
|
309
|
-
return _intervals
|
304
|
+
return _intervals.front().a;
|
310
305
|
}
|
311
306
|
|
312
307
|
std::vector<Interval> const& IntervalSet::getIntervals() const {
|
@@ -379,10 +374,6 @@ std::string IntervalSet::toString(bool elemAreChar) const {
|
|
379
374
|
return ss.str();
|
380
375
|
}
|
381
376
|
|
382
|
-
std::string IntervalSet::toString(const std::vector<std::string> &tokenNames) const {
|
383
|
-
return toString(dfa::Vocabulary::fromTokenNames(tokenNames));
|
384
|
-
}
|
385
|
-
|
386
377
|
std::string IntervalSet::toString(const dfa::Vocabulary &vocabulary) const {
|
387
378
|
if (_intervals.empty()) {
|
388
379
|
return "{}";
|
@@ -420,10 +411,6 @@ std::string IntervalSet::toString(const dfa::Vocabulary &vocabulary) const {
|
|
420
411
|
return ss.str();
|
421
412
|
}
|
422
413
|
|
423
|
-
std::string IntervalSet::elementName(const std::vector<std::string> &tokenNames, ssize_t a) const {
|
424
|
-
return elementName(dfa::Vocabulary::fromTokenNames(tokenNames), a);
|
425
|
-
}
|
426
|
-
|
427
414
|
std::string IntervalSet::elementName(const dfa::Vocabulary &vocabulary, ssize_t a) const {
|
428
415
|
if (a == -1) {
|
429
416
|
return "<EOF>";
|
@@ -23,7 +23,7 @@ namespace misc {
|
|
23
23
|
* the range {@link Integer#MIN_VALUE} to {@link Integer#MAX_VALUE}
|
24
24
|
* (inclusive).</p>
|
25
25
|
*/
|
26
|
-
class ANTLR4CPP_PUBLIC IntervalSet {
|
26
|
+
class ANTLR4CPP_PUBLIC IntervalSet final {
|
27
27
|
public:
|
28
28
|
static IntervalSet const COMPLETE_CHAR_SET;
|
29
29
|
static IntervalSet const EMPTY_SET;
|
@@ -151,17 +151,9 @@ namespace misc {
|
|
151
151
|
std::string toString() const;
|
152
152
|
std::string toString(bool elemAreChar) const;
|
153
153
|
|
154
|
-
/**
|
155
|
-
* @deprecated Use {@link #toString(Vocabulary)} instead.
|
156
|
-
*/
|
157
|
-
std::string toString(const std::vector<std::string> &tokenNames) const;
|
158
154
|
std::string toString(const dfa::Vocabulary &vocabulary) const;
|
159
155
|
|
160
156
|
protected:
|
161
|
-
/**
|
162
|
-
* @deprecated Use {@link #elementName(Vocabulary, int)} instead.
|
163
|
-
*/
|
164
|
-
std::string elementName(const std::vector<std::string> &tokenNames, ssize_t a) const;
|
165
157
|
std::string elementName(const dfa::Vocabulary &vocabulary, ssize_t a) const;
|
166
158
|
|
167
159
|
public:
|
@@ -3,6 +3,10 @@
|
|
3
3
|
* can be found in the LICENSE.txt file in the project root.
|
4
4
|
*/
|
5
5
|
|
6
|
+
#include <cstddef>
|
7
|
+
#include <cstdint>
|
8
|
+
#include <cstring>
|
9
|
+
|
6
10
|
#include "misc/MurmurHash.h"
|
7
11
|
|
8
12
|
using namespace antlr4::misc;
|
@@ -17,118 +21,100 @@ using namespace antlr4::misc;
|
|
17
21
|
|
18
22
|
#if defined(_MSC_VER)
|
19
23
|
|
20
|
-
#define FORCE_INLINE __forceinline
|
21
|
-
|
22
24
|
#include <stdlib.h>
|
23
25
|
|
24
26
|
#define ROTL32(x,y) _rotl(x,y)
|
25
27
|
#define ROTL64(x,y) _rotl64(x,y)
|
26
28
|
|
27
|
-
#
|
29
|
+
#elif ANTLR4CPP_HAVE_BUILTIN(__builtin_rotateleft32) && ANTLR4CPP_HAVE_BUILTIN(__builtin_rotateleft64)
|
30
|
+
|
31
|
+
#define ROTL32(x, y) __builtin_rotateleft32(x, y)
|
32
|
+
#define ROTL64(x, y) __builtin_rotateleft64(x, y)
|
28
33
|
|
29
34
|
#else // defined(_MSC_VER)
|
30
35
|
|
31
36
|
// Other compilers
|
32
37
|
|
33
|
-
|
38
|
+
namespace {
|
34
39
|
|
35
|
-
|
36
|
-
{
|
40
|
+
constexpr uint32_t ROTL32(uint32_t x, int r) {
|
37
41
|
return (x << r) | (x >> (32 - r));
|
38
42
|
}
|
39
|
-
|
40
|
-
inline uint64_t rotl64 (uint64_t x, int8_t r)
|
41
|
-
{
|
43
|
+
constexpr uint64_t ROTL64(uint64_t x, int r) {
|
42
44
|
return (x << r) | (x >> (64 - r));
|
43
45
|
}
|
44
46
|
|
45
|
-
#define ROTL32(x,y) rotl32(x,y)
|
46
|
-
#define ROTL64(x,y) rotl64(x,y)
|
47
|
-
|
48
|
-
#define BIG_CONSTANT(x) (x##LLU)
|
49
|
-
|
50
|
-
#endif // !defined(_MSC_VER)
|
51
|
-
|
52
|
-
size_t MurmurHash::initialize() {
|
53
|
-
return initialize(DEFAULT_SEED);
|
54
|
-
}
|
55
|
-
|
56
|
-
size_t MurmurHash::initialize(size_t seed) {
|
57
|
-
return seed;
|
58
47
|
}
|
59
48
|
|
60
|
-
#
|
61
|
-
#if _WIN64
|
62
|
-
#define ENVIRONMENT64
|
63
|
-
#else
|
64
|
-
#define ENVIRONMENT32
|
65
|
-
#endif
|
66
|
-
#endif
|
67
|
-
|
68
|
-
#if defined(__GNUC__)
|
69
|
-
#if defined(__x86_64__) || defined(__ppc64__)
|
70
|
-
#define ENVIRONMENT64
|
71
|
-
#else
|
72
|
-
#define ENVIRONMENT32
|
73
|
-
#endif
|
74
|
-
#endif
|
49
|
+
#endif // !defined(_MSC_VER)
|
75
50
|
|
76
|
-
#if
|
51
|
+
#if SIZE_MAX == UINT64_MAX
|
77
52
|
|
78
53
|
size_t MurmurHash::update(size_t hash, size_t value) {
|
79
|
-
static const size_t c1 = 0xCC9E2D51;
|
80
|
-
static const size_t c2 = 0x1B873593;
|
81
|
-
|
82
54
|
size_t k1 = value;
|
83
|
-
k1 *=
|
84
|
-
k1 =
|
85
|
-
k1 *=
|
55
|
+
k1 *= UINT64_C(0x87c37b91114253d5);
|
56
|
+
k1 = ROTL64(k1, 31);
|
57
|
+
k1 *= UINT64_C(0x4cf5ad432745937f);
|
86
58
|
|
87
59
|
hash ^= k1;
|
88
|
-
hash =
|
89
|
-
hash = hash * 5 +
|
60
|
+
hash = ROTL64(hash, 27);
|
61
|
+
hash = hash * 5 + UINT64_C(0x52dce729);
|
90
62
|
|
91
63
|
return hash;
|
92
64
|
}
|
93
65
|
|
66
|
+
size_t MurmurHash::update(size_t hash, const void *data, size_t size) {
|
67
|
+
size_t value;
|
68
|
+
const uint8_t *bytes = static_cast<const uint8_t*>(data);
|
69
|
+
while (size >= sizeof(size_t)) {
|
70
|
+
std::memcpy(&value, bytes, sizeof(size_t));
|
71
|
+
hash = update(hash, value);
|
72
|
+
bytes += sizeof(size_t);
|
73
|
+
size -= sizeof(size_t);
|
74
|
+
}
|
75
|
+
if (size != 0) {
|
76
|
+
value = 0;
|
77
|
+
std::memcpy(&value, bytes, size);
|
78
|
+
hash = update(hash, value);
|
79
|
+
}
|
80
|
+
return hash;
|
81
|
+
}
|
94
82
|
|
95
83
|
size_t MurmurHash::finish(size_t hash, size_t entryCount) {
|
96
|
-
hash ^= entryCount *
|
97
|
-
hash ^= hash >>
|
98
|
-
hash *=
|
99
|
-
hash ^= hash >>
|
100
|
-
hash *=
|
101
|
-
hash ^= hash >>
|
84
|
+
hash ^= entryCount * 8;
|
85
|
+
hash ^= hash >> 33;
|
86
|
+
hash *= UINT64_C(0xff51afd7ed558ccd);
|
87
|
+
hash ^= hash >> 33;
|
88
|
+
hash *= UINT64_C(0xc4ceb9fe1a85ec53);
|
89
|
+
hash ^= hash >> 33;
|
102
90
|
return hash;
|
103
91
|
}
|
104
92
|
|
105
|
-
#
|
93
|
+
#elif SIZE_MAX == UINT32_MAX
|
106
94
|
|
107
95
|
size_t MurmurHash::update(size_t hash, size_t value) {
|
108
|
-
static const size_t c1 = BIG_CONSTANT(0x87c37b91114253d5);
|
109
|
-
static const size_t c2 = BIG_CONSTANT(0x4cf5ad432745937f);
|
110
|
-
|
111
96
|
size_t k1 = value;
|
112
|
-
k1 *=
|
113
|
-
k1 =
|
114
|
-
k1 *=
|
97
|
+
k1 *= UINT32_C(0xCC9E2D51);
|
98
|
+
k1 = ROTL32(k1, 15);
|
99
|
+
k1 *= UINT32_C(0x1B873593);
|
115
100
|
|
116
101
|
hash ^= k1;
|
117
|
-
hash =
|
118
|
-
hash = hash * 5 +
|
102
|
+
hash = ROTL32(hash, 13);
|
103
|
+
hash = hash * 5 + UINT32_C(0xE6546B64);
|
119
104
|
|
120
105
|
return hash;
|
121
106
|
}
|
122
107
|
|
123
|
-
|
124
108
|
size_t MurmurHash::finish(size_t hash, size_t entryCount) {
|
125
|
-
hash ^= entryCount *
|
126
|
-
hash ^= hash >>
|
127
|
-
hash *=
|
128
|
-
hash ^= hash >>
|
129
|
-
hash *=
|
130
|
-
hash ^= hash >>
|
109
|
+
hash ^= entryCount * 4;
|
110
|
+
hash ^= hash >> 16;
|
111
|
+
hash *= UINT32_C(0x85EBCA6B);
|
112
|
+
hash ^= hash >> 13;
|
113
|
+
hash *= UINT32_C(0xC2B2AE35);
|
114
|
+
hash ^= hash >> 16;
|
131
115
|
return hash;
|
132
116
|
}
|
133
117
|
|
118
|
+
#else
|
119
|
+
#error "Expected sizeof(size_t) to be 4 or 8."
|
134
120
|
#endif
|
@@ -5,29 +5,25 @@
|
|
5
5
|
|
6
6
|
#pragma once
|
7
7
|
|
8
|
+
#include <cstdint>
|
9
|
+
#include <type_traits>
|
10
|
+
|
8
11
|
#include "antlr4-common.h"
|
9
12
|
|
10
13
|
namespace antlr4 {
|
11
14
|
namespace misc {
|
12
15
|
|
13
|
-
class ANTLR4CPP_PUBLIC MurmurHash {
|
14
|
-
|
16
|
+
class ANTLR4CPP_PUBLIC MurmurHash final {
|
15
17
|
private:
|
16
|
-
#if __cplusplus >= 201703L
|
17
18
|
static constexpr size_t DEFAULT_SEED = 0;
|
18
|
-
#else
|
19
|
-
enum : size_t {
|
20
|
-
DEFAULT_SEED = 0,
|
21
|
-
};
|
22
|
-
#endif
|
23
19
|
|
24
20
|
/// Initialize the hash using the default seed value.
|
25
21
|
/// Returns the intermediate hash value.
|
26
22
|
public:
|
27
|
-
static size_t initialize();
|
23
|
+
static size_t initialize() { return initialize(DEFAULT_SEED); }
|
28
24
|
|
29
25
|
/// Initialize the hash using the specified seed.
|
30
|
-
static size_t initialize(size_t seed);
|
26
|
+
static size_t initialize(size_t seed) { return seed; }
|
31
27
|
|
32
28
|
/// Update the intermediate hash value for the next input {@code value}.
|
33
29
|
/// <param name="hash"> the intermediate hash value </param>
|
@@ -52,6 +48,13 @@ namespace misc {
|
|
52
48
|
return update(hash, value != nullptr ? value->hashCode() : 0);
|
53
49
|
}
|
54
50
|
|
51
|
+
static size_t update(size_t hash, const void *data, size_t size);
|
52
|
+
|
53
|
+
template <typename T>
|
54
|
+
static size_t update(size_t hash, const T *data, size_t size) {
|
55
|
+
return update(hash, static_cast<const void*>(data), size * sizeof(std::remove_reference_t<T>));
|
56
|
+
}
|
57
|
+
|
55
58
|
/// <summary>
|
56
59
|
/// Apply the final computation steps to the intermediate value {@code hash}
|
57
60
|
/// to form the final result of the MurmurHash 3 hash function.
|
@@ -68,14 +71,31 @@ namespace misc {
|
|
68
71
|
/// <param name="seed"> the seed for the MurmurHash algorithm </param>
|
69
72
|
/// <returns> the hash code of the data </returns>
|
70
73
|
template<typename T> // where T is C array type
|
71
|
-
static size_t hashCode(const std::vector<Ref<T>> &data, size_t seed) {
|
74
|
+
static size_t hashCode(const std::vector<Ref<T>> &data, size_t seed = DEFAULT_SEED) {
|
72
75
|
size_t hash = initialize(seed);
|
73
|
-
for (auto entry : data) {
|
74
|
-
hash = update(hash, entry
|
76
|
+
for (auto &entry : data) {
|
77
|
+
hash = update(hash, entry);
|
75
78
|
}
|
76
|
-
|
77
79
|
return finish(hash, data.size());
|
78
80
|
}
|
81
|
+
|
82
|
+
static size_t hashCode(const void *data, size_t size, size_t seed = DEFAULT_SEED) {
|
83
|
+
size_t hash = initialize(seed);
|
84
|
+
hash = update(hash, data, size);
|
85
|
+
return finish(hash, size);
|
86
|
+
}
|
87
|
+
|
88
|
+
template <typename T>
|
89
|
+
static size_t hashCode(const T *data, size_t size, size_t seed = DEFAULT_SEED) {
|
90
|
+
return hashCode(static_cast<const void*>(data), size * sizeof(std::remove_reference_t<T>), seed);
|
91
|
+
}
|
92
|
+
|
93
|
+
private:
|
94
|
+
MurmurHash() = delete;
|
95
|
+
|
96
|
+
MurmurHash(const MurmurHash&) = delete;
|
97
|
+
|
98
|
+
MurmurHash& operator=(const MurmurHash&) = delete;
|
79
99
|
};
|
80
100
|
|
81
101
|
} // namespace atn
|
@@ -9,162 +9,8 @@
|
|
9
9
|
|
10
10
|
#include "antlr4-common.h"
|
11
11
|
|
12
|
-
#ifdef _MSC_VER
|
13
|
-
#pragma warning(push)
|
14
|
-
#pragma warning(disable: 4521) // 'antlrcpp::Any': multiple copy constructors specified
|
15
|
-
#endif
|
16
|
-
|
17
12
|
namespace antlrcpp {
|
18
13
|
|
19
|
-
|
20
|
-
using StorageType = typename std::decay<T>::type;
|
21
|
-
|
22
|
-
struct ANTLR4CPP_PUBLIC Any
|
23
|
-
{
|
24
|
-
bool isNull() const { return _ptr == nullptr; }
|
25
|
-
bool isNotNull() const { return _ptr != nullptr; }
|
26
|
-
|
27
|
-
Any() : _ptr(nullptr) {
|
28
|
-
}
|
29
|
-
|
30
|
-
Any(Any& that) : _ptr(that.clone()) {
|
31
|
-
}
|
32
|
-
|
33
|
-
Any(Any&& that) : _ptr(that._ptr) {
|
34
|
-
that._ptr = nullptr;
|
35
|
-
}
|
36
|
-
|
37
|
-
Any(const Any& that) : _ptr(that.clone()) {
|
38
|
-
}
|
39
|
-
|
40
|
-
Any(const Any&& that) : _ptr(that.clone()) {
|
41
|
-
}
|
42
|
-
|
43
|
-
template<typename U>
|
44
|
-
Any(U&& value) : _ptr(new Derived<StorageType<U>>(std::forward<U>(value))) {
|
45
|
-
}
|
46
|
-
|
47
|
-
template<class U>
|
48
|
-
bool is() const {
|
49
|
-
auto derived = getDerived<U>(false);
|
50
|
-
|
51
|
-
return derived != nullptr;
|
52
|
-
}
|
53
|
-
|
54
|
-
template<class U>
|
55
|
-
StorageType<U>& as() {
|
56
|
-
auto derived = getDerived<U>(true);
|
57
|
-
|
58
|
-
return derived->value;
|
59
|
-
}
|
60
|
-
|
61
|
-
template<class U>
|
62
|
-
const StorageType<U>& as() const {
|
63
|
-
auto derived = getDerived<U>(true);
|
64
|
-
|
65
|
-
return derived->value;
|
66
|
-
}
|
67
|
-
|
68
|
-
template<class U>
|
69
|
-
operator U() {
|
70
|
-
return as<StorageType<U>>();
|
71
|
-
}
|
72
|
-
|
73
|
-
template<class U>
|
74
|
-
operator const U() const {
|
75
|
-
return as<const StorageType<U>>();
|
76
|
-
}
|
77
|
-
|
78
|
-
Any& operator = (const Any& a) {
|
79
|
-
if (_ptr == a._ptr)
|
80
|
-
return *this;
|
81
|
-
|
82
|
-
auto * old_ptr = _ptr;
|
83
|
-
_ptr = a.clone();
|
84
|
-
|
85
|
-
if (old_ptr)
|
86
|
-
delete old_ptr;
|
87
|
-
|
88
|
-
return *this;
|
89
|
-
}
|
90
|
-
|
91
|
-
Any& operator = (Any&& a) {
|
92
|
-
if (_ptr == a._ptr)
|
93
|
-
return *this;
|
94
|
-
|
95
|
-
std::swap(_ptr, a._ptr);
|
96
|
-
|
97
|
-
return *this;
|
98
|
-
}
|
99
|
-
|
100
|
-
virtual ~Any();
|
101
|
-
|
102
|
-
virtual bool equals(Any other) const {
|
103
|
-
return _ptr == other._ptr;
|
104
|
-
}
|
105
|
-
|
106
|
-
private:
|
107
|
-
struct Base {
|
108
|
-
virtual ~Base() {};
|
109
|
-
virtual Base* clone() const = 0;
|
110
|
-
};
|
111
|
-
|
112
|
-
template<typename T>
|
113
|
-
struct Derived : Base
|
114
|
-
{
|
115
|
-
template<typename U> Derived(U&& value_) : value(std::forward<U>(value_)) {
|
116
|
-
}
|
117
|
-
|
118
|
-
T value;
|
119
|
-
|
120
|
-
Base* clone() const {
|
121
|
-
return clone<>();
|
122
|
-
}
|
123
|
-
|
124
|
-
private:
|
125
|
-
template<int N = 0, typename std::enable_if<N == N && std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
|
126
|
-
Base* clone() const {
|
127
|
-
return new Derived<T>(value);
|
128
|
-
}
|
129
|
-
|
130
|
-
template<int N = 0, typename std::enable_if<N == N && !std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
|
131
|
-
Base* clone() const {
|
132
|
-
return nullptr;
|
133
|
-
}
|
134
|
-
|
135
|
-
};
|
136
|
-
|
137
|
-
Base* clone() const
|
138
|
-
{
|
139
|
-
if (_ptr)
|
140
|
-
return _ptr->clone();
|
141
|
-
else
|
142
|
-
return nullptr;
|
143
|
-
}
|
144
|
-
|
145
|
-
template<class U>
|
146
|
-
Derived<StorageType<U>>* getDerived(bool checkCast) const {
|
147
|
-
typedef StorageType<U> T;
|
148
|
-
|
149
|
-
auto derived = dynamic_cast<Derived<T>*>(_ptr);
|
150
|
-
|
151
|
-
if (checkCast && !derived)
|
152
|
-
throw std::bad_cast();
|
153
|
-
|
154
|
-
return derived;
|
155
|
-
}
|
156
|
-
|
157
|
-
Base *_ptr;
|
158
|
-
|
159
|
-
};
|
160
|
-
|
161
|
-
template<> inline
|
162
|
-
Any::Any(std::nullptr_t&& ) : _ptr(nullptr) {
|
163
|
-
}
|
164
|
-
|
14
|
+
using Any = std::any;
|
165
15
|
|
166
16
|
} // namespace antlrcpp
|
167
|
-
|
168
|
-
#ifdef _MSC_VER
|
169
|
-
#pragma warning(pop)
|
170
|
-
#endif
|