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
@@ -32,8 +32,13 @@ namespace antlrcpp {
|
|
32
32
|
return false;
|
33
33
|
|
34
34
|
for (size_t i = 0; i < a.size(); ++i) {
|
35
|
+
if (!a[i] && !b[i])
|
36
|
+
continue;
|
37
|
+
if (!a[i] || !b[i])
|
38
|
+
return false;
|
35
39
|
if (a[i] == b[i])
|
36
40
|
continue;
|
41
|
+
|
37
42
|
if (!(*a[i] == *b[i]))
|
38
43
|
return false;
|
39
44
|
}
|
@@ -61,6 +66,26 @@ namespace antlrcpp {
|
|
61
66
|
return true;
|
62
67
|
}
|
63
68
|
|
69
|
+
template <typename T>
|
70
|
+
static bool equals(const std::vector<std::unique_ptr<T>> &a, const std::vector<std::unique_ptr<T>> &b) {
|
71
|
+
if (a.size() != b.size())
|
72
|
+
return false;
|
73
|
+
|
74
|
+
for (size_t i = 0; i < a.size(); ++i) {
|
75
|
+
if (!a[i] && !b[i])
|
76
|
+
continue;
|
77
|
+
if (!a[i] || !b[i])
|
78
|
+
return false;
|
79
|
+
if (a[i] == b[i])
|
80
|
+
continue;
|
81
|
+
|
82
|
+
if (!(*a[i] == *b[i]))
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
|
86
|
+
return true;
|
87
|
+
}
|
88
|
+
|
64
89
|
template <typename T>
|
65
90
|
static std::string toString(const std::vector<T> &source) {
|
66
91
|
std::string result = "[";
|
@@ -89,6 +114,20 @@ namespace antlrcpp {
|
|
89
114
|
return result + "]";
|
90
115
|
}
|
91
116
|
|
117
|
+
template <typename T>
|
118
|
+
static std::string toString(const std::vector<std::unique_ptr<T>> &source) {
|
119
|
+
std::string result = "[";
|
120
|
+
bool firstEntry = true;
|
121
|
+
for (auto &value : source) {
|
122
|
+
result += value->toString();
|
123
|
+
if (firstEntry) {
|
124
|
+
result += ", ";
|
125
|
+
firstEntry = false;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
return result + "]";
|
129
|
+
}
|
130
|
+
|
92
131
|
template <typename T>
|
93
132
|
static std::string toString(const std::vector<T *> &source) {
|
94
133
|
std::string result = "[";
|
@@ -7,10 +7,10 @@
|
|
7
7
|
|
8
8
|
namespace antlrcpp {
|
9
9
|
|
10
|
-
std::string join(std::vector<std::string> strings, const std::string &separator) {
|
10
|
+
std::string join(const std::vector<std::string> &strings, const std::string &separator) {
|
11
11
|
std::string str;
|
12
12
|
bool firstItem = true;
|
13
|
-
for (std::string s : strings) {
|
13
|
+
for (const std::string &s : strings) {
|
14
14
|
if (!firstItem) {
|
15
15
|
str.append(separator);
|
16
16
|
}
|
@@ -49,15 +49,12 @@ namespace antlrcpp {
|
|
49
49
|
result += "\u00B7";
|
50
50
|
break;
|
51
51
|
}
|
52
|
-
|
53
|
-
|
54
|
-
#if __has_cpp_attribute(clang::fallthrough)
|
55
|
-
[[clang::fallthrough]];
|
56
|
-
#endif
|
57
|
-
#endif
|
52
|
+
result += c;
|
53
|
+
break;
|
58
54
|
|
59
55
|
default:
|
60
56
|
result += c;
|
57
|
+
break;
|
61
58
|
}
|
62
59
|
}
|
63
60
|
|
@@ -72,8 +69,13 @@ namespace antlrcpp {
|
|
72
69
|
|
73
70
|
std::string arrayToString(const std::vector<std::string> &data) {
|
74
71
|
std::string answer;
|
75
|
-
|
76
|
-
|
72
|
+
size_t toReserve = 0;
|
73
|
+
for (const auto &sub : data) {
|
74
|
+
toReserve += sub.size();
|
75
|
+
}
|
76
|
+
answer.reserve(toReserve);
|
77
|
+
for (const auto &sub: data) {
|
78
|
+
answer.append(sub);
|
77
79
|
}
|
78
80
|
return answer;
|
79
81
|
}
|
@@ -202,47 +204,4 @@ namespace antlrcpp {
|
|
202
204
|
return result;
|
203
205
|
}
|
204
206
|
|
205
|
-
//----------------- FinallyAction ------------------------------------------------------------------------------------
|
206
|
-
|
207
|
-
FinalAction finally(std::function<void ()> f) {
|
208
|
-
return FinalAction(f);
|
209
|
-
}
|
210
|
-
|
211
|
-
//----------------- SingleWriteMultipleRead --------------------------------------------------------------------------
|
212
|
-
|
213
|
-
void SingleWriteMultipleReadLock::readLock() {
|
214
|
-
std::unique_lock<std::mutex> lock(_mutex);
|
215
|
-
while (_waitingWriters != 0)
|
216
|
-
_readerGate.wait(lock);
|
217
|
-
++_activeReaders;
|
218
|
-
lock.unlock();
|
219
|
-
}
|
220
|
-
|
221
|
-
void SingleWriteMultipleReadLock::readUnlock() {
|
222
|
-
std::unique_lock<std::mutex> lock(_mutex);
|
223
|
-
--_activeReaders;
|
224
|
-
lock.unlock();
|
225
|
-
_writerGate.notify_one();
|
226
|
-
}
|
227
|
-
|
228
|
-
void SingleWriteMultipleReadLock::writeLock() {
|
229
|
-
std::unique_lock<std::mutex> lock(_mutex);
|
230
|
-
++_waitingWriters;
|
231
|
-
while (_activeReaders != 0 || _activeWriters != 0)
|
232
|
-
_writerGate.wait(lock);
|
233
|
-
++_activeWriters;
|
234
|
-
lock.unlock();
|
235
|
-
}
|
236
|
-
|
237
|
-
void SingleWriteMultipleReadLock::writeUnlock() {
|
238
|
-
std::unique_lock<std::mutex> lock(_mutex);
|
239
|
-
--_waitingWriters;
|
240
|
-
--_activeWriters;
|
241
|
-
if (_waitingWriters > 0)
|
242
|
-
_writerGate.notify_one();
|
243
|
-
else
|
244
|
-
_readerGate.notify_all();
|
245
|
-
lock.unlock();
|
246
|
-
}
|
247
|
-
|
248
207
|
} // namespace antlrcpp
|
@@ -9,18 +9,19 @@
|
|
9
9
|
|
10
10
|
namespace antlrcpp {
|
11
11
|
|
12
|
-
std::string join(std::vector<std::string> strings, const std::string &separator);
|
13
|
-
std::map<std::string, size_t> toMap(const std::vector<std::string> &keys);
|
14
|
-
std::string escapeWhitespace(std::string str, bool escapeSpaces);
|
15
|
-
std::string toHexString(const int t);
|
16
|
-
std::string arrayToString(const std::vector<std::string> &data);
|
17
|
-
std::string replaceString(const std::string &s, const std::string &from, const std::string &to);
|
18
|
-
std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
|
19
|
-
std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
|
12
|
+
ANTLR4CPP_PUBLIC std::string join(const std::vector<std::string> &strings, const std::string &separator);
|
13
|
+
ANTLR4CPP_PUBLIC std::map<std::string, size_t> toMap(const std::vector<std::string> &keys);
|
14
|
+
ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string str, bool escapeSpaces);
|
15
|
+
ANTLR4CPP_PUBLIC std::string toHexString(const int t);
|
16
|
+
ANTLR4CPP_PUBLIC std::string arrayToString(const std::vector<std::string> &data);
|
17
|
+
ANTLR4CPP_PUBLIC std::string replaceString(const std::string &s, const std::string &from, const std::string &to);
|
18
|
+
ANTLR4CPP_PUBLIC std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
|
19
|
+
ANTLR4CPP_PUBLIC std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
|
20
20
|
|
21
21
|
// Using RAII + a lambda to implement a "finally" replacement.
|
22
|
+
template <typename OnEnd>
|
22
23
|
struct FinalAction {
|
23
|
-
FinalAction(
|
24
|
+
FinalAction(OnEnd f) : _cleanUp { std::move(f) } {}
|
24
25
|
FinalAction(FinalAction &&other) :
|
25
26
|
_cleanUp(std::move(other._cleanUp)), _enabled(other._enabled) {
|
26
27
|
other._enabled = false; // Don't trigger the lambda after ownership has moved.
|
@@ -29,11 +30,14 @@ namespace antlrcpp {
|
|
29
30
|
|
30
31
|
void disable() { _enabled = false; }
|
31
32
|
private:
|
32
|
-
|
33
|
+
OnEnd _cleanUp;
|
33
34
|
bool _enabled {true};
|
34
35
|
};
|
35
36
|
|
36
|
-
|
37
|
+
template <typename OnEnd>
|
38
|
+
FinalAction<OnEnd> finally(OnEnd f) {
|
39
|
+
return FinalAction<OnEnd>(std::move(f));
|
40
|
+
}
|
37
41
|
|
38
42
|
// Convenience functions to avoid lengthy dynamic_cast() != nullptr checks in many places.
|
39
43
|
template <typename T1, typename T2>
|
@@ -56,23 +60,6 @@ namespace antlrcpp {
|
|
56
60
|
}
|
57
61
|
|
58
62
|
// Get the error text from an exception pointer or the current exception.
|
59
|
-
std::string what(std::exception_ptr eptr = std::current_exception());
|
60
|
-
|
61
|
-
class SingleWriteMultipleReadLock {
|
62
|
-
public:
|
63
|
-
void readLock();
|
64
|
-
void readUnlock();
|
65
|
-
void writeLock();
|
66
|
-
void writeUnlock();
|
67
|
-
|
68
|
-
private:
|
69
|
-
std::condition_variable _readerGate;
|
70
|
-
std::condition_variable _writerGate;
|
71
|
-
|
72
|
-
std::mutex _mutex;
|
73
|
-
size_t _activeReaders = 0;
|
74
|
-
size_t _waitingWriters = 0;
|
75
|
-
size_t _activeWriters = 0;
|
76
|
-
};
|
63
|
+
ANTLR4CPP_PUBLIC std::string what(std::exception_ptr eptr = std::current_exception());
|
77
64
|
|
78
65
|
} // namespace antlrcpp
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/* Copyright (c) 2012-2021 The ANTLR Project. All rights reserved.
|
2
|
+
* Use of this file is governed by the BSD 3-clause license that
|
3
|
+
* can be found in the LICENSE.txt file in the project root.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#pragma once
|
7
|
+
|
8
|
+
#include <cassert>
|
9
|
+
#include <memory>
|
10
|
+
#include <type_traits>
|
11
|
+
|
12
|
+
namespace antlrcpp {
|
13
|
+
|
14
|
+
template <typename To, typename From>
|
15
|
+
To downCast(From* from) {
|
16
|
+
static_assert(std::is_pointer_v<To>, "Target type not a pointer.");
|
17
|
+
static_assert(std::is_base_of_v<From, std::remove_pointer_t<To>>, "Target type not derived from source type.");
|
18
|
+
#if !defined(__GNUC__) || defined(__GXX_RTTI)
|
19
|
+
assert(from == nullptr || dynamic_cast<To>(from) != nullptr);
|
20
|
+
#endif
|
21
|
+
return static_cast<To>(from);
|
22
|
+
}
|
23
|
+
|
24
|
+
template <typename To, typename From>
|
25
|
+
To downCast(From& from) {
|
26
|
+
static_assert(std::is_lvalue_reference_v<To>, "Target type not a lvalue reference.");
|
27
|
+
static_assert(std::is_base_of_v<From, std::remove_reference_t<To>>, "Target type not derived from source type.");
|
28
|
+
#if !defined(__GNUC__) || defined(__GXX_RTTI)
|
29
|
+
assert(dynamic_cast<std::add_pointer_t<std::remove_reference_t<To>>>(std::addressof(from)) != nullptr);
|
30
|
+
#endif
|
31
|
+
return static_cast<To>(from);
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
@@ -69,7 +69,6 @@ namespace antlr4 {
|
|
69
69
|
class ATNSimulator;
|
70
70
|
class ATNState;
|
71
71
|
enum class ATNType;
|
72
|
-
class AbstractPredicateTransition;
|
73
72
|
class ActionTransition;
|
74
73
|
class ArrayPredictionContext;
|
75
74
|
class AtomTransition;
|
@@ -78,7 +77,6 @@ namespace antlr4 {
|
|
78
77
|
class BlockEndState;
|
79
78
|
class BlockStartState;
|
80
79
|
class DecisionState;
|
81
|
-
class EmptyPredictionContext;
|
82
80
|
class EpsilonTransition;
|
83
81
|
class LL1Analyzer;
|
84
82
|
class LexerAction;
|
@@ -7,40 +7,32 @@
|
|
7
7
|
|
8
8
|
namespace antlrcpp {
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
size_t start_pos = 0;
|
16
|
-
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
17
|
-
str.replace(start_pos, from.length(), to);
|
18
|
-
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'.
|
10
|
+
std::string escapeWhitespace(std::string_view in) {
|
11
|
+
std::string out;
|
12
|
+
escapeWhitespace(out, in);
|
13
|
+
out.shrink_to_fit();
|
14
|
+
return out;
|
19
15
|
}
|
20
|
-
}
|
21
|
-
|
22
|
-
std::string ws2s(std::wstring const& wstr) {
|
23
|
-
#ifndef USE_UTF8_INSTEAD_OF_CODECVT
|
24
|
-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
25
|
-
std::string narrow = converter.to_bytes(wstr);
|
26
|
-
#else
|
27
|
-
std::string narrow;
|
28
|
-
utf8::utf32to8(wstr.begin(), wstr.end(), std::back_inserter(narrow));
|
29
|
-
#endif
|
30
|
-
|
31
|
-
return narrow;
|
32
|
-
}
|
33
16
|
|
34
|
-
std::
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
17
|
+
std::string& escapeWhitespace(std::string& out, std::string_view in) {
|
18
|
+
out.reserve(in.size()); // Best case, no escaping.
|
19
|
+
for (const auto &c : in) {
|
20
|
+
switch (c) {
|
21
|
+
case '\t':
|
22
|
+
out.append("\\t");
|
23
|
+
break;
|
24
|
+
case '\r':
|
25
|
+
out.append("\\r");
|
26
|
+
break;
|
27
|
+
case '\n':
|
28
|
+
out.append("\\n");
|
29
|
+
break;
|
30
|
+
default:
|
31
|
+
out.push_back(c);
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return out;
|
36
|
+
}
|
45
37
|
|
46
38
|
} // namespace antrlcpp
|
@@ -7,70 +7,10 @@
|
|
7
7
|
|
8
8
|
#include "antlr4-common.h"
|
9
9
|
|
10
|
-
#ifdef USE_UTF8_INSTEAD_OF_CODECVT
|
11
|
-
#include "utf8.h"
|
12
|
-
#endif
|
13
|
-
|
14
10
|
namespace antlrcpp {
|
15
11
|
|
16
|
-
|
17
|
-
// I wouldn't prefer wstring_convert because: according to
|
18
|
-
// https://en.cppreference.com/w/cpp/locale/wstring_convert,
|
19
|
-
// wstring_convert is deprecated in C++17.
|
20
|
-
// utfcpp (https://github.com/nemtrif/utfcpp) is a substitution.
|
21
|
-
#ifndef USE_UTF8_INSTEAD_OF_CODECVT
|
22
|
-
// VS 2015 and VS 2017 have different bugs in std::codecvt_utf8<char32_t> (VS 2013 works fine).
|
23
|
-
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
24
|
-
typedef std::wstring_convert<std::codecvt_utf8<__int32>, __int32> UTF32Converter;
|
25
|
-
#else
|
26
|
-
typedef std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> UTF32Converter;
|
27
|
-
#endif
|
28
|
-
#endif
|
29
|
-
|
30
|
-
// The conversion functions fails in VS2017, so we explicitly use a workaround.
|
31
|
-
template<typename T>
|
32
|
-
inline std::string utf32_to_utf8(T const& data)
|
33
|
-
{
|
34
|
-
#ifndef USE_UTF8_INSTEAD_OF_CODECVT
|
35
|
-
// Don't make the converter static or we have to serialize access to it.
|
36
|
-
thread_local UTF32Converter converter;
|
37
|
-
|
38
|
-
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
39
|
-
const auto p = reinterpret_cast<const int32_t *>(data.data());
|
40
|
-
return converter.to_bytes(p, p + data.size());
|
41
|
-
#else
|
42
|
-
return converter.to_bytes(data);
|
43
|
-
#endif
|
44
|
-
#else
|
45
|
-
std::string narrow;
|
46
|
-
utf8::utf32to8(data.begin(), data.end(), std::back_inserter(narrow));
|
47
|
-
return narrow;
|
48
|
-
#endif
|
49
|
-
}
|
50
|
-
|
51
|
-
inline UTF32String utf8_to_utf32(const char* first, const char* last)
|
52
|
-
{
|
53
|
-
#ifndef USE_UTF8_INSTEAD_OF_CODECVT
|
54
|
-
thread_local UTF32Converter converter;
|
55
|
-
|
56
|
-
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
57
|
-
auto r = converter.from_bytes(first, last);
|
58
|
-
i32string s = reinterpret_cast<const int32_t *>(r.data());
|
59
|
-
return s;
|
60
|
-
#else
|
61
|
-
std::u32string s = converter.from_bytes(first, last);
|
62
|
-
return s;
|
63
|
-
#endif
|
64
|
-
#else
|
65
|
-
UTF32String wide;
|
66
|
-
utf8::utf8to32(first, last, std::back_inserter(wide));
|
67
|
-
return wide;
|
68
|
-
#endif
|
69
|
-
}
|
12
|
+
ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string_view in);
|
70
13
|
|
71
|
-
|
14
|
+
ANTLR4CPP_PUBLIC std::string& escapeWhitespace(std::string& out, std::string_view in);
|
72
15
|
|
73
|
-
// string <-> wstring conversion (UTF-16), e.g. for use with Window's wide APIs.
|
74
|
-
ANTLR4CPP_PUBLIC std::string ws2s(std::wstring const& wstr);
|
75
|
-
ANTLR4CPP_PUBLIC std::wstring s2ws(std::string const& str);
|
76
16
|
}
|
@@ -0,0 +1,28 @@
|
|
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 "antlr4-common.h"
|
9
|
+
|
10
|
+
namespace antlrcpp {
|
11
|
+
|
12
|
+
class ANTLR4CPP_PUBLIC Unicode final {
|
13
|
+
public:
|
14
|
+
static constexpr char32_t REPLACEMENT_CHARACTER = 0xfffd;
|
15
|
+
|
16
|
+
static constexpr bool isValid(char32_t codePoint) {
|
17
|
+
return codePoint < 0xd800 || (codePoint > 0xdfff && codePoint <= 0x10ffff);
|
18
|
+
}
|
19
|
+
|
20
|
+
private:
|
21
|
+
Unicode() = delete;
|
22
|
+
Unicode(const Unicode&) = delete;
|
23
|
+
Unicode(Unicode&&) = delete;
|
24
|
+
Unicode& operator=(const Unicode&) = delete;
|
25
|
+
Unicode& operator=(Unicode&&) = delete;
|
26
|
+
};
|
27
|
+
|
28
|
+
}
|