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,159 @@
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 "ProxyErrorListener.h"
9
+ #include "support/Casts.h"
10
+ #include "atn/SerializedATNView.h"
11
+
12
+ namespace antlr4 {
13
+
14
+ class ANTLR4CPP_PUBLIC Recognizer {
15
+ public:
16
+ static constexpr size_t EOF = std::numeric_limits<size_t>::max();
17
+
18
+ Recognizer();
19
+ Recognizer(Recognizer const&) = delete;
20
+ virtual ~Recognizer();
21
+
22
+ Recognizer& operator=(Recognizer const&) = delete;
23
+
24
+ virtual std::vector<std::string> const& getRuleNames() const = 0;
25
+
26
+ /**
27
+ * Get the vocabulary used by the recognizer.
28
+ *
29
+ * @return A {@link Vocabulary} instance providing information about the
30
+ * vocabulary used by the grammar.
31
+ */
32
+ virtual dfa::Vocabulary const& getVocabulary() const = 0;
33
+
34
+ /// <summary>
35
+ /// Get a map from token names to token types.
36
+ /// <p/>
37
+ /// Used for XPath and tree pattern compilation.
38
+ /// </summary>
39
+ virtual std::map<std::string_view, size_t> getTokenTypeMap();
40
+
41
+ /// <summary>
42
+ /// Get a map from rule names to rule indexes.
43
+ /// <p/>
44
+ /// Used for XPath and tree pattern compilation.
45
+ /// </summary>
46
+ virtual std::map<std::string, size_t> getRuleIndexMap();
47
+
48
+ virtual size_t getTokenType(std::string_view tokenName);
49
+
50
+ /// <summary>
51
+ /// If this recognizer was generated, it will have a serialized ATN
52
+ /// representation of the grammar.
53
+ /// <p/>
54
+ /// For interpreters, we don't know their serialized ATN despite having
55
+ /// created the interpreter from it.
56
+ /// </summary>
57
+ virtual atn::SerializedATNView getSerializedATN() const {
58
+ throw "there is no serialized ATN";
59
+ }
60
+
61
+ /// <summary>
62
+ /// For debugging and other purposes, might want the grammar name.
63
+ /// Have ANTLR generate an implementation for this method.
64
+ /// </summary>
65
+ virtual std::string getGrammarFileName() const = 0;
66
+
67
+ /// Get the ATN interpreter (in fact one of it's descendants) used by the recognizer for prediction.
68
+ /// @returns The ATN interpreter used by the recognizer for prediction.
69
+ template <class T>
70
+ T* getInterpreter() const {
71
+ return antlrcpp::downCast<T *>(_interpreter);
72
+ }
73
+
74
+ /**
75
+ * Set the ATN interpreter used by the recognizer for prediction.
76
+ *
77
+ * @param interpreter The ATN interpreter used by the recognizer for
78
+ * prediction.
79
+ */
80
+ void setInterpreter(atn::ATNSimulator *interpreter);
81
+
82
+ /// What is the error header, normally line/character position information?
83
+ virtual std::string getErrorHeader(RecognitionException *e);
84
+
85
+ /** How should a token be displayed in an error message? The default
86
+ * is to display just the text, but during development you might
87
+ * want to have a lot of information spit out. Override in that case
88
+ * to use t.toString() (which, for CommonToken, dumps everything about
89
+ * the token). This is better than forcing you to override a method in
90
+ * your token objects because you don't have to go modify your lexer
91
+ * so that it creates a new Java type.
92
+ *
93
+ * @deprecated This method is not called by the ANTLR 4 Runtime. Specific
94
+ * implementations of {@link ANTLRErrorStrategy} may provide a similar
95
+ * feature when necessary. For example, see
96
+ * {@link DefaultErrorStrategy#getTokenErrorDisplay}.
97
+ */
98
+ virtual std::string getTokenErrorDisplay(Token *t);
99
+
100
+ /// <exception cref="NullPointerException"> if {@code listener} is {@code null}. </exception>
101
+ virtual void addErrorListener(ANTLRErrorListener *listener);
102
+
103
+ virtual void removeErrorListener(ANTLRErrorListener *listener);
104
+
105
+ virtual void removeErrorListeners();
106
+
107
+ virtual ProxyErrorListener& getErrorListenerDispatch();
108
+
109
+ // subclass needs to override these if there are sempreds or actions
110
+ // that the ATN interp needs to execute
111
+ virtual bool sempred(RuleContext *localctx, size_t ruleIndex, size_t actionIndex);
112
+
113
+ virtual bool precpred(RuleContext *localctx, int precedence);
114
+
115
+ virtual void action(RuleContext *localctx, size_t ruleIndex, size_t actionIndex);
116
+
117
+ size_t getState() const { return _stateNumber; }
118
+
119
+ // Get the ATN used by the recognizer for prediction.
120
+ virtual const atn::ATN& getATN() const = 0;
121
+
122
+ /// <summary>
123
+ /// Indicate that the recognizer has changed internal state that is
124
+ /// consistent with the ATN state passed in. This way we always know
125
+ /// where we are in the ATN as the parser goes along. The rule
126
+ /// context objects form a stack that lets us see the stack of
127
+ /// invoking rules. Combine this and we have complete ATN
128
+ /// configuration information.
129
+ /// </summary>
130
+ void setState(size_t atnState) { _stateNumber = atnState; }
131
+
132
+ virtual IntStream* getInputStream() = 0;
133
+
134
+ virtual void setInputStream(IntStream *input) = 0;
135
+
136
+ virtual TokenFactory<CommonToken>* getTokenFactory() = 0;
137
+
138
+ template<typename T1>
139
+ void setTokenFactory(TokenFactory<T1> *input);
140
+
141
+ protected:
142
+ atn::ATNSimulator *_interpreter; // Set and deleted in descendants (or the profiler).
143
+
144
+ // Mutex to manage synchronized access for multithreading.
145
+ std::mutex _mutex;
146
+
147
+ private:
148
+ static std::map<const dfa::Vocabulary*, std::map<std::string_view, size_t>> _tokenTypeMapCache;
149
+ static std::map<std::vector<std::string>, std::map<std::string, size_t>> _ruleIndexMapCache;
150
+
151
+ ProxyErrorListener _proxListener; // Manages a collection of listeners.
152
+
153
+ size_t _stateNumber;
154
+
155
+ void InitializeInstanceFields();
156
+
157
+ };
158
+
159
+ } // namespace antlr4
@@ -0,0 +1,144 @@
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 "tree/Trees.h"
7
+ #include "misc/Interval.h"
8
+ #include "Parser.h"
9
+ #include "atn/ATN.h"
10
+ #include "atn/ATNState.h"
11
+ #include "tree/ParseTreeVisitor.h"
12
+
13
+ #include "RuleContext.h"
14
+
15
+ using namespace antlr4;
16
+ using namespace antlr4::atn;
17
+ using namespace antlr4::tree;
18
+
19
+ RuleContext::RuleContext() : ParseTree(ParseTreeType::RULE) {
20
+ InitializeInstanceFields();
21
+ }
22
+
23
+ RuleContext::RuleContext(RuleContext *parent_, size_t invokingState_) : ParseTree(ParseTreeType::RULE) {
24
+ InitializeInstanceFields();
25
+ this->parent = parent_;
26
+ this->invokingState = invokingState_;
27
+ }
28
+
29
+ int RuleContext::depth() {
30
+ int n = 1;
31
+ RuleContext *p = this;
32
+ while (true) {
33
+ if (p->parent == nullptr)
34
+ break;
35
+ p = static_cast<RuleContext *>(p->parent);
36
+ n++;
37
+ }
38
+ return n;
39
+ }
40
+
41
+ bool RuleContext::isEmpty() {
42
+ return invokingState == ATNState::INVALID_STATE_NUMBER;
43
+ }
44
+
45
+ misc::Interval RuleContext::getSourceInterval() {
46
+ return misc::Interval::INVALID;
47
+ }
48
+
49
+ std::string RuleContext::getText() {
50
+ if (children.empty()) {
51
+ return "";
52
+ }
53
+
54
+ std::stringstream ss;
55
+ for (size_t i = 0; i < children.size(); i++) {
56
+ ParseTree *tree = children[i];
57
+ if (tree != nullptr)
58
+ ss << tree->getText();
59
+ }
60
+
61
+ return ss.str();
62
+ }
63
+
64
+ size_t RuleContext::getRuleIndex() const {
65
+ return INVALID_INDEX;
66
+ }
67
+
68
+ size_t RuleContext::getAltNumber() const {
69
+ return atn::ATN::INVALID_ALT_NUMBER;
70
+ }
71
+
72
+ void RuleContext::setAltNumber(size_t /*altNumber*/) {
73
+ }
74
+
75
+ std::any RuleContext::accept(tree::ParseTreeVisitor *visitor) {
76
+ return visitor->visitChildren(this);
77
+ }
78
+
79
+ std::string RuleContext::toStringTree(Parser *recog, bool pretty) {
80
+ return tree::Trees::toStringTree(this, recog, pretty);
81
+ }
82
+
83
+ std::string RuleContext::toStringTree(std::vector<std::string> &ruleNames, bool pretty) {
84
+ return tree::Trees::toStringTree(this, ruleNames, pretty);
85
+ }
86
+
87
+ std::string RuleContext::toStringTree(bool pretty) {
88
+ return toStringTree(nullptr, pretty);
89
+ }
90
+
91
+
92
+ std::string RuleContext::toString(const std::vector<std::string> &ruleNames) {
93
+ return toString(ruleNames, nullptr);
94
+ }
95
+
96
+
97
+ std::string RuleContext::toString(const std::vector<std::string> &ruleNames, RuleContext *stop) {
98
+ std::stringstream ss;
99
+
100
+ RuleContext *currentParent = this;
101
+ ss << "[";
102
+ while (currentParent != stop) {
103
+ if (ruleNames.empty()) {
104
+ if (!currentParent->isEmpty()) {
105
+ ss << currentParent->invokingState;
106
+ }
107
+ } else {
108
+ size_t ruleIndex = currentParent->getRuleIndex();
109
+
110
+ std::string ruleName = (ruleIndex < ruleNames.size()) ? ruleNames[ruleIndex] : std::to_string(ruleIndex);
111
+ ss << ruleName;
112
+ }
113
+
114
+ if (currentParent->parent == nullptr) // No parent anymore.
115
+ break;
116
+ currentParent = static_cast<RuleContext *>(currentParent->parent);
117
+ if (!ruleNames.empty() || !currentParent->isEmpty()) {
118
+ ss << " ";
119
+ }
120
+ }
121
+
122
+ ss << "]";
123
+
124
+ return ss.str();
125
+ }
126
+
127
+ std::string RuleContext::toString() {
128
+ return toString(nullptr);
129
+ }
130
+
131
+ std::string RuleContext::toString(Recognizer *recog) {
132
+ return toString(recog, &ParserRuleContext::EMPTY);
133
+ }
134
+
135
+ std::string RuleContext::toString(Recognizer *recog, RuleContext *stop) {
136
+ if (recog == nullptr)
137
+ return toString(std::vector<std::string>(), stop); // Don't use an initializer {} here or we end up calling ourselve recursivly.
138
+ return toString(recog->getRuleNames(), stop);
139
+ }
140
+
141
+ void RuleContext::InitializeInstanceFields() {
142
+ invokingState = INVALID_INDEX;
143
+ }
144
+
@@ -0,0 +1,141 @@
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 "tree/ParseTree.h"
9
+
10
+ namespace antlr4 {
11
+
12
+ /** A rule context is a record of a single rule invocation.
13
+ *
14
+ * We form a stack of these context objects using the parent
15
+ * pointer. A parent pointer of null indicates that the current
16
+ * context is the bottom of the stack. The ParserRuleContext subclass
17
+ * as a children list so that we can turn this data structure into a
18
+ * tree.
19
+ *
20
+ * The root node always has a null pointer and invokingState of -1.
21
+ *
22
+ * Upon entry to parsing, the first invoked rule function creates a
23
+ * context object (asubclass specialized for that rule such as
24
+ * SContext) and makes it the root of a parse tree, recorded by field
25
+ * Parser._ctx.
26
+ *
27
+ * public final SContext s() throws RecognitionException {
28
+ * SContext _localctx = new SContext(_ctx, getState()); <-- create new node
29
+ * enterRule(_localctx, 0, RULE_s); <-- push it
30
+ * ...
31
+ * exitRule(); <-- pop back to _localctx
32
+ * return _localctx;
33
+ * }
34
+ *
35
+ * A subsequent rule invocation of r from the start rule s pushes a
36
+ * new context object for r whose parent points at s and use invoking
37
+ * state is the state with r emanating as edge label.
38
+ *
39
+ * The invokingState fields from a context object to the root
40
+ * together form a stack of rule indication states where the root
41
+ * (bottom of the stack) has a -1 sentinel value. If we invoke start
42
+ * symbol s then call r1, which calls r2, the would look like
43
+ * this:
44
+ *
45
+ * SContext[-1] <- root node (bottom of the stack)
46
+ * R1Context[p] <- p in rule s called r1
47
+ * R2Context[q] <- q in rule r1 called r2
48
+ *
49
+ * So the top of the stack, _ctx, represents a call to the current
50
+ * rule and it holds the return address from another rule that invoke
51
+ * to this rule. To invoke a rule, we must always have a current context.
52
+ *
53
+ * The parent contexts are useful for computing lookahead sets and
54
+ * getting error information.
55
+ *
56
+ * These objects are used during parsing and prediction.
57
+ * For the special case of parsers, we use the subclass
58
+ * ParserRuleContext.
59
+ *
60
+ * @see ParserRuleContext
61
+ */
62
+ class ANTLR4CPP_PUBLIC RuleContext : public tree::ParseTree {
63
+ public:
64
+ static bool is(const tree::ParseTree &parseTree) { return parseTree.getTreeType() == tree::ParseTreeType::RULE; }
65
+
66
+ static bool is(const tree::ParseTree *parseTree) { return parseTree != nullptr && is(*parseTree); }
67
+
68
+ /// What state invoked the rule associated with this context?
69
+ /// The "return address" is the followState of invokingState
70
+ /// If parent is null, this should be -1 and this context object represents the start rule.
71
+ size_t invokingState;
72
+
73
+ RuleContext();
74
+ RuleContext(RuleContext *parent, size_t invokingState);
75
+
76
+ virtual int depth();
77
+
78
+ /// A context is empty if there is no invoking state; meaning nobody called current context.
79
+ virtual bool isEmpty();
80
+
81
+ // satisfy the ParseTree / SyntaxTree interface
82
+
83
+ virtual misc::Interval getSourceInterval() override;
84
+
85
+ virtual std::string getText() override;
86
+
87
+ virtual size_t getRuleIndex() const;
88
+
89
+ /** For rule associated with this parse tree internal node, return
90
+ * the outer alternative number used to match the input. Default
91
+ * implementation does not compute nor store this alt num. Create
92
+ * a subclass of ParserRuleContext with backing field and set
93
+ * option contextSuperClass.
94
+ * to set it.
95
+ *
96
+ * @since 4.5.3
97
+ */
98
+ virtual size_t getAltNumber() const;
99
+
100
+ /** Set the outer alternative number for this context node. Default
101
+ * implementation does nothing to avoid backing field overhead for
102
+ * trees that don't need it. Create
103
+ * a subclass of ParserRuleContext with backing field and set
104
+ * option contextSuperClass.
105
+ *
106
+ * @since 4.5.3
107
+ */
108
+ virtual void setAltNumber(size_t altNumber);
109
+
110
+ virtual std::any accept(tree::ParseTreeVisitor *visitor) override;
111
+
112
+ /// <summary>
113
+ /// Print out a whole tree, not just a node, in LISP format
114
+ /// (root child1 .. childN). Print just a node if this is a leaf.
115
+ /// We have to know the recognizer so we can get rule names.
116
+ /// </summary>
117
+ virtual std::string toStringTree(Parser *recog, bool pretty = false) override;
118
+
119
+ /// <summary>
120
+ /// Print out a whole tree, not just a node, in LISP format
121
+ /// (root child1 .. childN). Print just a node if this is a leaf.
122
+ /// </summary>
123
+ virtual std::string toStringTree(std::vector<std::string> &ruleNames, bool pretty = false);
124
+
125
+ virtual std::string toStringTree(bool pretty = false) override;
126
+ virtual std::string toString() override;
127
+ std::string toString(Recognizer *recog);
128
+ std::string toString(const std::vector<std::string> &ruleNames);
129
+
130
+ // recog null unless ParserRuleContext, in which case we use subclass toString(...)
131
+ std::string toString(Recognizer *recog, RuleContext *stop);
132
+
133
+ virtual std::string toString(const std::vector<std::string> &ruleNames, RuleContext *stop);
134
+
135
+ bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
136
+
137
+ private:
138
+ void InitializeInstanceFields();
139
+ };
140
+
141
+ } // namespace antlr4
@@ -0,0 +1,27 @@
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 "atn/ATN.h"
7
+
8
+ #include "RuleContextWithAltNum.h"
9
+
10
+ using namespace antlr4;
11
+ using namespace antlr4::atn;
12
+
13
+ RuleContextWithAltNum::RuleContextWithAltNum() : ParserRuleContext() {
14
+ altNum = ATN::INVALID_ALT_NUMBER;
15
+ }
16
+
17
+ RuleContextWithAltNum::RuleContextWithAltNum(ParserRuleContext *parent, int invokingStateNumber)
18
+ : ParserRuleContext(parent, invokingStateNumber) {
19
+ }
20
+
21
+ size_t RuleContextWithAltNum::getAltNumber() const {
22
+ return altNum;
23
+ }
24
+
25
+ void RuleContextWithAltNum::setAltNumber(size_t number) {
26
+ altNum = number;
27
+ }
@@ -0,0 +1,32 @@
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 "ParserRuleContext.h"
9
+
10
+ namespace antlr4 {
11
+
12
+ /// A handy class for use with
13
+ ///
14
+ /// options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;}
15
+ ///
16
+ /// that provides a backing field / impl for the outer alternative number
17
+ /// matched for an internal parse tree node.
18
+ ///
19
+ /// I'm only putting into Java runtime as I'm certain I'm the only one that
20
+ /// will really every use this.
21
+ class ANTLR4CPP_PUBLIC RuleContextWithAltNum : public ParserRuleContext {
22
+ public:
23
+ size_t altNum = 0;
24
+
25
+ RuleContextWithAltNum();
26
+ RuleContextWithAltNum(ParserRuleContext *parent, int invokingStateNumber);
27
+
28
+ virtual size_t getAltNumber() const override;
29
+ virtual void setAltNumber(size_t altNum) override;
30
+ };
31
+
32
+ } // namespace antlr4
@@ -0,0 +1,54 @@
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 "RuntimeMetaData.h"
7
+ #include "Version.h"
8
+
9
+ using namespace antlr4;
10
+
11
+ const std::string RuntimeMetaData::VERSION = ANTLRCPP_VERSION_STRING;
12
+
13
+ std::string RuntimeMetaData::getRuntimeVersion() {
14
+ return VERSION;
15
+ }
16
+
17
+ void RuntimeMetaData::checkVersion(const std::string &generatingToolVersion, const std::string &compileTimeVersion) {
18
+ std::string runtimeVersion = VERSION;
19
+ bool runtimeConflictsWithGeneratingTool = false;
20
+ bool runtimeConflictsWithCompileTimeTool = false;
21
+
22
+ if (generatingToolVersion != "") {
23
+ runtimeConflictsWithGeneratingTool = runtimeVersion != generatingToolVersion
24
+ && getMajorMinorVersion(runtimeVersion) != getMajorMinorVersion(generatingToolVersion);
25
+ }
26
+
27
+ runtimeConflictsWithCompileTimeTool = runtimeVersion != compileTimeVersion
28
+ && getMajorMinorVersion(runtimeVersion) != getMajorMinorVersion(compileTimeVersion);
29
+
30
+ if (runtimeConflictsWithGeneratingTool) {
31
+ std::cerr << "ANTLR Tool version " << generatingToolVersion << " used for code generation does not match "
32
+ "the current runtime version " << runtimeVersion << std::endl;
33
+ }
34
+ if (runtimeConflictsWithCompileTimeTool) {
35
+ std::cerr << "ANTLR Runtime version " << compileTimeVersion << " used for parser compilation does not match "
36
+ "the current runtime version " << runtimeVersion << std::endl;
37
+ }
38
+ }
39
+
40
+ std::string RuntimeMetaData::getMajorMinorVersion(const std::string &version) {
41
+ size_t firstDot = version.find('.');
42
+ size_t secondDot = firstDot != std::string::npos ? version.find('.', firstDot + 1) : std::string::npos;
43
+ size_t firstDash = version.find('-');
44
+ size_t referenceLength = version.size();
45
+ if (secondDot != std::string::npos) {
46
+ referenceLength = std::min(referenceLength, secondDot);
47
+ }
48
+
49
+ if (firstDash != std::string::npos) {
50
+ referenceLength = std::min(referenceLength, firstDash);
51
+ }
52
+
53
+ return version.substr(0, referenceLength);
54
+ }