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,115 @@
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 "dfa/DFASerializer.h"
7
+ #include "dfa/LexerDFASerializer.h"
8
+ #include "support/CPPUtils.h"
9
+ #include "atn/StarLoopEntryState.h"
10
+ #include "atn/ATNConfigSet.h"
11
+ #include "support/Casts.h"
12
+
13
+ #include "dfa/DFA.h"
14
+
15
+ using namespace antlr4;
16
+ using namespace antlr4::dfa;
17
+ using namespace antlrcpp;
18
+
19
+ DFA::DFA(atn::DecisionState *atnStartState) : DFA(atnStartState, 0) {
20
+ }
21
+
22
+ DFA::DFA(atn::DecisionState *atnStartState, size_t decision)
23
+ : atnStartState(atnStartState), s0(nullptr), decision(decision) {
24
+
25
+ _precedenceDfa = false;
26
+ if (atn::StarLoopEntryState::is(atnStartState)) {
27
+ if (downCast<atn::StarLoopEntryState*>(atnStartState)->isPrecedenceDecision) {
28
+ _precedenceDfa = true;
29
+ s0 = new DFAState(std::unique_ptr<atn::ATNConfigSet>(new atn::ATNConfigSet()));
30
+ s0->isAcceptState = false;
31
+ s0->requiresFullContext = false;
32
+ }
33
+ }
34
+ }
35
+
36
+ DFA::DFA(DFA &&other) : atnStartState(other.atnStartState), s0(other.s0), decision(other.decision) {
37
+ // Source states are implicitly cleared by the move.
38
+ states = std::move(other.states);
39
+
40
+ other.atnStartState = nullptr;
41
+ other.decision = 0;
42
+ other.s0 = nullptr;
43
+ _precedenceDfa = other._precedenceDfa;
44
+ other._precedenceDfa = false;
45
+ }
46
+
47
+ DFA::~DFA() {
48
+ bool s0InList = (s0 == nullptr);
49
+ for (auto *state : states) {
50
+ if (state == s0)
51
+ s0InList = true;
52
+ delete state;
53
+ }
54
+
55
+ if (!s0InList) {
56
+ delete s0;
57
+ }
58
+ }
59
+
60
+ bool DFA::isPrecedenceDfa() const {
61
+ return _precedenceDfa;
62
+ }
63
+
64
+ DFAState* DFA::getPrecedenceStartState(int precedence) const {
65
+ assert(_precedenceDfa); // Only precedence DFAs may contain a precedence start state.
66
+
67
+ auto iterator = s0->edges.find(precedence);
68
+ if (iterator == s0->edges.end())
69
+ return nullptr;
70
+
71
+ return iterator->second;
72
+ }
73
+
74
+ void DFA::setPrecedenceStartState(int precedence, DFAState *startState) {
75
+ if (!isPrecedenceDfa()) {
76
+ throw IllegalStateException("Only precedence DFAs may contain a precedence start state.");
77
+ }
78
+
79
+ if (precedence < 0) {
80
+ return;
81
+ }
82
+
83
+ s0->edges[precedence] = startState;
84
+ }
85
+
86
+ std::vector<DFAState *> DFA::getStates() const {
87
+ std::vector<DFAState *> result;
88
+ for (auto *state : states)
89
+ result.push_back(state);
90
+
91
+ std::sort(result.begin(), result.end(), [](DFAState *o1, DFAState *o2) -> bool {
92
+ return o1->stateNumber < o2->stateNumber;
93
+ });
94
+
95
+ return result;
96
+ }
97
+
98
+ std::string DFA::toString(const Vocabulary &vocabulary) const {
99
+ if (s0 == nullptr) {
100
+ return "";
101
+ }
102
+
103
+ DFASerializer serializer(this, vocabulary);
104
+ return serializer.toString();
105
+ }
106
+
107
+ std::string DFA::toLexerString() const {
108
+ if (s0 == nullptr) {
109
+ return "";
110
+ }
111
+ LexerDFASerializer serializer(this);
112
+
113
+ return serializer.toString();
114
+ }
115
+
@@ -0,0 +1,96 @@
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 "dfa/DFAState.h"
9
+
10
+ namespace antlr4 {
11
+ namespace dfa {
12
+
13
+ class ANTLR4CPP_PUBLIC DFA final {
14
+ private:
15
+ struct DFAStateHasher final {
16
+ size_t operator()(const DFAState *dfaState) const {
17
+ return dfaState->hashCode();
18
+ }
19
+ };
20
+
21
+ struct DFAStateComparer final {
22
+ bool operator()(const DFAState *lhs, const DFAState *rhs) const {
23
+ return lhs == rhs || *lhs == *rhs;
24
+ }
25
+ };
26
+
27
+ public:
28
+ /// A set of all DFA states. Use a map so we can get old state back.
29
+ /// Set only allows you to see if it's there.
30
+
31
+ /// From which ATN state did we create this DFA?
32
+ atn::DecisionState *atnStartState;
33
+ std::unordered_set<DFAState*, DFAStateHasher, DFAStateComparer> states; // States are owned by this class.
34
+ DFAState *s0;
35
+ size_t decision;
36
+
37
+ explicit DFA(atn::DecisionState *atnStartState);
38
+ DFA(atn::DecisionState *atnStartState, size_t decision);
39
+ DFA(const DFA &other) = delete;
40
+ DFA(DFA &&other);
41
+ ~DFA();
42
+
43
+ /**
44
+ * Gets whether this DFA is a precedence DFA. Precedence DFAs use a special
45
+ * start state {@link #s0} which is not stored in {@link #states}. The
46
+ * {@link DFAState#edges} array for this start state contains outgoing edges
47
+ * supplying individual start states corresponding to specific precedence
48
+ * values.
49
+ *
50
+ * @return {@code true} if this is a precedence DFA; otherwise,
51
+ * {@code false}.
52
+ * @see Parser#getPrecedence()
53
+ */
54
+ bool isPrecedenceDfa() const;
55
+
56
+ /**
57
+ * Get the start state for a specific precedence value.
58
+ *
59
+ * @param precedence The current precedence.
60
+ * @return The start state corresponding to the specified precedence, or
61
+ * {@code null} if no start state exists for the specified precedence.
62
+ *
63
+ * @throws IllegalStateException if this is not a precedence DFA.
64
+ * @see #isPrecedenceDfa()
65
+ */
66
+ DFAState* getPrecedenceStartState(int precedence) const;
67
+
68
+ /**
69
+ * Set the start state for a specific precedence value.
70
+ *
71
+ * @param precedence The current precedence.
72
+ * @param startState The start state corresponding to the specified
73
+ * precedence.
74
+ *
75
+ * @throws IllegalStateException if this is not a precedence DFA.
76
+ * @see #isPrecedenceDfa()
77
+ */
78
+ void setPrecedenceStartState(int precedence, DFAState *startState);
79
+
80
+ /// Return a list of all states in this DFA, ordered by state number.
81
+ std::vector<DFAState *> getStates() const;
82
+
83
+ std::string toString(const Vocabulary &vocabulary) const;
84
+
85
+ std::string toLexerString() const;
86
+
87
+ private:
88
+ /**
89
+ * {@code true} if this DFA is for a precedence decision; otherwise,
90
+ * {@code false}. This is the backing field for {@link #isPrecedenceDfa}.
91
+ */
92
+ bool _precedenceDfa;
93
+ };
94
+
95
+ } // namespace atn
96
+ } // namespace antlr4
@@ -0,0 +1,60 @@
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 "dfa/DFA.h"
7
+ #include "Vocabulary.h"
8
+
9
+ #include "dfa/DFASerializer.h"
10
+
11
+ using namespace antlr4::dfa;
12
+
13
+ DFASerializer::DFASerializer(const DFA *dfa, const Vocabulary &vocabulary) : _dfa(dfa), _vocabulary(vocabulary) {
14
+ }
15
+
16
+ std::string DFASerializer::toString() const {
17
+ if (_dfa->s0 == nullptr) {
18
+ return "";
19
+ }
20
+
21
+ std::stringstream ss;
22
+ std::vector<DFAState *> states = _dfa->getStates();
23
+ for (auto *s : states) {
24
+ for (size_t i = 0; i < s->edges.size(); i++) {
25
+ DFAState *t = s->edges[i];
26
+ if (t != nullptr && t->stateNumber != INT32_MAX) {
27
+ ss << getStateString(s);
28
+ std::string label = getEdgeLabel(i);
29
+ ss << "-" << label << "->" << getStateString(t) << "\n";
30
+ }
31
+ }
32
+ }
33
+
34
+ return ss.str();
35
+ }
36
+
37
+ std::string DFASerializer::getEdgeLabel(size_t i) const {
38
+ return _vocabulary.getDisplayName(i); // ml: no longer needed -1 as we use a map for edges, without offset.
39
+ }
40
+
41
+ std::string DFASerializer::getStateString(DFAState *s) const {
42
+ size_t n = s->stateNumber;
43
+
44
+ const std::string baseStateStr = std::string(s->isAcceptState ? ":" : "") + "s" + std::to_string(n) +
45
+ (s->requiresFullContext ? "^" : "");
46
+
47
+ if (s->isAcceptState) {
48
+ if (!s->predicates.empty()) {
49
+ std::string buf;
50
+ for (size_t i = 0; i < s->predicates.size(); i++) {
51
+ buf.append(s->predicates[i].toString());
52
+ }
53
+ return baseStateStr + "=>" + buf;
54
+ } else {
55
+ return baseStateStr + "=>" + std::to_string(s->prediction);
56
+ }
57
+ } else {
58
+ return baseStateStr;
59
+ }
60
+ }
@@ -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 "Vocabulary.h"
9
+
10
+ namespace antlr4 {
11
+ namespace dfa {
12
+
13
+ /// A DFA walker that knows how to dump them to serialized strings.
14
+ class ANTLR4CPP_PUBLIC DFASerializer {
15
+ public:
16
+ DFASerializer(const DFA *dfa, const Vocabulary &vocabulary);
17
+
18
+ virtual ~DFASerializer() = default;
19
+
20
+ std::string toString() const;
21
+
22
+ protected:
23
+ virtual std::string getEdgeLabel(size_t i) const;
24
+ std::string getStateString(DFAState *s) const;
25
+
26
+ private:
27
+ const DFA *_dfa;
28
+ const Vocabulary &_vocabulary;
29
+ };
30
+
31
+ } // namespace atn
32
+ } // namespace antlr4
@@ -0,0 +1,59 @@
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/ATNConfigSet.h"
7
+ #include "atn/SemanticContext.h"
8
+ #include "atn/ATNConfig.h"
9
+ #include "misc/MurmurHash.h"
10
+
11
+ #include "dfa/DFAState.h"
12
+
13
+ using namespace antlr4::dfa;
14
+ using namespace antlr4::atn;
15
+
16
+ std::string DFAState::PredPrediction::toString() const {
17
+ return std::string("(") + pred->toString() + ", " + std::to_string(alt) + ")";
18
+ }
19
+
20
+ std::set<size_t> DFAState::getAltSet() const {
21
+ std::set<size_t> alts;
22
+ if (configs != nullptr) {
23
+ for (size_t i = 0; i < configs->size(); i++) {
24
+ alts.insert(configs->get(i)->alt);
25
+ }
26
+ }
27
+ return alts;
28
+ }
29
+
30
+ size_t DFAState::hashCode() const {
31
+ return configs != nullptr ? configs->hashCode() : 0;
32
+ }
33
+
34
+ bool DFAState::equals(const DFAState &other) const {
35
+ if (this == std::addressof(other)) {
36
+ return true;
37
+ }
38
+ return configs == other.configs ||
39
+ (configs != nullptr && other.configs != nullptr && *configs == *other.configs);
40
+ }
41
+
42
+ std::string DFAState::toString() const {
43
+ std::stringstream ss;
44
+ ss << stateNumber;
45
+ if (configs) {
46
+ ss << ":" << configs->toString();
47
+ }
48
+ if (isAcceptState) {
49
+ ss << " => ";
50
+ if (!predicates.empty()) {
51
+ for (size_t i = 0; i < predicates.size(); i++) {
52
+ ss << predicates[i].toString();
53
+ }
54
+ } else {
55
+ ss << prediction;
56
+ }
57
+ }
58
+ return ss.str();
59
+ }
@@ -0,0 +1,153 @@
1
+ /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2
+ * Use of this file is governed by the BSD 3-clause license that
3
+ * can be found in the LICENSE.txt file in the project root.
4
+ */
5
+
6
+ #pragma once
7
+
8
+ #include "antlr4-common.h"
9
+
10
+ #include "atn/ATNConfigSet.h"
11
+
12
+ namespace antlr4 {
13
+ namespace dfa {
14
+
15
+ /// <summary>
16
+ /// A DFA state represents a set of possible ATN configurations.
17
+ /// As Aho, Sethi, Ullman p. 117 says "The DFA uses its state
18
+ /// to keep track of all possible states the ATN can be in after
19
+ /// reading each input symbol. That is to say, after reading
20
+ /// input a1a2..an, the DFA is in a state that represents the
21
+ /// subset T of the states of the ATN that are reachable from the
22
+ /// ATN's start state along some path labeled a1a2..an."
23
+ /// In conventional NFA->DFA conversion, therefore, the subset T
24
+ /// would be a bitset representing the set of states the
25
+ /// ATN could be in. We need to track the alt predicted by each
26
+ /// state as well, however. More importantly, we need to maintain
27
+ /// a stack of states, tracking the closure operations as they
28
+ /// jump from rule to rule, emulating rule invocations (method calls).
29
+ /// I have to add a stack to simulate the proper lookahead sequences for
30
+ /// the underlying LL grammar from which the ATN was derived.
31
+ /// <p/>
32
+ /// I use a set of ATNConfig objects not simple states. An ATNConfig
33
+ /// is both a state (ala normal conversion) and a RuleContext describing
34
+ /// the chain of rules (if any) followed to arrive at that state.
35
+ /// <p/>
36
+ /// A DFA state may have multiple references to a particular state,
37
+ /// but with different ATN contexts (with same or different alts)
38
+ /// meaning that state was reached via a different set of rule invocations.
39
+ /// </summary>
40
+ class ANTLR4CPP_PUBLIC DFAState final {
41
+ public:
42
+ struct ANTLR4CPP_PUBLIC PredPrediction final {
43
+ public:
44
+ Ref<const atn::SemanticContext> pred; // never null; at least SemanticContext.NONE
45
+ int alt;
46
+
47
+ PredPrediction() = delete;
48
+
49
+ PredPrediction(const PredPrediction&) = default;
50
+ PredPrediction(PredPrediction&&) = default;
51
+
52
+ PredPrediction(Ref<const atn::SemanticContext> pred, int alt) : pred(std::move(pred)), alt(alt) {}
53
+
54
+ PredPrediction& operator=(const PredPrediction&) = default;
55
+ PredPrediction& operator=(PredPrediction&&) = default;
56
+
57
+ std::string toString() const;
58
+ };
59
+
60
+ std::unique_ptr<atn::ATNConfigSet> configs;
61
+
62
+ /// {@code edges[symbol]} points to target of symbol. Shift up by 1 so (-1)
63
+ /// <seealso cref="Token#EOF"/> maps to {@code edges[0]}.
64
+ // ml: this is a sparse list, so we use a map instead of a vector.
65
+ // Watch out: we no longer have the -1 offset, as it isn't needed anymore.
66
+ std::unordered_map<size_t, DFAState*> edges;
67
+
68
+ /// if accept state, what ttype do we match or alt do we predict?
69
+ /// This is set to <seealso cref="ATN#INVALID_ALT_NUMBER"/> when <seealso cref="#predicates"/>{@code !=null} or
70
+ /// <seealso cref="#requiresFullContext"/>.
71
+ size_t prediction = 0;
72
+
73
+ Ref<const atn::LexerActionExecutor> lexerActionExecutor;
74
+
75
+ /// <summary>
76
+ /// During SLL parsing, this is a list of predicates associated with the
77
+ /// ATN configurations of the DFA state. When we have predicates,
78
+ /// <seealso cref="#requiresFullContext"/> is {@code false} since full context prediction evaluates predicates
79
+ /// on-the-fly. If this is not null, then <seealso cref="#prediction"/> is
80
+ /// <seealso cref="ATN#INVALID_ALT_NUMBER"/>.
81
+ /// <p/>
82
+ /// We only use these for non-<seealso cref="#requiresFullContext"/> but conflicting states. That
83
+ /// means we know from the context (it's $ or we don't dip into outer
84
+ /// context) that it's an ambiguity not a conflict.
85
+ /// <p/>
86
+ /// This list is computed by <seealso cref="ParserATNSimulator#predicateDFAState"/>.
87
+ /// </summary>
88
+ std::vector<PredPrediction> predicates;
89
+
90
+ int stateNumber = -1;
91
+
92
+ bool isAcceptState = false;
93
+
94
+ /// <summary>
95
+ /// Indicates that this state was created during SLL prediction that
96
+ /// discovered a conflict between the configurations in the state. Future
97
+ /// <seealso cref="ParserATNSimulator#execATN"/> invocations immediately jumped doing
98
+ /// full context prediction if this field is true.
99
+ /// </summary>
100
+ bool requiresFullContext = false;
101
+
102
+ /// Map a predicate to a predicted alternative.
103
+ DFAState() = default;
104
+
105
+ explicit DFAState(int stateNumber) : stateNumber(stateNumber) {}
106
+
107
+ explicit DFAState(std::unique_ptr<atn::ATNConfigSet> configs) : configs(std::move(configs)) {}
108
+
109
+ /// <summary>
110
+ /// Get the set of all alts mentioned by all ATN configurations in this
111
+ /// DFA state.
112
+ /// </summary>
113
+ std::set<size_t> getAltSet() const;
114
+
115
+ size_t hashCode() const;
116
+
117
+ /// Two DFAState instances are equal if their ATN configuration sets
118
+ /// are the same. This method is used to see if a state already exists.
119
+ ///
120
+ /// Because the number of alternatives and number of ATN configurations are
121
+ /// finite, there is a finite number of DFA states that can be processed.
122
+ /// This is necessary to show that the algorithm terminates.
123
+ ///
124
+ /// Cannot test the DFA state numbers here because in
125
+ /// ParserATNSimulator#addDFAState we need to know if any other state
126
+ /// exists that has this exact set of ATN configurations. The
127
+ /// stateNumber is irrelevant.
128
+ bool equals(const DFAState &other) const;
129
+
130
+ std::string toString() const;
131
+ };
132
+
133
+ inline bool operator==(const DFAState &lhs, const DFAState &rhs) {
134
+ return lhs.equals(rhs);
135
+ }
136
+
137
+ inline bool operator!=(const DFAState &lhs, const DFAState &rhs) {
138
+ return !operator==(lhs, rhs);
139
+ }
140
+
141
+ } // namespace dfa
142
+ } // namespace antlr4
143
+
144
+ namespace std {
145
+
146
+ template <>
147
+ struct hash<::antlr4::dfa::DFAState> {
148
+ size_t operator()(const ::antlr4::dfa::DFAState &dfaState) const {
149
+ return dfaState.hashCode();
150
+ }
151
+ };
152
+
153
+ } // namespace std
@@ -0,0 +1,17 @@
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 "Vocabulary.h"
7
+
8
+ #include "dfa/LexerDFASerializer.h"
9
+
10
+ using namespace antlr4::dfa;
11
+
12
+ LexerDFASerializer::LexerDFASerializer(const DFA *dfa) : DFASerializer(dfa, Vocabulary()) {
13
+ }
14
+
15
+ std::string LexerDFASerializer::getEdgeLabel(size_t i) const {
16
+ return std::string("'") + static_cast<char>(i) + "'";
17
+ }
@@ -0,0 +1,22 @@
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 "dfa/DFASerializer.h"
9
+
10
+ namespace antlr4 {
11
+ namespace dfa {
12
+
13
+ class ANTLR4CPP_PUBLIC LexerDFASerializer final : public DFASerializer {
14
+ public:
15
+ explicit LexerDFASerializer(const DFA *dfa);
16
+
17
+ protected:
18
+ std::string getEdgeLabel(size_t i) const override;
19
+ };
20
+
21
+ } // namespace atn
22
+ } // namespace antlr4
@@ -0,0 +1,124 @@
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
+ #include "atn/ATNDeserializer.h"
8
+ #include "Vocabulary.h"
9
+
10
+ #include "misc/InterpreterDataReader.h"
11
+
12
+ using namespace antlr4::dfa;
13
+ using namespace antlr4::atn;
14
+ using namespace antlr4::misc;
15
+
16
+ InterpreterData::InterpreterData(std::vector<std::string> const& literalNames, std::vector<std::string> const& symbolicNames)
17
+ : vocabulary(literalNames, symbolicNames) {
18
+ }
19
+
20
+ InterpreterData InterpreterDataReader::parseFile(std::string const& fileName) {
21
+ // The structure of the data file is very simple. Everything is line based with empty lines
22
+ // separating the different parts. For lexers the layout is:
23
+ // token literal names:
24
+ // ...
25
+ //
26
+ // token symbolic names:
27
+ // ...
28
+ //
29
+ // rule names:
30
+ // ...
31
+ //
32
+ // channel names:
33
+ // ...
34
+ //
35
+ // mode names:
36
+ // ...
37
+ //
38
+ // atn:
39
+ // <a single line with comma separated int values> enclosed in a pair of squared brackets.
40
+ //
41
+ // Data for a parser does not contain channel and mode names.
42
+
43
+ std::ifstream input(fileName);
44
+ if (!input.good())
45
+ return {};
46
+
47
+ std::vector<std::string> literalNames;
48
+ std::vector<std::string> symbolicNames;
49
+
50
+ std::string line;
51
+
52
+ std::getline(input, line, '\n');
53
+ assert(line == "token literal names:");
54
+ while (true) {
55
+ std::getline(input, line, '\n');
56
+ if (line.empty())
57
+ break;
58
+
59
+ literalNames.push_back(line == "null" ? "" : line);
60
+ };
61
+
62
+ std::getline(input, line, '\n');
63
+ assert(line == "token symbolic names:");
64
+ while (true) {
65
+ std::getline(input, line, '\n');
66
+ if (line.empty())
67
+ break;
68
+
69
+ symbolicNames.push_back(line == "null" ? "" : line);
70
+ };
71
+ InterpreterData result(literalNames, symbolicNames);
72
+
73
+ std::getline(input, line, '\n');
74
+ assert(line == "rule names:");
75
+ while (true) {
76
+ std::getline(input, line, '\n');
77
+ if (line.empty())
78
+ break;
79
+
80
+ result.ruleNames.push_back(line);
81
+ };
82
+
83
+ std::getline(input, line, '\n');
84
+ if (line == "channel names:") {
85
+ while (true) {
86
+ std::getline(input, line, '\n');
87
+ if (line.empty())
88
+ break;
89
+
90
+ result.channels.push_back(line);
91
+ };
92
+
93
+ std::getline(input, line, '\n');
94
+ assert(line == "mode names:");
95
+ while (true) {
96
+ std::getline(input, line, '\n');
97
+ if (line.empty())
98
+ break;
99
+
100
+ result.modes.push_back(line);
101
+ };
102
+ }
103
+
104
+ std::vector<int32_t> serializedATN;
105
+
106
+ std::getline(input, line, '\n');
107
+ assert(line == "atn:");
108
+ std::getline(input, line, '\n');
109
+ std::stringstream tokenizer(line);
110
+ std::string value;
111
+ while (tokenizer.good()) {
112
+ std::getline(tokenizer, value, ',');
113
+ unsigned long number;
114
+ if (value[0] == '[')
115
+ number = std::strtoul(&value[1], nullptr, 10);
116
+ else
117
+ number = std::strtoul(value.c_str(), nullptr, 10);
118
+ serializedATN.push_back(static_cast<int32_t>(number));
119
+ }
120
+
121
+ ATNDeserializer deserializer;
122
+ result.atn = deserializer.deserialize(serializedATN);
123
+ return result;
124
+ }