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,629 @@
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/ATNDeserializationOptions.h"
7
+
8
+ #include "atn/ATNType.h"
9
+ #include "atn/ATNState.h"
10
+ #include "atn/ATN.h"
11
+
12
+ #include "atn/LoopEndState.h"
13
+ #include "atn/DecisionState.h"
14
+ #include "atn/RuleStartState.h"
15
+ #include "atn/RuleStopState.h"
16
+ #include "atn/TokensStartState.h"
17
+ #include "atn/RuleTransition.h"
18
+ #include "atn/EpsilonTransition.h"
19
+ #include "atn/PlusLoopbackState.h"
20
+ #include "atn/PlusBlockStartState.h"
21
+ #include "atn/StarLoopbackState.h"
22
+ #include "atn/BasicBlockStartState.h"
23
+ #include "atn/BasicState.h"
24
+ #include "atn/BlockEndState.h"
25
+ #include "atn/StarLoopEntryState.h"
26
+
27
+ #include "atn/AtomTransition.h"
28
+ #include "atn/StarBlockStartState.h"
29
+ #include "atn/RangeTransition.h"
30
+ #include "atn/PredicateTransition.h"
31
+ #include "atn/PrecedencePredicateTransition.h"
32
+ #include "atn/ActionTransition.h"
33
+ #include "atn/SetTransition.h"
34
+ #include "atn/NotSetTransition.h"
35
+ #include "atn/WildcardTransition.h"
36
+ #include "atn/TransitionType.h"
37
+ #include "Token.h"
38
+
39
+ #include "misc/IntervalSet.h"
40
+ #include "Exceptions.h"
41
+ #include "support/CPPUtils.h"
42
+ #include "support/Casts.h"
43
+
44
+ #include "atn/LexerCustomAction.h"
45
+ #include "atn/LexerChannelAction.h"
46
+ #include "atn/LexerModeAction.h"
47
+ #include "atn/LexerMoreAction.h"
48
+ #include "atn/LexerPopModeAction.h"
49
+ #include "atn/LexerPushModeAction.h"
50
+ #include "atn/LexerSkipAction.h"
51
+ #include "atn/LexerTypeAction.h"
52
+
53
+ #include "atn/ATNDeserializer.h"
54
+
55
+ #include <cassert>
56
+ #include <mutex>
57
+ #include <string>
58
+ #include <vector>
59
+
60
+ using namespace antlr4;
61
+ using namespace antlr4::atn;
62
+ using namespace antlrcpp;
63
+
64
+ namespace {
65
+
66
+ void checkCondition(bool condition, std::string_view message) {
67
+ if (!condition) {
68
+ throw IllegalStateException(std::string(message));
69
+ }
70
+ }
71
+
72
+ void checkCondition(bool condition) {
73
+ checkCondition(condition, "");
74
+ }
75
+
76
+ /**
77
+ * Analyze the {@link StarLoopEntryState} states in the specified ATN to set
78
+ * the {@link StarLoopEntryState#isPrecedenceDecision} field to the
79
+ * correct value.
80
+ *
81
+ * @param atn The ATN.
82
+ */
83
+ void markPrecedenceDecisions(const ATN &atn) {
84
+ for (ATNState *state : atn.states) {
85
+ if (!StarLoopEntryState::is(state)) {
86
+ continue;
87
+ }
88
+
89
+ /* We analyze the ATN to determine if this ATN decision state is the
90
+ * decision for the closure block that determines whether a
91
+ * precedence rule should continue or complete.
92
+ */
93
+ if (atn.ruleToStartState[state->ruleIndex]->isLeftRecursiveRule) {
94
+ ATNState *maybeLoopEndState = state->transitions[state->transitions.size() - 1]->target;
95
+ if (LoopEndState::is(maybeLoopEndState)) {
96
+ if (maybeLoopEndState->epsilonOnlyTransitions && RuleStopState::is(maybeLoopEndState->transitions[0]->target)) {
97
+ downCast<StarLoopEntryState*>(state)->isPrecedenceDecision = true;
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+
104
+ Ref<const LexerAction> lexerActionFactory(LexerActionType type, int data1, int data2) {
105
+ switch (type) {
106
+ case LexerActionType::CHANNEL:
107
+ return std::make_shared<LexerChannelAction>(data1);
108
+
109
+ case LexerActionType::CUSTOM:
110
+ return std::make_shared<LexerCustomAction>(data1, data2);
111
+
112
+ case LexerActionType::MODE:
113
+ return std::make_shared< LexerModeAction>(data1);
114
+
115
+ case LexerActionType::MORE:
116
+ return LexerMoreAction::getInstance();
117
+
118
+ case LexerActionType::POP_MODE:
119
+ return LexerPopModeAction::getInstance();
120
+
121
+ case LexerActionType::PUSH_MODE:
122
+ return std::make_shared<LexerPushModeAction>(data1);
123
+
124
+ case LexerActionType::SKIP:
125
+ return LexerSkipAction::getInstance();
126
+
127
+ case LexerActionType::TYPE:
128
+ return std::make_shared<LexerTypeAction>(data1);
129
+
130
+ default:
131
+ throw IllegalArgumentException("The specified lexer action type " + std::to_string(static_cast<size_t>(type)) +
132
+ " is not valid.");
133
+ }
134
+ }
135
+
136
+ ConstTransitionPtr edgeFactory(const ATN &atn, TransitionType type, size_t trg, size_t arg1, size_t arg2,
137
+ size_t arg3, const std::vector<misc::IntervalSet> &sets) {
138
+ ATNState *target = atn.states[trg];
139
+ switch (type) {
140
+ case TransitionType::EPSILON:
141
+ return std::make_unique<EpsilonTransition>(target);
142
+ case TransitionType::RANGE:
143
+ if (arg3 != 0) {
144
+ return std::make_unique<RangeTransition>(target, Token::EOF, arg2);
145
+ } else {
146
+ return std::make_unique<RangeTransition>(target, arg1, arg2);
147
+ }
148
+ case TransitionType::RULE:
149
+ return std::make_unique<RuleTransition>(downCast<RuleStartState*>(atn.states[arg1]), arg2, (int)arg3, target);
150
+ case TransitionType::PREDICATE:
151
+ return std::make_unique<PredicateTransition>(target, arg1, arg2, arg3 != 0);
152
+ case TransitionType::PRECEDENCE:
153
+ return std::make_unique<PrecedencePredicateTransition>(target, (int)arg1);
154
+ case TransitionType::ATOM:
155
+ if (arg3 != 0) {
156
+ return std::make_unique<AtomTransition>(target, Token::EOF);
157
+ } else {
158
+ return std::make_unique<AtomTransition>(target, arg1);
159
+ }
160
+ case TransitionType::ACTION:
161
+ return std::make_unique<ActionTransition>(target, arg1, arg2, arg3 != 0);
162
+ case TransitionType::SET:
163
+ return std::make_unique<SetTransition>(target, sets[arg1]);
164
+ case TransitionType::NOT_SET:
165
+ return std::make_unique<NotSetTransition>(target, sets[arg1]);
166
+ case TransitionType::WILDCARD:
167
+ return std::make_unique<WildcardTransition>(target);
168
+ }
169
+
170
+ throw IllegalArgumentException("The specified transition type is not valid.");
171
+ }
172
+
173
+ /* mem check: all created instances are freed in the d-tor of the ATN. */
174
+ ATNState* stateFactory(ATNStateType type, size_t ruleIndex) {
175
+ ATNState *s;
176
+ switch (type) {
177
+ case ATNStateType::INVALID:
178
+ return nullptr;
179
+ case ATNStateType::BASIC :
180
+ s = new BasicState();
181
+ break;
182
+ case ATNStateType::RULE_START :
183
+ s = new RuleStartState();
184
+ break;
185
+ case ATNStateType::BLOCK_START :
186
+ s = new BasicBlockStartState();
187
+ break;
188
+ case ATNStateType::PLUS_BLOCK_START :
189
+ s = new PlusBlockStartState();
190
+ break;
191
+ case ATNStateType::STAR_BLOCK_START :
192
+ s = new StarBlockStartState();
193
+ break;
194
+ case ATNStateType::TOKEN_START :
195
+ s = new TokensStartState();
196
+ break;
197
+ case ATNStateType::RULE_STOP :
198
+ s = new RuleStopState();
199
+ break;
200
+ case ATNStateType::BLOCK_END :
201
+ s = new BlockEndState();
202
+ break;
203
+ case ATNStateType::STAR_LOOP_BACK :
204
+ s = new StarLoopbackState();
205
+ break;
206
+ case ATNStateType::STAR_LOOP_ENTRY :
207
+ s = new StarLoopEntryState();
208
+ break;
209
+ case ATNStateType::PLUS_LOOP_BACK :
210
+ s = new PlusLoopbackState();
211
+ break;
212
+ case ATNStateType::LOOP_END :
213
+ s = new LoopEndState();
214
+ break;
215
+ default :
216
+ std::string message = "The specified state type " + std::to_string(static_cast<size_t>(type)) + " is not valid.";
217
+ throw IllegalArgumentException(message);
218
+ }
219
+ assert(s->getStateType() == type);
220
+ s->ruleIndex = ruleIndex;
221
+ return s;
222
+ }
223
+
224
+ ssize_t readUnicodeInt32(SerializedATNView data, int& p) {
225
+ return static_cast<ssize_t>(data[p++]);
226
+ }
227
+
228
+ void deserializeSets(
229
+ SerializedATNView data,
230
+ int& p,
231
+ std::vector<misc::IntervalSet>& sets) {
232
+ size_t nsets = data[p++];
233
+ sets.reserve(sets.size() + nsets);
234
+ for (size_t i = 0; i < nsets; i++) {
235
+ size_t nintervals = data[p++];
236
+ misc::IntervalSet set;
237
+
238
+ bool containsEof = data[p++] != 0;
239
+ if (containsEof) {
240
+ set.add(-1);
241
+ }
242
+
243
+ for (size_t j = 0; j < nintervals; j++) {
244
+ auto a = readUnicodeInt32(data, p);
245
+ auto b = readUnicodeInt32(data, p);
246
+ set.add(a, b);
247
+ }
248
+ sets.push_back(set);
249
+ }
250
+ }
251
+
252
+ }
253
+
254
+ ATNDeserializer::ATNDeserializer() : ATNDeserializer(ATNDeserializationOptions::getDefaultOptions()) {}
255
+
256
+ ATNDeserializer::ATNDeserializer(ATNDeserializationOptions deserializationOptions) : _deserializationOptions(std::move(deserializationOptions)) {}
257
+
258
+ std::unique_ptr<ATN> ATNDeserializer::deserialize(SerializedATNView data) const {
259
+ int p = 0;
260
+ int version = data[p++];
261
+ if (version != SERIALIZED_VERSION) {
262
+ std::string reason = "Could not deserialize ATN with version" + std::to_string(version) + "(expected " + std::to_string(SERIALIZED_VERSION) + ").";
263
+
264
+ throw UnsupportedOperationException(reason);
265
+ }
266
+
267
+ ATNType grammarType = (ATNType)data[p++];
268
+ size_t maxTokenType = data[p++];
269
+ auto atn = std::make_unique<ATN>(grammarType, maxTokenType);
270
+
271
+ //
272
+ // STATES
273
+ //
274
+ {
275
+ std::vector<std::pair<LoopEndState*, size_t>> loopBackStateNumbers;
276
+ std::vector<std::pair<BlockStartState*, size_t>> endStateNumbers;
277
+ size_t nstates = data[p++];
278
+ atn->states.reserve(nstates);
279
+ loopBackStateNumbers.reserve(nstates); // Reserve worst case size, its short lived.
280
+ endStateNumbers.reserve(nstates); // Reserve worst case size, its short lived.
281
+ for (size_t i = 0; i < nstates; i++) {
282
+ ATNStateType stype = static_cast<ATNStateType>(data[p++]);
283
+ // ignore bad type of states
284
+ if (stype == ATNStateType::INVALID) {
285
+ atn->addState(nullptr);
286
+ continue;
287
+ }
288
+
289
+ size_t ruleIndex = data[p++];
290
+ ATNState *s = stateFactory(stype, ruleIndex);
291
+ if (stype == ATNStateType::LOOP_END) { // special case
292
+ int loopBackStateNumber = data[p++];
293
+ loopBackStateNumbers.push_back({ downCast<LoopEndState*>(s), loopBackStateNumber });
294
+ } else if (BlockStartState::is(s)) {
295
+ int endStateNumber = data[p++];
296
+ endStateNumbers.push_back({ downCast<BlockStartState*>(s), endStateNumber });
297
+ }
298
+ atn->addState(s);
299
+ }
300
+
301
+ // delay the assignment of loop back and end states until we know all the state instances have been initialized
302
+ for (auto &pair : loopBackStateNumbers) {
303
+ pair.first->loopBackState = atn->states[pair.second];
304
+ }
305
+
306
+ for (auto &pair : endStateNumbers) {
307
+ pair.first->endState = downCast<BlockEndState*>(atn->states[pair.second]);
308
+ }
309
+ }
310
+
311
+ size_t numNonGreedyStates = data[p++];
312
+ for (size_t i = 0; i < numNonGreedyStates; i++) {
313
+ size_t stateNumber = data[p++];
314
+ // The serialized ATN must be specifying the right states, so that the
315
+ // cast below is correct.
316
+ downCast<DecisionState*>(atn->states[stateNumber])->nonGreedy = true;
317
+ }
318
+
319
+ size_t numPrecedenceStates = data[p++];
320
+ for (size_t i = 0; i < numPrecedenceStates; i++) {
321
+ size_t stateNumber = data[p++];
322
+ downCast<RuleStartState*>(atn->states[stateNumber])->isLeftRecursiveRule = true;
323
+ }
324
+
325
+ //
326
+ // RULES
327
+ //
328
+ size_t nrules = data[p++];
329
+ atn->ruleToStartState.reserve(nrules);
330
+ for (size_t i = 0; i < nrules; i++) {
331
+ size_t s = data[p++];
332
+ // Also here, the serialized atn must ensure to point to the correct class type.
333
+ RuleStartState *startState = downCast<RuleStartState*>(atn->states[s]);
334
+ atn->ruleToStartState.push_back(startState);
335
+ if (atn->grammarType == ATNType::LEXER) {
336
+ size_t tokenType = data[p++];
337
+ atn->ruleToTokenType.push_back(tokenType);
338
+ }
339
+ }
340
+
341
+ atn->ruleToStopState.resize(nrules);
342
+ for (ATNState *state : atn->states) {
343
+ if (!RuleStopState::is(state)) {
344
+ continue;
345
+ }
346
+
347
+ RuleStopState *stopState = downCast<RuleStopState*>(state);
348
+ atn->ruleToStopState[state->ruleIndex] = stopState;
349
+ atn->ruleToStartState[state->ruleIndex]->stopState = stopState;
350
+ }
351
+
352
+ //
353
+ // MODES
354
+ //
355
+ size_t nmodes = data[p++];
356
+ atn->modeToStartState.reserve(nmodes);
357
+ for (size_t i = 0; i < nmodes; i++) {
358
+ size_t s = data[p++];
359
+ atn->modeToStartState.push_back(downCast<TokensStartState*>(atn->states[s]));
360
+ }
361
+
362
+ //
363
+ // SETS
364
+ //
365
+ {
366
+ std::vector<misc::IntervalSet> sets;
367
+
368
+ deserializeSets(data, p, sets);
369
+ sets.shrink_to_fit();
370
+
371
+ //
372
+ // EDGES
373
+ //
374
+ int nedges = data[p++];
375
+ for (int i = 0; i < nedges; i++) {
376
+ size_t src = data[p];
377
+ size_t trg = data[p + 1];
378
+ TransitionType ttype = static_cast<TransitionType>(data[p + 2]);
379
+ size_t arg1 = data[p + 3];
380
+ size_t arg2 = data[p + 4];
381
+ size_t arg3 = data[p + 5];
382
+ ConstTransitionPtr trans = edgeFactory(*atn, ttype, trg, arg1, arg2, arg3, sets);
383
+ ATNState *srcState = atn->states[src];
384
+ srcState->addTransition(std::move(trans));
385
+ p += 6;
386
+ }
387
+ }
388
+ // edges for rule stop states can be derived, so they aren't serialized
389
+ for (ATNState *state : atn->states) {
390
+ for (size_t i = 0; i < state->transitions.size(); i++) {
391
+ const Transition *t = state->transitions[i].get();
392
+ if (!RuleTransition::is(t)) {
393
+ continue;
394
+ }
395
+
396
+ const RuleTransition *ruleTransition = downCast<const RuleTransition*>(t);
397
+ size_t outermostPrecedenceReturn = INVALID_INDEX;
398
+ if (atn->ruleToStartState[ruleTransition->target->ruleIndex]->isLeftRecursiveRule) {
399
+ if (ruleTransition->precedence == 0) {
400
+ outermostPrecedenceReturn = ruleTransition->target->ruleIndex;
401
+ }
402
+ }
403
+
404
+ ConstTransitionPtr returnTransition = std::make_unique<EpsilonTransition>(ruleTransition->followState, outermostPrecedenceReturn);
405
+ atn->ruleToStopState[ruleTransition->target->ruleIndex]->addTransition(std::move(returnTransition));
406
+ }
407
+ }
408
+
409
+ for (ATNState *state : atn->states) {
410
+ if (BlockStartState::is(state)) {
411
+ BlockStartState *startState = downCast<BlockStartState*>(state);
412
+
413
+ // we need to know the end state to set its start state
414
+ if (startState->endState == nullptr) {
415
+ throw IllegalStateException();
416
+ }
417
+
418
+ // block end states can only be associated to a single block start state
419
+ if (startState->endState->startState != nullptr) {
420
+ throw IllegalStateException();
421
+ }
422
+
423
+ startState->endState->startState = downCast<BlockStartState*>(state);
424
+ }
425
+
426
+ if (PlusLoopbackState::is(state)) {
427
+ PlusLoopbackState *loopbackState = downCast<PlusLoopbackState*>(state);
428
+ for (size_t i = 0; i < loopbackState->transitions.size(); i++) {
429
+ ATNState *target = loopbackState->transitions[i]->target;
430
+ if (PlusBlockStartState::is(target)) {
431
+ (downCast<PlusBlockStartState*>(target))->loopBackState = loopbackState;
432
+ }
433
+ }
434
+ } else if (StarLoopbackState::is(state)) {
435
+ StarLoopbackState *loopbackState = downCast<StarLoopbackState*>(state);
436
+ for (size_t i = 0; i < loopbackState->transitions.size(); i++) {
437
+ ATNState *target = loopbackState->transitions[i]->target;
438
+ if (StarLoopEntryState::is(target)) {
439
+ downCast<StarLoopEntryState*>(target)->loopBackState = loopbackState;
440
+ }
441
+ }
442
+ }
443
+ }
444
+
445
+ //
446
+ // DECISIONS
447
+ //
448
+ size_t ndecisions = data[p++];
449
+ atn->decisionToState.reserve(ndecisions);
450
+ for (size_t i = 0; i < ndecisions; i++) {
451
+ size_t s = data[p++];
452
+ DecisionState *decState = downCast<DecisionState*>(atn->states[s]);
453
+ if (decState == nullptr)
454
+ throw IllegalStateException();
455
+
456
+ atn->decisionToState.push_back(decState);
457
+ decState->decision = static_cast<int>(i);
458
+ }
459
+
460
+ //
461
+ // LEXER ACTIONS
462
+ //
463
+ if (atn->grammarType == ATNType::LEXER) {
464
+ atn->lexerActions.resize(data[p++]);
465
+ for (size_t i = 0; i < atn->lexerActions.size(); i++) {
466
+ LexerActionType actionType = static_cast<LexerActionType>(data[p++]);
467
+ int data1 = data[p++];
468
+ int data2 = data[p++];
469
+ atn->lexerActions[i] = lexerActionFactory(actionType, data1, data2);
470
+ }
471
+ }
472
+
473
+ markPrecedenceDecisions(*atn);
474
+
475
+ if (_deserializationOptions.isVerifyATN()) {
476
+ verifyATN(*atn);
477
+ }
478
+
479
+ if (_deserializationOptions.isGenerateRuleBypassTransitions() && atn->grammarType == ATNType::PARSER) {
480
+ atn->ruleToTokenType.resize(atn->ruleToStartState.size());
481
+ for (size_t i = 0; i < atn->ruleToStartState.size(); i++) {
482
+ atn->ruleToTokenType[i] = static_cast<int>(atn->maxTokenType + i + 1);
483
+ }
484
+
485
+ for (std::vector<RuleStartState*>::size_type i = 0; i < atn->ruleToStartState.size(); i++) {
486
+ BasicBlockStartState *bypassStart = new BasicBlockStartState(); /* mem check: freed in ATN d-tor */
487
+ bypassStart->ruleIndex = static_cast<int>(i);
488
+ atn->addState(bypassStart);
489
+
490
+ BlockEndState *bypassStop = new BlockEndState(); /* mem check: freed in ATN d-tor */
491
+ bypassStop->ruleIndex = static_cast<int>(i);
492
+ atn->addState(bypassStop);
493
+
494
+ bypassStart->endState = bypassStop;
495
+ atn->defineDecisionState(bypassStart);
496
+
497
+ bypassStop->startState = bypassStart;
498
+
499
+ ATNState *endState;
500
+ const Transition *excludeTransition = nullptr;
501
+ if (atn->ruleToStartState[i]->isLeftRecursiveRule) {
502
+ // wrap from the beginning of the rule to the StarLoopEntryState
503
+ endState = nullptr;
504
+ for (ATNState *state : atn->states) {
505
+ if (state->ruleIndex != i) {
506
+ continue;
507
+ }
508
+
509
+ if (!StarLoopEntryState::is(state)) {
510
+ continue;
511
+ }
512
+
513
+ ATNState *maybeLoopEndState = state->transitions[state->transitions.size() - 1]->target;
514
+ if (!LoopEndState::is(maybeLoopEndState)) {
515
+ continue;
516
+ }
517
+
518
+ if (maybeLoopEndState->epsilonOnlyTransitions && RuleStopState::is(maybeLoopEndState->transitions[0]->target)) {
519
+ endState = state;
520
+ break;
521
+ }
522
+ }
523
+
524
+ if (endState == nullptr) {
525
+ throw UnsupportedOperationException("Couldn't identify final state of the precedence rule prefix section.");
526
+
527
+ }
528
+
529
+ excludeTransition = (static_cast<StarLoopEntryState*>(endState))->loopBackState->transitions[0].get();
530
+ } else {
531
+ endState = atn->ruleToStopState[i];
532
+ }
533
+
534
+ // all non-excluded transitions that currently target end state need to target blockEnd instead
535
+ for (ATNState *state : atn->states) {
536
+ for (auto &transition : state->transitions) {
537
+ if (transition.get() == excludeTransition) {
538
+ continue;
539
+ }
540
+
541
+ if (transition->target == endState) {
542
+ const_cast<Transition*>(transition.get())->target = bypassStop;
543
+ }
544
+ }
545
+ }
546
+
547
+ // all transitions leaving the rule start state need to leave blockStart instead
548
+ while (atn->ruleToStartState[i]->transitions.size() > 0) {
549
+ ConstTransitionPtr transition = atn->ruleToStartState[i]->removeTransition(atn->ruleToStartState[i]->transitions.size() - 1);
550
+ bypassStart->addTransition(std::move(transition));
551
+ }
552
+
553
+ // link the new states
554
+ atn->ruleToStartState[i]->addTransition(std::make_unique<EpsilonTransition>(bypassStart));
555
+ bypassStop->addTransition(std::make_unique<EpsilonTransition>(endState));
556
+
557
+ ATNState *matchState = new BasicState(); /* mem check: freed in ATN d-tor */
558
+ atn->addState(matchState);
559
+ matchState->addTransition(std::make_unique<AtomTransition>(bypassStop, atn->ruleToTokenType[i]));
560
+ bypassStart->addTransition(std::make_unique<EpsilonTransition>(matchState));
561
+ }
562
+
563
+ if (_deserializationOptions.isVerifyATN()) {
564
+ // reverify after modification
565
+ verifyATN(*atn);
566
+ }
567
+ }
568
+
569
+ return atn;
570
+ }
571
+
572
+ void ATNDeserializer::verifyATN(const ATN &atn) const {
573
+ // verify assumptions
574
+ for (ATNState *state : atn.states) {
575
+ if (state == nullptr) {
576
+ continue;
577
+ }
578
+
579
+ checkCondition(state->epsilonOnlyTransitions || state->transitions.size() <= 1);
580
+
581
+ if (PlusBlockStartState::is(state)) {
582
+ checkCondition((downCast<PlusBlockStartState*>(state))->loopBackState != nullptr);
583
+ }
584
+
585
+ if (StarLoopEntryState::is(state)) {
586
+ StarLoopEntryState *starLoopEntryState = downCast<StarLoopEntryState*>(state);
587
+ checkCondition(starLoopEntryState->loopBackState != nullptr);
588
+ checkCondition(starLoopEntryState->transitions.size() == 2);
589
+
590
+ if (StarBlockStartState::is(starLoopEntryState->transitions[0]->target)) {
591
+ checkCondition(downCast<LoopEndState*>(starLoopEntryState->transitions[1]->target) != nullptr);
592
+ checkCondition(!starLoopEntryState->nonGreedy);
593
+ } else if (LoopEndState::is(starLoopEntryState->transitions[0]->target)) {
594
+ checkCondition(StarBlockStartState::is(starLoopEntryState->transitions[1]->target));
595
+ checkCondition(starLoopEntryState->nonGreedy);
596
+ } else {
597
+ throw IllegalStateException();
598
+ }
599
+ }
600
+
601
+ if (StarLoopbackState::is(state)) {
602
+ checkCondition(state->transitions.size() == 1);
603
+ checkCondition(StarLoopEntryState::is(state->transitions[0]->target));
604
+ }
605
+
606
+ if (LoopEndState::is(state)) {
607
+ checkCondition((downCast<LoopEndState*>(state))->loopBackState != nullptr);
608
+ }
609
+
610
+ if (RuleStartState::is(state)) {
611
+ checkCondition((downCast<RuleStartState*>(state))->stopState != nullptr);
612
+ }
613
+
614
+ if (BlockStartState::is(state)) {
615
+ checkCondition((downCast<BlockStartState*>(state))->endState != nullptr);
616
+ }
617
+
618
+ if (BlockEndState::is(state)) {
619
+ checkCondition((downCast<BlockEndState*>(state))->startState != nullptr);
620
+ }
621
+
622
+ if (DecisionState::is(state)) {
623
+ DecisionState *decisionState = downCast<DecisionState*>(state);
624
+ checkCondition(decisionState->transitions.size() <= 1 || decisionState->decision >= 0);
625
+ } else {
626
+ checkCondition(state->transitions.size() <= 1 || RuleStopState::is(state));
627
+ }
628
+ }
629
+ }
@@ -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 "atn/ATNDeserializationOptions.h"
9
+ #include "atn/SerializedATNView.h"
10
+ #include "atn/LexerAction.h"
11
+ #include "atn/Transition.h"
12
+
13
+ namespace antlr4 {
14
+ namespace atn {
15
+
16
+ class ANTLR4CPP_PUBLIC ATNDeserializer final {
17
+ public:
18
+ static constexpr size_t SERIALIZED_VERSION = 4;
19
+
20
+ ATNDeserializer();
21
+
22
+ explicit ATNDeserializer(ATNDeserializationOptions deserializationOptions);
23
+
24
+ std::unique_ptr<ATN> deserialize(SerializedATNView input) const;
25
+ void verifyATN(const ATN &atn) const;
26
+
27
+ private:
28
+ const ATNDeserializationOptions _deserializationOptions;
29
+ };
30
+
31
+ } // namespace atn
32
+ } // namespace antlr4
@@ -0,0 +1,33 @@
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/ATNSimulator.h"
7
+
8
+ #include "atn/ATNConfigSet.h"
9
+ #include "atn/ATNDeserializer.h"
10
+ #include "atn/ATNType.h"
11
+ #include "dfa/DFAState.h"
12
+
13
+ using namespace antlr4;
14
+ using namespace antlr4::dfa;
15
+ using namespace antlr4::atn;
16
+
17
+ const Ref<DFAState> ATNSimulator::ERROR = std::make_shared<DFAState>(std::numeric_limits<int>::max());
18
+
19
+ ATNSimulator::ATNSimulator(const ATN &atn, PredictionContextCache &sharedContextCache)
20
+ : atn(atn), _sharedContextCache(sharedContextCache) {}
21
+
22
+ void ATNSimulator::clearDFA() {
23
+ throw UnsupportedOperationException("This ATN simulator does not support clearing the DFA.");
24
+ }
25
+
26
+ PredictionContextCache& ATNSimulator::getSharedContextCache() const {
27
+ return _sharedContextCache;
28
+ }
29
+
30
+ Ref<const PredictionContext> ATNSimulator::getCachedContext(const Ref<const PredictionContext> &context) {
31
+ // This function must only be called with an active state lock, as we are going to change a shared structure.
32
+ return PredictionContext::getCachedContext(context, getSharedContextCache());
33
+ }