expressir 1.2.3 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +223 -31
- data/.gitignore +7 -1
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- data/README.adoc +8 -0
- data/Rakefile +4 -1
- data/bin/console +0 -1
- data/bin/rspec +3 -3
- data/exe/expressir +4 -2
- data/exe/format +1 -1
- data/exe/format-test +25 -25
- data/exe/generate-parser +16 -13
- data/expressir.gemspec +11 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +19 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +51 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +1 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +9 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +43 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +16 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +2 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +9 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +51 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +20 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +21 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +12 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +7 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -58
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +6 -57
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +35 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +29 -36
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +36 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -464
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -62
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +42 -36
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -108
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +10 -43
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +17 -28
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +169 -152
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +87 -116
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +11 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +2 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +15 -28
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +35 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +13 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -23
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -40
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +14 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +30 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
- data/ext/express-parser/antlrgen/Express.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
- data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
- data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
- data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
- data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
- data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
- data/ext/express-parser/express_parser.cpp +165 -101
- data/ext/express-parser/extconf.rb +14 -14
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +17 -15
- data/lib/expressir/express/visitor.rb +7 -3
- data/lib/expressir/model.rb +78 -78
- data/lib/expressir/version.rb +1 -1
- data/rakelib/antlr4-native.rake +161 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +17 -2
- data/spec/expressir/express/cache_spec.rb +23 -5
- data/spec/expressir/express/formatter_spec.rb +54 -8
- data/spec/expressir/express/parser_spec.rb +47 -11
- data/spec/expressir/model/model_element_spec.rb +198 -146
- data/spec/spec_helper.rb +7 -0
- metadata +79 -91
- data/demo.rb +0 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
- data/original/examples/employment/eclipse/.project +0 -17
- data/original/examples/employment/eclipse/Export/Employment.png +0 -0
- data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
- data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
- data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
- data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
- data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
- data/original/examples/employment/eclipse/readme.txt +0 -7
- data/original/examples/employment/employment_schema.exp +0 -33
- data/original/examples/employment/employment_schema.rb +0 -232
- data/original/examples/employment/employment_schema.xml +0 -93
- data/original/examples/employment/employment_schema___module.rb +0 -46
- data/original/examples/employment/employment_schema___p28attr.rb +0 -126
- data/original/examples/employment/employment_schema___p28inst.rb +0 -26
- data/original/examples/employment/example_employment_data.xml +0 -1
- data/original/examples/employment/example_employment_data_copy.xml +0 -1
- data/original/examples/employment/example_employment_reader.rb +0 -30
- data/original/examples/employment/example_employment_writer.rb +0 -51
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
- data/original/exp2ruby.rb +0 -525
- data/original/expsm.rb +0 -34
- data/original/mapping_owl.rb +0 -1018
- data/original/mapping_sysml.rb +0 -2281
- data/original/mapping_uml2.rb +0 -599
- data/original/mapping_uml2_eclipse.rb +0 -433
- data/original/reeper.rb +0 -134
- data/spec/expressr_spec.rb +0 -5
@@ -5,23 +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
|
-
static
|
18
|
+
static constexpr size_t DEFAULT_SEED = 0;
|
17
19
|
|
18
20
|
/// Initialize the hash using the default seed value.
|
19
21
|
/// Returns the intermediate hash value.
|
20
22
|
public:
|
21
|
-
static size_t initialize();
|
23
|
+
static size_t initialize() { return initialize(DEFAULT_SEED); }
|
22
24
|
|
23
25
|
/// Initialize the hash using the specified seed.
|
24
|
-
static size_t initialize(size_t seed);
|
26
|
+
static size_t initialize(size_t seed) { return seed; }
|
25
27
|
|
26
28
|
/// Update the intermediate hash value for the next input {@code value}.
|
27
29
|
/// <param name="hash"> the intermediate hash value </param>
|
@@ -46,6 +48,13 @@ namespace misc {
|
|
46
48
|
return update(hash, value != nullptr ? value->hashCode() : 0);
|
47
49
|
}
|
48
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
|
+
|
49
58
|
/// <summary>
|
50
59
|
/// Apply the final computation steps to the intermediate value {@code hash}
|
51
60
|
/// to form the final result of the MurmurHash 3 hash function.
|
@@ -62,14 +71,31 @@ namespace misc {
|
|
62
71
|
/// <param name="seed"> the seed for the MurmurHash algorithm </param>
|
63
72
|
/// <returns> the hash code of the data </returns>
|
64
73
|
template<typename T> // where T is C array type
|
65
|
-
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) {
|
66
75
|
size_t hash = initialize(seed);
|
67
|
-
for (auto entry : data) {
|
68
|
-
hash = update(hash, entry
|
76
|
+
for (auto &entry : data) {
|
77
|
+
hash = update(hash, entry);
|
69
78
|
}
|
70
|
-
|
71
79
|
return finish(hash, data.size());
|
72
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;
|
73
99
|
};
|
74
100
|
|
75
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
|
@@ -16,7 +16,7 @@ std::string Arrays::listToString(const std::vector<std::string> &list, const std
|
|
16
16
|
bool firstEntry = true;
|
17
17
|
|
18
18
|
ss << '[';
|
19
|
-
for (auto &entry : list) {
|
19
|
+
for (const auto &entry : list) {
|
20
20
|
ss << entry;
|
21
21
|
if (firstEntry) {
|
22
22
|
ss << separator;
|
@@ -32,7 +32,7 @@ template <>
|
|
32
32
|
std::string Arrays::toString(const std::vector<antlr4::tree::ParseTree*> &source) {
|
33
33
|
std::string result = "[";
|
34
34
|
bool firstEntry = true;
|
35
|
-
for (auto value : source) {
|
35
|
+
for (auto *value : source) {
|
36
36
|
result += value->toStringTree();
|
37
37
|
if (firstEntry) {
|
38
38
|
result += ", ";
|
@@ -32,8 +32,13 @@ namespace antlrcpp {
|
|
32
32
|
return false;
|
33
33
|
|
34
34
|
for (size_t i = 0; i < a.size(); ++i) {
|
35
|
+
if (!a[i] && !b[i])
|
36
|
+
continue;
|
37
|
+
if (!a[i] || !b[i])
|
38
|
+
return false;
|
35
39
|
if (a[i] == b[i])
|
36
40
|
continue;
|
41
|
+
|
37
42
|
if (!(*a[i] == *b[i]))
|
38
43
|
return false;
|
39
44
|
}
|
@@ -61,6 +66,26 @@ namespace antlrcpp {
|
|
61
66
|
return true;
|
62
67
|
}
|
63
68
|
|
69
|
+
template <typename T>
|
70
|
+
static bool equals(const std::vector<std::unique_ptr<T>> &a, const std::vector<std::unique_ptr<T>> &b) {
|
71
|
+
if (a.size() != b.size())
|
72
|
+
return false;
|
73
|
+
|
74
|
+
for (size_t i = 0; i < a.size(); ++i) {
|
75
|
+
if (!a[i] && !b[i])
|
76
|
+
continue;
|
77
|
+
if (!a[i] || !b[i])
|
78
|
+
return false;
|
79
|
+
if (a[i] == b[i])
|
80
|
+
continue;
|
81
|
+
|
82
|
+
if (!(*a[i] == *b[i]))
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
|
86
|
+
return true;
|
87
|
+
}
|
88
|
+
|
64
89
|
template <typename T>
|
65
90
|
static std::string toString(const std::vector<T> &source) {
|
66
91
|
std::string result = "[";
|
@@ -89,6 +114,20 @@ namespace antlrcpp {
|
|
89
114
|
return result + "]";
|
90
115
|
}
|
91
116
|
|
117
|
+
template <typename T>
|
118
|
+
static std::string toString(const std::vector<std::unique_ptr<T>> &source) {
|
119
|
+
std::string result = "[";
|
120
|
+
bool firstEntry = true;
|
121
|
+
for (auto &value : source) {
|
122
|
+
result += value->toString();
|
123
|
+
if (firstEntry) {
|
124
|
+
result += ", ";
|
125
|
+
firstEntry = false;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
return result + "]";
|
129
|
+
}
|
130
|
+
|
92
131
|
template <typename T>
|
93
132
|
static std::string toString(const std::vector<T *> &source) {
|
94
133
|
std::string result = "[";
|
@@ -7,10 +7,10 @@
|
|
7
7
|
|
8
8
|
namespace antlrcpp {
|
9
9
|
|
10
|
-
std::string join(std::vector<std::string> strings, const std::string &separator) {
|
10
|
+
std::string join(const std::vector<std::string> &strings, const std::string &separator) {
|
11
11
|
std::string str;
|
12
12
|
bool firstItem = true;
|
13
|
-
for (std::string s : strings) {
|
13
|
+
for (const std::string &s : strings) {
|
14
14
|
if (!firstItem) {
|
15
15
|
str.append(separator);
|
16
16
|
}
|
@@ -46,18 +46,15 @@ namespace antlrcpp {
|
|
46
46
|
|
47
47
|
case ' ':
|
48
48
|
if (escapeSpaces) {
|
49
|
-
result += "
|
49
|
+
result += "\u00B7";
|
50
50
|
break;
|
51
51
|
}
|
52
|
-
|
53
|
-
|
54
|
-
#if __has_cpp_attribute(clang::fallthrough)
|
55
|
-
[[clang::fallthrough]];
|
56
|
-
#endif
|
57
|
-
#endif
|
52
|
+
result += c;
|
53
|
+
break;
|
58
54
|
|
59
55
|
default:
|
60
56
|
result += c;
|
57
|
+
break;
|
61
58
|
}
|
62
59
|
}
|
63
60
|
|
@@ -72,8 +69,13 @@ namespace antlrcpp {
|
|
72
69
|
|
73
70
|
std::string arrayToString(const std::vector<std::string> &data) {
|
74
71
|
std::string answer;
|
75
|
-
|
76
|
-
|
72
|
+
size_t toReserve = 0;
|
73
|
+
for (const auto &sub : data) {
|
74
|
+
toReserve += sub.size();
|
75
|
+
}
|
76
|
+
answer.reserve(toReserve);
|
77
|
+
for (const auto &sub: data) {
|
78
|
+
answer.append(sub);
|
77
79
|
}
|
78
80
|
return answer;
|
79
81
|
}
|
@@ -202,47 +204,4 @@ namespace antlrcpp {
|
|
202
204
|
return result;
|
203
205
|
}
|
204
206
|
|
205
|
-
//----------------- FinallyAction ------------------------------------------------------------------------------------
|
206
|
-
|
207
|
-
FinalAction finally(std::function<void ()> f) {
|
208
|
-
return FinalAction(f);
|
209
|
-
}
|
210
|
-
|
211
|
-
//----------------- SingleWriteMultipleRead --------------------------------------------------------------------------
|
212
|
-
|
213
|
-
void SingleWriteMultipleReadLock::readLock() {
|
214
|
-
std::unique_lock<std::mutex> lock(_mutex);
|
215
|
-
while (_waitingWriters != 0)
|
216
|
-
_readerGate.wait(lock);
|
217
|
-
++_activeReaders;
|
218
|
-
lock.unlock();
|
219
|
-
}
|
220
|
-
|
221
|
-
void SingleWriteMultipleReadLock::readUnlock() {
|
222
|
-
std::unique_lock<std::mutex> lock(_mutex);
|
223
|
-
--_activeReaders;
|
224
|
-
lock.unlock();
|
225
|
-
_writerGate.notify_one();
|
226
|
-
}
|
227
|
-
|
228
|
-
void SingleWriteMultipleReadLock::writeLock() {
|
229
|
-
std::unique_lock<std::mutex> lock(_mutex);
|
230
|
-
++_waitingWriters;
|
231
|
-
while (_activeReaders != 0 || _activeWriters != 0)
|
232
|
-
_writerGate.wait(lock);
|
233
|
-
++_activeWriters;
|
234
|
-
lock.unlock();
|
235
|
-
}
|
236
|
-
|
237
|
-
void SingleWriteMultipleReadLock::writeUnlock() {
|
238
|
-
std::unique_lock<std::mutex> lock(_mutex);
|
239
|
-
--_waitingWriters;
|
240
|
-
--_activeWriters;
|
241
|
-
if (_waitingWriters > 0)
|
242
|
-
_writerGate.notify_one();
|
243
|
-
else
|
244
|
-
_readerGate.notify_all();
|
245
|
-
lock.unlock();
|
246
|
-
}
|
247
|
-
|
248
207
|
} // namespace antlrcpp
|
@@ -9,18 +9,19 @@
|
|
9
9
|
|
10
10
|
namespace antlrcpp {
|
11
11
|
|
12
|
-
std::string join(std::vector<std::string> strings, const std::string &separator);
|
13
|
-
std::map<std::string, size_t> toMap(const std::vector<std::string> &keys);
|
14
|
-
std::string escapeWhitespace(std::string str, bool escapeSpaces);
|
15
|
-
std::string toHexString(const int t);
|
16
|
-
std::string arrayToString(const std::vector<std::string> &data);
|
17
|
-
std::string replaceString(const std::string &s, const std::string &from, const std::string &to);
|
18
|
-
std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
|
19
|
-
std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
|
12
|
+
ANTLR4CPP_PUBLIC std::string join(const std::vector<std::string> &strings, const std::string &separator);
|
13
|
+
ANTLR4CPP_PUBLIC std::map<std::string, size_t> toMap(const std::vector<std::string> &keys);
|
14
|
+
ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string str, bool escapeSpaces);
|
15
|
+
ANTLR4CPP_PUBLIC std::string toHexString(const int t);
|
16
|
+
ANTLR4CPP_PUBLIC std::string arrayToString(const std::vector<std::string> &data);
|
17
|
+
ANTLR4CPP_PUBLIC std::string replaceString(const std::string &s, const std::string &from, const std::string &to);
|
18
|
+
ANTLR4CPP_PUBLIC std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
|
19
|
+
ANTLR4CPP_PUBLIC std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
|
20
20
|
|
21
21
|
// Using RAII + a lambda to implement a "finally" replacement.
|
22
|
+
template <typename OnEnd>
|
22
23
|
struct FinalAction {
|
23
|
-
FinalAction(
|
24
|
+
FinalAction(OnEnd f) : _cleanUp { std::move(f) } {}
|
24
25
|
FinalAction(FinalAction &&other) :
|
25
26
|
_cleanUp(std::move(other._cleanUp)), _enabled(other._enabled) {
|
26
27
|
other._enabled = false; // Don't trigger the lambda after ownership has moved.
|
@@ -29,11 +30,14 @@ namespace antlrcpp {
|
|
29
30
|
|
30
31
|
void disable() { _enabled = false; }
|
31
32
|
private:
|
32
|
-
|
33
|
+
OnEnd _cleanUp;
|
33
34
|
bool _enabled {true};
|
34
35
|
};
|
35
36
|
|
36
|
-
|
37
|
+
template <typename OnEnd>
|
38
|
+
FinalAction<OnEnd> finally(OnEnd f) {
|
39
|
+
return FinalAction<OnEnd>(std::move(f));
|
40
|
+
}
|
37
41
|
|
38
42
|
// Convenience functions to avoid lengthy dynamic_cast() != nullptr checks in many places.
|
39
43
|
template <typename T1, typename T2>
|
@@ -56,23 +60,6 @@ namespace antlrcpp {
|
|
56
60
|
}
|
57
61
|
|
58
62
|
// Get the error text from an exception pointer or the current exception.
|
59
|
-
std::string what(std::exception_ptr eptr = std::current_exception());
|
60
|
-
|
61
|
-
class SingleWriteMultipleReadLock {
|
62
|
-
public:
|
63
|
-
void readLock();
|
64
|
-
void readUnlock();
|
65
|
-
void writeLock();
|
66
|
-
void writeUnlock();
|
67
|
-
|
68
|
-
private:
|
69
|
-
std::condition_variable _readerGate;
|
70
|
-
std::condition_variable _writerGate;
|
71
|
-
|
72
|
-
std::mutex _mutex;
|
73
|
-
size_t _activeReaders = 0;
|
74
|
-
size_t _waitingWriters = 0;
|
75
|
-
size_t _activeWriters = 0;
|
76
|
-
};
|
63
|
+
ANTLR4CPP_PUBLIC std::string what(std::exception_ptr eptr = std::current_exception());
|
77
64
|
|
78
65
|
} // namespace antlrcpp
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/* Copyright (c) 2012-2021 The ANTLR Project. All rights reserved.
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#pragma once
|
7
|
+
|
8
|
+
#include <cassert>
|
9
|
+
#include <memory>
|
10
|
+
#include <type_traits>
|
11
|
+
|
12
|
+
namespace antlrcpp {
|
13
|
+
|
14
|
+
template <typename To, typename From>
|
15
|
+
To downCast(From* from) {
|
16
|
+
static_assert(std::is_pointer_v<To>, "Target type not a pointer.");
|
17
|
+
static_assert(std::is_base_of_v<From, std::remove_pointer_t<To>>, "Target type not derived from source type.");
|
18
|
+
#if !defined(__GNUC__) || defined(__GXX_RTTI)
|
19
|
+
assert(from == nullptr || dynamic_cast<To>(from) != nullptr);
|
20
|
+
#endif
|
21
|
+
return static_cast<To>(from);
|
22
|
+
}
|
23
|
+
|
24
|
+
template <typename To, typename From>
|
25
|
+
To downCast(From& from) {
|
26
|
+
static_assert(std::is_lvalue_reference_v<To>, "Target type not a lvalue reference.");
|
27
|
+
static_assert(std::is_base_of_v<From, std::remove_reference_t<To>>, "Target type not derived from source type.");
|
28
|
+
#if !defined(__GNUC__) || defined(__GXX_RTTI)
|
29
|
+
assert(dynamic_cast<std::add_pointer_t<std::remove_reference_t<To>>>(std::addressof(from)) != nullptr);
|
30
|
+
#endif
|
31
|
+
return static_cast<To>(from);
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
@@ -69,7 +69,6 @@ namespace antlr4 {
|
|
69
69
|
class ATNSimulator;
|
70
70
|
class ATNState;
|
71
71
|
enum class ATNType;
|
72
|
-
class AbstractPredicateTransition;
|
73
72
|
class ActionTransition;
|
74
73
|
class ArrayPredictionContext;
|
75
74
|
class AtomTransition;
|
@@ -78,7 +77,6 @@ namespace antlr4 {
|
|
78
77
|
class BlockEndState;
|
79
78
|
class BlockStartState;
|
80
79
|
class DecisionState;
|
81
|
-
class EmptyPredictionContext;
|
82
80
|
class EpsilonTransition;
|
83
81
|
class LL1Analyzer;
|
84
82
|
class LexerAction;
|
@@ -7,30 +7,32 @@
|
|
7
7
|
|
8
8
|
namespace antlrcpp {
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
size_t start_pos = 0;
|
16
|
-
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
17
|
-
str.replace(start_pos, from.length(), to);
|
18
|
-
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'.
|
10
|
+
std::string escapeWhitespace(std::string_view in) {
|
11
|
+
std::string out;
|
12
|
+
escapeWhitespace(out, in);
|
13
|
+
out.shrink_to_fit();
|
14
|
+
return out;
|
19
15
|
}
|
20
|
-
}
|
21
|
-
|
22
|
-
std::string ws2s(std::wstring const& wstr) {
|
23
|
-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
24
|
-
std::string narrow = converter.to_bytes(wstr);
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
17
|
+
std::string& escapeWhitespace(std::string& out, std::string_view in) {
|
18
|
+
out.reserve(in.size()); // Best case, no escaping.
|
19
|
+
for (const auto &c : in) {
|
20
|
+
switch (c) {
|
21
|
+
case '\t':
|
22
|
+
out.append("\\t");
|
23
|
+
break;
|
24
|
+
case '\r':
|
25
|
+
out.append("\\r");
|
26
|
+
break;
|
27
|
+
case '\n':
|
28
|
+
out.append("\\n");
|
29
|
+
break;
|
30
|
+
default:
|
31
|
+
out.push_back(c);
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return out;
|
36
|
+
}
|
35
37
|
|
36
38
|
} // namespace antrlcpp
|
@@ -9,46 +9,8 @@
|
|
9
9
|
|
10
10
|
namespace antlrcpp {
|
11
11
|
|
12
|
-
|
13
|
-
// VS 2015 and VS 2017 have different bugs in std::codecvt_utf8<char32_t> (VS 2013 works fine).
|
14
|
-
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
15
|
-
typedef std::wstring_convert<std::codecvt_utf8<__int32>, __int32> UTF32Converter;
|
16
|
-
#else
|
17
|
-
typedef std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> UTF32Converter;
|
18
|
-
#endif
|
19
|
-
|
20
|
-
// The conversion functions fails in VS2017, so we explicitly use a workaround.
|
21
|
-
template<typename T>
|
22
|
-
inline std::string utf32_to_utf8(T const& data)
|
23
|
-
{
|
24
|
-
// Don't make the converter static or we have to serialize access to it.
|
25
|
-
thread_local UTF32Converter converter;
|
12
|
+
ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string_view in);
|
26
13
|
|
27
|
-
|
28
|
-
auto p = reinterpret_cast<const int32_t *>(data.data());
|
29
|
-
return converter.to_bytes(p, p + data.size());
|
30
|
-
#else
|
31
|
-
return converter.to_bytes(data);
|
32
|
-
#endif
|
33
|
-
}
|
14
|
+
ANTLR4CPP_PUBLIC std::string& escapeWhitespace(std::string& out, std::string_view in);
|
34
15
|
|
35
|
-
inline UTF32String utf8_to_utf32(const char* first, const char* last)
|
36
|
-
{
|
37
|
-
thread_local UTF32Converter converter;
|
38
|
-
|
39
|
-
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
40
|
-
auto r = converter.from_bytes(first, last);
|
41
|
-
i32string s = reinterpret_cast<const int32_t *>(r.data());
|
42
|
-
#else
|
43
|
-
std::u32string s = converter.from_bytes(first, last);
|
44
|
-
#endif
|
45
|
-
|
46
|
-
return s;
|
47
|
-
}
|
48
|
-
|
49
|
-
void replaceAll(std::string &str, std::string const& from, std::string const& to);
|
50
|
-
|
51
|
-
// string <-> wstring conversion (UTF-16), e.g. for use with Window's wide APIs.
|
52
|
-
ANTLR4CPP_PUBLIC std::string ws2s(std::wstring const& wstr);
|
53
|
-
ANTLR4CPP_PUBLIC std::wstring s2ws(std::string const& str);
|
54
16
|
}
|