expressir 0.2.4-x64-mingw32

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 (520) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/rake.yml +46 -0
  3. data/.github/workflows/release.yml +75 -0
  4. data/.gitignore +15 -0
  5. data/.gitmodules +3 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +508 -0
  8. data/Gemfile +6 -0
  9. data/README.adoc +147 -0
  10. data/Rakefile +17 -0
  11. data/bin/console +12 -0
  12. data/bin/rspec +29 -0
  13. data/bin/setup +8 -0
  14. data/demo.rb +18 -0
  15. data/docs/development.md +90 -0
  16. data/exe/expressir +20 -0
  17. data/exe/generate-parser +48 -0
  18. data/expressir.gemspec +40 -0
  19. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +118 -0
  20. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj +637 -0
  21. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2013.vcxproj.filters +984 -0
  22. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj +652 -0
  23. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2015.vcxproj.filters +990 -0
  24. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj +652 -0
  25. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2017.vcxproj.filters +990 -0
  26. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +652 -0
  27. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +990 -0
  28. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/Info.plist +26 -0
  29. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/antlrcpp_ios.h +17 -0
  30. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +3024 -0
  31. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  32. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  33. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +76 -0
  34. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +80 -0
  35. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +80 -0
  36. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.cpp +10 -0
  37. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.h +167 -0
  38. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.cpp +10 -0
  39. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.h +121 -0
  40. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +34 -0
  41. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +27 -0
  42. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +155 -0
  43. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +69 -0
  44. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +61 -0
  45. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.h +59 -0
  46. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.cpp +25 -0
  47. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.h +36 -0
  48. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +414 -0
  49. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.h +200 -0
  50. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.cpp +11 -0
  51. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.h +37 -0
  52. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +195 -0
  53. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.h +158 -0
  54. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +39 -0
  55. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +74 -0
  56. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.cpp +78 -0
  57. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.h +79 -0
  58. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +15 -0
  59. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.h +35 -0
  60. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +333 -0
  61. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.h +466 -0
  62. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +84 -0
  63. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.h +80 -0
  64. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +64 -0
  65. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +99 -0
  66. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +51 -0
  67. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +32 -0
  68. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.cpp +18 -0
  69. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.h +24 -0
  70. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.cpp +12 -0
  71. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +218 -0
  72. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.cpp +19 -0
  73. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.h +45 -0
  74. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +295 -0
  75. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +196 -0
  76. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +75 -0
  77. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +52 -0
  78. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.cpp +36 -0
  79. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.h +31 -0
  80. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +92 -0
  81. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +88 -0
  82. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.cpp +46 -0
  83. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.h +42 -0
  84. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +648 -0
  85. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +467 -0
  86. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +306 -0
  87. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +179 -0
  88. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +141 -0
  89. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +147 -0
  90. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +53 -0
  91. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.h +38 -0
  92. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +66 -0
  93. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.h +98 -0
  94. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +167 -0
  95. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +164 -0
  96. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +143 -0
  97. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +137 -0
  98. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.cpp +27 -0
  99. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.h +32 -0
  100. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +53 -0
  101. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.h +155 -0
  102. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.cpp +9 -0
  103. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +92 -0
  104. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenFactory.h +30 -0
  105. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.cpp +9 -0
  106. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +85 -0
  107. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.cpp +11 -0
  108. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.h +137 -0
  109. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +425 -0
  110. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +293 -0
  111. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +211 -0
  112. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +123 -0
  113. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +270 -0
  114. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.h +115 -0
  115. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +104 -0
  116. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +193 -0
  117. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.cpp +9 -0
  118. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.h +23 -0
  119. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +137 -0
  120. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +167 -0
  121. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +209 -0
  122. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +112 -0
  123. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +113 -0
  124. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +148 -0
  125. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +228 -0
  126. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +110 -0
  127. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +64 -0
  128. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +50 -0
  129. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +758 -0
  130. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +85 -0
  131. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +621 -0
  132. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSerializer.h +61 -0
  133. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +63 -0
  134. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +87 -0
  135. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +72 -0
  136. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +133 -0
  137. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNType.h +20 -0
  138. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.cpp +14 -0
  139. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AbstractPredicateTransition.h +24 -0
  140. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +33 -0
  141. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +33 -0
  142. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.cpp +16 -0
  143. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.h +68 -0
  144. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +82 -0
  145. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +43 -0
  146. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +31 -0
  147. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +30 -0
  148. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.cpp +12 -0
  149. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +22 -0
  150. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.cpp +12 -0
  151. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +21 -0
  152. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.cpp +15 -0
  153. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +24 -0
  154. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.cpp +9 -0
  155. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +21 -0
  156. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.cpp +14 -0
  157. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.h +47 -0
  158. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.cpp +14 -0
  159. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.h +70 -0
  160. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.cpp +25 -0
  161. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +227 -0
  162. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +17 -0
  163. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +30 -0
  164. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +35 -0
  165. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.h +27 -0
  166. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +35 -0
  167. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +39 -0
  168. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.cpp +15 -0
  169. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.h +43 -0
  170. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +158 -0
  171. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +109 -0
  172. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +84 -0
  173. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +44 -0
  174. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +628 -0
  175. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +210 -0
  176. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +9 -0
  177. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +66 -0
  178. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +107 -0
  179. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +115 -0
  180. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +55 -0
  181. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +55 -0
  182. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +63 -0
  183. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +62 -0
  184. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +87 -0
  185. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +63 -0
  186. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +82 -0
  187. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +56 -0
  188. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +61 -0
  189. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +47 -0
  190. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +57 -0
  191. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +47 -0
  192. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +57 -0
  193. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +56 -0
  194. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +61 -0
  195. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +47 -0
  196. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +55 -0
  197. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +56 -0
  198. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +55 -0
  199. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.cpp +16 -0
  200. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.h +42 -0
  201. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.cpp +12 -0
  202. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +22 -0
  203. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Makefile +67 -0
  204. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +27 -0
  205. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +25 -0
  206. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +12 -0
  207. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +20 -0
  208. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.cpp +102 -0
  209. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.h +102 -0
  210. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +1366 -0
  211. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +904 -0
  212. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.cpp +12 -0
  213. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +25 -0
  214. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.cpp +12 -0
  215. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +22 -0
  216. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +32 -0
  217. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +29 -0
  218. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +17 -0
  219. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +62 -0
  220. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +34 -0
  221. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +39 -0
  222. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +662 -0
  223. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +254 -0
  224. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +201 -0
  225. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +436 -0
  226. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +179 -0
  227. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +60 -0
  228. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +30 -0
  229. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +29 -0
  230. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.cpp +16 -0
  231. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +25 -0
  232. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.cpp +12 -0
  233. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +25 -0
  234. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +37 -0
  235. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +40 -0
  236. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +377 -0
  237. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +222 -0
  238. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +32 -0
  239. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +30 -0
  240. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +81 -0
  241. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +36 -0
  242. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.cpp +12 -0
  243. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +21 -0
  244. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.cpp +15 -0
  245. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +35 -0
  246. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +19 -0
  247. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +21 -0
  248. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.cpp +12 -0
  249. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +21 -0
  250. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +44 -0
  251. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +76 -0
  252. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +25 -0
  253. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +25 -0
  254. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +127 -0
  255. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +91 -0
  256. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +67 -0
  257. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +32 -0
  258. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +100 -0
  259. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +144 -0
  260. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +20 -0
  261. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +23 -0
  262. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +124 -0
  263. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +31 -0
  264. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +89 -0
  265. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +84 -0
  266. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +521 -0
  267. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +198 -0
  268. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +134 -0
  269. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +76 -0
  270. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.cpp +4 -0
  271. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.h +21 -0
  272. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +13 -0
  273. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +170 -0
  274. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +43 -0
  275. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +110 -0
  276. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +76 -0
  277. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +248 -0
  278. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +78 -0
  279. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +163 -0
  280. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +36 -0
  281. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +54 -0
  282. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.cpp +303 -0
  283. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/support/guid.h +112 -0
  284. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +128 -0
  285. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.cpp +9 -0
  286. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +19 -0
  287. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +23 -0
  288. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +33 -0
  289. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +71 -0
  290. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.h +53 -0
  291. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +15 -0
  292. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +102 -0
  293. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.cpp +9 -0
  294. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +39 -0
  295. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeProperty.h +50 -0
  296. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.cpp +9 -0
  297. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +57 -0
  298. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +49 -0
  299. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +31 -0
  300. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.cpp +9 -0
  301. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +32 -0
  302. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +57 -0
  303. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +33 -0
  304. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +241 -0
  305. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.h +78 -0
  306. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.cpp +9 -0
  307. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +44 -0
  308. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.cpp +69 -0
  309. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +132 -0
  310. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +64 -0
  311. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +105 -0
  312. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +371 -0
  313. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +185 -0
  314. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +77 -0
  315. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.h +117 -0
  316. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.cpp +39 -0
  317. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +86 -0
  318. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.cpp +28 -0
  319. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +51 -0
  320. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +36 -0
  321. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.h +80 -0
  322. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +154 -0
  323. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.h +86 -0
  324. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.cpp +31 -0
  325. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.h +40 -0
  326. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +173 -0
  327. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.g4 +64 -0
  328. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +56 -0
  329. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.tokens +12 -0
  330. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.cpp +13 -0
  331. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.h +22 -0
  332. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp +20 -0
  333. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.h +27 -0
  334. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +30 -0
  335. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.h +26 -0
  336. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp +20 -0
  337. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.h +25 -0
  338. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +33 -0
  339. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.h +26 -0
  340. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp +23 -0
  341. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h +23 -0
  342. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.cpp +24 -0
  343. data/ext/express-parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.h +23 -0
  344. data/ext/express-parser/antlrgen/Express.interp +532 -0
  345. data/ext/express-parser/antlrgen/Express.tokens +190 -0
  346. data/ext/express-parser/antlrgen/ExpressBaseListener.cpp +7 -0
  347. data/ext/express-parser/antlrgen/ExpressBaseListener.h +623 -0
  348. data/ext/express-parser/antlrgen/ExpressBaseVisitor.cpp +7 -0
  349. data/ext/express-parser/antlrgen/ExpressBaseVisitor.h +816 -0
  350. data/ext/express-parser/antlrgen/ExpressLexer.cpp +1169 -0
  351. data/ext/express-parser/antlrgen/ExpressLexer.h +85 -0
  352. data/ext/express-parser/antlrgen/ExpressLexer.interp +534 -0
  353. data/ext/express-parser/antlrgen/ExpressLexer.tokens +190 -0
  354. data/ext/express-parser/antlrgen/ExpressListener.cpp +7 -0
  355. data/ext/express-parser/antlrgen/ExpressListener.h +616 -0
  356. data/ext/express-parser/antlrgen/ExpressParser.cpp +17284 -0
  357. data/ext/express-parser/antlrgen/ExpressParser.h +3696 -0
  358. data/ext/express-parser/antlrgen/ExpressVisitor.cpp +7 -0
  359. data/ext/express-parser/antlrgen/ExpressVisitor.h +422 -0
  360. data/ext/express-parser/express_parser.cpp +17931 -0
  361. data/ext/express-parser/extconf.rb +34 -0
  362. data/lib/express_parser.so +0 -0
  363. data/lib/expressir.rb +21 -0
  364. data/lib/expressir/cli.rb +27 -0
  365. data/lib/expressir/cli/ui.rb +36 -0
  366. data/lib/expressir/config.rb +23 -0
  367. data/lib/expressir/express.rb +11 -0
  368. data/lib/expressir/express/aggregate_dimension.rb +38 -0
  369. data/lib/expressir/express/attribute.rb +15 -0
  370. data/lib/expressir/express/comment.rb +7 -0
  371. data/lib/expressir/express/defined_type.rb +36 -0
  372. data/lib/expressir/express/derived.rb +65 -0
  373. data/lib/expressir/express/derived_aggregate.rb +43 -0
  374. data/lib/expressir/express/entity.rb +137 -0
  375. data/lib/expressir/express/explicit.rb +70 -0
  376. data/lib/expressir/express/explicit_aggregate.rb +46 -0
  377. data/lib/expressir/express/explicit_or_derived.rb +16 -0
  378. data/lib/expressir/express/global_rule.rb +44 -0
  379. data/lib/expressir/express/interface_specification.rb +51 -0
  380. data/lib/expressir/express/interfaced_item.rb +38 -0
  381. data/lib/expressir/express/inverse.rb +46 -0
  382. data/lib/expressir/express/inverse_aggregate.rb +37 -0
  383. data/lib/expressir/express/model_element.rb +7 -0
  384. data/lib/expressir/express/named_type.rb +19 -0
  385. data/lib/expressir/express/remark.rb +8 -0
  386. data/lib/expressir/express/repository.rb +306 -0
  387. data/lib/expressir/express/schema_definition.rb +96 -0
  388. data/lib/expressir/express/subtype_constraint.rb +14 -0
  389. data/lib/expressir/express/type.rb +26 -0
  390. data/lib/expressir/express/type_aggregate.rb +42 -0
  391. data/lib/expressir/express/type_enum.rb +29 -0
  392. data/lib/expressir/express/type_parser.rb +45 -0
  393. data/lib/expressir/express/type_select.rb +82 -0
  394. data/lib/expressir/express/unique_rule.rb +35 -0
  395. data/lib/expressir/express/where_rule.rb +32 -0
  396. data/lib/expressir/express_exp/formatter.rb +1450 -0
  397. data/lib/expressir/express_exp/parser.rb +36 -0
  398. data/lib/expressir/express_exp/visitor.rb +2451 -0
  399. data/lib/expressir/express_parser.rb +30 -0
  400. data/lib/expressir/model.rb +65 -0
  401. data/lib/expressir/model/attribute.rb +27 -0
  402. data/lib/expressir/model/constant.rb +17 -0
  403. data/lib/expressir/model/entity.rb +46 -0
  404. data/lib/expressir/model/enumeration_item.rb +11 -0
  405. data/lib/expressir/model/expressions/aggregate_initializer.rb +13 -0
  406. data/lib/expressir/model/expressions/aggregate_item.rb +15 -0
  407. data/lib/expressir/model/expressions/attribute_reference.rb +15 -0
  408. data/lib/expressir/model/expressions/binary_expression.rb +40 -0
  409. data/lib/expressir/model/expressions/call.rb +15 -0
  410. data/lib/expressir/model/expressions/entity_constructor.rb +15 -0
  411. data/lib/expressir/model/expressions/group_reference.rb +15 -0
  412. data/lib/expressir/model/expressions/index_reference.rb +17 -0
  413. data/lib/expressir/model/expressions/interval.rb +21 -0
  414. data/lib/expressir/model/expressions/query_expression.rb +26 -0
  415. data/lib/expressir/model/expressions/simple_reference.rb +13 -0
  416. data/lib/expressir/model/expressions/unary_expression.rb +19 -0
  417. data/lib/expressir/model/function.rb +62 -0
  418. data/lib/expressir/model/identifier.rb +9 -0
  419. data/lib/expressir/model/interface.rb +18 -0
  420. data/lib/expressir/model/literals/binary.rb +13 -0
  421. data/lib/expressir/model/literals/integer.rb +13 -0
  422. data/lib/expressir/model/literals/logical.rb +17 -0
  423. data/lib/expressir/model/literals/real.rb +13 -0
  424. data/lib/expressir/model/literals/string.rb +15 -0
  425. data/lib/expressir/model/parameter.rb +17 -0
  426. data/lib/expressir/model/procedure.rb +60 -0
  427. data/lib/expressir/model/renamed_ref.rb +13 -0
  428. data/lib/expressir/model/repository.rb +19 -0
  429. data/lib/expressir/model/rule.rb +62 -0
  430. data/lib/expressir/model/schema.rb +67 -0
  431. data/lib/expressir/model/scope.rb +17 -0
  432. data/lib/expressir/model/statements/alias.rb +26 -0
  433. data/lib/expressir/model/statements/assignment.rb +15 -0
  434. data/lib/expressir/model/statements/call.rb +15 -0
  435. data/lib/expressir/model/statements/case.rb +17 -0
  436. data/lib/expressir/model/statements/case_action.rb +15 -0
  437. data/lib/expressir/model/statements/compound.rb +13 -0
  438. data/lib/expressir/model/statements/escape.rb +8 -0
  439. data/lib/expressir/model/statements/if.rb +17 -0
  440. data/lib/expressir/model/statements/null.rb +8 -0
  441. data/lib/expressir/model/statements/repeat.rb +34 -0
  442. data/lib/expressir/model/statements/return.rb +13 -0
  443. data/lib/expressir/model/statements/skip.rb +8 -0
  444. data/lib/expressir/model/subtype_constraint.rb +27 -0
  445. data/lib/expressir/model/type.rb +24 -0
  446. data/lib/expressir/model/types/aggregate.rb +17 -0
  447. data/lib/expressir/model/types/array.rb +21 -0
  448. data/lib/expressir/model/types/bag.rb +17 -0
  449. data/lib/expressir/model/types/binary.rb +15 -0
  450. data/lib/expressir/model/types/boolean.rb +8 -0
  451. data/lib/expressir/model/types/enumeration.rb +19 -0
  452. data/lib/expressir/model/types/generic.rb +13 -0
  453. data/lib/expressir/model/types/generic_entity.rb +13 -0
  454. data/lib/expressir/model/types/integer.rb +8 -0
  455. data/lib/expressir/model/types/list.rb +19 -0
  456. data/lib/expressir/model/types/logical.rb +8 -0
  457. data/lib/expressir/model/types/number.rb +8 -0
  458. data/lib/expressir/model/types/real.rb +13 -0
  459. data/lib/expressir/model/types/select.rb +21 -0
  460. data/lib/expressir/model/types/set.rb +17 -0
  461. data/lib/expressir/model/types/string.rb +15 -0
  462. data/lib/expressir/model/unique.rb +15 -0
  463. data/lib/expressir/model/variable.rb +17 -0
  464. data/lib/expressir/model/where.rb +15 -0
  465. data/lib/expressir/parser.rb +6 -0
  466. data/lib/expressir/parser/owl_parser.rb +8 -0
  467. data/lib/expressir/version.rb +3 -0
  468. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +9589 -0
  469. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +36619 -0
  470. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +13294 -0
  471. data/original/examples/employment/eclipse/.project +17 -0
  472. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  473. data/original/examples/employment/eclipse/Express/employment_schema.exp +33 -0
  474. data/original/examples/employment/eclipse/Express/employment_schema.xmi +77 -0
  475. data/original/examples/employment/eclipse/Express/employment_schema.xml +93 -0
  476. data/original/examples/employment/eclipse/Models/Employment.uml +4 -0
  477. data/original/examples/employment/eclipse/Models/Employment.umldi +240 -0
  478. data/original/examples/employment/eclipse/readme.txt +7 -0
  479. data/original/examples/employment/employment_schema.exp +33 -0
  480. data/original/examples/employment/employment_schema.rb +232 -0
  481. data/original/examples/employment/employment_schema.xml +93 -0
  482. data/original/examples/employment/employment_schema___module.rb +46 -0
  483. data/original/examples/employment/employment_schema___p28attr.rb +126 -0
  484. data/original/examples/employment/employment_schema___p28inst.rb +26 -0
  485. data/original/examples/employment/example_employment_data.xml +1 -0
  486. data/original/examples/employment/example_employment_data_copy.xml +1 -0
  487. data/original/examples/employment/example_employment_reader.rb +30 -0
  488. data/original/examples/employment/example_employment_writer.rb +51 -0
  489. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +3710 -0
  490. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +35880 -0
  491. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +15357 -0
  492. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +9468 -0
  493. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +8404 -0
  494. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +43147 -0
  495. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +18341 -0
  496. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +11632 -0
  497. data/original/examples/syntax/remark.exp +145 -0
  498. data/original/examples/syntax/remark_formatted.exp +174 -0
  499. data/original/examples/syntax/syntax.exp +310 -0
  500. data/original/examples/syntax/syntax_formatted.exp +1187 -0
  501. data/original/exp2ruby.rb +525 -0
  502. data/original/expsm.rb +34 -0
  503. data/original/mapping_owl.rb +1018 -0
  504. data/original/mapping_sysml.rb +2281 -0
  505. data/original/mapping_uml2.rb +599 -0
  506. data/original/mapping_uml2_eclipse.rb +433 -0
  507. data/original/reeper.rb +134 -0
  508. data/spec/acceptance/express_to_owl_spec.rb +18 -0
  509. data/spec/acceptance/version_spec.rb +12 -0
  510. data/spec/expressir/express/repository_spec.rb +25 -0
  511. data/spec/expressir/express_exp/ap233_spec.rb +22 -0
  512. data/spec/expressir/express_exp/format_remark_spec.rb +28 -0
  513. data/spec/expressir/express_exp/format_syntax_spec.rb +28 -0
  514. data/spec/expressir/express_exp/parse_remark_spec.rb +345 -0
  515. data/spec/expressir/express_exp/parse_syntax_spec.rb +2998 -0
  516. data/spec/expressir/model/find_spec.rb +110 -0
  517. data/spec/expressr_spec.rb +5 -0
  518. data/spec/spec_helper.rb +17 -0
  519. data/spec/support/console_helper.rb +29 -0
  520. metadata +695 -0
@@ -0,0 +1,904 @@
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 "PredictionMode.h"
9
+ #include "dfa/DFAState.h"
10
+ #include "atn/ATNSimulator.h"
11
+ #include "atn/PredictionContext.h"
12
+ #include "SemanticContext.h"
13
+ #include "atn/ATNConfig.h"
14
+
15
+ namespace antlr4 {
16
+ namespace atn {
17
+
18
+ /**
19
+ * The embodiment of the adaptive LL(*), ALL(*), parsing strategy.
20
+ *
21
+ * <p>
22
+ * The basic complexity of the adaptive strategy makes it harder to understand.
23
+ * We begin with ATN simulation to build paths in a DFA. Subsequent prediction
24
+ * requests go through the DFA first. If they reach a state without an edge for
25
+ * the current symbol, the algorithm fails over to the ATN simulation to
26
+ * complete the DFA path for the current input (until it finds a conflict state
27
+ * or uniquely predicting state).</p>
28
+ *
29
+ * <p>
30
+ * All of that is done without using the outer context because we want to create
31
+ * a DFA that is not dependent upon the rule invocation stack when we do a
32
+ * prediction. One DFA works in all contexts. We avoid using context not
33
+ * necessarily because it's slower, although it can be, but because of the DFA
34
+ * caching problem. The closure routine only considers the rule invocation stack
35
+ * created during prediction beginning in the decision rule. For example, if
36
+ * prediction occurs without invoking another rule's ATN, there are no context
37
+ * stacks in the configurations. When lack of context leads to a conflict, we
38
+ * don't know if it's an ambiguity or a weakness in the strong LL(*) parsing
39
+ * strategy (versus full LL(*)).</p>
40
+ *
41
+ * <p>
42
+ * When SLL yields a configuration set with conflict, we rewind the input and
43
+ * retry the ATN simulation, this time using full outer context without adding
44
+ * to the DFA. Configuration context stacks will be the full invocation stacks
45
+ * from the start rule. If we get a conflict using full context, then we can
46
+ * definitively say we have a true ambiguity for that input sequence. If we
47
+ * don't get a conflict, it implies that the decision is sensitive to the outer
48
+ * context. (It is not context-sensitive in the sense of context-sensitive
49
+ * grammars.)</p>
50
+ *
51
+ * <p>
52
+ * The next time we reach this DFA state with an SLL conflict, through DFA
53
+ * simulation, we will again retry the ATN simulation using full context mode.
54
+ * This is slow because we can't save the results and have to "interpret" the
55
+ * ATN each time we get that input.</p>
56
+ *
57
+ * <p>
58
+ * <strong>CACHING FULL CONTEXT PREDICTIONS</strong></p>
59
+ *
60
+ * <p>
61
+ * We could cache results from full context to predicted alternative easily and
62
+ * that saves a lot of time but doesn't work in presence of predicates. The set
63
+ * of visible predicates from the ATN start state changes depending on the
64
+ * context, because closure can fall off the end of a rule. I tried to cache
65
+ * tuples (stack context, semantic context, predicted alt) but it was slower
66
+ * than interpreting and much more complicated. Also required a huge amount of
67
+ * memory. The goal is not to create the world's fastest parser anyway. I'd like
68
+ * to keep this algorithm simple. By launching multiple threads, we can improve
69
+ * the speed of parsing across a large number of files.</p>
70
+ *
71
+ * <p>
72
+ * There is no strict ordering between the amount of input used by SLL vs LL,
73
+ * which makes it really hard to build a cache for full context. Let's say that
74
+ * we have input A B C that leads to an SLL conflict with full context X. That
75
+ * implies that using X we might only use A B but we could also use A B C D to
76
+ * resolve conflict. Input A B C D could predict alternative 1 in one position
77
+ * in the input and A B C E could predict alternative 2 in another position in
78
+ * input. The conflicting SLL configurations could still be non-unique in the
79
+ * full context prediction, which would lead us to requiring more input than the
80
+ * original A B C. To make a prediction cache work, we have to track the exact
81
+ * input used during the previous prediction. That amounts to a cache that maps
82
+ * X to a specific DFA for that context.</p>
83
+ *
84
+ * <p>
85
+ * Something should be done for left-recursive expression predictions. They are
86
+ * likely LL(1) + pred eval. Easier to do the whole SLL unless error and retry
87
+ * with full LL thing Sam does.</p>
88
+ *
89
+ * <p>
90
+ * <strong>AVOIDING FULL CONTEXT PREDICTION</strong></p>
91
+ *
92
+ * <p>
93
+ * We avoid doing full context retry when the outer context is empty, we did not
94
+ * dip into the outer context by falling off the end of the decision state rule,
95
+ * or when we force SLL mode.</p>
96
+ *
97
+ * <p>
98
+ * As an example of the not dip into outer context case, consider as super
99
+ * constructor calls versus function calls. One grammar might look like
100
+ * this:</p>
101
+ *
102
+ * <pre>
103
+ * ctorBody
104
+ * : '{' superCall? stat* '}'
105
+ * ;
106
+ * </pre>
107
+ *
108
+ * <p>
109
+ * Or, you might see something like</p>
110
+ *
111
+ * <pre>
112
+ * stat
113
+ * : superCall ';'
114
+ * | expression ';'
115
+ * | ...
116
+ * ;
117
+ * </pre>
118
+ *
119
+ * <p>
120
+ * In both cases I believe that no closure operations will dip into the outer
121
+ * context. In the first case ctorBody in the worst case will stop at the '}'.
122
+ * In the 2nd case it should stop at the ';'. Both cases should stay within the
123
+ * entry rule and not dip into the outer context.</p>
124
+ *
125
+ * <p>
126
+ * <strong>PREDICATES</strong></p>
127
+ *
128
+ * <p>
129
+ * Predicates are always evaluated if present in either SLL or LL both. SLL and
130
+ * LL simulation deals with predicates differently. SLL collects predicates as
131
+ * it performs closure operations like ANTLR v3 did. It delays predicate
132
+ * evaluation until it reaches and accept state. This allows us to cache the SLL
133
+ * ATN simulation whereas, if we had evaluated predicates on-the-fly during
134
+ * closure, the DFA state configuration sets would be different and we couldn't
135
+ * build up a suitable DFA.</p>
136
+ *
137
+ * <p>
138
+ * When building a DFA accept state during ATN simulation, we evaluate any
139
+ * predicates and return the sole semantically valid alternative. If there is
140
+ * more than 1 alternative, we report an ambiguity. If there are 0 alternatives,
141
+ * we throw an exception. Alternatives without predicates act like they have
142
+ * true predicates. The simple way to think about it is to strip away all
143
+ * alternatives with false predicates and choose the minimum alternative that
144
+ * remains.</p>
145
+ *
146
+ * <p>
147
+ * When we start in the DFA and reach an accept state that's predicated, we test
148
+ * those and return the minimum semantically viable alternative. If no
149
+ * alternatives are viable, we throw an exception.</p>
150
+ *
151
+ * <p>
152
+ * During full LL ATN simulation, closure always evaluates predicates and
153
+ * on-the-fly. This is crucial to reducing the configuration set size during
154
+ * closure. It hits a landmine when parsing with the Java grammar, for example,
155
+ * without this on-the-fly evaluation.</p>
156
+ *
157
+ * <p>
158
+ * <strong>SHARING DFA</strong></p>
159
+ *
160
+ * <p>
161
+ * All instances of the same parser share the same decision DFAs through a
162
+ * static field. Each instance gets its own ATN simulator but they share the
163
+ * same {@link #decisionToDFA} field. They also share a
164
+ * {@link PredictionContextCache} object that makes sure that all
165
+ * {@link PredictionContext} objects are shared among the DFA states. This makes
166
+ * a big size difference.</p>
167
+ *
168
+ * <p>
169
+ * <strong>THREAD SAFETY</strong></p>
170
+ *
171
+ * <p>
172
+ * The {@link ParserATNSimulator} locks on the {@link #decisionToDFA} field when
173
+ * it adds a new DFA object to that array. {@link #addDFAEdge}
174
+ * locks on the DFA for the current decision when setting the
175
+ * {@link DFAState#edges} field. {@link #addDFAState} locks on
176
+ * the DFA for the current decision when looking up a DFA state to see if it
177
+ * already exists. We must make sure that all requests to add DFA states that
178
+ * are equivalent result in the same shared DFA object. This is because lots of
179
+ * threads will be trying to update the DFA at once. The
180
+ * {@link #addDFAState} method also locks inside the DFA lock
181
+ * but this time on the shared context cache when it rebuilds the
182
+ * configurations' {@link PredictionContext} objects using cached
183
+ * subgraphs/nodes. No other locking occurs, even during DFA simulation. This is
184
+ * safe as long as we can guarantee that all threads referencing
185
+ * {@code s.edge[t]} get the same physical target {@link DFAState}, or
186
+ * {@code null}. Once into the DFA, the DFA simulation does not reference the
187
+ * {@link DFA#states} map. It follows the {@link DFAState#edges} field to new
188
+ * targets. The DFA simulator will either find {@link DFAState#edges} to be
189
+ * {@code null}, to be non-{@code null} and {@code dfa.edges[t]} null, or
190
+ * {@code dfa.edges[t]} to be non-null. The
191
+ * {@link #addDFAEdge} method could be racing to set the field
192
+ * but in either case the DFA simulator works; if {@code null}, and requests ATN
193
+ * simulation. It could also race trying to get {@code dfa.edges[t]}, but either
194
+ * way it will work because it's not doing a test and set operation.</p>
195
+ *
196
+ * <p>
197
+ * <strong>Starting with SLL then failing to combined SLL/LL (Two-Stage
198
+ * Parsing)</strong></p>
199
+ *
200
+ * <p>
201
+ * Sam pointed out that if SLL does not give a syntax error, then there is no
202
+ * point in doing full LL, which is slower. We only have to try LL if we get a
203
+ * syntax error. For maximum speed, Sam starts the parser set to pure SLL
204
+ * mode with the {@link BailErrorStrategy}:</p>
205
+ *
206
+ * <pre>
207
+ * parser.{@link Parser#getInterpreter() getInterpreter()}.{@link #setPredictionMode setPredictionMode}{@code (}{@link PredictionMode#SLL}{@code )};
208
+ * parser.{@link Parser#setErrorHandler setErrorHandler}(new {@link BailErrorStrategy}());
209
+ * </pre>
210
+ *
211
+ * <p>
212
+ * If it does not get a syntax error, then we're done. If it does get a syntax
213
+ * error, we need to retry with the combined SLL/LL strategy.</p>
214
+ *
215
+ * <p>
216
+ * The reason this works is as follows. If there are no SLL conflicts, then the
217
+ * grammar is SLL (at least for that input set). If there is an SLL conflict,
218
+ * the full LL analysis must yield a set of viable alternatives which is a
219
+ * subset of the alternatives reported by SLL. If the LL set is a singleton,
220
+ * then the grammar is LL but not SLL. If the LL set is the same size as the SLL
221
+ * set, the decision is SLL. If the LL set has size &gt; 1, then that decision
222
+ * is truly ambiguous on the current input. If the LL set is smaller, then the
223
+ * SLL conflict resolution might choose an alternative that the full LL would
224
+ * rule out as a possibility based upon better context information. If that's
225
+ * the case, then the SLL parse will definitely get an error because the full LL
226
+ * analysis says it's not viable. If SLL conflict resolution chooses an
227
+ * alternative within the LL set, them both SLL and LL would choose the same
228
+ * alternative because they both choose the minimum of multiple conflicting
229
+ * alternatives.</p>
230
+ *
231
+ * <p>
232
+ * Let's say we have a set of SLL conflicting alternatives {@code {1, 2, 3}} and
233
+ * a smaller LL set called <em>s</em>. If <em>s</em> is {@code {2, 3}}, then SLL
234
+ * parsing will get an error because SLL will pursue alternative 1. If
235
+ * <em>s</em> is {@code {1, 2}} or {@code {1, 3}} then both SLL and LL will
236
+ * choose the same alternative because alternative one is the minimum of either
237
+ * set. If <em>s</em> is {@code {2}} or {@code {3}} then SLL will get a syntax
238
+ * error. If <em>s</em> is {@code {1}} then SLL will succeed.</p>
239
+ *
240
+ * <p>
241
+ * Of course, if the input is invalid, then we will get an error for sure in
242
+ * both SLL and LL parsing. Erroneous input will therefore require 2 passes over
243
+ * the input.</p>
244
+ */
245
+ class ANTLR4CPP_PUBLIC ParserATNSimulator : public ATNSimulator {
246
+ public:
247
+ /// Testing only!
248
+ ParserATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
249
+ PredictionContextCache &sharedContextCache);
250
+
251
+ ParserATNSimulator(Parser *parser, const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
252
+ PredictionContextCache &sharedContextCache);
253
+
254
+ virtual void reset() override;
255
+ virtual void clearDFA() override;
256
+ virtual size_t adaptivePredict(TokenStream *input, size_t decision, ParserRuleContext *outerContext);
257
+
258
+ static const bool TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT;
259
+
260
+ std::vector<dfa::DFA> &decisionToDFA;
261
+
262
+ /** Implements first-edge (loop entry) elimination as an optimization
263
+ * during closure operations. See antlr/antlr4#1398.
264
+ *
265
+ * The optimization is to avoid adding the loop entry config when
266
+ * the exit path can only lead back to the same
267
+ * StarLoopEntryState after popping context at the rule end state
268
+ * (traversing only epsilon edges, so we're still in closure, in
269
+ * this same rule).
270
+ *
271
+ * We need to detect any state that can reach loop entry on
272
+ * epsilon w/o exiting rule. We don't have to look at FOLLOW
273
+ * links, just ensure that all stack tops for config refer to key
274
+ * states in LR rule.
275
+ *
276
+ * To verify we are in the right situation we must first check
277
+ * closure is at a StarLoopEntryState generated during LR removal.
278
+ * Then we check that each stack top of context is a return state
279
+ * from one of these cases:
280
+ *
281
+ * 1. 'not' expr, '(' type ')' expr. The return state points at loop entry state
282
+ * 2. expr op expr. The return state is the block end of internal block of (...)*
283
+ * 3. 'between' expr 'and' expr. The return state of 2nd expr reference.
284
+ * That state points at block end of internal block of (...)*.
285
+ * 4. expr '?' expr ':' expr. The return state points at block end,
286
+ * which points at loop entry state.
287
+ *
288
+ * If any is true for each stack top, then closure does not add a
289
+ * config to the current config set for edge[0], the loop entry branch.
290
+ *
291
+ * Conditions fail if any context for the current config is:
292
+ *
293
+ * a. empty (we'd fall out of expr to do a global FOLLOW which could
294
+ * even be to some weird spot in expr) or,
295
+ * b. lies outside of expr or,
296
+ * c. lies within expr but at a state not the BlockEndState
297
+ * generated during LR removal
298
+ *
299
+ * Do we need to evaluate predicates ever in closure for this case?
300
+ *
301
+ * No. Predicates, including precedence predicates, are only
302
+ * evaluated when computing a DFA start state. I.e., only before
303
+ * the lookahead (but not parser) consumes a token.
304
+ *
305
+ * There are no epsilon edges allowed in LR rule alt blocks or in
306
+ * the "primary" part (ID here). If closure is in
307
+ * StarLoopEntryState any lookahead operation will have consumed a
308
+ * token as there are no epsilon-paths that lead to
309
+ * StarLoopEntryState. We do not have to evaluate predicates
310
+ * therefore if we are in the generated StarLoopEntryState of a LR
311
+ * rule. Note that when making a prediction starting at that
312
+ * decision point, decision d=2, compute-start-state performs
313
+ * closure starting at edges[0], edges[1] emanating from
314
+ * StarLoopEntryState. That means it is not performing closure on
315
+ * StarLoopEntryState during compute-start-state.
316
+ *
317
+ * How do we know this always gives same prediction answer?
318
+ *
319
+ * Without predicates, loop entry and exit paths are ambiguous
320
+ * upon remaining input +b (in, say, a+b). Either paths lead to
321
+ * valid parses. Closure can lead to consuming + immediately or by
322
+ * falling out of this call to expr back into expr and loop back
323
+ * again to StarLoopEntryState to match +b. In this special case,
324
+ * we choose the more efficient path, which is to take the bypass
325
+ * path.
326
+ *
327
+ * The lookahead language has not changed because closure chooses
328
+ * one path over the other. Both paths lead to consuming the same
329
+ * remaining input during a lookahead operation. If the next token
330
+ * is an operator, lookahead will enter the choice block with
331
+ * operators. If it is not, lookahead will exit expr. Same as if
332
+ * closure had chosen to enter the choice block immediately.
333
+ *
334
+ * Closure is examining one config (some loopentrystate, some alt,
335
+ * context) which means it is considering exactly one alt. Closure
336
+ * always copies the same alt to any derived configs.
337
+ *
338
+ * How do we know this optimization doesn't mess up precedence in
339
+ * our parse trees?
340
+ *
341
+ * Looking through expr from left edge of stat only has to confirm
342
+ * that an input, say, a+b+c; begins with any valid interpretation
343
+ * of an expression. The precedence actually doesn't matter when
344
+ * making a decision in stat seeing through expr. It is only when
345
+ * parsing rule expr that we must use the precedence to get the
346
+ * right interpretation and, hence, parse tree.
347
+ */
348
+ bool canDropLoopEntryEdgeInLeftRecursiveRule(ATNConfig *config) const;
349
+ virtual std::string getRuleName(size_t index);
350
+
351
+ virtual Ref<ATNConfig> precedenceTransition(Ref<ATNConfig> const& config, PrecedencePredicateTransition *pt,
352
+ bool collectPredicates, bool inContext, bool fullCtx);
353
+
354
+ void setPredictionMode(PredictionMode newMode);
355
+ PredictionMode getPredictionMode();
356
+
357
+ Parser* getParser();
358
+
359
+ virtual std::string getTokenName(size_t t);
360
+
361
+ virtual std::string getLookaheadName(TokenStream *input);
362
+
363
+ /// <summary>
364
+ /// Used for debugging in adaptivePredict around execATN but I cut
365
+ /// it out for clarity now that alg. works well. We can leave this
366
+ /// "dead" code for a bit.
367
+ /// </summary>
368
+ virtual void dumpDeadEndConfigs(NoViableAltException &nvae);
369
+
370
+ protected:
371
+ Parser *const parser;
372
+
373
+ /// <summary>
374
+ /// Each prediction operation uses a cache for merge of prediction contexts.
375
+ /// Don't keep around as it wastes huge amounts of memory. The merge cache
376
+ /// isn't synchronized but we're ok since two threads shouldn't reuse same
377
+ /// parser/atnsim object because it can only handle one input at a time.
378
+ /// This maps graphs a and b to merged result c. (a,b)->c. We can avoid
379
+ /// the merge if we ever see a and b again. Note that (b,a)->c should
380
+ /// also be examined during cache lookup.
381
+ /// </summary>
382
+ PredictionContextMergeCache mergeCache;
383
+
384
+ // LAME globals to avoid parameters!!!!! I need these down deep in predTransition
385
+ TokenStream *_input;
386
+ size_t _startIndex;
387
+ ParserRuleContext *_outerContext;
388
+ dfa::DFA *_dfa; // Reference into the decisionToDFA vector.
389
+
390
+ /// <summary>
391
+ /// Performs ATN simulation to compute a predicted alternative based
392
+ /// upon the remaining input, but also updates the DFA cache to avoid
393
+ /// having to traverse the ATN again for the same input sequence.
394
+ ///
395
+ /// There are some key conditions we're looking for after computing a new
396
+ /// set of ATN configs (proposed DFA state):
397
+ /// if the set is empty, there is no viable alternative for current symbol
398
+ /// does the state uniquely predict an alternative?
399
+ /// does the state have a conflict that would prevent us from
400
+ /// putting it on the work list?
401
+ ///
402
+ /// We also have some key operations to do:
403
+ /// add an edge from previous DFA state to potentially new DFA state, D,
404
+ /// upon current symbol but only if adding to work list, which means in all
405
+ /// cases except no viable alternative (and possibly non-greedy decisions?)
406
+ /// collecting predicates and adding semantic context to DFA accept states
407
+ /// adding rule context to context-sensitive DFA accept states
408
+ /// consuming an input symbol
409
+ /// reporting a conflict
410
+ /// reporting an ambiguity
411
+ /// reporting a context sensitivity
412
+ /// reporting insufficient predicates
413
+ ///
414
+ /// cover these cases:
415
+ /// dead end
416
+ /// single alt
417
+ /// single alt + preds
418
+ /// conflict
419
+ /// conflict + preds
420
+ /// </summary>
421
+ virtual size_t execATN(dfa::DFA &dfa, dfa::DFAState *s0, TokenStream *input, size_t startIndex,
422
+ ParserRuleContext *outerContext);
423
+
424
+ /// <summary>
425
+ /// Get an existing target state for an edge in the DFA. If the target state
426
+ /// for the edge has not yet been computed or is otherwise not available,
427
+ /// this method returns {@code null}.
428
+ /// </summary>
429
+ /// <param name="previousD"> The current DFA state </param>
430
+ /// <param name="t"> The next input symbol </param>
431
+ /// <returns> The existing target DFA state for the given input symbol
432
+ /// {@code t}, or {@code null} if the target state for this edge is not
433
+ /// already cached </returns>
434
+ virtual dfa::DFAState* getExistingTargetState(dfa::DFAState *previousD, size_t t);
435
+
436
+ /// <summary>
437
+ /// Compute a target state for an edge in the DFA, and attempt to add the
438
+ /// computed state and corresponding edge to the DFA.
439
+ /// </summary>
440
+ /// <param name="dfa"> The DFA </param>
441
+ /// <param name="previousD"> The current DFA state </param>
442
+ /// <param name="t"> The next input symbol
443
+ /// </param>
444
+ /// <returns> The computed target DFA state for the given input symbol
445
+ /// {@code t}. If {@code t} does not lead to a valid DFA state, this method
446
+ /// returns <seealso cref="#ERROR"/>. </returns>
447
+ virtual dfa::DFAState *computeTargetState(dfa::DFA &dfa, dfa::DFAState *previousD, size_t t);
448
+
449
+ virtual void predicateDFAState(dfa::DFAState *dfaState, DecisionState *decisionState);
450
+
451
+ // comes back with reach.uniqueAlt set to a valid alt
452
+ virtual size_t execATNWithFullContext(dfa::DFA &dfa, dfa::DFAState *D, ATNConfigSet *s0,
453
+ TokenStream *input, size_t startIndex, ParserRuleContext *outerContext); // how far we got before failing over
454
+
455
+ virtual std::unique_ptr<ATNConfigSet> computeReachSet(ATNConfigSet *closure, size_t t, bool fullCtx);
456
+
457
+ /// <summary>
458
+ /// Return a configuration set containing only the configurations from
459
+ /// {@code configs} which are in a <seealso cref="RuleStopState"/>. If all
460
+ /// configurations in {@code configs} are already in a rule stop state, this
461
+ /// method simply returns {@code configs}.
462
+ /// <p/>
463
+ /// When {@code lookToEndOfRule} is true, this method uses
464
+ /// <seealso cref="ATN#nextTokens"/> for each configuration in {@code configs} which is
465
+ /// not already in a rule stop state to see if a rule stop state is reachable
466
+ /// from the configuration via epsilon-only transitions.
467
+ /// </summary>
468
+ /// <param name="configs"> the configuration set to update </param>
469
+ /// <param name="lookToEndOfRule"> when true, this method checks for rule stop states
470
+ /// reachable by epsilon-only transitions from each configuration in
471
+ /// {@code configs}.
472
+ /// </param>
473
+ /// <returns> {@code configs} if all configurations in {@code configs} are in a
474
+ /// rule stop state, otherwise return a new configuration set containing only
475
+ /// the configurations from {@code configs} which are in a rule stop state </returns>
476
+ virtual ATNConfigSet* removeAllConfigsNotInRuleStopState(ATNConfigSet *configs, bool lookToEndOfRule);
477
+
478
+ virtual std::unique_ptr<ATNConfigSet> computeStartState(ATNState *p, RuleContext *ctx, bool fullCtx);
479
+
480
+ /* parrt internal source braindump that doesn't mess up
481
+ * external API spec.
482
+
483
+ applyPrecedenceFilter is an optimization to avoid highly
484
+ nonlinear prediction of expressions and other left recursive
485
+ rules. The precedence predicates such as {3>=prec}? Are highly
486
+ context-sensitive in that they can only be properly evaluated
487
+ in the context of the proper prec argument. Without pruning,
488
+ these predicates are normal predicates evaluated when we reach
489
+ conflict state (or unique prediction). As we cannot evaluate
490
+ these predicates out of context, the resulting conflict leads
491
+ to full LL evaluation and nonlinear prediction which shows up
492
+ very clearly with fairly large expressions.
493
+
494
+ Example grammar:
495
+
496
+ e : e '*' e
497
+ | e '+' e
498
+ | INT
499
+ ;
500
+
501
+ We convert that to the following:
502
+
503
+ e[int prec]
504
+ : INT
505
+ ( {3>=prec}? '*' e[4]
506
+ | {2>=prec}? '+' e[3]
507
+ )*
508
+ ;
509
+
510
+ The (..)* loop has a decision for the inner block as well as
511
+ an enter or exit decision, which is what concerns us here. At
512
+ the 1st + of input 1+2+3, the loop entry sees both predicates
513
+ and the loop exit also sees both predicates by falling off the
514
+ edge of e. This is because we have no stack information with
515
+ SLL and find the follow of e, which will hit the return states
516
+ inside the loop after e[4] and e[3], which brings it back to
517
+ the enter or exit decision. In this case, we know that we
518
+ cannot evaluate those predicates because we have fallen off
519
+ the edge of the stack and will in general not know which prec
520
+ parameter is the right one to use in the predicate.
521
+
522
+ Because we have special information, that these are precedence
523
+ predicates, we can resolve them without failing over to full
524
+ LL despite their context sensitive nature. We make an
525
+ assumption that prec[-1] <= prec[0], meaning that the current
526
+ precedence level is greater than or equal to the precedence
527
+ level of recursive invocations above us in the stack. For
528
+ example, if predicate {3>=prec}? is true of the current prec,
529
+ then one option is to enter the loop to match it now. The
530
+ other option is to exit the loop and the left recursive rule
531
+ to match the current operator in rule invocation further up
532
+ the stack. But, we know that all of those prec are lower or
533
+ the same value and so we can decide to enter the loop instead
534
+ of matching it later. That means we can strip out the other
535
+ configuration for the exit branch.
536
+
537
+ So imagine we have (14,1,$,{2>=prec}?) and then
538
+ (14,2,$-dipsIntoOuterContext,{2>=prec}?). The optimization
539
+ allows us to collapse these two configurations. We know that
540
+ if {2>=prec}? is true for the current prec parameter, it will
541
+ also be true for any prec from an invoking e call, indicated
542
+ by dipsIntoOuterContext. As the predicates are both true, we
543
+ have the option to evaluate them early in the decision start
544
+ state. We do this by stripping both predicates and choosing to
545
+ enter the loop as it is consistent with the notion of operator
546
+ precedence. It's also how the full LL conflict resolution
547
+ would work.
548
+
549
+ The solution requires a different DFA start state for each
550
+ precedence level.
551
+
552
+ The basic filter mechanism is to remove configurations of the
553
+ form (p, 2, pi) if (p, 1, pi) exists for the same p and pi. In
554
+ other words, for the same ATN state and predicate context,
555
+ remove any configuration associated with an exit branch if
556
+ there is a configuration associated with the enter branch.
557
+
558
+ It's also the case that the filter evaluates precedence
559
+ predicates and resolves conflicts according to precedence
560
+ levels. For example, for input 1+2+3 at the first +, we see
561
+ prediction filtering
562
+
563
+ [(11,1,[$],{3>=prec}?), (14,1,[$],{2>=prec}?), (5,2,[$],up=1),
564
+ (11,2,[$],up=1), (14,2,[$],up=1)],hasSemanticContext=true,dipsIntoOuterContext
565
+
566
+ to
567
+
568
+ [(11,1,[$]), (14,1,[$]), (5,2,[$],up=1)],dipsIntoOuterContext
569
+
570
+ This filters because {3>=prec}? evals to true and collapses
571
+ (11,1,[$],{3>=prec}?) and (11,2,[$],up=1) since early conflict
572
+ resolution based upon rules of operator precedence fits with
573
+ our usual match first alt upon conflict.
574
+
575
+ We noticed a problem where a recursive call resets precedence
576
+ to 0. Sam's fix: each config has flag indicating if it has
577
+ returned from an expr[0] call. then just don't filter any
578
+ config with that flag set. flag is carried along in
579
+ closure(). so to avoid adding field, set bit just under sign
580
+ bit of dipsIntoOuterContext (SUPPRESS_PRECEDENCE_FILTER).
581
+ With the change you filter "unless (p, 2, pi) was reached
582
+ after leaving the rule stop state of the LR rule containing
583
+ state p, corresponding to a rule invocation with precedence
584
+ level 0"
585
+ */
586
+
587
+ /**
588
+ * This method transforms the start state computed by
589
+ * {@link #computeStartState} to the special start state used by a
590
+ * precedence DFA for a particular precedence value. The transformation
591
+ * process applies the following changes to the start state's configuration
592
+ * set.
593
+ *
594
+ * <ol>
595
+ * <li>Evaluate the precedence predicates for each configuration using
596
+ * {@link SemanticContext#evalPrecedence}.</li>
597
+ * <li>When {@link ATNConfig#isPrecedenceFilterSuppressed} is {@code false},
598
+ * remove all configurations which predict an alternative greater than 1,
599
+ * for which another configuration that predicts alternative 1 is in the
600
+ * same ATN state with the same prediction context. This transformation is
601
+ * valid for the following reasons:
602
+ * <ul>
603
+ * <li>The closure block cannot contain any epsilon transitions which bypass
604
+ * the body of the closure, so all states reachable via alternative 1 are
605
+ * part of the precedence alternatives of the transformed left-recursive
606
+ * rule.</li>
607
+ * <li>The "primary" portion of a left recursive rule cannot contain an
608
+ * epsilon transition, so the only way an alternative other than 1 can exist
609
+ * in a state that is also reachable via alternative 1 is by nesting calls
610
+ * to the left-recursive rule, with the outer calls not being at the
611
+ * preferred precedence level. The
612
+ * {@link ATNConfig#isPrecedenceFilterSuppressed} property marks ATN
613
+ * configurations which do not meet this condition, and therefore are not
614
+ * eligible for elimination during the filtering process.</li>
615
+ * </ul>
616
+ * </li>
617
+ * </ol>
618
+ *
619
+ * <p>
620
+ * The prediction context must be considered by this filter to address
621
+ * situations like the following.
622
+ * </p>
623
+ * <code>
624
+ * <pre>
625
+ * grammar TA;
626
+ * prog: statement* EOF;
627
+ * statement: letterA | statement letterA 'b' ;
628
+ * letterA: 'a';
629
+ * </pre>
630
+ * </code>
631
+ * <p>
632
+ * If the above grammar, the ATN state immediately before the token
633
+ * reference {@code 'a'} in {@code letterA} is reachable from the left edge
634
+ * of both the primary and closure blocks of the left-recursive rule
635
+ * {@code statement}. The prediction context associated with each of these
636
+ * configurations distinguishes between them, and prevents the alternative
637
+ * which stepped out to {@code prog} (and then back in to {@code statement}
638
+ * from being eliminated by the filter.
639
+ * </p>
640
+ *
641
+ * @param configs The configuration set computed by
642
+ * {@link #computeStartState} as the start state for the DFA.
643
+ * @return The transformed configuration set representing the start state
644
+ * for a precedence DFA at a particular precedence level (determined by
645
+ * calling {@link Parser#getPrecedence}).
646
+ */
647
+ std::unique_ptr<ATNConfigSet> applyPrecedenceFilter(ATNConfigSet *configs);
648
+
649
+ virtual ATNState *getReachableTarget(Transition *trans, size_t ttype);
650
+
651
+ virtual std::vector<Ref<SemanticContext>> getPredsForAmbigAlts(const antlrcpp::BitSet &ambigAlts,
652
+ ATNConfigSet *configs, size_t nalts);
653
+
654
+ virtual std::vector<dfa::DFAState::PredPrediction*> getPredicatePredictions(const antlrcpp::BitSet &ambigAlts,
655
+ std::vector<Ref<SemanticContext>> const& altToPred);
656
+
657
+ /**
658
+ * This method is used to improve the localization of error messages by
659
+ * choosing an alternative rather than throwing a
660
+ * {@link NoViableAltException} in particular prediction scenarios where the
661
+ * {@link #ERROR} state was reached during ATN simulation.
662
+ *
663
+ * <p>
664
+ * The default implementation of this method uses the following
665
+ * algorithm to identify an ATN configuration which successfully parsed the
666
+ * decision entry rule. Choosing such an alternative ensures that the
667
+ * {@link ParserRuleContext} returned by the calling rule will be complete
668
+ * and valid, and the syntax error will be reported later at a more
669
+ * localized location.</p>
670
+ *
671
+ * <ul>
672
+ * <li>If a syntactically valid path or paths reach the end of the decision rule and
673
+ * they are semantically valid if predicated, return the min associated alt.</li>
674
+ * <li>Else, if a semantically invalid but syntactically valid path exist
675
+ * or paths exist, return the minimum associated alt.
676
+ * </li>
677
+ * <li>Otherwise, return {@link ATN#INVALID_ALT_NUMBER}.</li>
678
+ * </ul>
679
+ *
680
+ * <p>
681
+ * In some scenarios, the algorithm described above could predict an
682
+ * alternative which will result in a {@link FailedPredicateException} in
683
+ * the parser. Specifically, this could occur if the <em>only</em> configuration
684
+ * capable of successfully parsing to the end of the decision rule is
685
+ * blocked by a semantic predicate. By choosing this alternative within
686
+ * {@link #adaptivePredict} instead of throwing a
687
+ * {@link NoViableAltException}, the resulting
688
+ * {@link FailedPredicateException} in the parser will identify the specific
689
+ * predicate which is preventing the parser from successfully parsing the
690
+ * decision rule, which helps developers identify and correct logic errors
691
+ * in semantic predicates.
692
+ * </p>
693
+ *
694
+ * @param configs The ATN configurations which were valid immediately before
695
+ * the {@link #ERROR} state was reached
696
+ * @param outerContext The is the \gamma_0 initial parser context from the paper
697
+ * or the parser stack at the instant before prediction commences.
698
+ *
699
+ * @return The value to return from {@link #adaptivePredict}, or
700
+ * {@link ATN#INVALID_ALT_NUMBER} if a suitable alternative was not
701
+ * identified and {@link #adaptivePredict} should report an error instead.
702
+ */
703
+ size_t getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(ATNConfigSet *configs,
704
+ ParserRuleContext *outerContext);
705
+
706
+ virtual size_t getAltThatFinishedDecisionEntryRule(ATNConfigSet *configs);
707
+
708
+ /** Walk the list of configurations and split them according to
709
+ * those that have preds evaluating to true/false. If no pred, assume
710
+ * true pred and include in succeeded set. Returns Pair of sets.
711
+ *
712
+ * Create a new set so as not to alter the incoming parameter.
713
+ *
714
+ * Assumption: the input stream has been restored to the starting point
715
+ * prediction, which is where predicates need to evaluate.
716
+ */
717
+ std::pair<ATNConfigSet *, ATNConfigSet *> splitAccordingToSemanticValidity(ATNConfigSet *configs,
718
+ ParserRuleContext *outerContext);
719
+
720
+ /// <summary>
721
+ /// Look through a list of predicate/alt pairs, returning alts for the
722
+ /// pairs that win. A {@code NONE} predicate indicates an alt containing an
723
+ /// unpredicated config which behaves as "always true." If !complete
724
+ /// then we stop at the first predicate that evaluates to true. This
725
+ /// includes pairs with null predicates.
726
+ /// </summary>
727
+ virtual antlrcpp::BitSet evalSemanticContext(std::vector<dfa::DFAState::PredPrediction*> predPredictions,
728
+ ParserRuleContext *outerContext, bool complete);
729
+
730
+ /**
731
+ * Evaluate a semantic context within a specific parser context.
732
+ *
733
+ * <p>
734
+ * This method might not be called for every semantic context evaluated
735
+ * during the prediction process. In particular, we currently do not
736
+ * evaluate the following but it may change in the future:</p>
737
+ *
738
+ * <ul>
739
+ * <li>Precedence predicates (represented by
740
+ * {@link SemanticContext.PrecedencePredicate}) are not currently evaluated
741
+ * through this method.</li>
742
+ * <li>Operator predicates (represented by {@link SemanticContext.AND} and
743
+ * {@link SemanticContext.OR}) are evaluated as a single semantic
744
+ * context, rather than evaluating the operands individually.
745
+ * Implementations which require evaluation results from individual
746
+ * predicates should override this method to explicitly handle evaluation of
747
+ * the operands within operator predicates.</li>
748
+ * </ul>
749
+ *
750
+ * @param pred The semantic context to evaluate
751
+ * @param parserCallStack The parser context in which to evaluate the
752
+ * semantic context
753
+ * @param alt The alternative which is guarded by {@code pred}
754
+ * @param fullCtx {@code true} if the evaluation is occurring during LL
755
+ * prediction; otherwise, {@code false} if the evaluation is occurring
756
+ * during SLL prediction
757
+ *
758
+ * @since 4.3
759
+ */
760
+ virtual bool evalSemanticContext(Ref<SemanticContext> const& pred, ParserRuleContext *parserCallStack,
761
+ size_t alt, bool fullCtx);
762
+
763
+ /* TODO: If we are doing predicates, there is no point in pursuing
764
+ closure operations if we reach a DFA state that uniquely predicts
765
+ alternative. We will not be caching that DFA state and it is a
766
+ waste to pursue the closure. Might have to advance when we do
767
+ ambig detection thought :(
768
+ */
769
+ virtual void closure(Ref<ATNConfig> const& config, ATNConfigSet *configs, ATNConfig::Set &closureBusy,
770
+ bool collectPredicates, bool fullCtx, bool treatEofAsEpsilon);
771
+
772
+ virtual void closureCheckingStopState(Ref<ATNConfig> const& config, ATNConfigSet *configs, ATNConfig::Set &closureBusy,
773
+ bool collectPredicates, bool fullCtx, int depth, bool treatEofAsEpsilon);
774
+
775
+ /// Do the actual work of walking epsilon edges.
776
+ virtual void closure_(Ref<ATNConfig> const& config, ATNConfigSet *configs, ATNConfig::Set &closureBusy,
777
+ bool collectPredicates, bool fullCtx, int depth, bool treatEofAsEpsilon);
778
+
779
+ virtual Ref<ATNConfig> getEpsilonTarget(Ref<ATNConfig> const& config, Transition *t, bool collectPredicates,
780
+ bool inContext, bool fullCtx, bool treatEofAsEpsilon);
781
+ virtual Ref<ATNConfig> actionTransition(Ref<ATNConfig> const& config, ActionTransition *t);
782
+
783
+ virtual Ref<ATNConfig> predTransition(Ref<ATNConfig> const& config, PredicateTransition *pt, bool collectPredicates,
784
+ bool inContext, bool fullCtx);
785
+
786
+ virtual Ref<ATNConfig> ruleTransition(Ref<ATNConfig> const& config, RuleTransition *t);
787
+
788
+ /**
789
+ * Gets a {@link BitSet} containing the alternatives in {@code configs}
790
+ * which are part of one or more conflicting alternative subsets.
791
+ *
792
+ * @param configs The {@link ATNConfigSet} to analyze.
793
+ * @return The alternatives in {@code configs} which are part of one or more
794
+ * conflicting alternative subsets. If {@code configs} does not contain any
795
+ * conflicting subsets, this method returns an empty {@link BitSet}.
796
+ */
797
+ virtual antlrcpp::BitSet getConflictingAlts(ATNConfigSet *configs);
798
+
799
+ /// <summary>
800
+ /// Sam pointed out a problem with the previous definition, v3, of
801
+ /// ambiguous states. If we have another state associated with conflicting
802
+ /// alternatives, we should keep going. For example, the following grammar
803
+ ///
804
+ /// s : (ID | ID ID?) ';' ;
805
+ ///
806
+ /// When the ATN simulation reaches the state before ';', it has a DFA
807
+ /// state that looks like: [12|1|[], 6|2|[], 12|2|[]]. Naturally
808
+ /// 12|1|[] and 12|2|[] conflict, but we cannot stop processing this node
809
+ /// because alternative to has another way to continue, via [6|2|[]].
810
+ /// The key is that we have a single state that has config's only associated
811
+ /// with a single alternative, 2, and crucially the state transitions
812
+ /// among the configurations are all non-epsilon transitions. That means
813
+ /// we don't consider any conflicts that include alternative 2. So, we
814
+ /// ignore the conflict between alts 1 and 2. We ignore a set of
815
+ /// conflicting alts when there is an intersection with an alternative
816
+ /// associated with a single alt state in the state->config-list map.
817
+ ///
818
+ /// It's also the case that we might have two conflicting configurations but
819
+ /// also a 3rd nonconflicting configuration for a different alternative:
820
+ /// [1|1|[], 1|2|[], 8|3|[]]. This can come about from grammar:
821
+ ///
822
+ /// a : A | A | A B ;
823
+ ///
824
+ /// After matching input A, we reach the stop state for rule A, state 1.
825
+ /// State 8 is the state right before B. Clearly alternatives 1 and 2
826
+ /// conflict and no amount of further lookahead will separate the two.
827
+ /// However, alternative 3 will be able to continue and so we do not
828
+ /// stop working on this state. In the previous example, we're concerned
829
+ /// with states associated with the conflicting alternatives. Here alt
830
+ /// 3 is not associated with the conflicting configs, but since we can continue
831
+ /// looking for input reasonably, I don't declare the state done. We
832
+ /// ignore a set of conflicting alts when we have an alternative
833
+ /// that we still need to pursue.
834
+ /// </summary>
835
+
836
+ virtual antlrcpp::BitSet getConflictingAltsOrUniqueAlt(ATNConfigSet *configs);
837
+
838
+ virtual NoViableAltException noViableAlt(TokenStream *input, ParserRuleContext *outerContext,
839
+ ATNConfigSet *configs, size_t startIndex, bool deleteConfigs);
840
+
841
+ static size_t getUniqueAlt(ATNConfigSet *configs);
842
+
843
+ /// <summary>
844
+ /// Add an edge to the DFA, if possible. This method calls
845
+ /// <seealso cref="#addDFAState"/> to ensure the {@code to} state is present in the
846
+ /// DFA. If {@code from} is {@code null}, or if {@code t} is outside the
847
+ /// range of edges that can be represented in the DFA tables, this method
848
+ /// returns without adding the edge to the DFA.
849
+ /// <p/>
850
+ /// If {@code to} is {@code null}, this method returns {@code null}.
851
+ /// Otherwise, this method returns the <seealso cref="DFAState"/> returned by calling
852
+ /// <seealso cref="#addDFAState"/> for the {@code to} state.
853
+ /// </summary>
854
+ /// <param name="dfa"> The DFA </param>
855
+ /// <param name="from"> The source state for the edge </param>
856
+ /// <param name="t"> The input symbol </param>
857
+ /// <param name="to"> The target state for the edge
858
+ /// </param>
859
+ /// <returns> If {@code to} is {@code null}, this method returns {@code null};
860
+ /// otherwise this method returns the result of calling <seealso cref="#addDFAState"/>
861
+ /// on {@code to} </returns>
862
+ virtual dfa::DFAState *addDFAEdge(dfa::DFA &dfa, dfa::DFAState *from, ssize_t t, dfa::DFAState *to);
863
+
864
+ /// <summary>
865
+ /// Add state {@code D} to the DFA if it is not already present, and return
866
+ /// the actual instance stored in the DFA. If a state equivalent to {@code D}
867
+ /// is already in the DFA, the existing state is returned. Otherwise this
868
+ /// method returns {@code D} after adding it to the DFA.
869
+ /// <p/>
870
+ /// If {@code D} is <seealso cref="#ERROR"/>, this method returns <seealso cref="#ERROR"/> and
871
+ /// does not change the DFA.
872
+ /// </summary>
873
+ /// <param name="dfa"> The dfa </param>
874
+ /// <param name="D"> The DFA state to add </param>
875
+ /// <returns> The state stored in the DFA. This will be either the existing
876
+ /// state if {@code D} is already in the DFA, or {@code D} itself if the
877
+ /// state was not already present. </returns>
878
+ virtual dfa::DFAState *addDFAState(dfa::DFA &dfa, dfa::DFAState *D);
879
+
880
+ virtual void reportAttemptingFullContext(dfa::DFA &dfa, const antlrcpp::BitSet &conflictingAlts,
881
+ ATNConfigSet *configs, size_t startIndex, size_t stopIndex);
882
+
883
+ virtual void reportContextSensitivity(dfa::DFA &dfa, size_t prediction, ATNConfigSet *configs,
884
+ size_t startIndex, size_t stopIndex);
885
+
886
+ /// If context sensitive parsing, we know it's ambiguity not conflict.
887
+ virtual void reportAmbiguity(dfa::DFA &dfa,
888
+ dfa::DFAState *D, // the DFA state from execATN() that had SLL conflicts
889
+ size_t startIndex, size_t stopIndex,
890
+ bool exact,
891
+ const antlrcpp::BitSet &ambigAlts,
892
+ ATNConfigSet *configs); // configs that LL not SLL considered conflicting
893
+
894
+ private:
895
+ // SLL, LL, or LL + exact ambig detection?
896
+ PredictionMode _mode;
897
+
898
+ static bool getLrLoopSetting();
899
+ void InitializeInstanceFields();
900
+ };
901
+
902
+ } // namespace atn
903
+ } // namespace antlr4
904
+