expressir 1.4.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +2 -14
- data/.github/workflows/rake.yml +6 -364
- data/.github/workflows/release.yml +15 -178
- data/.github/workflows/stress.yml +1 -18
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +7 -0
- data/Gemfile +13 -0
- data/README.adoc +6 -19
- data/Rakefile +6 -7
- data/expressir.gemspec +23 -32
- data/expressir_wrapped.txt +23068 -0
- data/lib/expressir/cli.rb +3 -2
- data/lib/expressir/express/formatter.rb +661 -661
- data/lib/expressir/express/parser.rb +299 -33
- data/lib/expressir/express/visitor.rb +238 -133
- data/lib/expressir/model/declarations/interface_item.rb +1 -1
- data/lib/expressir/version.rb +1 -1
- metadata +15 -573
- data/.cross_rubies +0 -28
- data/.gitmodules +0 -6
- data/.yardopts +0 -11
- data/exe/generate-parser +0 -51
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +0 -191
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +0 -652
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -948
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2022.vcxproj +0 -652
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2022.vcxproj.filters +0 -948
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/Info.plist +0 -26
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/antlrcpp_ios.h +0 -17
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +0 -3040
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +0 -76
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +0 -76
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +0 -76
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.noarch.nuspec +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.noarch.targets +0 -8
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.shared.nuspec +0 -30
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.shared.props +0 -21
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.shared.targets +0 -44
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.static.nuspec +0 -29
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.static.targets +0 -44
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/antlr4.jpg +0 -0
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/pack.cmd +0 -93
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.cpp +0 -10
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.h +0 -167
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.cpp +0 -10
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.h +0 -121
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +0 -30
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +0 -180
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +0 -79
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +0 -61
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.h +0 -59
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.cpp +0 -25
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.h +0 -36
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +0 -414
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.h +0 -200
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.cpp +0 -11
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.h +0 -37
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +0 -193
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.h +0 -158
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +0 -39
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +0 -74
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.cpp +0 -78
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.h +0 -79
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +0 -15
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.h +0 -35
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +0 -336
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.h +0 -466
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +0 -84
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.h +0 -80
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +0 -64
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +0 -99
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +0 -52
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +0 -32
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/FlatHashMap.h +0 -57
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/FlatHashSet.h +0 -57
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.cpp +0 -18
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.h +0 -24
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.cpp +0 -12
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -218
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.cpp +0 -19
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.h +0 -45
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -294
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -196
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -60
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +0 -46
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.cpp +0 -36
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.h +0 -31
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +0 -92
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +0 -88
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.cpp +0 -46
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.h +0 -42
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +0 -670
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -461
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +0 -294
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +0 -173
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +0 -138
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +0 -147
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +0 -53
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.h +0 -38
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -65
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.h +0 -98
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +0 -157
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +0 -160
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +0 -144
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +0 -141
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.cpp +0 -27
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.h +0 -32
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +0 -54
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.h +0 -155
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.cpp +0 -9
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -92
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenFactory.h +0 -30
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.cpp +0 -9
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +0 -85
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.cpp +0 -11
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.h +0 -137
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +0 -425
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +0 -295
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +0 -208
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +0 -117
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +0 -270
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.h +0 -115
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +0 -42
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +0 -64
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +0 -177
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.cpp +0 -9
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.h +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +0 -101
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +0 -168
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +0 -159
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +0 -133
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +0 -106
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +0 -157
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +0 -233
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +0 -157
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +0 -39
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +0 -48
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +0 -628
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +0 -32
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +0 -33
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +0 -71
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +0 -56
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +0 -139
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +0 -33
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +0 -36
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNType.h +0 -20
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +0 -29
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +0 -35
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.cpp +0 -16
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.h +0 -68
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +0 -129
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +0 -51
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +0 -27
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +0 -33
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +0 -24
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +0 -26
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +0 -30
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.cpp +0 -14
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.h +0 -47
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.cpp +0 -14
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.h +0 -70
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.cpp +0 -25
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +0 -227
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -12
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +0 -34
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +0 -31
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +0 -42
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.cpp +0 -15
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.h +0 -43
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/HashUtils.h +0 -18
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +0 -189
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +0 -76
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +0 -67
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +0 -44
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +0 -621
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +0 -199
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +0 -15
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +0 -100
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +0 -108
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +0 -128
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +0 -57
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +0 -43
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +0 -59
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +0 -45
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +0 -75
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +0 -50
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +0 -76
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +0 -43
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +0 -57
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +0 -36
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +0 -53
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +0 -36
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +0 -53
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +0 -43
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +0 -57
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +0 -36
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +0 -51
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +0 -43
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +0 -51
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.cpp +0 -16
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.h +0 -42
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +0 -26
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +0 -22
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +0 -27
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +0 -16
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +0 -25
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.cpp +0 -102
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.h +0 -102
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +0 -1413
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +0 -911
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +0 -50
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +0 -29
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +0 -25
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +0 -35
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +0 -17
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +0 -62
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +0 -24
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +0 -50
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +0 -601
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +0 -225
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +0 -56
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +0 -63
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +0 -167
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +0 -101
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +0 -71
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +0 -21
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +0 -202
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +0 -436
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +0 -179
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +0 -60
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +0 -26
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +0 -31
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +0 -26
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +0 -27
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +0 -33
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +0 -42
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +0 -418
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +0 -237
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +0 -101
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +0 -28
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +0 -38
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +0 -79
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +0 -43
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +0 -24
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +0 -37
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +0 -19
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +0 -25
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +0 -24
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +0 -36
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +0 -65
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +0 -27
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +0 -33
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +0 -21
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +0 -27
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +0 -115
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +0 -96
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +0 -60
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +0 -32
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +0 -59
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +0 -154
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +0 -17
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +0 -22
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/internal/Synchronization.cpp +0 -100
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/internal/Synchronization.h +0 -154
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +0 -124
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +0 -33
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +0 -61
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +0 -84
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +0 -508
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +0 -190
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +0 -120
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +0 -102
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.cpp +0 -4
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.h +0 -21
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -8
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +0 -16
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +0 -43
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +0 -149
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +0 -76
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +0 -207
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +0 -65
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +0 -34
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -161
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +0 -38
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +0 -16
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +0 -28
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +0 -242
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +0 -54
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +0 -129
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +0 -24
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +0 -54
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +0 -43
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +0 -66
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.h +0 -53
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -12
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +0 -111
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.cpp +0 -9
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +0 -39
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeProperty.h +0 -50
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +0 -22
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.cpp +0 -9
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +0 -57
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +0 -48
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +0 -55
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +0 -40
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +0 -54
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +0 -32
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +0 -241
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.h +0 -78
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.cpp +0 -9
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +0 -44
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.cpp +0 -69
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +0 -132
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +0 -64
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +0 -105
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +0 -370
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +0 -185
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +0 -77
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.h +0 -117
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.cpp +0 -39
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +0 -86
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.cpp +0 -28
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +0 -51
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +0 -36
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.h +0 -80
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +0 -154
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.h +0 -86
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.cpp +0 -31
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.h +0 -40
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +0 -180
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.g4 +0 -64
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +0 -53
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.tokens +0 -12
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.cpp +0 -13
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.h +0 -22
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp +0 -20
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.h +0 -27
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +0 -30
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.h +0 -26
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp +0 -20
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.h +0 -25
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +0 -33
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.h +0 -26
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.cpp +0 -24
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.h +0 -23
- data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +0 -110
- data/ext/express_parser/antlrgen/Express.interp +0 -532
- data/ext/express_parser/antlrgen/Express.tokens +0 -190
- data/ext/express_parser/antlrgen/ExpressBaseListener.cpp +0 -7
- data/ext/express_parser/antlrgen/ExpressBaseListener.h +0 -623
- data/ext/express_parser/antlrgen/ExpressBaseVisitor.cpp +0 -7
- data/ext/express_parser/antlrgen/ExpressBaseVisitor.h +0 -816
- data/ext/express_parser/antlrgen/ExpressLexer.cpp +0 -685
- data/ext/express_parser/antlrgen/ExpressLexer.h +0 -78
- data/ext/express_parser/antlrgen/ExpressLexer.interp +0 -534
- data/ext/express_parser/antlrgen/ExpressLexer.tokens +0 -190
- data/ext/express_parser/antlrgen/ExpressListener.cpp +0 -7
- data/ext/express_parser/antlrgen/ExpressListener.h +0 -616
- data/ext/express_parser/antlrgen/ExpressParser.cpp +0 -17591
- data/ext/express_parser/antlrgen/ExpressParser.h +0 -3692
- data/ext/express_parser/antlrgen/ExpressVisitor.cpp +0 -7
- data/ext/express_parser/antlrgen/ExpressVisitor.h +0 -422
- data/ext/express_parser/express_parser.cpp +0 -19405
- data/ext/express_parser/extconf.rb +0 -63
- data/rakelib/antlr4-native.rake +0 -173
- data/rakelib/cross-ruby.rake +0 -403
- data/spec/acceptance/version_spec.rb +0 -30
- data/spec/expressir/express/cache_spec.rb +0 -89
- data/spec/expressir/express/formatter_spec.rb +0 -171
- data/spec/expressir/express/parser_spec.rb +0 -141
- data/spec/expressir/model/model_element_spec.rb +0 -343
- data/spec/spec_helper.rb +0 -24
- data/spec/support/console_helper.rb +0 -29
- data/spec/syntax/multiple.exp +0 -23
- data/spec/syntax/multiple.yaml +0 -198
- data/spec/syntax/multiple_formatted.exp +0 -71
- data/spec/syntax/multiple_hyperlink_formatted.exp +0 -71
- data/spec/syntax/multiple_schema_head_hyperlink_formatted.exp +0 -13
- data/spec/syntax/remark.exp +0 -193
- data/spec/syntax/remark.yaml +0 -471
- data/spec/syntax/remark_formatted.exp +0 -228
- data/spec/syntax/single.exp +0 -4
- data/spec/syntax/single.yaml +0 -18
- data/spec/syntax/single_formatted.exp +0 -10
- data/spec/syntax/single_formatted.yaml +0 -36
- data/spec/syntax/syntax.exp +0 -333
- data/spec/syntax/syntax.yaml +0 -3509
- data/spec/syntax/syntax_formatted.exp +0 -902
- data/spec/syntax/syntax_hyperlink_formatted.exp +0 -902
- data/spec/syntax/syntax_schema_head_formatted.exp +0 -18
@@ -1,295 +0,0 @@
|
|
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 "antlr4-common.h"
|
9
|
-
|
10
|
-
namespace antlr4 {
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Useful for rewriting out a buffered input token stream after doing some
|
14
|
-
* augmentation or other manipulations on it.
|
15
|
-
*
|
16
|
-
* <p>
|
17
|
-
* You can insert stuff, replace, and delete chunks. Note that the operations
|
18
|
-
* are done lazily--only if you convert the buffer to a {@link String} with
|
19
|
-
* {@link TokenStream#getText()}. This is very efficient because you are not
|
20
|
-
* moving data around all the time. As the buffer of tokens is converted to
|
21
|
-
* strings, the {@link #getText()} method(s) scan the input token stream and
|
22
|
-
* check to see if there is an operation at the current index. If so, the
|
23
|
-
* operation is done and then normal {@link String} rendering continues on the
|
24
|
-
* buffer. This is like having multiple Turing machine instruction streams
|
25
|
-
* (programs) operating on a single input tape. :)</p>
|
26
|
-
*
|
27
|
-
* <p>
|
28
|
-
* This rewriter makes no modifications to the token stream. It does not ask the
|
29
|
-
* stream to fill itself up nor does it advance the input cursor. The token
|
30
|
-
* stream {@link TokenStream#index()} will return the same value before and
|
31
|
-
* after any {@link #getText()} call.</p>
|
32
|
-
*
|
33
|
-
* <p>
|
34
|
-
* The rewriter only works on tokens that you have in the buffer and ignores the
|
35
|
-
* current input cursor. If you are buffering tokens on-demand, calling
|
36
|
-
* {@link #getText()} halfway through the input will only do rewrites for those
|
37
|
-
* tokens in the first half of the file.</p>
|
38
|
-
*
|
39
|
-
* <p>
|
40
|
-
* Since the operations are done lazily at {@link #getText}-time, operations do
|
41
|
-
* not screw up the token index values. That is, an insert operation at token
|
42
|
-
* index {@code i} does not change the index values for tokens
|
43
|
-
* {@code i}+1..n-1.</p>
|
44
|
-
*
|
45
|
-
* <p>
|
46
|
-
* Because operations never actually alter the buffer, you may always get the
|
47
|
-
* original token stream back without undoing anything. Since the instructions
|
48
|
-
* are queued up, you can easily simulate transactions and roll back any changes
|
49
|
-
* if there is an error just by removing instructions. For example,</p>
|
50
|
-
*
|
51
|
-
* <pre>
|
52
|
-
* CharStream input = new ANTLRFileStream("input");
|
53
|
-
* TLexer lex = new TLexer(input);
|
54
|
-
* CommonTokenStream tokens = new CommonTokenStream(lex);
|
55
|
-
* T parser = new T(tokens);
|
56
|
-
* TokenStreamRewriter rewriter = new TokenStreamRewriter(tokens);
|
57
|
-
* parser.startRule();
|
58
|
-
* </pre>
|
59
|
-
*
|
60
|
-
* <p>
|
61
|
-
* Then in the rules, you can execute (assuming rewriter is visible):</p>
|
62
|
-
*
|
63
|
-
* <pre>
|
64
|
-
* Token t,u;
|
65
|
-
* ...
|
66
|
-
* rewriter.insertAfter(t, "text to put after t");}
|
67
|
-
* rewriter.insertAfter(u, "text after u");}
|
68
|
-
* System.out.println(rewriter.getText());
|
69
|
-
* </pre>
|
70
|
-
*
|
71
|
-
* <p>
|
72
|
-
* You can also have multiple "instruction streams" and get multiple rewrites
|
73
|
-
* from a single pass over the input. Just name the instruction streams and use
|
74
|
-
* that name again when printing the buffer. This could be useful for generating
|
75
|
-
* a C file and also its header file--all from the same buffer:</p>
|
76
|
-
*
|
77
|
-
* <pre>
|
78
|
-
* rewriter.insertAfter("pass1", t, "text to put after t");}
|
79
|
-
* rewriter.insertAfter("pass2", u, "text after u");}
|
80
|
-
* System.out.println(rewriter.getText("pass1"));
|
81
|
-
* System.out.println(rewriter.getText("pass2"));
|
82
|
-
* </pre>
|
83
|
-
*
|
84
|
-
* <p>
|
85
|
-
* If you don't use named rewrite streams, a "default" stream is used as the
|
86
|
-
* first example shows.</p>
|
87
|
-
*/
|
88
|
-
class ANTLR4CPP_PUBLIC TokenStreamRewriter {
|
89
|
-
public:
|
90
|
-
static const std::string DEFAULT_PROGRAM_NAME;
|
91
|
-
static constexpr size_t PROGRAM_INIT_SIZE = 100;
|
92
|
-
static constexpr size_t MIN_TOKEN_INDEX = 0;
|
93
|
-
|
94
|
-
TokenStreamRewriter(TokenStream *tokens);
|
95
|
-
virtual ~TokenStreamRewriter();
|
96
|
-
|
97
|
-
TokenStream *getTokenStream();
|
98
|
-
|
99
|
-
virtual void rollback(size_t instructionIndex);
|
100
|
-
|
101
|
-
/// Rollback the instruction stream for a program so that
|
102
|
-
/// the indicated instruction (via instructionIndex) is no
|
103
|
-
/// longer in the stream. UNTESTED!
|
104
|
-
virtual void rollback(const std::string &programName, size_t instructionIndex);
|
105
|
-
|
106
|
-
virtual void deleteProgram();
|
107
|
-
|
108
|
-
/// Reset the program so that no instructions exist.
|
109
|
-
virtual void deleteProgram(const std::string &programName);
|
110
|
-
virtual void insertAfter(Token *t, const std::string& text);
|
111
|
-
virtual void insertAfter(size_t index, const std::string& text);
|
112
|
-
virtual void insertAfter(const std::string &programName, Token *t, const std::string& text);
|
113
|
-
virtual void insertAfter(const std::string &programName, size_t index, const std::string& text);
|
114
|
-
|
115
|
-
virtual void insertBefore(Token *t, const std::string& text);
|
116
|
-
virtual void insertBefore(size_t index, const std::string& text);
|
117
|
-
virtual void insertBefore(const std::string &programName, Token *t, const std::string& text);
|
118
|
-
virtual void insertBefore(const std::string &programName, size_t index, const std::string& text);
|
119
|
-
|
120
|
-
virtual void replace(size_t index, const std::string& text);
|
121
|
-
virtual void replace(size_t from, size_t to, const std::string& text);
|
122
|
-
virtual void replace(Token *indexT, const std::string& text);
|
123
|
-
virtual void replace(Token *from, Token *to, const std::string& text);
|
124
|
-
virtual void replace(const std::string &programName, size_t from, size_t to, const std::string& text);
|
125
|
-
virtual void replace(const std::string &programName, Token *from, Token *to, const std::string& text);
|
126
|
-
|
127
|
-
virtual void Delete(size_t index);
|
128
|
-
virtual void Delete(size_t from, size_t to);
|
129
|
-
virtual void Delete(Token *indexT);
|
130
|
-
virtual void Delete(Token *from, Token *to);
|
131
|
-
virtual void Delete(const std::string &programName, size_t from, size_t to);
|
132
|
-
virtual void Delete(const std::string &programName, Token *from, Token *to);
|
133
|
-
|
134
|
-
virtual size_t getLastRewriteTokenIndex();
|
135
|
-
|
136
|
-
/// Return the text from the original tokens altered per the
|
137
|
-
/// instructions given to this rewriter.
|
138
|
-
virtual std::string getText();
|
139
|
-
|
140
|
-
/** Return the text from the original tokens altered per the
|
141
|
-
* instructions given to this rewriter in programName.
|
142
|
-
*/
|
143
|
-
std::string getText(std::string programName);
|
144
|
-
|
145
|
-
/// Return the text associated with the tokens in the interval from the
|
146
|
-
/// original token stream but with the alterations given to this rewriter.
|
147
|
-
/// The interval refers to the indexes in the original token stream.
|
148
|
-
/// We do not alter the token stream in any way, so the indexes
|
149
|
-
/// and intervals are still consistent. Includes any operations done
|
150
|
-
/// to the first and last token in the interval. So, if you did an
|
151
|
-
/// insertBefore on the first token, you would get that insertion.
|
152
|
-
/// The same is true if you do an insertAfter the stop token.
|
153
|
-
virtual std::string getText(const misc::Interval &interval);
|
154
|
-
|
155
|
-
virtual std::string getText(const std::string &programName, const misc::Interval &interval);
|
156
|
-
|
157
|
-
protected:
|
158
|
-
class RewriteOperation {
|
159
|
-
public:
|
160
|
-
/// What index into rewrites List are we?
|
161
|
-
size_t index;
|
162
|
-
std::string text;
|
163
|
-
|
164
|
-
/// Token buffer index.
|
165
|
-
size_t instructionIndex;
|
166
|
-
|
167
|
-
RewriteOperation(TokenStreamRewriter *outerInstance, size_t index);
|
168
|
-
RewriteOperation(TokenStreamRewriter *outerInstance, size_t index, const std::string& text);
|
169
|
-
virtual ~RewriteOperation();
|
170
|
-
|
171
|
-
/// Execute the rewrite operation by possibly adding to the buffer.
|
172
|
-
/// Return the index of the next token to operate on.
|
173
|
-
|
174
|
-
virtual size_t execute(std::string *buf);
|
175
|
-
virtual std::string toString();
|
176
|
-
|
177
|
-
private:
|
178
|
-
TokenStreamRewriter *const outerInstance;
|
179
|
-
void InitializeInstanceFields();
|
180
|
-
};
|
181
|
-
|
182
|
-
class InsertBeforeOp : public RewriteOperation {
|
183
|
-
private:
|
184
|
-
TokenStreamRewriter *const outerInstance;
|
185
|
-
|
186
|
-
public:
|
187
|
-
InsertBeforeOp(TokenStreamRewriter *outerInstance, size_t index, const std::string& text);
|
188
|
-
|
189
|
-
virtual size_t execute(std::string *buf) override;
|
190
|
-
};
|
191
|
-
|
192
|
-
class ReplaceOp : public RewriteOperation {
|
193
|
-
private:
|
194
|
-
TokenStreamRewriter *const outerInstance;
|
195
|
-
|
196
|
-
public:
|
197
|
-
size_t lastIndex;
|
198
|
-
|
199
|
-
ReplaceOp(TokenStreamRewriter *outerInstance, size_t from, size_t to, const std::string& text);
|
200
|
-
virtual size_t execute(std::string *buf) override;
|
201
|
-
virtual std::string toString() override;
|
202
|
-
|
203
|
-
private:
|
204
|
-
void InitializeInstanceFields();
|
205
|
-
};
|
206
|
-
|
207
|
-
/// Our source stream
|
208
|
-
TokenStream *const tokens;
|
209
|
-
|
210
|
-
/// You may have multiple, named streams of rewrite operations.
|
211
|
-
/// I'm calling these things "programs."
|
212
|
-
/// Maps String (name) -> rewrite (List)
|
213
|
-
std::map<std::string, std::vector<RewriteOperation*>> _programs;
|
214
|
-
|
215
|
-
/// <summary>
|
216
|
-
/// Map String (program name) -> Integer index </summary>
|
217
|
-
std::map<std::string, size_t> _lastRewriteTokenIndexes;
|
218
|
-
virtual size_t getLastRewriteTokenIndex(const std::string &programName);
|
219
|
-
virtual void setLastRewriteTokenIndex(const std::string &programName, size_t i);
|
220
|
-
virtual std::vector<RewriteOperation*>& getProgram(const std::string &name);
|
221
|
-
|
222
|
-
/// <summary>
|
223
|
-
/// We need to combine operations and report invalid operations (like
|
224
|
-
/// overlapping replaces that are not completed nested). Inserts to
|
225
|
-
/// same index need to be combined etc... Here are the cases:
|
226
|
-
///
|
227
|
-
/// I.i.u I.j.v leave alone, nonoverlapping
|
228
|
-
/// I.i.u I.i.v combine: Iivu
|
229
|
-
///
|
230
|
-
/// R.i-j.u R.x-y.v | i-j in x-y delete first R
|
231
|
-
/// R.i-j.u R.i-j.v delete first R
|
232
|
-
/// R.i-j.u R.x-y.v | x-y in i-j ERROR
|
233
|
-
/// R.i-j.u R.x-y.v | boundaries overlap ERROR
|
234
|
-
///
|
235
|
-
/// Delete special case of replace (text==null):
|
236
|
-
/// D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
|
237
|
-
///
|
238
|
-
/// I.i.u R.x-y.v | i in (x+1)-y delete I (since insert before
|
239
|
-
/// we're not deleting i)
|
240
|
-
/// I.i.u R.x-y.v | i not in (x+1)-y leave alone, nonoverlapping
|
241
|
-
/// R.x-y.v I.i.u | i in x-y ERROR
|
242
|
-
/// R.x-y.v I.x.u R.x-y.uv (combine, delete I)
|
243
|
-
/// R.x-y.v I.i.u | i not in x-y leave alone, nonoverlapping
|
244
|
-
///
|
245
|
-
/// I.i.u = insert u before op @ index i
|
246
|
-
/// R.x-y.u = replace x-y indexed tokens with u
|
247
|
-
///
|
248
|
-
/// First we need to examine replaces. For any replace op:
|
249
|
-
///
|
250
|
-
/// 1. wipe out any insertions before op within that range.
|
251
|
-
/// 2. Drop any replace op before that is contained completely within
|
252
|
-
/// that range.
|
253
|
-
/// 3. Throw exception upon boundary overlap with any previous replace.
|
254
|
-
///
|
255
|
-
/// Then we can deal with inserts:
|
256
|
-
///
|
257
|
-
/// 1. for any inserts to same index, combine even if not adjacent.
|
258
|
-
/// 2. for any prior replace with same left boundary, combine this
|
259
|
-
/// insert with replace and delete this replace.
|
260
|
-
/// 3. throw exception if index in same range as previous replace
|
261
|
-
///
|
262
|
-
/// Don't actually delete; make op null in list. Easier to walk list.
|
263
|
-
/// Later we can throw as we add to index -> op map.
|
264
|
-
///
|
265
|
-
/// Note that I.2 R.2-2 will wipe out I.2 even though, technically, the
|
266
|
-
/// inserted stuff would be before the replace range. But, if you
|
267
|
-
/// add tokens in front of a method body '{' and then delete the method
|
268
|
-
/// body, I think the stuff before the '{' you added should disappear too.
|
269
|
-
///
|
270
|
-
/// Return a map from token index to operation.
|
271
|
-
/// </summary>
|
272
|
-
virtual std::unordered_map<size_t, RewriteOperation*> reduceToSingleOperationPerIndex(std::vector<RewriteOperation*> &rewrites);
|
273
|
-
|
274
|
-
virtual std::string catOpText(std::string *a, std::string *b);
|
275
|
-
|
276
|
-
/// Get all operations before an index of a particular kind.
|
277
|
-
template <typename T>
|
278
|
-
std::vector<T *> getKindOfOps(std::vector<RewriteOperation *> rewrites, size_t before) {
|
279
|
-
std::vector<T *> ops;
|
280
|
-
for (size_t i = 0; i < before && i < rewrites.size(); i++) {
|
281
|
-
T *op = dynamic_cast<T *>(rewrites[i]);
|
282
|
-
if (op == nullptr) { // ignore deleted or non matching entries
|
283
|
-
continue;
|
284
|
-
}
|
285
|
-
ops.push_back(op);
|
286
|
-
}
|
287
|
-
return ops;
|
288
|
-
}
|
289
|
-
|
290
|
-
private:
|
291
|
-
std::vector<RewriteOperation *>& initializeProgram(const std::string &name);
|
292
|
-
|
293
|
-
};
|
294
|
-
|
295
|
-
} // namespace antlr4
|
@@ -1,208 +0,0 @@
|
|
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
|
-
#include "misc/Interval.h"
|
7
|
-
#include "Exceptions.h"
|
8
|
-
#include "support/Utf8.h"
|
9
|
-
|
10
|
-
#include "UnbufferedCharStream.h"
|
11
|
-
|
12
|
-
using namespace antlrcpp;
|
13
|
-
using namespace antlr4;
|
14
|
-
using namespace antlr4::misc;
|
15
|
-
|
16
|
-
UnbufferedCharStream::UnbufferedCharStream(std::wistream &input)
|
17
|
-
: _p(0), _numMarkers(0), _lastChar(0), _lastCharBufferStart(0), _currentCharIndex(0), _input(input) {
|
18
|
-
// The vector's size is what used to be n in Java code.
|
19
|
-
fill(1); // prime
|
20
|
-
}
|
21
|
-
|
22
|
-
void UnbufferedCharStream::consume() {
|
23
|
-
if (LA(1) == EOF) {
|
24
|
-
throw IllegalStateException("cannot consume EOF");
|
25
|
-
}
|
26
|
-
|
27
|
-
// buf always has at least data[p==0] in this method due to ctor
|
28
|
-
_lastChar = _data[_p]; // track last char for LA(-1)
|
29
|
-
|
30
|
-
if (_p == _data.size() - 1 && _numMarkers == 0) {
|
31
|
-
size_t capacity = _data.capacity();
|
32
|
-
_data.clear();
|
33
|
-
_data.reserve(capacity);
|
34
|
-
|
35
|
-
_p = 0;
|
36
|
-
_lastCharBufferStart = _lastChar;
|
37
|
-
} else {
|
38
|
-
_p++;
|
39
|
-
}
|
40
|
-
|
41
|
-
_currentCharIndex++;
|
42
|
-
sync(1);
|
43
|
-
}
|
44
|
-
|
45
|
-
void UnbufferedCharStream::sync(size_t want) {
|
46
|
-
if (_p + want <= _data.size()) // Already enough data loaded?
|
47
|
-
return;
|
48
|
-
|
49
|
-
fill(_p + want - _data.size());
|
50
|
-
}
|
51
|
-
|
52
|
-
size_t UnbufferedCharStream::fill(size_t n) {
|
53
|
-
for (size_t i = 0; i < n; i++) {
|
54
|
-
if (_data.size() > 0 && _data.back() == 0xFFFF) {
|
55
|
-
return i;
|
56
|
-
}
|
57
|
-
|
58
|
-
try {
|
59
|
-
char32_t c = nextChar();
|
60
|
-
add(c);
|
61
|
-
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023026
|
62
|
-
} catch (IOException &ioe) {
|
63
|
-
// throw_with_nested is not available before VS 2015.
|
64
|
-
throw ioe;
|
65
|
-
#else
|
66
|
-
} catch (IOException & /*ioe*/) {
|
67
|
-
std::throw_with_nested(RuntimeException());
|
68
|
-
#endif
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
return n;
|
73
|
-
}
|
74
|
-
|
75
|
-
char32_t UnbufferedCharStream::nextChar() {
|
76
|
-
return _input.get();
|
77
|
-
}
|
78
|
-
|
79
|
-
void UnbufferedCharStream::add(char32_t c) {
|
80
|
-
_data += c;
|
81
|
-
}
|
82
|
-
|
83
|
-
size_t UnbufferedCharStream::LA(ssize_t i) {
|
84
|
-
if (i == -1) { // special case
|
85
|
-
return _lastChar;
|
86
|
-
}
|
87
|
-
|
88
|
-
// We can look back only as many chars as we have buffered.
|
89
|
-
ssize_t index = static_cast<ssize_t>(_p) + i - 1;
|
90
|
-
if (index < 0) {
|
91
|
-
throw IndexOutOfBoundsException();
|
92
|
-
}
|
93
|
-
|
94
|
-
if (i > 0) {
|
95
|
-
sync(static_cast<size_t>(i)); // No need to sync if we look back.
|
96
|
-
}
|
97
|
-
if (static_cast<size_t>(index) >= _data.size()) {
|
98
|
-
return EOF;
|
99
|
-
}
|
100
|
-
|
101
|
-
if (_data[static_cast<size_t>(index)] == std::char_traits<wchar_t>::eof()) {
|
102
|
-
return EOF;
|
103
|
-
}
|
104
|
-
|
105
|
-
return _data[static_cast<size_t>(index)];
|
106
|
-
}
|
107
|
-
|
108
|
-
ssize_t UnbufferedCharStream::mark() {
|
109
|
-
if (_numMarkers == 0) {
|
110
|
-
_lastCharBufferStart = _lastChar;
|
111
|
-
}
|
112
|
-
|
113
|
-
ssize_t mark = -static_cast<ssize_t>(_numMarkers) - 1;
|
114
|
-
_numMarkers++;
|
115
|
-
return mark;
|
116
|
-
}
|
117
|
-
|
118
|
-
void UnbufferedCharStream::release(ssize_t marker) {
|
119
|
-
ssize_t expectedMark = -static_cast<ssize_t>(_numMarkers);
|
120
|
-
if (marker != expectedMark) {
|
121
|
-
throw IllegalStateException("release() called with an invalid marker.");
|
122
|
-
}
|
123
|
-
|
124
|
-
_numMarkers--;
|
125
|
-
if (_numMarkers == 0 && _p > 0) {
|
126
|
-
_data.erase(0, _p);
|
127
|
-
_p = 0;
|
128
|
-
_lastCharBufferStart = _lastChar;
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
size_t UnbufferedCharStream::index() {
|
133
|
-
return _currentCharIndex;
|
134
|
-
}
|
135
|
-
|
136
|
-
void UnbufferedCharStream::seek(size_t index) {
|
137
|
-
if (index == _currentCharIndex) {
|
138
|
-
return;
|
139
|
-
}
|
140
|
-
|
141
|
-
if (index > _currentCharIndex) {
|
142
|
-
sync(index - _currentCharIndex);
|
143
|
-
index = std::min(index, getBufferStartIndex() + _data.size() - 1);
|
144
|
-
}
|
145
|
-
|
146
|
-
// index == to bufferStartIndex should set p to 0
|
147
|
-
ssize_t i = static_cast<ssize_t>(index) - static_cast<ssize_t>(getBufferStartIndex());
|
148
|
-
if (i < 0) {
|
149
|
-
throw IllegalArgumentException(std::string("cannot seek to negative index ") + std::to_string(index));
|
150
|
-
} else if (i >= static_cast<ssize_t>(_data.size())) {
|
151
|
-
throw UnsupportedOperationException("Seek to index outside buffer: " + std::to_string(index) +
|
152
|
-
" not in " + std::to_string(getBufferStartIndex()) + ".." +
|
153
|
-
std::to_string(getBufferStartIndex() + _data.size()));
|
154
|
-
}
|
155
|
-
|
156
|
-
_p = static_cast<size_t>(i);
|
157
|
-
_currentCharIndex = index;
|
158
|
-
if (_p == 0) {
|
159
|
-
_lastChar = _lastCharBufferStart;
|
160
|
-
} else {
|
161
|
-
_lastChar = _data[_p - 1];
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
size_t UnbufferedCharStream::size() {
|
166
|
-
throw UnsupportedOperationException("Unbuffered stream cannot know its size");
|
167
|
-
}
|
168
|
-
|
169
|
-
std::string UnbufferedCharStream::getSourceName() const {
|
170
|
-
if (name.empty()) {
|
171
|
-
return UNKNOWN_SOURCE_NAME;
|
172
|
-
}
|
173
|
-
|
174
|
-
return name;
|
175
|
-
}
|
176
|
-
|
177
|
-
std::string UnbufferedCharStream::getText(const misc::Interval &interval) {
|
178
|
-
if (interval.a < 0 || interval.b < interval.a - 1) {
|
179
|
-
throw IllegalArgumentException("invalid interval");
|
180
|
-
}
|
181
|
-
|
182
|
-
size_t bufferStartIndex = getBufferStartIndex();
|
183
|
-
if (!_data.empty() && _data.back() == 0xFFFF) {
|
184
|
-
if (interval.a + interval.length() > bufferStartIndex + _data.size()) {
|
185
|
-
throw IllegalArgumentException("the interval extends past the end of the stream");
|
186
|
-
}
|
187
|
-
}
|
188
|
-
|
189
|
-
if (interval.a < static_cast<ssize_t>(bufferStartIndex) || interval.b >= ssize_t(bufferStartIndex + _data.size())) {
|
190
|
-
throw UnsupportedOperationException("interval " + interval.toString() + " outside buffer: " +
|
191
|
-
std::to_string(bufferStartIndex) + ".." + std::to_string(bufferStartIndex + _data.size() - 1));
|
192
|
-
}
|
193
|
-
// convert from absolute to local index
|
194
|
-
size_t i = interval.a - bufferStartIndex;
|
195
|
-
auto maybeUtf8 = Utf8::strictEncode(std::u32string_view(_data).substr(i, interval.length()));
|
196
|
-
if (!maybeUtf8.has_value()) {
|
197
|
-
throw IllegalArgumentException("Unbuffered stream contains invalid Unicode code points");
|
198
|
-
}
|
199
|
-
return std::move(maybeUtf8).value();
|
200
|
-
}
|
201
|
-
|
202
|
-
std::string UnbufferedCharStream::toString() const {
|
203
|
-
throw UnsupportedOperationException("Unbuffered stream cannot be materialized to a string");
|
204
|
-
}
|
205
|
-
|
206
|
-
size_t UnbufferedCharStream::getBufferStartIndex() const {
|
207
|
-
return _currentCharIndex - _p;
|
208
|
-
}
|
@@ -1,117 +0,0 @@
|
|
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 "CharStream.h"
|
9
|
-
|
10
|
-
namespace antlr4 {
|
11
|
-
|
12
|
-
/// Do not buffer up the entire char stream. It does keep a small buffer
|
13
|
-
/// for efficiency and also buffers while a mark exists (set by the
|
14
|
-
/// lookahead prediction in parser). "Unbuffered" here refers to fact
|
15
|
-
/// that it doesn't buffer all data, not that's it's on demand loading of char.
|
16
|
-
class ANTLR4CPP_PUBLIC UnbufferedCharStream : public CharStream {
|
17
|
-
public:
|
18
|
-
/// The name or source of this char stream.
|
19
|
-
std::string name;
|
20
|
-
|
21
|
-
explicit UnbufferedCharStream(std::wistream &input);
|
22
|
-
|
23
|
-
void consume() override;
|
24
|
-
size_t LA(ssize_t i) override;
|
25
|
-
|
26
|
-
/// <summary>
|
27
|
-
/// Return a marker that we can release later.
|
28
|
-
/// <p/>
|
29
|
-
/// The specific marker value used for this class allows for some level of
|
30
|
-
/// protection against misuse where {@code seek()} is called on a mark or
|
31
|
-
/// {@code release()} is called in the wrong order.
|
32
|
-
/// </summary>
|
33
|
-
ssize_t mark() override;
|
34
|
-
|
35
|
-
/// <summary>
|
36
|
-
/// Decrement number of markers, resetting buffer if we hit 0. </summary>
|
37
|
-
/// <param name="marker"> </param>
|
38
|
-
void release(ssize_t marker) override;
|
39
|
-
size_t index() override;
|
40
|
-
|
41
|
-
/// <summary>
|
42
|
-
/// Seek to absolute character index, which might not be in the current
|
43
|
-
/// sliding window. Move {@code p} to {@code index-bufferStartIndex}.
|
44
|
-
/// </summary>
|
45
|
-
void seek(size_t index) override;
|
46
|
-
size_t size() override;
|
47
|
-
std::string getSourceName() const override;
|
48
|
-
std::string getText(const misc::Interval &interval) override;
|
49
|
-
|
50
|
-
std::string toString() const override;
|
51
|
-
|
52
|
-
protected:
|
53
|
-
/// A moving window buffer of the data being scanned. While there's a marker,
|
54
|
-
/// we keep adding to buffer. Otherwise, <seealso cref="#consume consume()"/> resets so
|
55
|
-
/// we start filling at index 0 again.
|
56
|
-
// UTF-32 encoded.
|
57
|
-
std::u32string _data;
|
58
|
-
typedef char32_t storage_type;
|
59
|
-
|
60
|
-
/// <summary>
|
61
|
-
/// 0..n-1 index into <seealso cref="#data data"/> of next character.
|
62
|
-
/// <p/>
|
63
|
-
/// The {@code LA(1)} character is {@code data[p]}. If {@code p == n}, we are
|
64
|
-
/// out of buffered characters.
|
65
|
-
/// </summary>
|
66
|
-
size_t _p;
|
67
|
-
|
68
|
-
/// <summary>
|
69
|
-
/// Count up with <seealso cref="#mark mark()"/> and down with
|
70
|
-
/// <seealso cref="#release release()"/>. When we {@code release()} the last mark,
|
71
|
-
/// {@code numMarkers} reaches 0 and we reset the buffer. Copy
|
72
|
-
/// {@code data[p]..data[n-1]} to {@code data[0]..data[(n-1)-p]}.
|
73
|
-
/// </summary>
|
74
|
-
size_t _numMarkers;
|
75
|
-
|
76
|
-
/// This is the {@code LA(-1)} character for the current position.
|
77
|
-
size_t _lastChar; // UTF-32
|
78
|
-
|
79
|
-
/// <summary>
|
80
|
-
/// When {@code numMarkers > 0}, this is the {@code LA(-1)} character for the
|
81
|
-
/// first character in <seealso cref="#data data"/>. Otherwise, this is unspecified.
|
82
|
-
/// </summary>
|
83
|
-
size_t _lastCharBufferStart; // UTF-32
|
84
|
-
|
85
|
-
/// <summary>
|
86
|
-
/// Absolute character index. It's the index of the character about to be
|
87
|
-
/// read via {@code LA(1)}. Goes from 0 to the number of characters in the
|
88
|
-
/// entire stream, although the stream size is unknown before the end is
|
89
|
-
/// reached.
|
90
|
-
/// </summary>
|
91
|
-
size_t _currentCharIndex;
|
92
|
-
|
93
|
-
std::wistream &_input;
|
94
|
-
|
95
|
-
/// <summary>
|
96
|
-
/// Make sure we have 'want' elements from current position <seealso cref="#p p"/>.
|
97
|
-
/// Last valid {@code p} index is {@code data.length-1}. {@code p+need-1} is
|
98
|
-
/// the char index 'need' elements ahead. If we need 1 element,
|
99
|
-
/// {@code (p+1-1)==p} must be less than {@code data.length}.
|
100
|
-
/// </summary>
|
101
|
-
virtual void sync(size_t want);
|
102
|
-
|
103
|
-
/// <summary>
|
104
|
-
/// Add {@code n} characters to the buffer. Returns the number of characters
|
105
|
-
/// actually added to the buffer. If the return value is less than {@code n},
|
106
|
-
/// then EOF was reached before {@code n} characters could be added.
|
107
|
-
/// </summary>
|
108
|
-
virtual size_t fill(size_t n);
|
109
|
-
|
110
|
-
/// Override to provide different source of characters than
|
111
|
-
/// <seealso cref="#input input"/>.
|
112
|
-
virtual char32_t nextChar();
|
113
|
-
virtual void add(char32_t c);
|
114
|
-
size_t getBufferStartIndex() const;
|
115
|
-
};
|
116
|
-
|
117
|
-
} // namespace antlr4
|