did_parser 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +12 -0
  3. data/Rakefile +28 -0
  4. data/did_parser.gemspec +31 -0
  5. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.cpp +10 -0
  6. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.h +167 -0
  7. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.cpp +10 -0
  8. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.h +121 -0
  9. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +23 -0
  10. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +30 -0
  11. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +180 -0
  12. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +79 -0
  13. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +61 -0
  14. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.h +59 -0
  15. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.cpp +25 -0
  16. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.h +36 -0
  17. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +414 -0
  18. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.h +200 -0
  19. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.cpp +11 -0
  20. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.h +37 -0
  21. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +193 -0
  22. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.h +158 -0
  23. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +39 -0
  24. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +74 -0
  25. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.cpp +78 -0
  26. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.h +79 -0
  27. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +15 -0
  28. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.h +35 -0
  29. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +336 -0
  30. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.h +466 -0
  31. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +84 -0
  32. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.h +80 -0
  33. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +64 -0
  34. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +99 -0
  35. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +52 -0
  36. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +32 -0
  37. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.cpp +18 -0
  38. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.h +24 -0
  39. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.cpp +12 -0
  40. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +218 -0
  41. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.cpp +19 -0
  42. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.h +45 -0
  43. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +294 -0
  44. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +196 -0
  45. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +60 -0
  46. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +46 -0
  47. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.cpp +36 -0
  48. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.h +31 -0
  49. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +92 -0
  50. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +88 -0
  51. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.cpp +46 -0
  52. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.h +42 -0
  53. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +668 -0
  54. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +461 -0
  55. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +294 -0
  56. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +173 -0
  57. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +138 -0
  58. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +147 -0
  59. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +53 -0
  60. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.h +38 -0
  61. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +65 -0
  62. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.h +98 -0
  63. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +156 -0
  64. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +159 -0
  65. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +144 -0
  66. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +141 -0
  67. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.cpp +27 -0
  68. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.h +32 -0
  69. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +54 -0
  70. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.h +155 -0
  71. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.cpp +9 -0
  72. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +92 -0
  73. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenFactory.h +30 -0
  74. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.cpp +9 -0
  75. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +85 -0
  76. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.cpp +11 -0
  77. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.h +137 -0
  78. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +425 -0
  79. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +295 -0
  80. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +208 -0
  81. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +117 -0
  82. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +270 -0
  83. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.h +115 -0
  84. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +42 -0
  85. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +64 -0
  86. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +177 -0
  87. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.cpp +9 -0
  88. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.h +23 -0
  89. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +98 -0
  90. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +169 -0
  91. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +158 -0
  92. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +132 -0
  93. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +106 -0
  94. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +157 -0
  95. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +232 -0
  96. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +156 -0
  97. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +54 -0
  98. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +48 -0
  99. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +629 -0
  100. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +32 -0
  101. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +33 -0
  102. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +71 -0
  103. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +56 -0
  104. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +139 -0
  105. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +33 -0
  106. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +36 -0
  107. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNType.h +20 -0
  108. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +29 -0
  109. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +35 -0
  110. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.cpp +16 -0
  111. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.h +68 -0
  112. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +109 -0
  113. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +51 -0
  114. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +27 -0
  115. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +33 -0
  116. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +24 -0
  117. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +23 -0
  118. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +26 -0
  119. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +30 -0
  120. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.cpp +14 -0
  121. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.h +47 -0
  122. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.cpp +14 -0
  123. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.h +70 -0
  124. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.cpp +25 -0
  125. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +227 -0
  126. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +12 -0
  127. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +34 -0
  128. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +31 -0
  129. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +42 -0
  130. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.cpp +15 -0
  131. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.h +43 -0
  132. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +189 -0
  133. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +76 -0
  134. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +67 -0
  135. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +44 -0
  136. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +615 -0
  137. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +199 -0
  138. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +15 -0
  139. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +100 -0
  140. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +111 -0
  141. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +128 -0
  142. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +57 -0
  143. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +43 -0
  144. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +59 -0
  145. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +45 -0
  146. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +75 -0
  147. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +57 -0
  148. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +76 -0
  149. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +43 -0
  150. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +57 -0
  151. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +36 -0
  152. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +53 -0
  153. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +36 -0
  154. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +53 -0
  155. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +43 -0
  156. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +57 -0
  157. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +36 -0
  158. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +51 -0
  159. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +43 -0
  160. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +51 -0
  161. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.cpp +16 -0
  162. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.h +42 -0
  163. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +26 -0
  164. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +22 -0
  165. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +27 -0
  166. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +16 -0
  167. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +25 -0
  168. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.cpp +102 -0
  169. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.h +102 -0
  170. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +1383 -0
  171. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +911 -0
  172. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +50 -0
  173. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +29 -0
  174. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +25 -0
  175. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +23 -0
  176. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +35 -0
  177. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +17 -0
  178. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +62 -0
  179. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +24 -0
  180. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +50 -0
  181. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +579 -0
  182. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +225 -0
  183. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +56 -0
  184. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +64 -0
  185. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +167 -0
  186. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +101 -0
  187. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +71 -0
  188. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +21 -0
  189. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +202 -0
  190. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +436 -0
  191. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +179 -0
  192. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +60 -0
  193. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +26 -0
  194. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +31 -0
  195. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +26 -0
  196. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +27 -0
  197. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +33 -0
  198. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +42 -0
  199. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +418 -0
  200. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +233 -0
  201. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +23 -0
  202. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +101 -0
  203. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +28 -0
  204. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +38 -0
  205. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +86 -0
  206. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +43 -0
  207. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +24 -0
  208. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +37 -0
  209. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +19 -0
  210. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +25 -0
  211. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +24 -0
  212. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +36 -0
  213. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +65 -0
  214. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +27 -0
  215. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +33 -0
  216. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +21 -0
  217. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +27 -0
  218. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +115 -0
  219. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +96 -0
  220. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +60 -0
  221. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +32 -0
  222. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +59 -0
  223. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +153 -0
  224. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +17 -0
  225. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +22 -0
  226. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +124 -0
  227. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +33 -0
  228. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +61 -0
  229. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +84 -0
  230. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +508 -0
  231. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +190 -0
  232. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +120 -0
  233. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +102 -0
  234. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.cpp +4 -0
  235. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.h +21 -0
  236. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +8 -0
  237. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +16 -0
  238. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +43 -0
  239. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +149 -0
  240. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +76 -0
  241. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +207 -0
  242. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +65 -0
  243. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +34 -0
  244. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +161 -0
  245. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +38 -0
  246. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +16 -0
  247. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +28 -0
  248. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +242 -0
  249. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +54 -0
  250. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +129 -0
  251. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +24 -0
  252. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +54 -0
  253. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +43 -0
  254. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +66 -0
  255. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.h +53 -0
  256. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +12 -0
  257. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +111 -0
  258. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.cpp +9 -0
  259. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +39 -0
  260. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeProperty.h +50 -0
  261. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +22 -0
  262. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.cpp +9 -0
  263. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +57 -0
  264. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +48 -0
  265. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +55 -0
  266. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +40 -0
  267. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +54 -0
  268. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +32 -0
  269. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +241 -0
  270. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.h +78 -0
  271. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.cpp +9 -0
  272. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +44 -0
  273. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.cpp +69 -0
  274. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +132 -0
  275. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +64 -0
  276. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +105 -0
  277. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +370 -0
  278. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +185 -0
  279. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +77 -0
  280. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.h +117 -0
  281. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.cpp +39 -0
  282. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +86 -0
  283. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.cpp +28 -0
  284. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +51 -0
  285. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +36 -0
  286. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.h +80 -0
  287. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +154 -0
  288. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.h +86 -0
  289. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.cpp +31 -0
  290. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.h +40 -0
  291. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +182 -0
  292. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +47 -0
  293. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.cpp +13 -0
  294. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.h +22 -0
  295. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp +20 -0
  296. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.h +27 -0
  297. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +30 -0
  298. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.h +26 -0
  299. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp +20 -0
  300. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.h +25 -0
  301. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +33 -0
  302. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.h +26 -0
  303. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp +23 -0
  304. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h +23 -0
  305. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.cpp +24 -0
  306. data/ext/did_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.h +23 -0
  307. data/ext/did_parser/antlrgen/DIDLexer.cpp +225 -0
  308. data/ext/did_parser/antlrgen/DIDLexer.h +52 -0
  309. data/ext/did_parser/antlrgen/DIDLexer.interp +93 -0
  310. data/ext/did_parser/antlrgen/DIDLexer.tokens +42 -0
  311. data/ext/did_parser/antlrgen/DIDParser.cpp +2042 -0
  312. data/ext/did_parser/antlrgen/DIDParser.h +537 -0
  313. data/ext/did_parser/antlrgen/DIDParser.interp +74 -0
  314. data/ext/did_parser/antlrgen/DIDParser.tokens +42 -0
  315. data/ext/did_parser/antlrgen/DIDParserBaseListener.cpp +7 -0
  316. data/ext/did_parser/antlrgen/DIDParserBaseListener.h +104 -0
  317. data/ext/did_parser/antlrgen/DIDParserBaseVisitor.cpp +7 -0
  318. data/ext/did_parser/antlrgen/DIDParserBaseVisitor.h +124 -0
  319. data/ext/did_parser/antlrgen/DIDParserListener.cpp +7 -0
  320. data/ext/did_parser/antlrgen/DIDParserListener.h +97 -0
  321. data/ext/did_parser/antlrgen/DIDParserVisitor.cpp +7 -0
  322. data/ext/did_parser/antlrgen/DIDParserVisitor.h +76 -0
  323. data/ext/did_parser/did_parser.cpp +2996 -0
  324. data/ext/did_parser/extconf.rb +38 -0
  325. data/lib/did_parser/version.rb +3 -0
  326. data/lib/did_parser.rb +2 -0
  327. metadata +382 -0
@@ -0,0 +1,295 @@
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
@@ -0,0 +1,208 @@
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
+ }
@@ -0,0 +1,117 @@
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