expressir 1.2.4 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cross_rubies +0 -6
- data/.github/workflows/rake.yml +200 -21
- data/.gitignore +7 -2
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -4
- data/README.adoc +8 -0
- data/Rakefile +4 -1
- data/bin/console +0 -1
- data/bin/rspec +3 -3
- data/exe/expressir +4 -2
- data/exe/format +1 -1
- data/exe/format-test +25 -25
- data/exe/generate-parser +16 -13
- data/expressir.gemspec +12 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +44 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +11 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +11 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +30 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +13 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +2 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +16 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +5 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -13
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +47 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +27 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +1 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +19 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +20 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +16 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +10 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +2 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +2 -7
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +15 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +12 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +13 -45
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +11 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +19 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +7 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +4 -55
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +34 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +30 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +35 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +58 -54
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +77 -31
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +22 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +22 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +335 -462
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +9 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +9 -39
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +6 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +10 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +41 -42
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +49 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +20 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +10 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +12 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +6 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +139 -106
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +9 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +16 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +12 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +69 -82
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +15 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +12 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +45 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +48 -44
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +31 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +14 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +15 -32
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +12 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +23 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +13 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +12 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +6 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +11 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +13 -26
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +13 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +1 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +8 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +164 -151
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +26 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +5 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +2 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +15 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +4 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +22 -11
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +255 -338
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +86 -127
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +18 -17
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +4 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +5 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +197 -156
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +92 -81
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +2 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +11 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +39 -34
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +17 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +6 -6
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +6 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +5 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +11 -22
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +1 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +4 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +9 -21
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +20 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +1 -8
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +9 -50
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +57 -48
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +1 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +3 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +2 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +3 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +1 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +10 -10
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +7 -20
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +1 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +54 -68
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +34 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +1 -155
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +39 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +1 -1
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +12 -53
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +16 -29
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +25 -33
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +2 -62
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +13 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +7 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +36 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +14 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +14 -19
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -3
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +13 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +8 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +4 -4
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +10 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +2 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +4 -5
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +1 -2
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +128 -119
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +18 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +110 -0
- data/ext/express-parser/antlrgen/Express.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +200 -200
- data/ext/express-parser/antlrgen/ExpressLexer.cpp +645 -1129
- data/ext/express-parser/antlrgen/ExpressLexer.h +20 -27
- data/ext/express-parser/antlrgen/ExpressLexer.interp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressListener.h +1 -1
- data/ext/express-parser/antlrgen/ExpressParser.cpp +1754 -1447
- data/ext/express-parser/antlrgen/ExpressParser.h +219 -223
- data/ext/express-parser/antlrgen/ExpressVisitor.cpp +1 -1
- data/ext/express-parser/antlrgen/ExpressVisitor.h +200 -200
- data/ext/express-parser/express_parser.cpp +294 -86
- data/ext/express-parser/extconf.rb +13 -12
- data/lib/expressir/config.rb +1 -1
- data/lib/expressir/express/parser.rb +3 -4
- data/lib/expressir/express/visitor.rb +7 -5
- data/lib/expressir/model.rb +78 -78
- data/lib/expressir/version.rb +1 -1
- data/rakelib/antlr4-native.rake +161 -0
- data/rakelib/cross-ruby.rake +213 -162
- data/spec/acceptance/version_spec.rb +17 -2
- data/spec/expressir/express/cache_spec.rb +23 -5
- data/spec/expressir/express/formatter_spec.rb +54 -8
- data/spec/expressir/express/parser_spec.rb +47 -11
- data/spec/expressir/model/model_element_spec.rb +198 -146
- data/spec/spec_helper.rb +7 -0
- metadata +81 -93
- data/demo.rb +0 -18
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +0 -621
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +0 -61
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +0 -14
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +0 -24
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +0 -35
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +0 -27
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +0 -67
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +0 -16
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +0 -15
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +0 -12
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +0 -303
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +0 -112
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +0 -9
- data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +0 -9
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +0 -9589
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +0 -36619
- data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +0 -13294
- data/original/examples/employment/eclipse/.project +0 -17
- data/original/examples/employment/eclipse/Export/Employment.png +0 -0
- data/original/examples/employment/eclipse/Express/employment_schema.exp +0 -33
- data/original/examples/employment/eclipse/Express/employment_schema.xmi +0 -77
- data/original/examples/employment/eclipse/Express/employment_schema.xml +0 -93
- data/original/examples/employment/eclipse/Models/Employment.uml +0 -4
- data/original/examples/employment/eclipse/Models/Employment.umldi +0 -240
- data/original/examples/employment/eclipse/readme.txt +0 -7
- data/original/examples/employment/employment_schema.exp +0 -33
- data/original/examples/employment/employment_schema.rb +0 -232
- data/original/examples/employment/employment_schema.xml +0 -93
- data/original/examples/employment/employment_schema___module.rb +0 -46
- data/original/examples/employment/employment_schema___p28attr.rb +0 -126
- data/original/examples/employment/employment_schema___p28inst.rb +0 -26
- data/original/examples/employment/example_employment_data.xml +0 -1
- data/original/examples/employment/example_employment_data_copy.xml +0 -1
- data/original/examples/employment/example_employment_reader.rb +0 -30
- data/original/examples/employment/example_employment_writer.rb +0 -51
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +0 -3710
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +0 -35880
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +0 -15357
- data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +0 -9468
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +0 -8404
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +0 -43147
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +0 -18341
- data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +0 -11632
- data/original/exp2ruby.rb +0 -525
- data/original/expsm.rb +0 -34
- data/original/mapping_owl.rb +0 -1018
- data/original/mapping_sysml.rb +0 -2281
- data/original/mapping_uml2.rb +0 -599
- data/original/mapping_uml2_eclipse.rb +0 -433
- data/original/reeper.rb +0 -134
- data/spec/expressr_spec.rb +0 -5
@@ -0,0 +1,242 @@
|
|
1
|
+
/* Copyright (c) 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
|
+
#include <cassert>
|
7
|
+
#include <cstdint>
|
8
|
+
|
9
|
+
#include "support/Utf8.h"
|
10
|
+
#include "support/Unicode.h"
|
11
|
+
|
12
|
+
// The below implementation is based off of https://github.com/google/cel-cpp/internal/utf8.cc,
|
13
|
+
// which is itself based off of https://go.googlesource.com/go/+/refs/heads/master/src/unicode/utf8/utf8.go.
|
14
|
+
// If for some reason you feel the need to copy this implementation, please retain a comment
|
15
|
+
// referencing the two source files and giving credit, as well as maintaining any and all
|
16
|
+
// obligations required by the BSD 3-clause license that governs this file.
|
17
|
+
|
18
|
+
namespace antlrcpp {
|
19
|
+
|
20
|
+
namespace {
|
21
|
+
|
22
|
+
#undef SELF
|
23
|
+
constexpr uint8_t SELF = 0x80;
|
24
|
+
|
25
|
+
#undef LOW
|
26
|
+
constexpr uint8_t LOW = 0x80;
|
27
|
+
#undef HIGH
|
28
|
+
constexpr uint8_t HIGH = 0xbf;
|
29
|
+
|
30
|
+
#undef MASKX
|
31
|
+
constexpr uint8_t MASKX = 0x3f;
|
32
|
+
#undef MASK2
|
33
|
+
constexpr uint8_t MASK2 = 0x1f;
|
34
|
+
#undef MASK3
|
35
|
+
constexpr uint8_t MASK3 = 0xf;
|
36
|
+
#undef MASK4
|
37
|
+
constexpr uint8_t MASK4 = 0x7;
|
38
|
+
|
39
|
+
#undef TX
|
40
|
+
constexpr uint8_t TX = 0x80;
|
41
|
+
#undef T2
|
42
|
+
constexpr uint8_t T2 = 0xc0;
|
43
|
+
#undef T3
|
44
|
+
constexpr uint8_t T3 = 0xe0;
|
45
|
+
#undef T4
|
46
|
+
constexpr uint8_t T4 = 0xf0;
|
47
|
+
|
48
|
+
#undef XX
|
49
|
+
constexpr uint8_t XX = 0xf1;
|
50
|
+
#undef AS
|
51
|
+
constexpr uint8_t AS = 0xf0;
|
52
|
+
#undef S1
|
53
|
+
constexpr uint8_t S1 = 0x02;
|
54
|
+
#undef S2
|
55
|
+
constexpr uint8_t S2 = 0x13;
|
56
|
+
#undef S3
|
57
|
+
constexpr uint8_t S3 = 0x03;
|
58
|
+
#undef S4
|
59
|
+
constexpr uint8_t S4 = 0x23;
|
60
|
+
#undef S5
|
61
|
+
constexpr uint8_t S5 = 0x34;
|
62
|
+
#undef S6
|
63
|
+
constexpr uint8_t S6 = 0x04;
|
64
|
+
#undef S7
|
65
|
+
constexpr uint8_t S7 = 0x44;
|
66
|
+
|
67
|
+
// NOLINTBEGIN
|
68
|
+
// clang-format off
|
69
|
+
#undef LEADING
|
70
|
+
constexpr uint8_t LEADING[256] = {
|
71
|
+
// 1 2 3 4 5 6 7 8 9 A B C D E F
|
72
|
+
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x00-0x0F
|
73
|
+
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x10-0x1F
|
74
|
+
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x20-0x2F
|
75
|
+
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x30-0x3F
|
76
|
+
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x40-0x4F
|
77
|
+
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x50-0x5F
|
78
|
+
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x60-0x6F
|
79
|
+
AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, AS, // 0x70-0x7F
|
80
|
+
// 1 2 3 4 5 6 7 8 9 A B C D E F
|
81
|
+
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0x80-0x8F
|
82
|
+
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0x90-0x9F
|
83
|
+
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0xA0-0xAF
|
84
|
+
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0xB0-0xBF
|
85
|
+
XX, XX, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, // 0xC0-0xCF
|
86
|
+
S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, S1, // 0xD0-0xDF
|
87
|
+
S2, S3, S3, S3, S3, S3, S3, S3, S3, S3, S3, S3, S3, S4, S3, S3, // 0xE0-0xEF
|
88
|
+
S5, S6, S6, S6, S7, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, // 0xF0-0xFF
|
89
|
+
};
|
90
|
+
// clang-format on
|
91
|
+
// NOLINTEND
|
92
|
+
|
93
|
+
#undef ACCEPT
|
94
|
+
constexpr std::pair<uint8_t, uint8_t> ACCEPT[16] = {
|
95
|
+
{LOW, HIGH}, {0xa0, HIGH}, {LOW, 0x9f}, {0x90, HIGH},
|
96
|
+
{LOW, 0x8f}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0},
|
97
|
+
{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0},
|
98
|
+
{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0},
|
99
|
+
};
|
100
|
+
|
101
|
+
} // namespace
|
102
|
+
|
103
|
+
std::pair<char32_t, size_t> Utf8::decode(std::string_view input) {
|
104
|
+
assert(!input.empty());
|
105
|
+
const auto b = static_cast<uint8_t>(input.front());
|
106
|
+
input.remove_prefix(1);
|
107
|
+
if (b < SELF) {
|
108
|
+
return {static_cast<char32_t>(b), 1};
|
109
|
+
}
|
110
|
+
const auto leading = LEADING[b];
|
111
|
+
if (leading == XX) {
|
112
|
+
return {Unicode::REPLACEMENT_CHARACTER, 1};
|
113
|
+
}
|
114
|
+
auto size = static_cast<size_t>(leading & 7) - 1;
|
115
|
+
if (size > input.size()) {
|
116
|
+
return {Unicode::REPLACEMENT_CHARACTER, 1};
|
117
|
+
}
|
118
|
+
const auto& accept = ACCEPT[leading >> 4];
|
119
|
+
const auto b1 = static_cast<uint8_t>(input.front());
|
120
|
+
input.remove_prefix(1);
|
121
|
+
if (b1 < accept.first || b1 > accept.second) {
|
122
|
+
return {Unicode::REPLACEMENT_CHARACTER, 1};
|
123
|
+
}
|
124
|
+
if (size <= 1) {
|
125
|
+
return {(static_cast<char32_t>(b & MASK2) << 6) |
|
126
|
+
static_cast<char32_t>(b1 & MASKX),
|
127
|
+
2};
|
128
|
+
}
|
129
|
+
const auto b2 = static_cast<uint8_t>(input.front());
|
130
|
+
input.remove_prefix(1);
|
131
|
+
if (b2 < LOW || b2 > HIGH) {
|
132
|
+
return {Unicode::REPLACEMENT_CHARACTER, 1};
|
133
|
+
}
|
134
|
+
if (size <= 2) {
|
135
|
+
return {(static_cast<char32_t>(b & MASK3) << 12) |
|
136
|
+
(static_cast<char32_t>(b1 & MASKX) << 6) |
|
137
|
+
static_cast<char32_t>(b2 & MASKX),
|
138
|
+
3};
|
139
|
+
}
|
140
|
+
const auto b3 = static_cast<uint8_t>(input.front());
|
141
|
+
input.remove_prefix(1);
|
142
|
+
if (b3 < LOW || b3 > HIGH) {
|
143
|
+
return {Unicode::REPLACEMENT_CHARACTER, 1};
|
144
|
+
}
|
145
|
+
return {(static_cast<char32_t>(b & MASK4) << 18) |
|
146
|
+
(static_cast<char32_t>(b1 & MASKX) << 12) |
|
147
|
+
(static_cast<char32_t>(b2 & MASKX) << 6) |
|
148
|
+
static_cast<char32_t>(b3 & MASKX),
|
149
|
+
4};
|
150
|
+
}
|
151
|
+
|
152
|
+
std::optional<std::u32string> Utf8::strictDecode(std::string_view input) {
|
153
|
+
std::u32string output;
|
154
|
+
char32_t codePoint;
|
155
|
+
size_t codeUnits;
|
156
|
+
output.reserve(input.size()); // Worst case is each byte is a single Unicode code point.
|
157
|
+
for (size_t index = 0; index < input.size(); index += codeUnits) {
|
158
|
+
std::tie(codePoint, codeUnits) = Utf8::decode(input.substr(index));
|
159
|
+
if (codePoint == Unicode::REPLACEMENT_CHARACTER && codeUnits == 1) {
|
160
|
+
// Condition is only met when an illegal byte sequence is encountered. See Utf8::decode.
|
161
|
+
return std::nullopt;
|
162
|
+
}
|
163
|
+
output.push_back(codePoint);
|
164
|
+
}
|
165
|
+
output.shrink_to_fit();
|
166
|
+
return output;
|
167
|
+
}
|
168
|
+
|
169
|
+
std::u32string Utf8::lenientDecode(std::string_view input) {
|
170
|
+
std::u32string output;
|
171
|
+
char32_t codePoint;
|
172
|
+
size_t codeUnits;
|
173
|
+
output.reserve(input.size()); // Worst case is each byte is a single Unicode code point.
|
174
|
+
for (size_t index = 0; index < input.size(); index += codeUnits) {
|
175
|
+
std::tie(codePoint, codeUnits) = Utf8::decode(input.substr(index));
|
176
|
+
output.push_back(codePoint);
|
177
|
+
}
|
178
|
+
output.shrink_to_fit();
|
179
|
+
return output;
|
180
|
+
}
|
181
|
+
|
182
|
+
std::string& Utf8::encode(std::string* buffer, char32_t codePoint) {
|
183
|
+
assert(buffer != nullptr);
|
184
|
+
if (!Unicode::isValid(codePoint)) {
|
185
|
+
codePoint = Unicode::REPLACEMENT_CHARACTER;
|
186
|
+
}
|
187
|
+
if (codePoint <= 0x7f) {
|
188
|
+
buffer->push_back(static_cast<char>(static_cast<uint8_t>(codePoint)));
|
189
|
+
} else if (codePoint <= 0x7ff) {
|
190
|
+
buffer->push_back(
|
191
|
+
static_cast<char>(T2 | static_cast<uint8_t>(codePoint >> 6)));
|
192
|
+
buffer->push_back(
|
193
|
+
static_cast<char>(TX | (static_cast<uint8_t>(codePoint) & MASKX)));
|
194
|
+
} else if (codePoint <= 0xffff) {
|
195
|
+
buffer->push_back(
|
196
|
+
static_cast<char>(T3 | static_cast<uint8_t>(codePoint >> 12)));
|
197
|
+
buffer->push_back(static_cast<char>(
|
198
|
+
TX | (static_cast<uint8_t>(codePoint >> 6) & MASKX)));
|
199
|
+
buffer->push_back(
|
200
|
+
static_cast<char>(TX | (static_cast<uint8_t>(codePoint) & MASKX)));
|
201
|
+
} else {
|
202
|
+
buffer->push_back(
|
203
|
+
static_cast<char>(T4 | static_cast<uint8_t>(codePoint >> 18)));
|
204
|
+
buffer->push_back(static_cast<char>(
|
205
|
+
TX | (static_cast<uint8_t>(codePoint >> 12) & MASKX)));
|
206
|
+
buffer->push_back(static_cast<char>(
|
207
|
+
TX | (static_cast<uint8_t>(codePoint >> 6) & MASKX)));
|
208
|
+
buffer->push_back(
|
209
|
+
static_cast<char>(TX | (static_cast<uint8_t>(codePoint) & MASKX)));
|
210
|
+
}
|
211
|
+
return *buffer;
|
212
|
+
}
|
213
|
+
|
214
|
+
std::optional<std::string> Utf8::strictEncode(std::u32string_view input) {
|
215
|
+
std::string output;
|
216
|
+
output.reserve(input.size() * 4); // Worst case is each Unicode code point encodes to 4 bytes.
|
217
|
+
for (size_t index = 0; index < input.size(); index++) {
|
218
|
+
char32_t codePoint = input[index];
|
219
|
+
if (!Unicode::isValid(codePoint)) {
|
220
|
+
return std::nullopt;
|
221
|
+
}
|
222
|
+
Utf8::encode(&output, codePoint);
|
223
|
+
}
|
224
|
+
output.shrink_to_fit();
|
225
|
+
return output;
|
226
|
+
}
|
227
|
+
|
228
|
+
std::string Utf8::lenientEncode(std::u32string_view input) {
|
229
|
+
std::string output;
|
230
|
+
output.reserve(input.size() * 4); // Worst case is each Unicode code point encodes to 4 bytes.
|
231
|
+
for (size_t index = 0; index < input.size(); index++) {
|
232
|
+
char32_t codePoint = input[index];
|
233
|
+
if (!Unicode::isValid(codePoint)) {
|
234
|
+
codePoint = Unicode::REPLACEMENT_CHARACTER;
|
235
|
+
}
|
236
|
+
Utf8::encode(&output, codePoint);
|
237
|
+
}
|
238
|
+
output.shrink_to_fit();
|
239
|
+
return output;
|
240
|
+
}
|
241
|
+
|
242
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/* Copyright (c) 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 <optional>
|
9
|
+
#include <string>
|
10
|
+
#include <string_view>
|
11
|
+
#include <tuple>
|
12
|
+
|
13
|
+
#include "antlr4-common.h"
|
14
|
+
|
15
|
+
namespace antlrcpp {
|
16
|
+
|
17
|
+
class ANTLR4CPP_PUBLIC Utf8 final {
|
18
|
+
public:
|
19
|
+
// Decodes the next code point, returning the decoded code point and the number
|
20
|
+
// of code units (a.k.a. bytes) consumed. In the event that an invalid code unit
|
21
|
+
// sequence is returned the replacement character, U+FFFD, is returned with a
|
22
|
+
// code unit count of 1. As U+FFFD requires 3 code units when encoded, this can
|
23
|
+
// be used to differentiate valid input from malformed input.
|
24
|
+
static std::pair<char32_t, size_t> decode(std::string_view input);
|
25
|
+
|
26
|
+
// Decodes the given UTF-8 encoded input into a string of code points.
|
27
|
+
static std::optional<std::u32string> strictDecode(std::string_view input);
|
28
|
+
|
29
|
+
// Decodes the given UTF-8 encoded input into a string of code points. Unlike strictDecode(),
|
30
|
+
// each byte in an illegal byte sequence is replaced with the Unicode replacement character,
|
31
|
+
// U+FFFD.
|
32
|
+
static std::u32string lenientDecode(std::string_view input);
|
33
|
+
|
34
|
+
// Encodes the given code point and appends it to the buffer. If the code point
|
35
|
+
// is an unpaired surrogate or outside of the valid Unicode range it is replaced
|
36
|
+
// with the replacement character, U+FFFD.
|
37
|
+
static std::string& encode(std::string *buffer, char32_t codePoint);
|
38
|
+
|
39
|
+
// Encodes the given Unicode code point string as UTF-8.
|
40
|
+
static std::optional<std::string> strictEncode(std::u32string_view input);
|
41
|
+
|
42
|
+
// Encodes the given Unicode code point string as UTF-8. Unlike strictEncode(),
|
43
|
+
// each invalid Unicode code point is replaced with the Unicode replacement character, U+FFFD.
|
44
|
+
static std::string lenientEncode(std::u32string_view input);
|
45
|
+
|
46
|
+
private:
|
47
|
+
Utf8() = delete;
|
48
|
+
Utf8(const Utf8&) = delete;
|
49
|
+
Utf8(Utf8&&) = delete;
|
50
|
+
Utf8& operator=(const Utf8&) = delete;
|
51
|
+
Utf8& operator=(Utf8&&) = delete;
|
52
|
+
};
|
53
|
+
|
54
|
+
}
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
#pragma once
|
7
7
|
|
8
|
+
#include "tree/ParseTree.h"
|
8
9
|
#include "tree/ParseTreeVisitor.h"
|
9
10
|
|
10
11
|
namespace antlr4 {
|
@@ -14,7 +15,7 @@ namespace tree {
|
|
14
15
|
public:
|
15
16
|
/// The default implementation calls <seealso cref="ParseTree#accept"/> on the
|
16
17
|
/// specified tree.
|
17
|
-
virtual
|
18
|
+
virtual std::any visit(ParseTree *tree) override {
|
18
19
|
return tree->accept(this);
|
19
20
|
}
|
20
21
|
|
@@ -31,16 +32,16 @@ namespace tree {
|
|
31
32
|
* the tree structure. Visitors that modify the tree should override this
|
32
33
|
* method to behave properly in respect to the specific algorithm in use.</p>
|
33
34
|
*/
|
34
|
-
virtual
|
35
|
-
|
35
|
+
virtual std::any visitChildren(ParseTree *node) override {
|
36
|
+
std::any result = defaultResult();
|
36
37
|
size_t n = node->children.size();
|
37
38
|
for (size_t i = 0; i < n; i++) {
|
38
39
|
if (!shouldVisitNextChild(node, result)) {
|
39
40
|
break;
|
40
41
|
}
|
41
42
|
|
42
|
-
|
43
|
-
result = aggregateResult(result, childResult);
|
43
|
+
std::any childResult = node->children[i]->accept(this);
|
44
|
+
result = aggregateResult(std::move(result), std::move(childResult));
|
44
45
|
}
|
45
46
|
|
46
47
|
return result;
|
@@ -48,13 +49,13 @@ namespace tree {
|
|
48
49
|
|
49
50
|
/// The default implementation returns the result of
|
50
51
|
/// <seealso cref="#defaultResult defaultResult"/>.
|
51
|
-
virtual
|
52
|
+
virtual std::any visitTerminal(TerminalNode * /*node*/) override {
|
52
53
|
return defaultResult();
|
53
54
|
}
|
54
55
|
|
55
56
|
/// The default implementation returns the result of
|
56
57
|
/// <seealso cref="#defaultResult defaultResult"/>.
|
57
|
-
virtual
|
58
|
+
virtual std::any visitErrorNode(ErrorNode * /*node*/) override {
|
58
59
|
return defaultResult();
|
59
60
|
}
|
60
61
|
|
@@ -66,11 +67,11 @@ namespace tree {
|
|
66
67
|
/// The default implementation of <seealso cref="#visitChildren visitChildren"/>
|
67
68
|
/// initializes its aggregate result to this value.
|
68
69
|
/// <p/>
|
69
|
-
/// The base implementation returns {@code
|
70
|
+
/// The base implementation returns {@code std::any()}.
|
70
71
|
/// </summary>
|
71
72
|
/// <returns> The default value returned by visitor methods. </returns>
|
72
|
-
virtual
|
73
|
-
return
|
73
|
+
virtual std::any defaultResult() {
|
74
|
+
return std::any();
|
74
75
|
}
|
75
76
|
|
76
77
|
/// <summary>
|
@@ -91,7 +92,7 @@ namespace tree {
|
|
91
92
|
/// a child node.
|
92
93
|
/// </param>
|
93
94
|
/// <returns> The updated aggregate result. </returns>
|
94
|
-
virtual
|
95
|
+
virtual std::any aggregateResult(std::any /*aggregate*/, std::any nextResult) {
|
95
96
|
return nextResult;
|
96
97
|
}
|
97
98
|
|
@@ -118,7 +119,7 @@ namespace tree {
|
|
118
119
|
/// <returns> {@code true} to continue visiting children. Otherwise return
|
119
120
|
/// {@code false} to stop visiting children and immediately return the
|
120
121
|
/// current aggregate result from <seealso cref="#visitChildren"/>. </returns>
|
121
|
-
virtual bool shouldVisitNextChild(ParseTree * /*node*/, const
|
122
|
+
virtual bool shouldVisitNextChild(ParseTree * /*node*/, const std::any &/*currentResult*/) {
|
122
123
|
return true;
|
123
124
|
}
|
124
125
|
|
@@ -10,9 +10,14 @@
|
|
10
10
|
namespace antlr4 {
|
11
11
|
namespace tree {
|
12
12
|
|
13
|
-
class ANTLR4CPP_PUBLIC ErrorNode : public
|
13
|
+
class ANTLR4CPP_PUBLIC ErrorNode : public TerminalNode {
|
14
14
|
public:
|
15
|
-
|
15
|
+
static bool is(const tree::ParseTree &parseTree) { return parseTree.getTreeType() == tree::ParseTreeType::ERROR; }
|
16
|
+
|
17
|
+
static bool is(const tree::ParseTree *parseTree) { return parseTree != nullptr && is(*parseTree); }
|
18
|
+
|
19
|
+
protected:
|
20
|
+
using TerminalNode::TerminalNode;
|
16
21
|
};
|
17
22
|
|
18
23
|
} // namespace tree
|
@@ -3,21 +3,52 @@
|
|
3
3
|
* can be found in the LICENSE.txt file in the project root.
|
4
4
|
*/
|
5
5
|
|
6
|
-
#include "
|
6
|
+
#include "misc/Interval.h"
|
7
|
+
#include "Token.h"
|
8
|
+
#include "RuleContext.h"
|
7
9
|
#include "tree/ParseTreeVisitor.h"
|
8
10
|
|
9
11
|
#include "tree/ErrorNodeImpl.h"
|
10
12
|
|
11
13
|
using namespace antlr4;
|
12
|
-
using namespace antlr4::misc;
|
13
14
|
using namespace antlr4::tree;
|
14
15
|
|
15
|
-
ErrorNodeImpl::
|
16
|
+
Token* ErrorNodeImpl::getSymbol() const {
|
17
|
+
return symbol;
|
16
18
|
}
|
17
19
|
|
18
|
-
ErrorNodeImpl
|
20
|
+
void ErrorNodeImpl::setParent(RuleContext *parent_) {
|
21
|
+
this->parent = parent_;
|
19
22
|
}
|
20
23
|
|
21
|
-
|
24
|
+
misc::Interval ErrorNodeImpl::getSourceInterval() {
|
25
|
+
if (symbol == nullptr) {
|
26
|
+
return misc::Interval::INVALID;
|
27
|
+
}
|
28
|
+
|
29
|
+
size_t tokenIndex = symbol->getTokenIndex();
|
30
|
+
return misc::Interval(tokenIndex, tokenIndex);
|
31
|
+
}
|
32
|
+
|
33
|
+
std::any ErrorNodeImpl::accept(ParseTreeVisitor *visitor) {
|
22
34
|
return visitor->visitErrorNode(this);
|
23
35
|
}
|
36
|
+
|
37
|
+
std::string ErrorNodeImpl::getText() {
|
38
|
+
return symbol->getText();
|
39
|
+
}
|
40
|
+
|
41
|
+
std::string ErrorNodeImpl::toStringTree(Parser * /*parser*/, bool /*pretty*/) {
|
42
|
+
return toString();
|
43
|
+
}
|
44
|
+
|
45
|
+
std::string ErrorNodeImpl::toString() {
|
46
|
+
if (symbol->getType() == Token::EOF) {
|
47
|
+
return "<EOF>";
|
48
|
+
}
|
49
|
+
return symbol->getText();
|
50
|
+
}
|
51
|
+
|
52
|
+
std::string ErrorNodeImpl::toStringTree(bool /*pretty*/) {
|
53
|
+
return toString();
|
54
|
+
}
|
@@ -21,12 +21,22 @@ namespace tree {
|
|
21
21
|
/// and deletion as well as during "consume until error recovery set"
|
22
22
|
/// upon no viable alternative exceptions.
|
23
23
|
/// </summary>
|
24
|
-
class ANTLR4CPP_PUBLIC ErrorNodeImpl : public
|
24
|
+
class ANTLR4CPP_PUBLIC ErrorNodeImpl : public ErrorNode {
|
25
25
|
public:
|
26
|
-
|
27
|
-
~ErrorNodeImpl() override;
|
26
|
+
Token *symbol;
|
28
27
|
|
29
|
-
|
28
|
+
explicit ErrorNodeImpl(Token *symbol) : ErrorNode(ParseTreeType::ERROR), symbol(symbol) {}
|
29
|
+
|
30
|
+
virtual Token* getSymbol() const override;
|
31
|
+
virtual void setParent(RuleContext *parent) override;
|
32
|
+
virtual misc::Interval getSourceInterval() override;
|
33
|
+
|
34
|
+
virtual std::any accept(ParseTreeVisitor *visitor) override;
|
35
|
+
|
36
|
+
virtual std::string getText() override;
|
37
|
+
virtual std::string toStringTree(Parser *parser, bool pretty = false) override;
|
38
|
+
virtual std::string toString() override;
|
39
|
+
virtual std::string toStringTree(bool pretty = false) override;
|
30
40
|
};
|
31
41
|
|
32
42
|
} // namespace tree
|
data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
|
6
6
|
#include "support/CPPUtils.h"
|
7
|
+
#include "support/Casts.h"
|
7
8
|
|
8
9
|
#include "tree/ParseTreeListener.h"
|
9
10
|
#include "tree/ParseTree.h"
|
@@ -12,29 +13,26 @@
|
|
12
13
|
#include "IterativeParseTreeWalker.h"
|
13
14
|
|
14
15
|
using namespace antlr4::tree;
|
16
|
+
using namespace antlrcpp;
|
15
17
|
|
16
18
|
void IterativeParseTreeWalker::walk(ParseTreeListener *listener, ParseTree *t) const {
|
17
|
-
|
18
|
-
std::vector<ParseTree *> nodeStack;
|
19
|
-
std::vector<size_t> indexStack;
|
20
|
-
|
19
|
+
std::vector<std::pair<ParseTree*, size_t>> stack;
|
21
20
|
ParseTree *currentNode = t;
|
22
21
|
size_t currentIndex = 0;
|
23
22
|
|
24
23
|
while (currentNode != nullptr) {
|
25
24
|
// pre-order visit
|
26
|
-
if (
|
27
|
-
listener->visitErrorNode(
|
28
|
-
} else if (
|
29
|
-
listener->visitTerminal((
|
25
|
+
if (ErrorNode::is(*currentNode)) {
|
26
|
+
listener->visitErrorNode(downCast<ErrorNode*>(currentNode));
|
27
|
+
} else if (TerminalNode::is(*currentNode)) {
|
28
|
+
listener->visitTerminal(downCast<TerminalNode*>(currentNode));
|
30
29
|
} else {
|
31
30
|
enterRule(listener, currentNode);
|
32
31
|
}
|
33
32
|
|
34
33
|
// Move down to first child, if it exists.
|
35
34
|
if (!currentNode->children.empty()) {
|
36
|
-
|
37
|
-
indexStack.push_back(currentIndex);
|
35
|
+
stack.push_back(std::make_pair(currentNode, currentIndex));
|
38
36
|
currentIndex = 0;
|
39
37
|
currentNode = currentNode->children[0];
|
40
38
|
continue;
|
@@ -43,29 +41,26 @@ void IterativeParseTreeWalker::walk(ParseTreeListener *listener, ParseTree *t) c
|
|
43
41
|
// No child nodes, so walk tree.
|
44
42
|
do {
|
45
43
|
// post-order visit
|
46
|
-
if (!
|
44
|
+
if (!TerminalNode::is(*currentNode)) {
|
47
45
|
exitRule(listener, currentNode);
|
48
46
|
}
|
49
47
|
|
50
48
|
// No parent, so no siblings.
|
51
|
-
if (
|
49
|
+
if (stack.empty()) {
|
52
50
|
currentNode = nullptr;
|
53
51
|
currentIndex = 0;
|
54
52
|
break;
|
55
53
|
}
|
56
54
|
|
57
55
|
// Move to next sibling if possible.
|
58
|
-
if (
|
59
|
-
currentNode =
|
56
|
+
if (stack.back().first->children.size() > ++currentIndex) {
|
57
|
+
currentNode = stack.back().first->children[currentIndex];
|
60
58
|
break;
|
61
59
|
}
|
62
60
|
|
63
61
|
// No next sibling, so move up.
|
64
|
-
currentNode =
|
65
|
-
|
66
|
-
currentIndex = indexStack.back();
|
67
|
-
indexStack.pop_back();
|
68
|
-
|
62
|
+
std::tie(currentNode, currentIndex) = stack.back();
|
63
|
+
stack.pop_back();
|
69
64
|
} while (currentNode != nullptr);
|
70
65
|
}
|
71
66
|
}
|
@@ -6,6 +6,7 @@
|
|
6
6
|
#pragma once
|
7
7
|
|
8
8
|
#include "support/Any.h"
|
9
|
+
#include "tree/ParseTreeType.h"
|
9
10
|
|
10
11
|
namespace antlr4 {
|
11
12
|
namespace tree {
|
@@ -19,15 +20,15 @@ namespace tree {
|
|
19
20
|
// ml: This class unites 4 Java classes: RuleNode, ParseTree, SyntaxTree and Tree.
|
20
21
|
class ANTLR4CPP_PUBLIC ParseTree {
|
21
22
|
public:
|
22
|
-
ParseTree();
|
23
23
|
ParseTree(ParseTree const&) = delete;
|
24
|
-
|
24
|
+
|
25
|
+
virtual ~ParseTree() = default;
|
25
26
|
|
26
27
|
ParseTree& operator=(ParseTree const&) = delete;
|
27
28
|
|
28
29
|
/// The parent of this node. If the return value is null, then this
|
29
30
|
/// node is the root of the tree.
|
30
|
-
ParseTree *parent;
|
31
|
+
ParseTree *parent = nullptr;
|
31
32
|
|
32
33
|
/// If we are debugging or building a parse tree for a visitor,
|
33
34
|
/// we need to track all of the tokens and rule invocations associated
|
@@ -50,7 +51,7 @@ namespace tree {
|
|
50
51
|
|
51
52
|
/// The <seealso cref="ParseTreeVisitor"/> needs a double dispatch method.
|
52
53
|
// ml: This has been changed to use Any instead of a template parameter, to avoid the need of a virtual template function.
|
53
|
-
virtual
|
54
|
+
virtual std::any accept(ParseTreeVisitor *visitor) = 0;
|
54
55
|
|
55
56
|
/// Return the combined text of all leaf nodes. Does not get any
|
56
57
|
/// off-channel tokens (if any) so won't return whitespace and
|
@@ -74,6 +75,14 @@ namespace tree {
|
|
74
75
|
* EOF is unspecified.</p>
|
75
76
|
*/
|
76
77
|
virtual misc::Interval getSourceInterval() = 0;
|
78
|
+
|
79
|
+
ParseTreeType getTreeType() const { return _treeType; }
|
80
|
+
|
81
|
+
protected:
|
82
|
+
explicit ParseTree(ParseTreeType treeType) : _treeType(treeType) {}
|
83
|
+
|
84
|
+
private:
|
85
|
+
const ParseTreeType _treeType;
|
77
86
|
};
|
78
87
|
|
79
88
|
// A class to help managing ParseTree instances without the need of a shared_ptr.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/* Copyright (c) 2012-2017 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 <cstddef>
|
9
|
+
|
10
|
+
#include "antlr4-common.h"
|
11
|
+
|
12
|
+
namespace antlr4 {
|
13
|
+
namespace tree {
|
14
|
+
|
15
|
+
enum class ParseTreeType : size_t {
|
16
|
+
TERMINAL = 1,
|
17
|
+
ERROR = 2,
|
18
|
+
RULE = 3,
|
19
|
+
};
|
20
|
+
|
21
|
+
} // namespace tree
|
22
|
+
} // namespace antlr4
|