expressir 1.2.4 → 1.2.5
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 -9
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- data/Rakefile +4 -1
- data/bin/console +0 -1
- data/bin/rspec +3 -3
- data/exe/expressir +4 -2
- data/exe/format +1 -1
- data/exe/format-test +25 -25
- data/exe/generate-parser +16 -13
- data/expressir.gemspec +11 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
- data/ext/express-parser/antlrgen/Express.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
- data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
- data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
- data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
- data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
- data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
- data/ext/express-parser/express_parser.cpp +207 -75
- data/ext/express-parser/extconf.rb +10 -9
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +2 -2
- data/lib/expressir/express/visitor.rb +7 -5
- data/lib/expressir/model.rb +78 -78
- data/lib/expressir/version.rb +1 -1
- data/rakelib/antlr4-native.rake +63 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +7 -2
- data/spec/expressir/express/cache_spec.rb +8 -5
- data/spec/expressir/express/formatter_spec.rb +16 -8
- data/spec/expressir/express/parser_spec.rb +17 -11
- data/spec/expressir/model/model_element_spec.rb +154 -146
- metadata +79 -91
- data/demo.rb +0 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
- data/original/examples/employment/eclipse/.project +0 -17
- data/original/examples/employment/eclipse/Export/Employment.png +0 -0
- data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
- data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
- data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
- data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
- data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
- data/original/examples/employment/eclipse/readme.txt +0 -7
- data/original/examples/employment/employment_schema.exp +0 -33
- data/original/examples/employment/employment_schema.rb +0 -232
- data/original/examples/employment/employment_schema.xml +0 -93
- data/original/examples/employment/employment_schema___module.rb +0 -46
- data/original/examples/employment/employment_schema___p28attr.rb +0 -126
- data/original/examples/employment/employment_schema___p28inst.rb +0 -26
- data/original/examples/employment/example_employment_data.xml +0 -1
- data/original/examples/employment/example_employment_data_copy.xml +0 -1
- data/original/examples/employment/example_employment_reader.rb +0 -30
- data/original/examples/employment/example_employment_writer.rb +0 -51
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
- data/original/exp2ruby.rb +0 -525
- data/original/expsm.rb +0 -34
- data/original/mapping_owl.rb +0 -1018
- data/original/mapping_sysml.rb +0 -2281
- data/original/mapping_uml2.rb +0 -599
- data/original/mapping_uml2_eclipse.rb +0 -433
- data/original/reeper.rb +0 -134
- data/spec/expressr_spec.rb +0 -5
@@ -6,18 +6,14 @@
|
|
6
6
|
#pragma once
|
7
7
|
|
8
8
|
#include "ProxyErrorListener.h"
|
9
|
+
#include "support/Casts.h"
|
10
|
+
#include "atn/SerializedATNView.h"
|
9
11
|
|
10
12
|
namespace antlr4 {
|
11
13
|
|
12
14
|
class ANTLR4CPP_PUBLIC Recognizer {
|
13
15
|
public:
|
14
|
-
#if __cplusplus >= 201703L
|
15
16
|
static constexpr size_t EOF = std::numeric_limits<size_t>::max();
|
16
|
-
#else
|
17
|
-
enum : size_t {
|
18
|
-
EOF = static_cast<size_t>(-1), // std::numeric_limits<size_t>::max(); doesn't work in VS 2013.
|
19
|
-
};
|
20
|
-
#endif
|
21
17
|
|
22
18
|
Recognizer();
|
23
19
|
Recognizer(Recognizer const&) = delete;
|
@@ -25,13 +21,6 @@ namespace antlr4 {
|
|
25
21
|
|
26
22
|
Recognizer& operator=(Recognizer const&) = delete;
|
27
23
|
|
28
|
-
/** Used to print out token names like ID during debugging and
|
29
|
-
* error reporting. The generated parsers implement a method
|
30
|
-
* that overrides this to point to their String[] tokenNames.
|
31
|
-
*
|
32
|
-
* @deprecated Use {@link #getVocabulary()} instead.
|
33
|
-
*/
|
34
|
-
virtual std::vector<std::string> const& getTokenNames() const = 0;
|
35
24
|
virtual std::vector<std::string> const& getRuleNames() const = 0;
|
36
25
|
|
37
26
|
/**
|
@@ -40,14 +29,14 @@ namespace antlr4 {
|
|
40
29
|
* @return A {@link Vocabulary} instance providing information about the
|
41
30
|
* vocabulary used by the grammar.
|
42
31
|
*/
|
43
|
-
virtual dfa::Vocabulary const& getVocabulary() const;
|
32
|
+
virtual dfa::Vocabulary const& getVocabulary() const = 0;
|
44
33
|
|
45
34
|
/// <summary>
|
46
35
|
/// Get a map from token names to token types.
|
47
36
|
/// <p/>
|
48
37
|
/// Used for XPath and tree pattern compilation.
|
49
38
|
/// </summary>
|
50
|
-
virtual std::map<std::
|
39
|
+
virtual std::map<std::string_view, size_t> getTokenTypeMap();
|
51
40
|
|
52
41
|
/// <summary>
|
53
42
|
/// Get a map from rule names to rule indexes.
|
@@ -56,7 +45,7 @@ namespace antlr4 {
|
|
56
45
|
/// </summary>
|
57
46
|
virtual std::map<std::string, size_t> getRuleIndexMap();
|
58
47
|
|
59
|
-
virtual size_t getTokenType(
|
48
|
+
virtual size_t getTokenType(std::string_view tokenName);
|
60
49
|
|
61
50
|
/// <summary>
|
62
51
|
/// If this recognizer was generated, it will have a serialized ATN
|
@@ -65,7 +54,7 @@ namespace antlr4 {
|
|
65
54
|
/// For interpreters, we don't know their serialized ATN despite having
|
66
55
|
/// created the interpreter from it.
|
67
56
|
/// </summary>
|
68
|
-
virtual
|
57
|
+
virtual atn::SerializedATNView getSerializedATN() const {
|
69
58
|
throw "there is no serialized ATN";
|
70
59
|
}
|
71
60
|
|
@@ -79,7 +68,7 @@ namespace antlr4 {
|
|
79
68
|
/// @returns The ATN interpreter used by the recognizer for prediction.
|
80
69
|
template <class T>
|
81
70
|
T* getInterpreter() const {
|
82
|
-
return
|
71
|
+
return antlrcpp::downCast<T *>(_interpreter);
|
83
72
|
}
|
84
73
|
|
85
74
|
/**
|
@@ -125,7 +114,7 @@ namespace antlr4 {
|
|
125
114
|
|
126
115
|
virtual void action(RuleContext *localctx, size_t ruleIndex, size_t actionIndex);
|
127
116
|
|
128
|
-
|
117
|
+
size_t getState() const { return _stateNumber; }
|
129
118
|
|
130
119
|
// Get the ATN used by the recognizer for prediction.
|
131
120
|
virtual const atn::ATN& getATN() const = 0;
|
@@ -138,7 +127,7 @@ namespace antlr4 {
|
|
138
127
|
/// invoking rules. Combine this and we have complete ATN
|
139
128
|
/// configuration information.
|
140
129
|
/// </summary>
|
141
|
-
void setState(size_t atnState);
|
130
|
+
void setState(size_t atnState) { _stateNumber = atnState; }
|
142
131
|
|
143
132
|
virtual IntStream* getInputStream() = 0;
|
144
133
|
|
@@ -156,7 +145,7 @@ namespace antlr4 {
|
|
156
145
|
std::mutex _mutex;
|
157
146
|
|
158
147
|
private:
|
159
|
-
static std::map<const dfa::Vocabulary*, std::map<std::
|
148
|
+
static std::map<const dfa::Vocabulary*, std::map<std::string_view, size_t>> _tokenTypeMapCache;
|
160
149
|
static std::map<std::vector<std::string>, std::map<std::string, size_t>> _ruleIndexMapCache;
|
161
150
|
|
162
151
|
ProxyErrorListener _proxListener; // Manages a collection of listeners.
|
@@ -14,12 +14,13 @@
|
|
14
14
|
|
15
15
|
using namespace antlr4;
|
16
16
|
using namespace antlr4::atn;
|
17
|
+
using namespace antlr4::tree;
|
17
18
|
|
18
|
-
RuleContext::RuleContext() {
|
19
|
+
RuleContext::RuleContext() : ParseTree(ParseTreeType::RULE) {
|
19
20
|
InitializeInstanceFields();
|
20
21
|
}
|
21
22
|
|
22
|
-
RuleContext::RuleContext(RuleContext *parent_, size_t invokingState_) {
|
23
|
+
RuleContext::RuleContext(RuleContext *parent_, size_t invokingState_) : ParseTree(ParseTreeType::RULE) {
|
23
24
|
InitializeInstanceFields();
|
24
25
|
this->parent = parent_;
|
25
26
|
this->invokingState = invokingState_;
|
@@ -71,7 +72,7 @@ size_t RuleContext::getAltNumber() const {
|
|
71
72
|
void RuleContext::setAltNumber(size_t /*altNumber*/) {
|
72
73
|
}
|
73
74
|
|
74
|
-
|
75
|
+
std::any RuleContext::accept(tree::ParseTreeVisitor *visitor) {
|
75
76
|
return visitor->visitChildren(this);
|
76
77
|
}
|
77
78
|
|
@@ -61,6 +61,10 @@ namespace antlr4 {
|
|
61
61
|
*/
|
62
62
|
class ANTLR4CPP_PUBLIC RuleContext : public tree::ParseTree {
|
63
63
|
public:
|
64
|
+
static bool is(const tree::ParseTree &parseTree) { return parseTree.getTreeType() == tree::ParseTreeType::RULE; }
|
65
|
+
|
66
|
+
static bool is(const tree::ParseTree *parseTree) { return parseTree != nullptr && is(*parseTree); }
|
67
|
+
|
64
68
|
/// What state invoked the rule associated with this context?
|
65
69
|
/// The "return address" is the followState of invokingState
|
66
70
|
/// If parent is null, this should be -1 and this context object represents the start rule.
|
@@ -103,7 +107,7 @@ namespace antlr4 {
|
|
103
107
|
*/
|
104
108
|
virtual void setAltNumber(size_t altNumber);
|
105
109
|
|
106
|
-
virtual
|
110
|
+
virtual std::any accept(tree::ParseTreeVisitor *visitor) override;
|
107
111
|
|
108
112
|
/// <summary>
|
109
113
|
/// Print out a whole tree, not just a node, in LISP format
|
@@ -4,10 +4,11 @@
|
|
4
4
|
*/
|
5
5
|
|
6
6
|
#include "RuntimeMetaData.h"
|
7
|
+
#include "Version.h"
|
7
8
|
|
8
9
|
using namespace antlr4;
|
9
10
|
|
10
|
-
const std::string RuntimeMetaData::VERSION =
|
11
|
+
const std::string RuntimeMetaData::VERSION = ANTLRCPP_VERSION_STRING;
|
11
12
|
|
12
13
|
std::string RuntimeMetaData::getRuntimeVersion() {
|
13
14
|
return VERSION;
|
@@ -14,50 +14,24 @@ namespace antlr4 {
|
|
14
14
|
/// we obtained this token.
|
15
15
|
class ANTLR4CPP_PUBLIC Token {
|
16
16
|
public:
|
17
|
-
#if __cplusplus >= 201703L
|
18
17
|
static constexpr size_t INVALID_TYPE = 0;
|
19
|
-
#else
|
20
|
-
enum : size_t {
|
21
|
-
INVALID_TYPE = 0,
|
22
|
-
};
|
23
|
-
#endif
|
24
18
|
|
25
19
|
/// During lookahead operations, this "token" signifies we hit rule end ATN state
|
26
20
|
/// and did not follow it despite needing to.
|
27
|
-
#if __cplusplus >= 201703L
|
28
21
|
static constexpr size_t EPSILON = std::numeric_limits<size_t>::max() - 1;
|
29
22
|
static constexpr size_t MIN_USER_TOKEN_TYPE = 1;
|
30
23
|
static constexpr size_t EOF = IntStream::EOF;
|
31
|
-
#else
|
32
|
-
enum : size_t {
|
33
|
-
EPSILON = static_cast<size_t>(-2), // std::numeric_limits<size_t>::max() - 1; doesn't work in VS 2013
|
34
|
-
MIN_USER_TOKEN_TYPE = 1,
|
35
|
-
EOF = IntStream::EOF,
|
36
|
-
};
|
37
|
-
#endif
|
38
24
|
|
39
25
|
virtual ~Token();
|
40
26
|
|
41
27
|
/// All tokens go to the parser (unless skip() is called in that rule)
|
42
28
|
/// on a particular "channel". The parser tunes to a particular channel
|
43
29
|
/// so that whitespace etc... can go to the parser on a "hidden" channel.
|
44
|
-
#if __cplusplus >= 201703L
|
45
30
|
static constexpr size_t DEFAULT_CHANNEL = 0;
|
46
|
-
#else
|
47
|
-
enum : size_t {
|
48
|
-
DEFAULT_CHANNEL = 0,
|
49
|
-
};
|
50
|
-
#endif
|
51
31
|
|
52
32
|
/// Anything on different channel than DEFAULT_CHANNEL is not parsed
|
53
33
|
/// by parser.
|
54
|
-
#if __cplusplus >= 201703L
|
55
34
|
static constexpr size_t HIDDEN_CHANNEL = 1;
|
56
|
-
#else
|
57
|
-
enum : size_t {
|
58
|
-
HIDDEN_CHANNEL = 1,
|
59
|
-
};
|
60
|
-
#endif
|
61
35
|
|
62
36
|
/**
|
63
37
|
* This is the minimum constant value which can be assigned to a
|
@@ -70,13 +44,7 @@ namespace antlr4 {
|
|
70
44
|
*
|
71
45
|
* @see Token#getChannel()
|
72
46
|
*/
|
73
|
-
#if __cplusplus >= 201703L
|
74
47
|
static constexpr size_t MIN_USER_CHANNEL_VALUE = 2;
|
75
|
-
#else
|
76
|
-
enum : size_t {
|
77
|
-
MIN_USER_CHANNEL_VALUE = 2,
|
78
|
-
};
|
79
|
-
#endif
|
80
48
|
|
81
49
|
/// Get the text of the token.
|
82
50
|
virtual std::string getText() const = 0;
|
@@ -93,7 +93,7 @@ TokenStreamRewriter::TokenStreamRewriter(TokenStream *tokens_) : tokens(tokens_)
|
|
93
93
|
}
|
94
94
|
|
95
95
|
TokenStreamRewriter::~TokenStreamRewriter() {
|
96
|
-
for (auto program : _programs) {
|
96
|
+
for (const auto &program : _programs) {
|
97
97
|
for (auto *operation : program.second) {
|
98
98
|
delete operation;
|
99
99
|
}
|
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
#pragma once
|
7
7
|
|
8
|
+
#include "antlr4-common.h"
|
9
|
+
|
8
10
|
namespace antlr4 {
|
9
11
|
|
10
12
|
/**
|
@@ -86,15 +88,8 @@ namespace antlr4 {
|
|
86
88
|
class ANTLR4CPP_PUBLIC TokenStreamRewriter {
|
87
89
|
public:
|
88
90
|
static const std::string DEFAULT_PROGRAM_NAME;
|
89
|
-
#if __cplusplus >= 201703L
|
90
91
|
static constexpr size_t PROGRAM_INIT_SIZE = 100;
|
91
92
|
static constexpr size_t MIN_TOKEN_INDEX = 0;
|
92
|
-
#else
|
93
|
-
enum : size_t {
|
94
|
-
PROGRAM_INIT_SIZE = 100,
|
95
|
-
MIN_TOKEN_INDEX = 0,
|
96
|
-
};
|
97
|
-
#endif
|
98
93
|
|
99
94
|
TokenStreamRewriter(TokenStream *tokens);
|
100
95
|
virtual ~TokenStreamRewriter();
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
#include "misc/Interval.h"
|
7
7
|
#include "Exceptions.h"
|
8
|
-
#include "support/
|
8
|
+
#include "support/Utf8.h"
|
9
9
|
|
10
10
|
#include "UnbufferedCharStream.h"
|
11
11
|
|
@@ -13,9 +13,8 @@ using namespace antlrcpp;
|
|
13
13
|
using namespace antlr4;
|
14
14
|
using namespace antlr4::misc;
|
15
15
|
|
16
|
-
UnbufferedCharStream::UnbufferedCharStream(std::wistream &input)
|
17
|
-
|
18
|
-
|
16
|
+
UnbufferedCharStream::UnbufferedCharStream(std::wistream &input)
|
17
|
+
: _p(0), _numMarkers(0), _lastChar(0), _lastCharBufferStart(0), _currentCharIndex(0), _input(input) {
|
19
18
|
// The vector's size is what used to be n in Java code.
|
20
19
|
fill(1); // prime
|
21
20
|
}
|
@@ -74,9 +73,7 @@ size_t UnbufferedCharStream::fill(size_t n) {
|
|
74
73
|
}
|
75
74
|
|
76
75
|
char32_t UnbufferedCharStream::nextChar() {
|
77
|
-
|
78
|
-
_input >> result;
|
79
|
-
return result;
|
76
|
+
return _input.get();
|
80
77
|
}
|
81
78
|
|
82
79
|
void UnbufferedCharStream::add(char32_t c) {
|
@@ -101,7 +98,7 @@ size_t UnbufferedCharStream::LA(ssize_t i) {
|
|
101
98
|
return EOF;
|
102
99
|
}
|
103
100
|
|
104
|
-
if (_data[static_cast<size_t>(index)] ==
|
101
|
+
if (_data[static_cast<size_t>(index)] == std::char_traits<wchar_t>::eof()) {
|
105
102
|
return EOF;
|
106
103
|
}
|
107
104
|
|
@@ -178,7 +175,7 @@ std::string UnbufferedCharStream::getSourceName() const {
|
|
178
175
|
}
|
179
176
|
|
180
177
|
std::string UnbufferedCharStream::getText(const misc::Interval &interval) {
|
181
|
-
if (interval.a < 0 || interval.b
|
178
|
+
if (interval.a < 0 || interval.b < interval.a - 1) {
|
182
179
|
throw IllegalArgumentException("invalid interval");
|
183
180
|
}
|
184
181
|
|
@@ -195,17 +192,17 @@ std::string UnbufferedCharStream::getText(const misc::Interval &interval) {
|
|
195
192
|
}
|
196
193
|
// convert from absolute to local index
|
197
194
|
size_t i = interval.a - bufferStartIndex;
|
198
|
-
|
195
|
+
auto maybeUtf8 = Utf8::strictEncode(std::u32string_view(_data).substr(i, interval.length()));
|
196
|
+
if (!maybeUtf8.has_value()) {
|
197
|
+
throw IllegalArgumentException("Unbuffered stream contains invalid Unicode code points");
|
198
|
+
}
|
199
|
+
return std::move(maybeUtf8).value();
|
199
200
|
}
|
200
201
|
|
201
|
-
|
202
|
-
|
202
|
+
std::string UnbufferedCharStream::toString() const {
|
203
|
+
throw UnsupportedOperationException("Unbuffered stream cannot be materialized to a string");
|
203
204
|
}
|
204
205
|
|
205
|
-
|
206
|
-
|
207
|
-
_numMarkers = 0;
|
208
|
-
_lastChar = 0;
|
209
|
-
_lastCharBufferStart = 0;
|
210
|
-
_currentCharIndex = 0;
|
206
|
+
size_t UnbufferedCharStream::getBufferStartIndex() const {
|
207
|
+
return _currentCharIndex - _p;
|
211
208
|
}
|
@@ -18,10 +18,10 @@ namespace antlr4 {
|
|
18
18
|
/// The name or source of this char stream.
|
19
19
|
std::string name;
|
20
20
|
|
21
|
-
UnbufferedCharStream(std::wistream &input);
|
21
|
+
explicit UnbufferedCharStream(std::wistream &input);
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
void consume() override;
|
24
|
+
size_t LA(ssize_t i) override;
|
25
25
|
|
26
26
|
/// <summary>
|
27
27
|
/// Return a marker that we can release later.
|
@@ -30,35 +30,32 @@ namespace antlr4 {
|
|
30
30
|
/// protection against misuse where {@code seek()} is called on a mark or
|
31
31
|
/// {@code release()} is called in the wrong order.
|
32
32
|
/// </summary>
|
33
|
-
|
33
|
+
ssize_t mark() override;
|
34
34
|
|
35
35
|
/// <summary>
|
36
36
|
/// Decrement number of markers, resetting buffer if we hit 0. </summary>
|
37
37
|
/// <param name="marker"> </param>
|
38
|
-
|
39
|
-
|
38
|
+
void release(ssize_t marker) override;
|
39
|
+
size_t index() override;
|
40
40
|
|
41
41
|
/// <summary>
|
42
42
|
/// Seek to absolute character index, which might not be in the current
|
43
43
|
/// sliding window. Move {@code p} to {@code index-bufferStartIndex}.
|
44
44
|
/// </summary>
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
void seek(size_t index) override;
|
46
|
+
size_t size() override;
|
47
|
+
std::string getSourceName() const override;
|
48
|
+
std::string getText(const misc::Interval &interval) override;
|
49
|
+
|
50
|
+
std::string toString() const override;
|
49
51
|
|
50
52
|
protected:
|
51
53
|
/// A moving window buffer of the data being scanned. While there's a marker,
|
52
54
|
/// we keep adding to buffer. Otherwise, <seealso cref="#consume consume()"/> resets so
|
53
55
|
/// we start filling at index 0 again.
|
54
56
|
// UTF-32 encoded.
|
55
|
-
#if defined(_MSC_VER) && _MSC_VER == 1900
|
56
|
-
i32string _data; // Custom type for VS 2015.
|
57
|
-
typedef __int32 storage_type;
|
58
|
-
#else
|
59
57
|
std::u32string _data;
|
60
58
|
typedef char32_t storage_type;
|
61
|
-
#endif
|
62
59
|
|
63
60
|
/// <summary>
|
64
61
|
/// 0..n-1 index into <seealso cref="#data data"/> of next character.
|
@@ -115,9 +112,6 @@ namespace antlr4 {
|
|
115
112
|
virtual char32_t nextChar();
|
116
113
|
virtual void add(char32_t c);
|
117
114
|
size_t getBufferStartIndex() const;
|
118
|
-
|
119
|
-
private:
|
120
|
-
void InitializeInstanceFields();
|
121
115
|
};
|
122
116
|
|
123
117
|
} // namespace antlr4
|
@@ -0,0 +1,42 @@
|
|
1
|
+
// Copyright 2012-2022 The ANTLR Project
|
2
|
+
//
|
3
|
+
// Redistribution and use in source and binary forms, with or without modification, are permitted
|
4
|
+
// provided that the following conditions are met:
|
5
|
+
//
|
6
|
+
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
|
7
|
+
// and the following disclaimer.
|
8
|
+
//
|
9
|
+
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
10
|
+
// conditions and the following disclaimer in the documentation and/or other materials provided
|
11
|
+
// with the distribution.
|
12
|
+
//
|
13
|
+
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to
|
14
|
+
// endorse or promote products derived from this software without specific prior written
|
15
|
+
// permission.
|
16
|
+
//
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
18
|
+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
20
|
+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
22
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
23
|
+
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
24
|
+
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
|
26
|
+
#pragma once
|
27
|
+
|
28
|
+
#include "antlr4-common.h"
|
29
|
+
|
30
|
+
#define ANTLRCPP_VERSION_MAJOR 4
|
31
|
+
#define ANTLRCPP_VERSION_MINOR 10
|
32
|
+
#define ANTLRCPP_VERSION_PATCH 1
|
33
|
+
|
34
|
+
#define ANTLRCPP_MAKE_VERSION(major, minor, patch) ((major) * 100000 + (minor) * 1000 + (patch))
|
35
|
+
|
36
|
+
#define ANTLRCPP_VERSION \
|
37
|
+
ANTLRCPP_MAKE_VERSION(ANTLR4CPP_VERSION_MAJOR, ANTLR4CPP_VERSION_MINOR, ANTLR4CPP_VERSION_PATCH)
|
38
|
+
|
39
|
+
#define ANTLRCPP_VERSION_STRING \
|
40
|
+
ANTLR4CPP_STRINGIFY(ANTLR4CPP_VERSION_MAJOR) "." \
|
41
|
+
ANTLR4CPP_STRINGIFY(ANTLR4CPP_VERSION_MINOR) "." \
|
42
|
+
ANTLR4CPP_STRINGIFY(ANTLR4CPP_VERSION_PATCH)
|
@@ -11,50 +11,18 @@ using namespace antlr4::dfa;
|
|
11
11
|
|
12
12
|
const Vocabulary Vocabulary::EMPTY_VOCABULARY;
|
13
13
|
|
14
|
-
Vocabulary::Vocabulary(
|
15
|
-
: Vocabulary(literalNames, symbolicNames, {}) {
|
14
|
+
Vocabulary::Vocabulary(std::vector<std::string> literalNames, std::vector<std::string> symbolicNames)
|
15
|
+
: Vocabulary(std::move(literalNames), std::move(symbolicNames), {}) {
|
16
16
|
}
|
17
17
|
|
18
|
-
Vocabulary::Vocabulary(
|
19
|
-
|
20
|
-
: _literalNames(literalNames), _symbolicNames(symbolicNames), _displayNames(displayNames),
|
18
|
+
Vocabulary::Vocabulary(std::vector<std::string> literalNames,
|
19
|
+
std::vector<std::string> symbolicNames, std::vector<std::string> displayNames)
|
20
|
+
: _literalNames(std::move(literalNames)), _symbolicNames(std::move(symbolicNames)), _displayNames(std::move(displayNames)),
|
21
21
|
_maxTokenType(std::max(_displayNames.size(), std::max(_literalNames.size(), _symbolicNames.size())) - 1) {
|
22
22
|
// See note here on -1 part: https://github.com/antlr/antlr4/pull/1146
|
23
23
|
}
|
24
24
|
|
25
|
-
Vocabulary
|
26
|
-
|
27
|
-
Vocabulary Vocabulary::fromTokenNames(const std::vector<std::string> &tokenNames) {
|
28
|
-
if (tokenNames.empty()) {
|
29
|
-
return EMPTY_VOCABULARY;
|
30
|
-
}
|
31
|
-
|
32
|
-
std::vector<std::string> literalNames = tokenNames;
|
33
|
-
std::vector<std::string> symbolicNames = tokenNames;
|
34
|
-
std::locale locale;
|
35
|
-
for (size_t i = 0; i < tokenNames.size(); i++) {
|
36
|
-
const std::string& tokenName = tokenNames[i];
|
37
|
-
if (tokenName.empty()) {
|
38
|
-
continue;
|
39
|
-
} else if (tokenName.front() == '\'') {
|
40
|
-
symbolicNames[i].clear();
|
41
|
-
} else if (std::isupper(tokenName.front(), locale)) {
|
42
|
-
literalNames[i].clear();
|
43
|
-
} else {
|
44
|
-
// wasn't a literal or symbolic name
|
45
|
-
literalNames[i].clear();
|
46
|
-
symbolicNames[i].clear();
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
|
-
return Vocabulary(literalNames, symbolicNames, tokenNames);
|
51
|
-
}
|
52
|
-
|
53
|
-
size_t Vocabulary::getMaxTokenType() const {
|
54
|
-
return _maxTokenType;
|
55
|
-
}
|
56
|
-
|
57
|
-
std::string Vocabulary::getLiteralName(size_t tokenType) const {
|
25
|
+
std::string_view Vocabulary::getLiteralName(size_t tokenType) const {
|
58
26
|
if (tokenType < _literalNames.size()) {
|
59
27
|
return _literalNames[tokenType];
|
60
28
|
}
|
@@ -62,7 +30,7 @@ std::string Vocabulary::getLiteralName(size_t tokenType) const {
|
|
62
30
|
return "";
|
63
31
|
}
|
64
32
|
|
65
|
-
std::
|
33
|
+
std::string_view Vocabulary::getSymbolicName(size_t tokenType) const {
|
66
34
|
if (tokenType == Token::EOF) {
|
67
35
|
return "EOF";
|
68
36
|
}
|
@@ -76,20 +44,20 @@ std::string Vocabulary::getSymbolicName(size_t tokenType) const {
|
|
76
44
|
|
77
45
|
std::string Vocabulary::getDisplayName(size_t tokenType) const {
|
78
46
|
if (tokenType < _displayNames.size()) {
|
79
|
-
std::
|
47
|
+
std::string_view displayName = _displayNames[tokenType];
|
80
48
|
if (!displayName.empty()) {
|
81
|
-
return displayName;
|
49
|
+
return std::string(displayName);
|
82
50
|
}
|
83
51
|
}
|
84
52
|
|
85
|
-
std::
|
53
|
+
std::string_view literalName = getLiteralName(tokenType);
|
86
54
|
if (!literalName.empty()) {
|
87
|
-
return literalName;
|
55
|
+
return std::string(literalName);
|
88
56
|
}
|
89
57
|
|
90
|
-
std::
|
58
|
+
std::string_view symbolicName = getSymbolicName(tokenType);
|
91
59
|
if (!symbolicName.empty()) {
|
92
|
-
return symbolicName;
|
60
|
+
return std::string(symbolicName);
|
93
61
|
}
|
94
62
|
|
95
63
|
return std::to_string(tokenType);
|
@@ -12,7 +12,7 @@ namespace dfa {
|
|
12
12
|
|
13
13
|
/// This class provides a default implementation of the <seealso cref="Vocabulary"/>
|
14
14
|
/// interface.
|
15
|
-
class ANTLR4CPP_PUBLIC Vocabulary {
|
15
|
+
class ANTLR4CPP_PUBLIC Vocabulary final {
|
16
16
|
public:
|
17
17
|
/// Gets an empty <seealso cref="Vocabulary"/> instance.
|
18
18
|
///
|
@@ -20,11 +20,11 @@ namespace dfa {
|
|
20
20
|
/// No literal or symbol names are assigned to token types, so
|
21
21
|
/// <seealso cref="#getDisplayName(int)"/> returns the numeric value for all tokens
|
22
22
|
/// except <seealso cref="Token#EOF"/>.</para>
|
23
|
-
static const Vocabulary EMPTY_VOCABULARY;
|
23
|
+
[[deprecated("Use the default constructor of Vocabulary instead.")]] static const Vocabulary EMPTY_VOCABULARY;
|
24
24
|
|
25
25
|
Vocabulary() {}
|
26
|
-
|
27
|
-
|
26
|
+
|
27
|
+
Vocabulary(const Vocabulary&) = default;
|
28
28
|
|
29
29
|
/// <summary>
|
30
30
|
/// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified
|
@@ -37,7 +37,7 @@ namespace dfa {
|
|
37
37
|
/// </param>
|
38
38
|
/// <seealso cref= #getLiteralName(int) </seealso>
|
39
39
|
/// <seealso cref= #getSymbolicName(int) </seealso>
|
40
|
-
Vocabulary(
|
40
|
+
Vocabulary(std::vector<std::string> literalNames, std::vector<std::string> symbolicNames);
|
41
41
|
|
42
42
|
/// <summary>
|
43
43
|
/// Constructs a new instance of <seealso cref="Vocabulary"/> from the specified
|
@@ -55,29 +55,14 @@ namespace dfa {
|
|
55
55
|
/// <seealso cref= #getLiteralName(int) </seealso>
|
56
56
|
/// <seealso cref= #getSymbolicName(int) </seealso>
|
57
57
|
/// <seealso cref= #getDisplayName(int) </seealso>
|
58
|
-
Vocabulary(
|
59
|
-
|
60
|
-
|
61
|
-
/// <summary>
|
62
|
-
/// Returns a <seealso cref="Vocabulary"/> instance from the specified set of token
|
63
|
-
/// names. This method acts as a compatibility layer for the single
|
64
|
-
/// {@code tokenNames} array generated by previous releases of ANTLR.
|
65
|
-
///
|
66
|
-
/// <para>The resulting vocabulary instance returns {@code null} for
|
67
|
-
/// <seealso cref="#getLiteralName(int)"/> and <seealso cref="#getSymbolicName(int)"/>, and the
|
68
|
-
/// value from {@code tokenNames} for the display names.</para>
|
69
|
-
/// </summary>
|
70
|
-
/// <param name="tokenNames"> The token names, or {@code null} if no token names are
|
71
|
-
/// available. </param>
|
72
|
-
/// <returns> A <seealso cref="Vocabulary"/> instance which uses {@code tokenNames} for
|
73
|
-
/// the display names of tokens. </returns>
|
74
|
-
static Vocabulary fromTokenNames(const std::vector<std::string> &tokenNames);
|
58
|
+
Vocabulary(std::vector<std::string> literalNames, std::vector<std::string> symbolicNames,
|
59
|
+
std::vector<std::string> displayNames);
|
75
60
|
|
76
61
|
/// <summary>
|
77
62
|
/// Returns the highest token type value. It can be used to iterate from
|
78
63
|
/// zero to that number, inclusively, thus querying all stored entries. </summary>
|
79
64
|
/// <returns> the highest token type value </returns>
|
80
|
-
|
65
|
+
constexpr size_t getMaxTokenType() const { return _maxTokenType; }
|
81
66
|
|
82
67
|
/// <summary>
|
83
68
|
/// Gets the string literal associated with a token type. The string returned
|
@@ -114,7 +99,7 @@ namespace dfa {
|
|
114
99
|
/// </param>
|
115
100
|
/// <returns> The string literal associated with the specified token type, or
|
116
101
|
/// {@code null} if no string literal is associated with the type. </returns>
|
117
|
-
|
102
|
+
std::string_view getLiteralName(size_t tokenType) const;
|
118
103
|
|
119
104
|
/// <summary>
|
120
105
|
/// Gets the symbolic name associated with a token type. The string returned
|
@@ -158,7 +143,7 @@ namespace dfa {
|
|
158
143
|
/// </param>
|
159
144
|
/// <returns> The symbolic name associated with the specified token type, or
|
160
145
|
/// {@code null} if no symbolic name is associated with the type. </returns>
|
161
|
-
|
146
|
+
std::string_view getSymbolicName(size_t tokenType) const;
|
162
147
|
|
163
148
|
/// <summary>
|
164
149
|
/// Gets the display name of a token type.
|
@@ -179,7 +164,7 @@ namespace dfa {
|
|
179
164
|
/// </param>
|
180
165
|
/// <returns> The display name of the token type, for use in error reporting or
|
181
166
|
/// other user-visible messages which reference specific token types. </returns>
|
182
|
-
|
167
|
+
std::string getDisplayName(size_t tokenType) const;
|
183
168
|
|
184
169
|
private:
|
185
170
|
std::vector<std::string> const _literalNames;
|