expressir 1.4.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (482) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql.yml +2 -14
  3. data/.github/workflows/rake.yml +6 -364
  4. data/.github/workflows/release.yml +15 -178
  5. data/.github/workflows/stress.yml +1 -18
  6. data/.rubocop.yml +1 -0
  7. data/.rubocop_todo.yml +21 -0
  8. data/Gemfile +12 -0
  9. data/README.adoc +6 -19
  10. data/Rakefile +6 -7
  11. data/exe/{format-test → expressir-format-test} +1 -1
  12. data/expressir.gemspec +23 -32
  13. data/expressir_wrapped.txt +23068 -0
  14. data/lib/expressir/cli.rb +1 -1
  15. data/lib/expressir/express/formatter.rb +661 -661
  16. data/lib/expressir/express/parser.rb +299 -33
  17. data/lib/expressir/express/visitor.rb +238 -133
  18. data/lib/expressir/liquid/cache_drop.rb +20 -0
  19. data/lib/expressir/liquid/data_type_drop.rb +8 -0
  20. data/lib/expressir/liquid/data_types/aggregate_drop.rb +21 -0
  21. data/lib/expressir/liquid/data_types/array_drop.rb +34 -0
  22. data/lib/expressir/liquid/data_types/bag_drop.rb +26 -0
  23. data/lib/expressir/liquid/data_types/binary_drop.rb +22 -0
  24. data/lib/expressir/liquid/data_types/boolean_drop.rb +10 -0
  25. data/lib/expressir/liquid/data_types/enumeration_drop.rb +30 -0
  26. data/lib/expressir/liquid/data_types/enumeration_item_drop.rb +17 -0
  27. data/lib/expressir/liquid/data_types/generic_drop.rb +17 -0
  28. data/lib/expressir/liquid/data_types/generic_entity_drop.rb +17 -0
  29. data/lib/expressir/liquid/data_types/integer_drop.rb +10 -0
  30. data/lib/expressir/liquid/data_types/list_drop.rb +30 -0
  31. data/lib/expressir/liquid/data_types/logical_drop.rb +10 -0
  32. data/lib/expressir/liquid/data_types/number_drop.rb +10 -0
  33. data/lib/expressir/liquid/data_types/real_drop.rb +18 -0
  34. data/lib/expressir/liquid/data_types/select_drop.rb +34 -0
  35. data/lib/expressir/liquid/data_types/set_drop.rb +26 -0
  36. data/lib/expressir/liquid/data_types/string_drop.rb +22 -0
  37. data/lib/expressir/liquid/declaration_drop.rb +8 -0
  38. data/lib/expressir/liquid/declarations/attribute_drop.rb +37 -0
  39. data/lib/expressir/liquid/declarations/constant_drop.rb +25 -0
  40. data/lib/expressir/liquid/declarations/entity_drop.rb +65 -0
  41. data/lib/expressir/liquid/declarations/function_drop.rb +93 -0
  42. data/lib/expressir/liquid/declarations/interface_drop.rb +30 -0
  43. data/lib/expressir/liquid/declarations/interface_item_drop.rb +22 -0
  44. data/lib/expressir/liquid/declarations/interfaced_item_drop.rb +34 -0
  45. data/lib/expressir/liquid/declarations/parameter_drop.rb +25 -0
  46. data/lib/expressir/liquid/declarations/procedure_drop.rb +89 -0
  47. data/lib/expressir/liquid/declarations/remark_item_drop.rb +22 -0
  48. data/lib/expressir/liquid/declarations/rule_drop.rb +105 -0
  49. data/lib/expressir/liquid/declarations/schema_drop.rb +91 -0
  50. data/lib/expressir/liquid/declarations/schema_version_drop.rb +26 -0
  51. data/lib/expressir/liquid/declarations/schema_version_item_drop.rb +22 -0
  52. data/lib/expressir/liquid/declarations/subtype_constraint_drop.rb +37 -0
  53. data/lib/expressir/liquid/declarations/type_drop.rb +37 -0
  54. data/lib/expressir/liquid/declarations/unique_rule_drop.rb +21 -0
  55. data/lib/expressir/liquid/declarations/variable_drop.rb +25 -0
  56. data/lib/expressir/liquid/declarations/where_rule_drop.rb +21 -0
  57. data/lib/expressir/liquid/expression_drop.rb +8 -0
  58. data/lib/expressir/liquid/expressions/aggregate_initializer_drop.rb +24 -0
  59. data/lib/expressir/liquid/expressions/aggregate_initializer_item_drop.rb +22 -0
  60. data/lib/expressir/liquid/expressions/binary_expression_drop.rb +26 -0
  61. data/lib/expressir/liquid/expressions/entity_constructor_drop.rb +26 -0
  62. data/lib/expressir/liquid/expressions/function_call_drop.rb +26 -0
  63. data/lib/expressir/liquid/expressions/interval_drop.rb +34 -0
  64. data/lib/expressir/liquid/expressions/query_expression_drop.rb +25 -0
  65. data/lib/expressir/liquid/expressions/unary_expression_drop.rb +22 -0
  66. data/lib/expressir/liquid/identifier_drop.rb +33 -0
  67. data/lib/expressir/liquid/literal_drop.rb +8 -0
  68. data/lib/expressir/liquid/literals/binary_drop.rb +18 -0
  69. data/lib/expressir/liquid/literals/integer_drop.rb +18 -0
  70. data/lib/expressir/liquid/literals/logical_drop.rb +18 -0
  71. data/lib/expressir/liquid/literals/real_drop.rb +18 -0
  72. data/lib/expressir/liquid/literals/string_drop.rb +22 -0
  73. data/lib/expressir/liquid/model_element_drop.rb +33 -0
  74. data/lib/expressir/liquid/reference_drop.rb +8 -0
  75. data/lib/expressir/liquid/references/attribute_reference_drop.rb +22 -0
  76. data/lib/expressir/liquid/references/group_reference_drop.rb +22 -0
  77. data/lib/expressir/liquid/references/index_reference_drop.rb +26 -0
  78. data/lib/expressir/liquid/references/simple_reference_drop.rb +22 -0
  79. data/lib/expressir/liquid/repository_drop.rb +22 -0
  80. data/lib/expressir/liquid/statement_drop.rb +8 -0
  81. data/lib/expressir/liquid/statements/alias_drop.rb +29 -0
  82. data/lib/expressir/liquid/statements/assignment_drop.rb +22 -0
  83. data/lib/expressir/liquid/statements/case_action_drop.rb +26 -0
  84. data/lib/expressir/liquid/statements/case_drop.rb +30 -0
  85. data/lib/expressir/liquid/statements/compound_drop.rb +22 -0
  86. data/lib/expressir/liquid/statements/escape_drop.rb +10 -0
  87. data/lib/expressir/liquid/statements/if_drop.rb +34 -0
  88. data/lib/expressir/liquid/statements/null_drop.rb +10 -0
  89. data/lib/expressir/liquid/statements/procedure_call_drop.rb +26 -0
  90. data/lib/expressir/liquid/statements/repeat_drop.rb +45 -0
  91. data/lib/expressir/liquid/statements/return_drop.rb +18 -0
  92. data/lib/expressir/liquid/statements/skip_drop.rb +10 -0
  93. data/lib/expressir/liquid/supertype_expression_drop.rb +8 -0
  94. data/lib/expressir/liquid/supertype_expressions/binary_supertype_expression_drop.rb +26 -0
  95. data/lib/expressir/liquid/supertype_expressions/oneof_supertype_expression_drop.rb +22 -0
  96. data/lib/expressir/liquid.rb +18 -0
  97. data/lib/expressir/model/declarations/interface_item.rb +1 -1
  98. data/lib/expressir/model/model_element.rb +7 -0
  99. data/lib/expressir/version.rb +1 -1
  100. data/lib/expressir.rb +2 -0
  101. metadata +101 -569
  102. data/.cross_rubies +0 -28
  103. data/.gitmodules +0 -6
  104. data/.yardopts +0 -11
  105. data/exe/generate-parser +0 -51
  106. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/CMakeLists.txt +0 -191
  107. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj +0 -652
  108. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2019.vcxproj.filters +0 -948
  109. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2022.vcxproj +0 -652
  110. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlr4cpp-vs2022.vcxproj.filters +0 -948
  111. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/Info.plist +0 -26
  112. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp-ios/antlrcpp_ios.h +0 -17
  113. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +0 -3040
  114. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  115. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  116. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4.xcscheme +0 -76
  117. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_ios.xcscheme +0 -76
  118. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/antlrcpp.xcodeproj/xcshareddata/xcschemes/antlr4_static.xcscheme +0 -76
  119. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.noarch.nuspec +0 -23
  120. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.noarch.targets +0 -8
  121. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.shared.nuspec +0 -30
  122. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.shared.props +0 -21
  123. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.shared.targets +0 -44
  124. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.static.nuspec +0 -29
  125. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/ANTLR4.Runtime.cpp.static.targets +0 -44
  126. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/antlr4.jpg +0 -0
  127. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/nuget/pack.cmd +0 -93
  128. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.cpp +0 -10
  129. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorListener.h +0 -167
  130. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.cpp +0 -10
  131. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRErrorStrategy.h +0 -121
  132. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +0 -23
  133. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRFileStream.h +0 -30
  134. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +0 -180
  135. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ANTLRInputStream.h +0 -79
  136. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +0 -61
  137. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BailErrorStrategy.h +0 -59
  138. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.cpp +0 -25
  139. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BaseErrorListener.h +0 -36
  140. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +0 -414
  141. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/BufferedTokenStream.h +0 -200
  142. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.cpp +0 -11
  143. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CharStream.h +0 -37
  144. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.cpp +0 -193
  145. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonToken.h +0 -158
  146. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.cpp +0 -39
  147. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenFactory.h +0 -74
  148. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.cpp +0 -78
  149. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/CommonTokenStream.h +0 -79
  150. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +0 -15
  151. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ConsoleErrorListener.h +0 -35
  152. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +0 -336
  153. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/DefaultErrorStrategy.h +0 -466
  154. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +0 -84
  155. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/DiagnosticErrorListener.h +0 -80
  156. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.cpp +0 -64
  157. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Exceptions.h +0 -99
  158. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.cpp +0 -52
  159. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/FailedPredicateException.h +0 -32
  160. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/FlatHashMap.h +0 -57
  161. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/FlatHashSet.h +0 -57
  162. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.cpp +0 -18
  163. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/InputMismatchException.h +0 -24
  164. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.cpp +0 -12
  165. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/IntStream.h +0 -218
  166. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.cpp +0 -19
  167. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/InterpreterRuleContext.h +0 -45
  168. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.cpp +0 -294
  169. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Lexer.h +0 -196
  170. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.cpp +0 -60
  171. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerInterpreter.h +0 -46
  172. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.cpp +0 -36
  173. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/LexerNoViableAltException.h +0 -31
  174. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.cpp +0 -92
  175. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ListTokenSource.h +0 -88
  176. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.cpp +0 -46
  177. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/NoViableAltException.h +0 -42
  178. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.cpp +0 -670
  179. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Parser.h +0 -461
  180. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.cpp +0 -294
  181. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserInterpreter.h +0 -173
  182. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.cpp +0 -138
  183. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ParserRuleContext.h +0 -147
  184. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.cpp +0 -53
  185. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/ProxyErrorListener.h +0 -38
  186. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.cpp +0 -65
  187. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RecognitionException.h +0 -98
  188. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.cpp +0 -157
  189. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Recognizer.h +0 -160
  190. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.cpp +0 -144
  191. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContext.h +0 -141
  192. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.cpp +0 -27
  193. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuleContextWithAltNum.h +0 -32
  194. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.cpp +0 -54
  195. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/RuntimeMetaData.h +0 -155
  196. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.cpp +0 -9
  197. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Token.h +0 -92
  198. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenFactory.h +0 -30
  199. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.cpp +0 -9
  200. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenSource.h +0 -85
  201. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.cpp +0 -11
  202. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStream.h +0 -137
  203. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +0 -425
  204. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/TokenStreamRewriter.h +0 -295
  205. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.cpp +0 -208
  206. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedCharStream.h +0 -117
  207. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +0 -270
  208. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/UnbufferedTokenStream.h +0 -115
  209. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Version.h +0 -42
  210. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.cpp +0 -64
  211. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/Vocabulary.h +0 -177
  212. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.cpp +0 -9
  213. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/WritableToken.h +0 -23
  214. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-common.h +0 -101
  215. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/antlr4-runtime.h +0 -168
  216. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.cpp +0 -159
  217. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATN.h +0 -133
  218. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +0 -106
  219. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfig.h +0 -157
  220. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +0 -233
  221. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNConfigSet.h +0 -157
  222. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +0 -39
  223. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +0 -48
  224. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +0 -628
  225. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +0 -32
  226. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.cpp +0 -33
  227. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNSimulator.h +0 -71
  228. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.cpp +0 -56
  229. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNState.h +0 -139
  230. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.cpp +0 -33
  231. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNStateType.h +0 -36
  232. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ATNType.h +0 -20
  233. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +0 -29
  234. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ActionTransition.h +0 -35
  235. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.cpp +0 -16
  236. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AmbiguityInfo.h +0 -68
  237. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.cpp +0 -129
  238. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +0 -51
  239. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +0 -27
  240. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/AtomTransition.h +0 -33
  241. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicBlockStartState.h +0 -24
  242. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BasicState.h +0 -23
  243. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockEndState.h +0 -26
  244. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/BlockStartState.h +0 -30
  245. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.cpp +0 -14
  246. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ContextSensitivityInfo.h +0 -47
  247. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.cpp +0 -14
  248. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionEventInfo.h +0 -70
  249. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.cpp +0 -25
  250. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionInfo.h +0 -227
  251. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.cpp +0 -12
  252. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/DecisionState.h +0 -34
  253. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +0 -31
  254. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/EpsilonTransition.h +0 -42
  255. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.cpp +0 -15
  256. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ErrorInfo.h +0 -43
  257. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/HashUtils.h +0 -18
  258. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.cpp +0 -189
  259. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +0 -76
  260. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +0 -67
  261. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNConfig.h +0 -44
  262. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +0 -621
  263. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +0 -199
  264. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.cpp +0 -15
  265. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerAction.h +0 -100
  266. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +0 -108
  267. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +0 -128
  268. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerActionType.h +0 -57
  269. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.cpp +0 -43
  270. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerChannelAction.h +0 -59
  271. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.cpp +0 -45
  272. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerCustomAction.h +0 -75
  273. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.cpp +0 -50
  274. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerIndexedCustomAction.h +0 -76
  275. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.cpp +0 -43
  276. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerModeAction.h +0 -57
  277. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.cpp +0 -36
  278. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerMoreAction.h +0 -53
  279. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.cpp +0 -36
  280. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPopModeAction.h +0 -53
  281. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.cpp +0 -43
  282. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerPushModeAction.h +0 -57
  283. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.cpp +0 -36
  284. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerSkipAction.h +0 -51
  285. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.cpp +0 -43
  286. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LexerTypeAction.h +0 -51
  287. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.cpp +0 -16
  288. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LookaheadEventInfo.h +0 -42
  289. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/LoopEndState.h +0 -26
  290. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.cpp +0 -22
  291. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/NotSetTransition.h +0 -27
  292. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.cpp +0 -16
  293. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/OrderedATNConfigSet.h +0 -25
  294. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.cpp +0 -102
  295. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParseInfo.h +0 -102
  296. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +0 -1413
  297. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulator.h +0 -911
  298. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ParserATNSimulatorOptions.h +0 -50
  299. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusBlockStartState.h +0 -29
  300. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PlusLoopbackState.h +0 -25
  301. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +0 -23
  302. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.h +0 -35
  303. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.cpp +0 -17
  304. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateEvalInfo.h +0 -62
  305. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +0 -24
  306. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredicateTransition.h +0 -50
  307. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +0 -601
  308. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContext.h +0 -225
  309. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.cpp +0 -56
  310. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextCache.h +0 -63
  311. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.cpp +0 -167
  312. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCache.h +0 -101
  313. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextMergeCacheOptions.h +0 -71
  314. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionContextType.h +0 -21
  315. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.cpp +0 -202
  316. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/PredictionMode.h +0 -436
  317. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.cpp +0 -179
  318. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/ProfilingATNSimulator.h +0 -60
  319. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +0 -26
  320. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RangeTransition.h +0 -31
  321. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStartState.h +0 -26
  322. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleStopState.h +0 -27
  323. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +0 -33
  324. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/RuleTransition.h +0 -42
  325. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +0 -418
  326. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContext.h +0 -237
  327. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SemanticContextType.h +0 -23
  328. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SerializedATNView.h +0 -101
  329. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.cpp +0 -28
  330. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SetTransition.h +0 -38
  331. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.cpp +0 -79
  332. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +0 -43
  333. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarBlockStartState.h +0 -24
  334. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopEntryState.h +0 -37
  335. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.cpp +0 -19
  336. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/StarLoopbackState.h +0 -25
  337. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TokensStartState.h +0 -24
  338. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.cpp +0 -36
  339. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/Transition.h +0 -65
  340. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.cpp +0 -27
  341. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/TransitionType.h +0 -33
  342. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.cpp +0 -21
  343. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/atn/WildcardTransition.h +0 -27
  344. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.cpp +0 -115
  345. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFA.h +0 -96
  346. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.cpp +0 -60
  347. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFASerializer.h +0 -32
  348. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.cpp +0 -59
  349. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/DFAState.h +0 -154
  350. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.cpp +0 -17
  351. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +0 -22
  352. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/internal/Synchronization.cpp +0 -100
  353. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/internal/Synchronization.h +0 -154
  354. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.cpp +0 -124
  355. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/InterpreterDataReader.h +0 -33
  356. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.cpp +0 -61
  357. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Interval.h +0 -84
  358. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.cpp +0 -508
  359. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/IntervalSet.h +0 -190
  360. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +0 -120
  361. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/MurmurHash.h +0 -102
  362. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.cpp +0 -4
  363. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/misc/Predicate.h +0 -21
  364. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.cpp +0 -8
  365. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Any.h +0 -16
  366. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.cpp +0 -43
  367. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Arrays.h +0 -149
  368. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/BitSet.h +0 -76
  369. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.cpp +0 -207
  370. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/CPPUtils.h +0 -65
  371. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Casts.h +0 -34
  372. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Declarations.h +0 -161
  373. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.cpp +0 -38
  374. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/StringUtils.h +0 -16
  375. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Unicode.h +0 -28
  376. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.cpp +0 -242
  377. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/support/Utf8.h +0 -54
  378. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/AbstractParseTreeVisitor.h +0 -129
  379. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNode.h +0 -24
  380. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.cpp +0 -54
  381. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ErrorNodeImpl.h +0 -43
  382. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.cpp +0 -66
  383. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/IterativeParseTreeWalker.h +0 -53
  384. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.cpp +0 -12
  385. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTree.h +0 -111
  386. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.cpp +0 -9
  387. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +0 -39
  388. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeProperty.h +0 -50
  389. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeType.h +0 -22
  390. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.cpp +0 -9
  391. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeVisitor.h +0 -57
  392. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.cpp +0 -48
  393. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +0 -55
  394. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNode.h +0 -40
  395. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +0 -54
  396. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.h +0 -32
  397. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.cpp +0 -241
  398. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/Trees.h +0 -78
  399. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.cpp +0 -9
  400. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +0 -44
  401. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.cpp +0 -69
  402. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +0 -132
  403. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.cpp +0 -64
  404. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +0 -105
  405. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.cpp +0 -370
  406. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +0 -185
  407. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +0 -77
  408. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.h +0 -117
  409. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.cpp +0 -39
  410. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +0 -86
  411. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.cpp +0 -28
  412. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +0 -51
  413. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +0 -36
  414. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.h +0 -80
  415. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.cpp +0 -154
  416. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPath.h +0 -86
  417. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.cpp +0 -31
  418. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathElement.h +0 -40
  419. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.cpp +0 -180
  420. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.g4 +0 -64
  421. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.h +0 -53
  422. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexer.tokens +0 -12
  423. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.cpp +0 -13
  424. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathLexerErrorListener.h +0 -22
  425. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp +0 -20
  426. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleAnywhereElement.h +0 -27
  427. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.cpp +0 -30
  428. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathRuleElement.h +0 -26
  429. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp +0 -20
  430. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenAnywhereElement.h +0 -25
  431. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.cpp +0 -33
  432. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathTokenElement.h +0 -26
  433. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp +0 -23
  434. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h +0 -23
  435. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.cpp +0 -24
  436. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/src/tree/xpath/XPathWildcardElement.h +0 -23
  437. data/ext/express_parser/antlr4-upstream/runtime/Cpp/runtime/tests/Utf8Test.cpp +0 -110
  438. data/ext/express_parser/antlrgen/Express.interp +0 -532
  439. data/ext/express_parser/antlrgen/Express.tokens +0 -190
  440. data/ext/express_parser/antlrgen/ExpressBaseListener.cpp +0 -7
  441. data/ext/express_parser/antlrgen/ExpressBaseListener.h +0 -623
  442. data/ext/express_parser/antlrgen/ExpressBaseVisitor.cpp +0 -7
  443. data/ext/express_parser/antlrgen/ExpressBaseVisitor.h +0 -816
  444. data/ext/express_parser/antlrgen/ExpressLexer.cpp +0 -685
  445. data/ext/express_parser/antlrgen/ExpressLexer.h +0 -78
  446. data/ext/express_parser/antlrgen/ExpressLexer.interp +0 -534
  447. data/ext/express_parser/antlrgen/ExpressLexer.tokens +0 -190
  448. data/ext/express_parser/antlrgen/ExpressListener.cpp +0 -7
  449. data/ext/express_parser/antlrgen/ExpressListener.h +0 -616
  450. data/ext/express_parser/antlrgen/ExpressParser.cpp +0 -17591
  451. data/ext/express_parser/antlrgen/ExpressParser.h +0 -3692
  452. data/ext/express_parser/antlrgen/ExpressVisitor.cpp +0 -7
  453. data/ext/express_parser/antlrgen/ExpressVisitor.h +0 -422
  454. data/ext/express_parser/express_parser.cpp +0 -19405
  455. data/ext/express_parser/extconf.rb +0 -63
  456. data/rakelib/antlr4-native.rake +0 -173
  457. data/rakelib/cross-ruby.rake +0 -403
  458. data/spec/acceptance/version_spec.rb +0 -30
  459. data/spec/expressir/express/cache_spec.rb +0 -89
  460. data/spec/expressir/express/formatter_spec.rb +0 -171
  461. data/spec/expressir/express/parser_spec.rb +0 -141
  462. data/spec/expressir/model/model_element_spec.rb +0 -343
  463. data/spec/spec_helper.rb +0 -24
  464. data/spec/support/console_helper.rb +0 -29
  465. data/spec/syntax/multiple.exp +0 -23
  466. data/spec/syntax/multiple.yaml +0 -198
  467. data/spec/syntax/multiple_formatted.exp +0 -71
  468. data/spec/syntax/multiple_hyperlink_formatted.exp +0 -71
  469. data/spec/syntax/multiple_schema_head_hyperlink_formatted.exp +0 -13
  470. data/spec/syntax/remark.exp +0 -193
  471. data/spec/syntax/remark.yaml +0 -471
  472. data/spec/syntax/remark_formatted.exp +0 -228
  473. data/spec/syntax/single.exp +0 -4
  474. data/spec/syntax/single.yaml +0 -18
  475. data/spec/syntax/single_formatted.exp +0 -10
  476. data/spec/syntax/single_formatted.yaml +0 -36
  477. data/spec/syntax/syntax.exp +0 -333
  478. data/spec/syntax/syntax.yaml +0 -3509
  479. data/spec/syntax/syntax_formatted.exp +0 -902
  480. data/spec/syntax/syntax_hyperlink_formatted.exp +0 -902
  481. data/spec/syntax/syntax_schema_head_formatted.exp +0 -18
  482. /data/exe/{format → expressir-format} +0 -0
@@ -1,1413 +0,0 @@
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 "NoViableAltException.h"
8
- #include "atn/DecisionState.h"
9
- #include "ParserRuleContext.h"
10
- #include "misc/IntervalSet.h"
11
- #include "Parser.h"
12
- #include "CommonTokenStream.h"
13
- #include "atn/NotSetTransition.h"
14
- #include "atn/AtomTransition.h"
15
- #include "atn/RuleTransition.h"
16
- #include "atn/PredicateTransition.h"
17
- #include "atn/PrecedencePredicateTransition.h"
18
- #include "atn/SingletonPredictionContext.h"
19
- #include "atn/ActionTransition.h"
20
- #include "atn/EpsilonTransition.h"
21
- #include "atn/RuleStopState.h"
22
- #include "atn/ATNConfigSet.h"
23
- #include "atn/ATNConfig.h"
24
- #include "internal/Synchronization.h"
25
-
26
- #include "atn/StarLoopEntryState.h"
27
- #include "atn/BlockStartState.h"
28
- #include "atn/BlockEndState.h"
29
-
30
- #include "misc/Interval.h"
31
- #include "ANTLRErrorListener.h"
32
-
33
- #include "Vocabulary.h"
34
- #include "support/Arrays.h"
35
- #include "support/Casts.h"
36
-
37
- #include "atn/ParserATNSimulator.h"
38
-
39
- #ifndef DEBUG_ATN
40
- #define DEBUG_ATN 0
41
- #endif
42
- #ifndef TRACE_ATN_SIM
43
- #define TRACE_ATN_SIM 0
44
- #endif
45
- #ifndef DFA_DEBUG
46
- #define DFA_DEBUG 0
47
- #endif
48
- #ifndef RETRY_DEBUG
49
- #define RETRY_DEBUG 0
50
- #endif
51
-
52
- using namespace antlr4;
53
- using namespace antlr4::atn;
54
- using namespace antlr4::internal;
55
- using namespace antlrcpp;
56
-
57
- const bool ParserATNSimulator::TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT = ParserATNSimulator::getLrLoopSetting();
58
-
59
- ParserATNSimulator::ParserATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
60
- PredictionContextCache &sharedContextCache)
61
- : ParserATNSimulator(nullptr, atn, decisionToDFA, sharedContextCache) {
62
- }
63
-
64
- ParserATNSimulator::ParserATNSimulator(Parser *parser, const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
65
- PredictionContextCache &sharedContextCache)
66
- : ParserATNSimulator(parser, atn, decisionToDFA, sharedContextCache, ParserATNSimulatorOptions()) {}
67
-
68
- ParserATNSimulator::ParserATNSimulator(Parser *parser, const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,
69
- PredictionContextCache &sharedContextCache,
70
- const ParserATNSimulatorOptions &options)
71
- : ATNSimulator(atn, sharedContextCache), decisionToDFA(decisionToDFA), parser(parser),
72
- mergeCache(options.getPredictionContextMergeCacheOptions()) {
73
- InitializeInstanceFields();
74
- }
75
-
76
- void ParserATNSimulator::reset() {
77
- }
78
-
79
- void ParserATNSimulator::clearDFA() {
80
- int size = (int)decisionToDFA.size();
81
- decisionToDFA.clear();
82
- for (int d = 0; d < size; ++d) {
83
- decisionToDFA.push_back(dfa::DFA(atn.getDecisionState(d), d));
84
- }
85
- }
86
-
87
- size_t ParserATNSimulator::adaptivePredict(TokenStream *input, size_t decision, ParserRuleContext *outerContext) {
88
-
89
- #if DEBUG_ATN == 1 || TRACE_ATN_SIM == 1
90
- std::cout << "adaptivePredict decision " << decision << " exec LA(1)==" << getLookaheadName(input) << " line "
91
- << input->LT(1)->getLine() << ":" << input->LT(1)->getCharPositionInLine() << std::endl;
92
- #endif
93
-
94
- _input = input;
95
- _startIndex = input->index();
96
- _outerContext = outerContext;
97
- dfa::DFA &dfa = decisionToDFA[decision];
98
- _dfa = &dfa;
99
-
100
- ssize_t m = input->mark();
101
- size_t index = _startIndex;
102
-
103
- // Now we are certain to have a specific decision's DFA
104
- // But, do we still need an initial state?
105
- auto onExit = finally([this, input, index, m] {
106
- if (mergeCache.getOptions().getClearEveryN() != 0) {
107
- if (++_mergeCacheCounter == mergeCache.getOptions().getClearEveryN()) {
108
- mergeCache.clear();
109
- _mergeCacheCounter = 0;
110
- }
111
- }
112
- _dfa = nullptr;
113
- input->seek(index);
114
- input->release(m);
115
- });
116
-
117
- dfa::DFAState *s0;
118
- {
119
- SharedLock<SharedMutex> stateLock(atn._stateMutex);
120
- if (dfa.isPrecedenceDfa()) {
121
- // the start state for a precedence DFA depends on the current
122
- // parser precedence, and is provided by a DFA method.
123
- SharedLock<SharedMutex> edgeLock(atn._edgeMutex);
124
- s0 = dfa.getPrecedenceStartState(parser->getPrecedence());
125
- } else {
126
- // the start state for a "regular" DFA is just s0
127
- s0 = dfa.s0;
128
- }
129
- }
130
-
131
- if (s0 == nullptr) {
132
- auto s0_closure = computeStartState(dfa.atnStartState, &ParserRuleContext::EMPTY, false);
133
- std::unique_ptr<dfa::DFAState> newState;
134
- std::unique_ptr<dfa::DFAState> oldState;
135
- UniqueLock<SharedMutex> stateLock(atn._stateMutex);
136
- dfa::DFAState* ds0 = dfa.s0;
137
- if (dfa.isPrecedenceDfa()) {
138
- /* If this is a precedence DFA, we use applyPrecedenceFilter
139
- * to convert the computed start state to a precedence start
140
- * state. We then use DFA.setPrecedenceStartState to set the
141
- * appropriate start state for the precedence level rather
142
- * than simply setting DFA.s0.
143
- */
144
- ds0->configs = std::move(s0_closure); // not used for prediction but useful to know start configs anyway
145
- newState = std::make_unique<dfa::DFAState>(applyPrecedenceFilter(ds0->configs.get()));
146
- s0 = addDFAState(dfa, newState.get());
147
- UniqueLock<SharedMutex> edgeLock(atn._edgeMutex);
148
- dfa.setPrecedenceStartState(parser->getPrecedence(), s0);
149
- } else {
150
- newState = std::make_unique<dfa::DFAState>(std::move(s0_closure));
151
- s0 = addDFAState(dfa, newState.get());
152
- if (ds0 != s0) {
153
- oldState.reset(ds0);
154
- dfa.s0 = s0;
155
- }
156
- }
157
- if (s0 == newState.get()) {
158
- newState.release();
159
- }
160
- }
161
-
162
- // We can start with an existing DFA.
163
- size_t alt = execATN(dfa, s0, input, index, outerContext != nullptr ? outerContext : &ParserRuleContext::EMPTY);
164
-
165
- return alt;
166
- }
167
-
168
- size_t ParserATNSimulator::execATN(dfa::DFA &dfa, dfa::DFAState *s0, TokenStream *input, size_t startIndex,
169
- ParserRuleContext *outerContext) {
170
-
171
- #if DEBUG_ATN == 1 || TRACE_ATN_SIM == 1
172
- std::cout << "execATN decision " << dfa.decision << ", DFA state " << s0->toString() <<
173
- ", LA(1)==" << getLookaheadName(input) <<
174
- " line " << input->LT(1)->getLine() << ":" << input->LT(1)->getCharPositionInLine() << std::endl;
175
- #endif
176
-
177
- dfa::DFAState *previousD = s0;
178
-
179
- #if DEBUG_ATN == 1
180
- std::cout << "s0 = " << s0->toString() << std::endl;
181
- #endif
182
-
183
- size_t t = input->LA(1);
184
-
185
- while (true) { // while more work
186
- dfa::DFAState *D = getExistingTargetState(previousD, t);
187
- if (D == nullptr) {
188
- D = computeTargetState(dfa, previousD, t);
189
- }
190
-
191
- if (D == ERROR.get()) {
192
- // if any configs in previous dipped into outer context, that
193
- // means that input up to t actually finished entry rule
194
- // at least for SLL decision. Full LL doesn't dip into outer
195
- // so don't need special case.
196
- // We will get an error no matter what so delay until after
197
- // decision; better error message. Also, no reachable target
198
- // ATN states in SLL implies LL will also get nowhere.
199
- // If conflict in states that dip out, choose min since we
200
- // will get error no matter what.
201
- NoViableAltException e = noViableAlt(input, outerContext, previousD->configs.get(), startIndex, false);
202
- input->seek(startIndex);
203
- size_t alt = getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previousD->configs.get(), outerContext);
204
- if (alt != ATN::INVALID_ALT_NUMBER) {
205
- return alt;
206
- }
207
-
208
- throw e;
209
- }
210
-
211
- if (D->requiresFullContext && _mode != PredictionMode::SLL) {
212
- // IF PREDS, MIGHT RESOLVE TO SINGLE ALT => SLL (or syntax error)
213
- BitSet conflictingAlts;
214
- if (D->predicates.size() != 0) {
215
- #if DEBUG_ATN == 1
216
- std::cout << "DFA state has preds in DFA sim LL failover" << std::endl;
217
- #endif
218
-
219
- size_t conflictIndex = input->index();
220
- if (conflictIndex != startIndex) {
221
- input->seek(startIndex);
222
- }
223
-
224
- conflictingAlts = evalSemanticContext(D->predicates, outerContext, true);
225
- if (conflictingAlts.count() == 1) {
226
- #if DEBUG_ATN == 1
227
- std::cout << "Full LL avoided" << std::endl;
228
- #endif
229
-
230
- return conflictingAlts.nextSetBit(0);
231
- }
232
-
233
- if (conflictIndex != startIndex) {
234
- // restore the index so reporting the fallback to full
235
- // context occurs with the index at the correct spot
236
- input->seek(conflictIndex);
237
- }
238
- }
239
-
240
- #if DFA_DEBUG == 1
241
- std::cout << "ctx sensitive state " << outerContext << " in " << D << std::endl;
242
- #endif
243
-
244
- bool fullCtx = true;
245
- std::unique_ptr<ATNConfigSet> s0_closure = computeStartState(dfa.atnStartState, outerContext, fullCtx);
246
- reportAttemptingFullContext(dfa, conflictingAlts, D->configs.get(), startIndex, input->index());
247
- size_t alt = execATNWithFullContext(dfa, D, s0_closure.get(), input, startIndex, outerContext);
248
- return alt;
249
- }
250
-
251
- if (D->isAcceptState) {
252
- if (D->predicates.empty()) {
253
- return D->prediction;
254
- }
255
-
256
- size_t stopIndex = input->index();
257
- input->seek(startIndex);
258
- BitSet alts = evalSemanticContext(D->predicates, outerContext, true);
259
- switch (alts.count()) {
260
- case 0:
261
- throw noViableAlt(input, outerContext, D->configs.get(), startIndex, false);
262
-
263
- case 1:
264
- return alts.nextSetBit(0);
265
-
266
- default:
267
- // report ambiguity after predicate evaluation to make sure the correct
268
- // set of ambig alts is reported.
269
- reportAmbiguity(dfa, D, startIndex, stopIndex, false, alts, D->configs.get());
270
- return alts.nextSetBit(0);
271
- }
272
- }
273
-
274
- previousD = D;
275
-
276
- if (t != Token::EOF) {
277
- input->consume();
278
- t = input->LA(1);
279
- }
280
- }
281
- }
282
-
283
- dfa::DFAState *ParserATNSimulator::getExistingTargetState(dfa::DFAState *previousD, size_t t) {
284
- dfa::DFAState* retval;
285
- SharedLock<SharedMutex> edgeLock(atn._edgeMutex);
286
- auto iterator = previousD->edges.find(t);
287
- retval = (iterator == previousD->edges.end()) ? nullptr : iterator->second;
288
- return retval;
289
- }
290
-
291
- dfa::DFAState *ParserATNSimulator::computeTargetState(dfa::DFA &dfa, dfa::DFAState *previousD, size_t t) {
292
- std::unique_ptr<ATNConfigSet> reach = computeReachSet(previousD->configs.get(), t, false);
293
- if (reach == nullptr) {
294
- addDFAEdge(dfa, previousD, t, ERROR.get());
295
- return ERROR.get();
296
- }
297
-
298
- // create new target state; we'll add to DFA after it's complete
299
- dfa::DFAState *D = new dfa::DFAState(std::move(reach)); /* mem-check: managed by the DFA or deleted below, "reach" is no longer valid now. */
300
- size_t predictedAlt = getUniqueAlt(D->configs.get());
301
-
302
- if (predictedAlt != ATN::INVALID_ALT_NUMBER) {
303
- // NO CONFLICT, UNIQUELY PREDICTED ALT
304
- D->isAcceptState = true;
305
- D->configs->uniqueAlt = predictedAlt;
306
- D->prediction = predictedAlt;
307
- } else if (PredictionModeClass::hasSLLConflictTerminatingPrediction(_mode, D->configs.get())) {
308
- // MORE THAN ONE VIABLE ALTERNATIVE
309
- D->configs->conflictingAlts = getConflictingAlts(D->configs.get());
310
- D->requiresFullContext = true;
311
- // in SLL-only mode, we will stop at this state and return the minimum alt
312
- D->isAcceptState = true;
313
- D->prediction = D->configs->conflictingAlts.nextSetBit(0);
314
- }
315
-
316
- if (D->isAcceptState && D->configs->hasSemanticContext) {
317
- predicateDFAState(D, atn.getDecisionState(dfa.decision));
318
- if (D->predicates.size() != 0) {
319
- D->prediction = ATN::INVALID_ALT_NUMBER;
320
- }
321
- }
322
-
323
- // all adds to dfa are done after we've created full D state
324
- dfa::DFAState *state = addDFAEdge(dfa, previousD, t, D);
325
- if (state != D) {
326
- delete D; // If the new state exists already we don't need it and use the existing one instead.
327
- }
328
- return state;
329
- }
330
-
331
- void ParserATNSimulator::predicateDFAState(dfa::DFAState *dfaState, DecisionState *decisionState) {
332
- // We need to test all predicates, even in DFA states that
333
- // uniquely predict alternative.
334
- size_t nalts = decisionState->transitions.size();
335
-
336
- // Update DFA so reach becomes accept state with (predicate,alt)
337
- // pairs if preds found for conflicting alts
338
- BitSet altsToCollectPredsFrom = getConflictingAltsOrUniqueAlt(dfaState->configs.get());
339
- std::vector<Ref<const SemanticContext>> altToPred = getPredsForAmbigAlts(altsToCollectPredsFrom, dfaState->configs.get(), nalts);
340
- if (!altToPred.empty()) {
341
- dfaState->predicates = getPredicatePredictions(altsToCollectPredsFrom, altToPred);
342
- dfaState->prediction = ATN::INVALID_ALT_NUMBER; // make sure we use preds
343
- } else {
344
- // There are preds in configs but they might go away
345
- // when OR'd together like {p}? || NONE == NONE. If neither
346
- // alt has preds, resolve to min alt
347
- dfaState->prediction = altsToCollectPredsFrom.nextSetBit(0);
348
- }
349
- }
350
-
351
- size_t ParserATNSimulator::execATNWithFullContext(dfa::DFA &dfa, dfa::DFAState *D, ATNConfigSet *s0,
352
- TokenStream *input, size_t startIndex, ParserRuleContext *outerContext) {
353
-
354
- #if TRACE_ATN_SIM == 1
355
- std::cout << "execATNWithFullContext " << s0->toString() << std::endl;
356
- #endif
357
-
358
- bool fullCtx = true;
359
- bool foundExactAmbig = false;
360
-
361
- std::unique_ptr<ATNConfigSet> reach;
362
- ATNConfigSet *previous = s0;
363
- input->seek(startIndex);
364
- size_t t = input->LA(1);
365
- size_t predictedAlt;
366
-
367
- while (true) {
368
- reach = computeReachSet(previous, t, fullCtx);
369
- if (reach == nullptr) {
370
- // if any configs in previous dipped into outer context, that
371
- // means that input up to t actually finished entry rule
372
- // at least for LL decision. Full LL doesn't dip into outer
373
- // so don't need special case.
374
- // We will get an error no matter what so delay until after
375
- // decision; better error message. Also, no reachable target
376
- // ATN states in SLL implies LL will also get nowhere.
377
- // If conflict in states that dip out, choose min since we
378
- // will get error no matter what.
379
- NoViableAltException e = noViableAlt(input, outerContext, previous, startIndex, previous != s0);
380
- input->seek(startIndex);
381
- size_t alt = getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(previous, outerContext);
382
- if (alt != ATN::INVALID_ALT_NUMBER) {
383
- return alt;
384
- }
385
- throw e;
386
- }
387
- if (previous != s0) // Don't delete the start set.
388
- delete previous;
389
- previous = nullptr;
390
-
391
- std::vector<BitSet> altSubSets = PredictionModeClass::getConflictingAltSubsets(reach.get());
392
- reach->uniqueAlt = getUniqueAlt(reach.get());
393
- // unique prediction?
394
- if (reach->uniqueAlt != ATN::INVALID_ALT_NUMBER) {
395
- predictedAlt = reach->uniqueAlt;
396
- break;
397
- }
398
- if (_mode != PredictionMode::LL_EXACT_AMBIG_DETECTION) {
399
- predictedAlt = PredictionModeClass::resolvesToJustOneViableAlt(altSubSets);
400
- if (predictedAlt != ATN::INVALID_ALT_NUMBER) {
401
- break;
402
- }
403
- } else {
404
- // In exact ambiguity mode, we never try to terminate early.
405
- // Just keeps scarfing until we know what the conflict is
406
- if (PredictionModeClass::allSubsetsConflict(altSubSets) && PredictionModeClass::allSubsetsEqual(altSubSets)) {
407
- foundExactAmbig = true;
408
- predictedAlt = PredictionModeClass::getSingleViableAlt(altSubSets);
409
- break;
410
- }
411
- // else there are multiple non-conflicting subsets or
412
- // we're not sure what the ambiguity is yet.
413
- // So, keep going.
414
- }
415
- previous = reach.release();
416
-
417
- if (t != Token::EOF) {
418
- input->consume();
419
- t = input->LA(1);
420
- }
421
- }
422
-
423
- // If the configuration set uniquely predicts an alternative,
424
- // without conflict, then we know that it's a full LL decision
425
- // not SLL.
426
- if (reach->uniqueAlt != ATN::INVALID_ALT_NUMBER) {
427
- reportContextSensitivity(dfa, predictedAlt, reach.get(), startIndex, input->index());
428
- return predictedAlt;
429
- }
430
-
431
- // We do not check predicates here because we have checked them
432
- // on-the-fly when doing full context prediction.
433
-
434
- /*
435
- In non-exact ambiguity detection mode, we might actually be able to
436
- detect an exact ambiguity, but I'm not going to spend the cycles
437
- needed to check. We only emit ambiguity warnings in exact ambiguity
438
- mode.
439
-
440
- For example, we might know that we have conflicting configurations.
441
- But, that does not mean that there is no way forward without a
442
- conflict. It's possible to have nonconflicting alt subsets as in:
443
-
444
- LL altSubSets=[{1, 2}, {1, 2}, {1}, {1, 2}]
445
-
446
- from
447
-
448
- [(17,1,[5 $]), (13,1,[5 10 $]), (21,1,[5 10 $]), (11,1,[$]),
449
- (13,2,[5 10 $]), (21,2,[5 10 $]), (11,2,[$])]
450
-
451
- In this case, (17,1,[5 $]) indicates there is some next sequence that
452
- would resolve this without conflict to alternative 1. Any other viable
453
- next sequence, however, is associated with a conflict. We stop
454
- looking for input because no amount of further lookahead will alter
455
- the fact that we should predict alternative 1. We just can't say for
456
- sure that there is an ambiguity without looking further.
457
- */
458
- reportAmbiguity(dfa, D, startIndex, input->index(), foundExactAmbig, reach->getAlts(), reach.get());
459
-
460
- return predictedAlt;
461
- }
462
-
463
- std::unique_ptr<ATNConfigSet> ParserATNSimulator::computeReachSet(ATNConfigSet *closure_, size_t t, bool fullCtx) {
464
-
465
- std::unique_ptr<ATNConfigSet> intermediate(new ATNConfigSet(fullCtx));
466
-
467
- /* Configurations already in a rule stop state indicate reaching the end
468
- * of the decision rule (local context) or end of the start rule (full
469
- * context). Once reached, these configurations are never updated by a
470
- * closure operation, so they are handled separately for the performance
471
- * advantage of having a smaller intermediate set when calling closure.
472
- *
473
- * For full-context reach operations, separate handling is required to
474
- * ensure that the alternative matching the longest overall sequence is
475
- * chosen when multiple such configurations can match the input.
476
- */
477
- std::vector<Ref<ATNConfig>> skippedStopStates;
478
-
479
- // First figure out where we can reach on input t
480
- for (const auto &c : closure_->configs) {
481
- if (RuleStopState::is(c->state)) {
482
- assert(c->context->isEmpty());
483
-
484
- if (fullCtx || t == Token::EOF) {
485
- skippedStopStates.push_back(c);
486
- }
487
-
488
- continue;
489
- }
490
-
491
- size_t n = c->state->transitions.size();
492
- for (size_t ti = 0; ti < n; ti++) { // for each transition
493
- const Transition *trans = c->state->transitions[ti].get();
494
- ATNState *target = getReachableTarget(trans, (int)t);
495
- if (target != nullptr) {
496
- intermediate->add(std::make_shared<ATNConfig>(*c, target), &mergeCache);
497
- }
498
- }
499
- }
500
-
501
- // Now figure out where the reach operation can take us...
502
- std::unique_ptr<ATNConfigSet> reach;
503
-
504
- /* This block optimizes the reach operation for intermediate sets which
505
- * trivially indicate a termination state for the overall
506
- * adaptivePredict operation.
507
- *
508
- * The conditions assume that intermediate
509
- * contains all configurations relevant to the reach set, but this
510
- * condition is not true when one or more configurations have been
511
- * withheld in skippedStopStates, or when the current symbol is EOF.
512
- */
513
- if (skippedStopStates.empty() && t != Token::EOF) {
514
- if (intermediate->size() == 1) {
515
- // Don't pursue the closure if there is just one state.
516
- // It can only have one alternative; just add to result
517
- // Also don't pursue the closure if there is unique alternative
518
- // among the configurations.
519
- reach = std::move(intermediate);
520
- } else if (getUniqueAlt(intermediate.get()) != ATN::INVALID_ALT_NUMBER) {
521
- // Also don't pursue the closure if there is unique alternative
522
- // among the configurations.
523
- reach = std::move(intermediate);
524
- }
525
- }
526
-
527
- /* If the reach set could not be trivially determined, perform a closure
528
- * operation on the intermediate set to compute its initial value.
529
- */
530
- if (reach == nullptr) {
531
- reach.reset(new ATNConfigSet(fullCtx));
532
- ATNConfig::Set closureBusy;
533
-
534
- bool treatEofAsEpsilon = t == Token::EOF;
535
- for (const auto &c : intermediate->configs) {
536
- closure(c, reach.get(), closureBusy, false, fullCtx, treatEofAsEpsilon);
537
- }
538
- }
539
-
540
- if (t == IntStream::EOF) {
541
- /* After consuming EOF no additional input is possible, so we are
542
- * only interested in configurations which reached the end of the
543
- * decision rule (local context) or end of the start rule (full
544
- * context). Update reach to contain only these configurations. This
545
- * handles both explicit EOF transitions in the grammar and implicit
546
- * EOF transitions following the end of the decision or start rule.
547
- *
548
- * When reach==intermediate, no closure operation was performed. In
549
- * this case, removeAllConfigsNotInRuleStopState needs to check for
550
- * reachable rule stop states as well as configurations already in
551
- * a rule stop state.
552
- *
553
- * This is handled before the configurations in skippedStopStates,
554
- * because any configurations potentially added from that list are
555
- * already guaranteed to meet this condition whether or not it's
556
- * required.
557
- */
558
- ATNConfigSet *temp = removeAllConfigsNotInRuleStopState(reach.get(), *reach == *intermediate);
559
- if (temp != reach.get())
560
- reach.reset(temp); // We got a new set, so use that.
561
- }
562
-
563
- /* If skippedStopStates is not null, then it contains at least one
564
- * configuration. For full-context reach operations, these
565
- * configurations reached the end of the start rule, in which case we
566
- * only add them back to reach if no configuration during the current
567
- * closure operation reached such a state. This ensures adaptivePredict
568
- * chooses an alternative matching the longest overall sequence when
569
- * multiple alternatives are viable.
570
- */
571
- if (skippedStopStates.size() > 0 && (!fullCtx || !PredictionModeClass::hasConfigInRuleStopState(reach.get()))) {
572
- assert(!skippedStopStates.empty());
573
-
574
- for (const auto &c : skippedStopStates) {
575
- reach->add(c, &mergeCache);
576
- }
577
- }
578
-
579
- #if DEBUG_ATN == 1 || TRACE_ATN_SIM == 1
580
- std::cout << "computeReachSet " << closure_->toString() << " -> " << reach->toString() << std::endl;
581
- #endif
582
-
583
- if (reach->isEmpty()) {
584
- return nullptr;
585
- }
586
- return reach;
587
- }
588
-
589
- ATNConfigSet* ParserATNSimulator::removeAllConfigsNotInRuleStopState(ATNConfigSet *configs,
590
- bool lookToEndOfRule) {
591
- if (PredictionModeClass::allConfigsInRuleStopStates(configs)) {
592
- return configs;
593
- }
594
-
595
- ATNConfigSet *result = new ATNConfigSet(configs->fullCtx); /* mem-check: released by caller */
596
-
597
- for (const auto &config : configs->configs) {
598
- if (config->state != nullptr && config->state->getStateType() == ATNStateType::RULE_STOP) {
599
- result->add(config, &mergeCache);
600
- continue;
601
- }
602
-
603
- if (lookToEndOfRule && config->state->epsilonOnlyTransitions) {
604
- misc::IntervalSet nextTokens = atn.nextTokens(config->state);
605
- if (nextTokens.contains(Token::EPSILON)) {
606
- ATNState *endOfRuleState = atn.ruleToStopState[config->state->ruleIndex];
607
- result->add(std::make_shared<ATNConfig>(*config, endOfRuleState), &mergeCache);
608
- }
609
- }
610
- }
611
-
612
- return result;
613
- }
614
-
615
- std::unique_ptr<ATNConfigSet> ParserATNSimulator::computeStartState(ATNState *p, RuleContext *ctx, bool fullCtx) {
616
- // always at least the implicit call to start rule
617
- Ref<const PredictionContext> initialContext = PredictionContext::fromRuleContext(atn, ctx);
618
- std::unique_ptr<ATNConfigSet> configs(new ATNConfigSet(fullCtx));
619
-
620
- #if DEBUG_ATN == 1 || TRACE_ATN_SIM == 1
621
- std::cout << "computeStartState from ATN state " << p->toString() << " initialContext=" << initialContext->toString() << std::endl;
622
- #endif
623
-
624
- for (size_t i = 0; i < p->transitions.size(); i++) {
625
- ATNState *target = p->transitions[i]->target;
626
- Ref<ATNConfig> c = std::make_shared<ATNConfig>(target, (int)i + 1, initialContext);
627
- ATNConfig::Set closureBusy;
628
- closure(c, configs.get(), closureBusy, true, fullCtx, false);
629
- }
630
-
631
- return configs;
632
- }
633
-
634
- std::unique_ptr<ATNConfigSet> ParserATNSimulator::applyPrecedenceFilter(ATNConfigSet *configs) {
635
- std::map<size_t, Ref<const PredictionContext>> statesFromAlt1;
636
- std::unique_ptr<ATNConfigSet> configSet(new ATNConfigSet(configs->fullCtx));
637
- for (const auto &config : configs->configs) {
638
- // handle alt 1 first
639
- if (config->alt != 1) {
640
- continue;
641
- }
642
-
643
- Ref<const SemanticContext> updatedContext = config->semanticContext->evalPrecedence(parser, _outerContext);
644
- if (updatedContext == nullptr) {
645
- // the configuration was eliminated
646
- continue;
647
- }
648
-
649
- statesFromAlt1[config->state->stateNumber] = config->context;
650
- if (updatedContext != config->semanticContext) {
651
- configSet->add(std::make_shared<ATNConfig>(*config, updatedContext), &mergeCache);
652
- }
653
- else {
654
- configSet->add(config, &mergeCache);
655
- }
656
- }
657
-
658
- for (const auto &config : configs->configs) {
659
- if (config->alt == 1) {
660
- // already handled
661
- continue;
662
- }
663
-
664
- if (!config->isPrecedenceFilterSuppressed()) {
665
- /* In the future, this elimination step could be updated to also
666
- * filter the prediction context for alternatives predicting alt>1
667
- * (basically a graph subtraction algorithm).
668
- */
669
- auto iterator = statesFromAlt1.find(config->state->stateNumber);
670
- if (iterator != statesFromAlt1.end() && *iterator->second == *config->context) {
671
- // eliminated
672
- continue;
673
- }
674
- }
675
-
676
- configSet->add(config, &mergeCache);
677
- }
678
-
679
- return configSet;
680
- }
681
-
682
- atn::ATNState* ParserATNSimulator::getReachableTarget(const Transition *trans, size_t ttype) {
683
- if (trans->matches(ttype, 0, atn.maxTokenType)) {
684
- return trans->target;
685
- }
686
-
687
- return nullptr;
688
- }
689
-
690
- // Note that caller must memory manage the returned value from this function
691
- std::vector<Ref<const SemanticContext>> ParserATNSimulator::getPredsForAmbigAlts(const BitSet &ambigAlts,
692
- ATNConfigSet *configs, size_t nalts) {
693
- // REACH=[1|1|[]|0:0, 1|2|[]|0:1]
694
- /* altToPred starts as an array of all null contexts. The entry at index i
695
- * corresponds to alternative i. altToPred[i] may have one of three values:
696
- * 1. null: no ATNConfig c is found such that c.alt==i
697
- * 2. SemanticContext.NONE: At least one ATNConfig c exists such that
698
- * c.alt==i and c.semanticContext==SemanticContext.NONE. In other words,
699
- * alt i has at least one un-predicated config.
700
- * 3. Non-NONE Semantic Context: There exists at least one, and for all
701
- * ATNConfig c such that c.alt==i, c.semanticContext!=SemanticContext.NONE.
702
- *
703
- * From this, it is clear that NONE||anything==NONE.
704
- */
705
- std::vector<Ref<const SemanticContext>> altToPred(nalts + 1);
706
-
707
- for (const auto &c : configs->configs) {
708
- if (ambigAlts.test(c->alt)) {
709
- altToPred[c->alt] = SemanticContext::Or(altToPred[c->alt], c->semanticContext);
710
- }
711
- }
712
-
713
- size_t nPredAlts = 0;
714
- for (size_t i = 1; i <= nalts; i++) {
715
- if (altToPred[i] == nullptr) {
716
- altToPred[i] = SemanticContext::Empty::Instance;
717
- } else if (altToPred[i] != SemanticContext::Empty::Instance) {
718
- nPredAlts++;
719
- }
720
- }
721
-
722
- // nonambig alts are null in altToPred
723
- if (nPredAlts == 0) {
724
- altToPred.clear();
725
- }
726
- #if DEBUG_ATN == 1
727
- std::cout << "getPredsForAmbigAlts result " << Arrays::toString(altToPred) << std::endl;
728
- #endif
729
-
730
- return altToPred;
731
- }
732
-
733
- std::vector<dfa::DFAState::PredPrediction> ParserATNSimulator::getPredicatePredictions(const antlrcpp::BitSet &ambigAlts,
734
- const std::vector<Ref<const SemanticContext>> &altToPred) {
735
- bool containsPredicate = std::find_if(altToPred.begin(), altToPred.end(), [](const Ref<const SemanticContext> &context) {
736
- return context != SemanticContext::Empty::Instance;
737
- }) != altToPred.end();
738
- std::vector<dfa::DFAState::PredPrediction> pairs;
739
- if (containsPredicate) {
740
- for (size_t i = 1; i < altToPred.size(); i++) {
741
- const auto &pred = altToPred[i];
742
- assert(pred != nullptr); // unpredicted is indicated by SemanticContext.NONE
743
- if (ambigAlts.test(i)) {
744
- pairs.emplace_back(pred, static_cast<int>(i));
745
- }
746
- }
747
- }
748
- return pairs;
749
- }
750
-
751
- size_t ParserATNSimulator::getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(ATNConfigSet *configs,
752
- ParserRuleContext *outerContext)
753
- {
754
- std::pair<ATNConfigSet *, ATNConfigSet *> sets = splitAccordingToSemanticValidity(configs, outerContext);
755
- std::unique_ptr<ATNConfigSet> semValidConfigs(sets.first);
756
- std::unique_ptr<ATNConfigSet> semInvalidConfigs(sets.second);
757
- size_t alt = getAltThatFinishedDecisionEntryRule(semValidConfigs.get());
758
- if (alt != ATN::INVALID_ALT_NUMBER) { // semantically/syntactically viable path exists
759
- return alt;
760
- }
761
- // Is there a syntactically valid path with a failed pred?
762
- if (!semInvalidConfigs->configs.empty()) {
763
- alt = getAltThatFinishedDecisionEntryRule(semInvalidConfigs.get());
764
- if (alt != ATN::INVALID_ALT_NUMBER) { // syntactically viable path exists
765
- return alt;
766
- }
767
- }
768
- return ATN::INVALID_ALT_NUMBER;
769
- }
770
-
771
- size_t ParserATNSimulator::getAltThatFinishedDecisionEntryRule(ATNConfigSet *configs) {
772
- misc::IntervalSet alts;
773
- for (const auto &c : configs->configs) {
774
- if (c->getOuterContextDepth() > 0 || (c->state != nullptr && c->state->getStateType() == ATNStateType::RULE_STOP && c->context->hasEmptyPath())) {
775
- alts.add(c->alt);
776
- }
777
- }
778
- if (alts.size() == 0) {
779
- return ATN::INVALID_ALT_NUMBER;
780
- }
781
- return alts.getMinElement();
782
- }
783
-
784
- std::pair<ATNConfigSet *, ATNConfigSet *> ParserATNSimulator::splitAccordingToSemanticValidity(ATNConfigSet *configs,
785
- ParserRuleContext *outerContext) {
786
-
787
- // mem-check: both pointers must be freed by the caller.
788
- ATNConfigSet *succeeded(new ATNConfigSet(configs->fullCtx));
789
- ATNConfigSet *failed(new ATNConfigSet(configs->fullCtx));
790
- for (const auto &c : configs->configs) {
791
- if (c->semanticContext != SemanticContext::Empty::Instance) {
792
- bool predicateEvaluationResult = evalSemanticContext(c->semanticContext, outerContext, c->alt, configs->fullCtx);
793
- if (predicateEvaluationResult) {
794
- succeeded->add(c);
795
- } else {
796
- failed->add(c);
797
- }
798
- } else {
799
- succeeded->add(c);
800
- }
801
- }
802
- return { succeeded, failed };
803
- }
804
-
805
- BitSet ParserATNSimulator::evalSemanticContext(const std::vector<dfa::DFAState::PredPrediction> &predPredictions,
806
- ParserRuleContext *outerContext, bool complete) {
807
- BitSet predictions;
808
- for (const auto &prediction : predPredictions) {
809
- if (prediction.pred == SemanticContext::Empty::Instance) {
810
- predictions.set(prediction.alt);
811
- if (!complete) {
812
- break;
813
- }
814
- continue;
815
- }
816
-
817
- bool fullCtx = false; // in dfa
818
- bool predicateEvaluationResult = evalSemanticContext(prediction.pred, outerContext, prediction.alt, fullCtx);
819
- #if DEBUG_ATN == 1 || DFA_DEBUG == 1
820
- std::cout << "eval pred " << prediction.toString() << " = " << predicateEvaluationResult << std::endl;
821
- #endif
822
-
823
- if (predicateEvaluationResult) {
824
- #if DEBUG_ATN == 1 || DFA_DEBUG == 1
825
- std::cout << "PREDICT " << prediction.alt << std::endl;
826
- #endif
827
-
828
- predictions.set(prediction.alt);
829
- if (!complete) {
830
- break;
831
- }
832
- }
833
- }
834
-
835
- return predictions;
836
- }
837
-
838
- bool ParserATNSimulator::evalSemanticContext(Ref<const SemanticContext> const& pred, ParserRuleContext *parserCallStack,
839
- size_t /*alt*/, bool /*fullCtx*/) {
840
- return pred->eval(parser, parserCallStack);
841
- }
842
-
843
- void ParserATNSimulator::closure(Ref<ATNConfig> const& config, ATNConfigSet *configs, ATNConfig::Set &closureBusy,
844
- bool collectPredicates, bool fullCtx, bool treatEofAsEpsilon) {
845
- const int initialDepth = 0;
846
- closureCheckingStopState(config, configs, closureBusy, collectPredicates, fullCtx, initialDepth, treatEofAsEpsilon);
847
-
848
- assert(!fullCtx || !configs->dipsIntoOuterContext);
849
- }
850
-
851
- void ParserATNSimulator::closureCheckingStopState(Ref<ATNConfig> const& config, ATNConfigSet *configs,
852
- ATNConfig::Set &closureBusy, bool collectPredicates, bool fullCtx, int depth, bool treatEofAsEpsilon) {
853
-
854
- #if TRACE_ATN_SIM == 1
855
- std::cout << "closure(" << config->toString(true) << ")" << std::endl;
856
- #endif
857
-
858
- if (config->state != nullptr && config->state->getStateType() == ATNStateType::RULE_STOP) {
859
- // We hit rule end. If we have context info, use it
860
- // run thru all possible stack tops in ctx
861
- if (!config->context->isEmpty()) {
862
- for (size_t i = 0; i < config->context->size(); i++) {
863
- if (config->context->getReturnState(i) == PredictionContext::EMPTY_RETURN_STATE) {
864
- if (fullCtx) {
865
- configs->add(std::make_shared<ATNConfig>(*config, config->state, PredictionContext::EMPTY), &mergeCache);
866
- continue;
867
- } else {
868
- // we have no context info, just chase follow links (if greedy)
869
- #if DEBUG_ATN == 1
870
- std::cout << "FALLING off rule " << getRuleName(config->state->ruleIndex) << std::endl;
871
- #endif
872
- closure_(config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEofAsEpsilon);
873
- }
874
- continue;
875
- }
876
- ATNState *returnState = atn.states[config->context->getReturnState(i)];
877
- Ref<const PredictionContext> newContext = config->context->getParent(i); // "pop" return state
878
- Ref<ATNConfig> c = std::make_shared<ATNConfig>(returnState, config->alt, newContext, config->semanticContext);
879
- // While we have context to pop back from, we may have
880
- // gotten that context AFTER having falling off a rule.
881
- // Make sure we track that we are now out of context.
882
- //
883
- // This assignment also propagates the
884
- // isPrecedenceFilterSuppressed() value to the new
885
- // configuration.
886
- c->reachesIntoOuterContext = config->reachesIntoOuterContext;
887
- assert(depth > INT_MIN);
888
-
889
- closureCheckingStopState(c, configs, closureBusy, collectPredicates, fullCtx, depth - 1, treatEofAsEpsilon);
890
- }
891
- return;
892
- } else if (fullCtx) {
893
- // reached end of start rule
894
- configs->add(config, &mergeCache);
895
- return;
896
- } else {
897
- // else if we have no context info, just chase follow links (if greedy)
898
- }
899
- }
900
-
901
- closure_(config, configs, closureBusy, collectPredicates, fullCtx, depth, treatEofAsEpsilon);
902
- }
903
-
904
- void ParserATNSimulator::closure_(Ref<ATNConfig> const& config, ATNConfigSet *configs, ATNConfig::Set &closureBusy,
905
- bool collectPredicates, bool fullCtx, int depth, bool treatEofAsEpsilon) {
906
- ATNState *p = config->state;
907
- // optimization
908
- if (!p->epsilonOnlyTransitions) {
909
- // make sure to not return here, because EOF transitions can act as
910
- // both epsilon transitions and non-epsilon transitions.
911
- configs->add(config, &mergeCache);
912
- }
913
-
914
- for (size_t i = 0; i < p->transitions.size(); i++) {
915
- if (i == 0 && canDropLoopEntryEdgeInLeftRecursiveRule(config.get()))
916
- continue;
917
-
918
- const Transition *t = p->transitions[i].get();
919
- bool continueCollecting = !(t != nullptr && t->getTransitionType() == TransitionType::ACTION) && collectPredicates;
920
- Ref<ATNConfig> c = getEpsilonTarget(config, t, continueCollecting, depth == 0, fullCtx, treatEofAsEpsilon);
921
- if (c != nullptr) {
922
- int newDepth = depth;
923
- if (config->state != nullptr && config->state->getStateType() == ATNStateType::RULE_STOP) {
924
- assert(!fullCtx);
925
-
926
- // target fell off end of rule; mark resulting c as having dipped into outer context
927
- // We can't get here if incoming config was rule stop and we had context
928
- // track how far we dip into outer context. Might
929
- // come in handy and we avoid evaluating context dependent
930
- // preds if this is > 0.
931
-
932
- if (closureBusy.count(c) > 0) {
933
- // avoid infinite recursion for right-recursive rules
934
- continue;
935
- }
936
- closureBusy.insert(c);
937
-
938
- if (_dfa != nullptr && _dfa->isPrecedenceDfa()) {
939
- size_t outermostPrecedenceReturn = downCast<const EpsilonTransition *>(t)->outermostPrecedenceReturn();
940
- if (outermostPrecedenceReturn == _dfa->atnStartState->ruleIndex) {
941
- c->setPrecedenceFilterSuppressed(true);
942
- }
943
- }
944
-
945
- c->reachesIntoOuterContext++;
946
-
947
- if (!t->isEpsilon()) {
948
- // avoid infinite recursion for EOF* and EOF+
949
- if (closureBusy.count(c) == 0) {
950
- closureBusy.insert(c);
951
- } else {
952
- continue;
953
- }
954
- }
955
-
956
- configs->dipsIntoOuterContext = true; // TODO: can remove? only care when we add to set per middle of this method
957
- assert(newDepth > INT_MIN);
958
-
959
- newDepth--;
960
- #if DFA_DEBUG == 1
961
- std::cout << "dips into outer ctx: " << c << std::endl;
962
- #endif
963
-
964
- } else if (!t->isEpsilon()) {
965
- // avoid infinite recursion for EOF* and EOF+
966
- if (closureBusy.count(c) == 0) {
967
- closureBusy.insert(c);
968
- } else {
969
- continue;
970
- }
971
- }
972
-
973
- if (t != nullptr && t->getTransitionType() == TransitionType::RULE) {
974
- // latch when newDepth goes negative - once we step out of the entry context we can't return
975
- if (newDepth >= 0) {
976
- newDepth++;
977
- }
978
- }
979
-
980
- closureCheckingStopState(c, configs, closureBusy, continueCollecting, fullCtx, newDepth, treatEofAsEpsilon);
981
- }
982
- }
983
- }
984
-
985
- bool ParserATNSimulator::canDropLoopEntryEdgeInLeftRecursiveRule(ATNConfig *config) const {
986
- if (TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT)
987
- return false;
988
-
989
- ATNState *p = config->state;
990
-
991
- // First check to see if we are in StarLoopEntryState generated during
992
- // left-recursion elimination. For efficiency, also check if
993
- // the context has an empty stack case. If so, it would mean
994
- // global FOLLOW so we can't perform optimization
995
- if (p->getStateType() != ATNStateType::STAR_LOOP_ENTRY ||
996
- !((StarLoopEntryState *)p)->isPrecedenceDecision || // Are we the special loop entry/exit state?
997
- config->context->isEmpty() || // If SLL wildcard
998
- config->context->hasEmptyPath())
999
- {
1000
- return false;
1001
- }
1002
-
1003
- // Require all return states to return back to the same rule
1004
- // that p is in.
1005
- size_t numCtxs = config->context->size();
1006
- for (size_t i = 0; i < numCtxs; i++) { // for each stack context
1007
- ATNState *returnState = atn.states[config->context->getReturnState(i)];
1008
- if (returnState->ruleIndex != p->ruleIndex)
1009
- return false;
1010
- }
1011
-
1012
- BlockStartState *decisionStartState = (BlockStartState *)p->transitions[0]->target;
1013
- size_t blockEndStateNum = decisionStartState->endState->stateNumber;
1014
- BlockEndState *blockEndState = (BlockEndState *)atn.states[blockEndStateNum];
1015
-
1016
- // Verify that the top of each stack context leads to loop entry/exit
1017
- // state through epsilon edges and w/o leaving rule.
1018
- for (size_t i = 0; i < numCtxs; i++) { // for each stack context
1019
- size_t returnStateNumber = config->context->getReturnState(i);
1020
- ATNState *returnState = atn.states[returnStateNumber];
1021
- // All states must have single outgoing epsilon edge.
1022
- if (returnState->transitions.size() != 1 || !returnState->transitions[0]->isEpsilon())
1023
- {
1024
- return false;
1025
- }
1026
-
1027
- // Look for prefix op case like 'not expr', (' type ')' expr
1028
- ATNState *returnStateTarget = returnState->transitions[0]->target;
1029
- if (returnState->getStateType() == ATNStateType::BLOCK_END && returnStateTarget == p) {
1030
- continue;
1031
- }
1032
-
1033
- // Look for 'expr op expr' or case where expr's return state is block end
1034
- // of (...)* internal block; the block end points to loop back
1035
- // which points to p but we don't need to check that
1036
- if (returnState == blockEndState) {
1037
- continue;
1038
- }
1039
-
1040
- // Look for ternary expr ? expr : expr. The return state points at block end,
1041
- // which points at loop entry state
1042
- if (returnStateTarget == blockEndState) {
1043
- continue;
1044
- }
1045
-
1046
- // Look for complex prefix 'between expr and expr' case where 2nd expr's
1047
- // return state points at block end state of (...)* internal block
1048
- if (returnStateTarget->getStateType() == ATNStateType::BLOCK_END &&
1049
- returnStateTarget->transitions.size() == 1 &&
1050
- returnStateTarget->transitions[0]->isEpsilon() &&
1051
- returnStateTarget->transitions[0]->target == p)
1052
- {
1053
- continue;
1054
- }
1055
-
1056
- // Anything else ain't conforming.
1057
- return false;
1058
- }
1059
-
1060
- return true;
1061
- }
1062
-
1063
- std::string ParserATNSimulator::getRuleName(size_t index) {
1064
- if (parser != nullptr) {
1065
- return parser->getRuleNames()[index];
1066
- }
1067
- return "<rule " + std::to_string(index) + ">";
1068
- }
1069
-
1070
- Ref<ATNConfig> ParserATNSimulator::getEpsilonTarget(Ref<ATNConfig> const& config, const Transition *t, bool collectPredicates,
1071
- bool inContext, bool fullCtx, bool treatEofAsEpsilon) {
1072
- switch (t->getTransitionType()) {
1073
- case TransitionType::RULE:
1074
- return ruleTransition(config, static_cast<const RuleTransition*>(t));
1075
-
1076
- case TransitionType::PRECEDENCE:
1077
- return precedenceTransition(config, static_cast<const PrecedencePredicateTransition*>(t), collectPredicates, inContext, fullCtx);
1078
-
1079
- case TransitionType::PREDICATE:
1080
- return predTransition(config, static_cast<const PredicateTransition*>(t), collectPredicates, inContext, fullCtx);
1081
-
1082
- case TransitionType::ACTION:
1083
- return actionTransition(config, static_cast<const ActionTransition*>(t));
1084
-
1085
- case TransitionType::EPSILON:
1086
- return std::make_shared<ATNConfig>(*config, t->target);
1087
-
1088
- case TransitionType::ATOM:
1089
- case TransitionType::RANGE:
1090
- case TransitionType::SET:
1091
- // EOF transitions act like epsilon transitions after the first EOF
1092
- // transition is traversed
1093
- if (treatEofAsEpsilon) {
1094
- if (t->matches(Token::EOF, 0, 1)) {
1095
- return std::make_shared<ATNConfig>(*config, t->target);
1096
- }
1097
- }
1098
-
1099
- return nullptr;
1100
-
1101
- default:
1102
- return nullptr;
1103
- }
1104
- }
1105
-
1106
- Ref<ATNConfig> ParserATNSimulator::actionTransition(Ref<ATNConfig> const& config, const ActionTransition *t) {
1107
- #if DFA_DEBUG == 1
1108
- std::cout << "ACTION edge " << t->ruleIndex << ":" << t->actionIndex << std::endl;
1109
- #endif
1110
-
1111
- return std::make_shared<ATNConfig>(*config, t->target);
1112
- }
1113
-
1114
- Ref<ATNConfig> ParserATNSimulator::precedenceTransition(Ref<ATNConfig> const& config, const PrecedencePredicateTransition *pt,
1115
- bool collectPredicates, bool inContext, bool fullCtx) {
1116
- #if DFA_DEBUG == 1
1117
- std::cout << "PRED (collectPredicates=" << collectPredicates << ") " << pt->getPrecedence() << ">=_p" << ", ctx dependent=true" << std::endl;
1118
- if (parser != nullptr) {
1119
- std::cout << "context surrounding pred is " << Arrays::listToString(parser->getRuleInvocationStack(), ", ") << std::endl;
1120
- }
1121
- #endif
1122
-
1123
- Ref<ATNConfig> c;
1124
- if (collectPredicates && inContext) {
1125
- const auto &predicate = pt->getPredicate();
1126
-
1127
- if (fullCtx) {
1128
- // In full context mode, we can evaluate predicates on-the-fly
1129
- // during closure, which dramatically reduces the size of
1130
- // the config sets. It also obviates the need to test predicates
1131
- // later during conflict resolution.
1132
- size_t currentPosition = _input->index();
1133
- _input->seek(_startIndex);
1134
- bool predSucceeds = evalSemanticContext(predicate, _outerContext, config->alt, fullCtx);
1135
- _input->seek(currentPosition);
1136
- if (predSucceeds) {
1137
- c = std::make_shared<ATNConfig>(*config, pt->target); // no pred context
1138
- }
1139
- } else {
1140
- Ref<const SemanticContext> newSemCtx = SemanticContext::And(config->semanticContext, predicate);
1141
- c = std::make_shared<ATNConfig>(*config, pt->target, std::move(newSemCtx));
1142
- }
1143
- } else {
1144
- c = std::make_shared<ATNConfig>(*config, pt->target);
1145
- }
1146
-
1147
- #if DFA_DEBUG == 1
1148
- std::cout << "config from pred transition=" << c << std::endl;
1149
- #endif
1150
-
1151
- return c;
1152
- }
1153
-
1154
- Ref<ATNConfig> ParserATNSimulator::predTransition(Ref<ATNConfig> const& config, const PredicateTransition *pt,
1155
- bool collectPredicates, bool inContext, bool fullCtx) {
1156
- #if DFA_DEBUG == 1
1157
- std::cout << "PRED (collectPredicates=" << collectPredicates << ") " << pt->getRuleIndex() << ":" << pt->getPredIndex() << ", ctx dependent=" << pt->isCtxDependent() << std::endl;
1158
- if (parser != nullptr) {
1159
- std::cout << "context surrounding pred is " << Arrays::listToString(parser->getRuleInvocationStack(), ", ") << std::endl;
1160
- }
1161
- #endif
1162
-
1163
- Ref<ATNConfig> c = nullptr;
1164
- if (collectPredicates && (!pt->isCtxDependent() || (pt->isCtxDependent() && inContext))) {
1165
- const auto &predicate = pt->getPredicate();
1166
- if (fullCtx) {
1167
- // In full context mode, we can evaluate predicates on-the-fly
1168
- // during closure, which dramatically reduces the size of
1169
- // the config sets. It also obviates the need to test predicates
1170
- // later during conflict resolution.
1171
- size_t currentPosition = _input->index();
1172
- _input->seek(_startIndex);
1173
- bool predSucceeds = evalSemanticContext(predicate, _outerContext, config->alt, fullCtx);
1174
- _input->seek(currentPosition);
1175
- if (predSucceeds) {
1176
- c = std::make_shared<ATNConfig>(*config, pt->target); // no pred context
1177
- }
1178
- } else {
1179
- Ref<const SemanticContext> newSemCtx = SemanticContext::And(config->semanticContext, predicate);
1180
- c = std::make_shared<ATNConfig>(*config, pt->target, std::move(newSemCtx));
1181
- }
1182
- } else {
1183
- c = std::make_shared<ATNConfig>(*config, pt->target);
1184
- }
1185
-
1186
- #if DFA_DEBUG == 1
1187
- std::cout << "config from pred transition=" << c << std::endl;
1188
- #endif
1189
-
1190
- return c;
1191
- }
1192
-
1193
- Ref<ATNConfig> ParserATNSimulator::ruleTransition(Ref<ATNConfig> const& config, const RuleTransition *t) {
1194
- #if DFA_DEBUG == 1
1195
- std::cout << "CALL rule " << getRuleName(t->target->ruleIndex) << ", ctx=" << config->context << std::endl;
1196
- #endif
1197
-
1198
- atn::ATNState *returnState = t->followState;
1199
- Ref<const PredictionContext> newContext = SingletonPredictionContext::create(config->context, returnState->stateNumber);
1200
- return std::make_shared<ATNConfig>(*config, t->target, newContext);
1201
- }
1202
-
1203
- BitSet ParserATNSimulator::getConflictingAlts(ATNConfigSet *configs) {
1204
- std::vector<BitSet> altsets = PredictionModeClass::getConflictingAltSubsets(configs);
1205
- return PredictionModeClass::getAlts(altsets);
1206
- }
1207
-
1208
- BitSet ParserATNSimulator::getConflictingAltsOrUniqueAlt(ATNConfigSet *configs) {
1209
- BitSet conflictingAlts;
1210
- if (configs->uniqueAlt != ATN::INVALID_ALT_NUMBER) {
1211
- conflictingAlts.set(configs->uniqueAlt);
1212
- } else {
1213
- conflictingAlts = configs->conflictingAlts;
1214
- }
1215
- return conflictingAlts;
1216
- }
1217
-
1218
- std::string ParserATNSimulator::getTokenName(size_t t) {
1219
- if (t == Token::EOF) {
1220
- return "EOF";
1221
- }
1222
-
1223
- const dfa::Vocabulary &vocabulary = parser != nullptr ? parser->getVocabulary() : dfa::Vocabulary();
1224
- std::string displayName = vocabulary.getDisplayName(t);
1225
- if (displayName == std::to_string(t)) {
1226
- return displayName;
1227
- }
1228
-
1229
- return displayName + "<" + std::to_string(t) + ">";
1230
- }
1231
-
1232
- std::string ParserATNSimulator::getLookaheadName(TokenStream *input) {
1233
- return getTokenName(input->LA(1));
1234
- }
1235
-
1236
- void ParserATNSimulator::dumpDeadEndConfigs(NoViableAltException &nvae) {
1237
- std::cerr << "dead end configs: ";
1238
- for (const auto &c : nvae.getDeadEndConfigs()->configs) {
1239
- std::string trans = "no edges";
1240
- if (c->state->transitions.size() > 0) {
1241
- const Transition *t = c->state->transitions[0].get();
1242
- if (t != nullptr && t->getTransitionType() == TransitionType::ATOM) {
1243
- const AtomTransition *at = static_cast<const AtomTransition*>(t);
1244
- trans = "Atom " + getTokenName(at->_label);
1245
- } else if (t != nullptr && t->getTransitionType() == TransitionType::SET) {
1246
- const SetTransition *st = static_cast<const SetTransition*>(t);
1247
- trans = "Set ";
1248
- trans += st->set.toString();
1249
- } else if (t != nullptr && t->getTransitionType() == TransitionType::NOT_SET) {
1250
- const SetTransition *st = static_cast<const NotSetTransition*>(t);
1251
- trans = "~Set ";
1252
- trans += st->set.toString();
1253
- }
1254
- }
1255
- std::cerr << c->toString(true) + ":" + trans;
1256
- }
1257
- }
1258
-
1259
- NoViableAltException ParserATNSimulator::noViableAlt(TokenStream *input, ParserRuleContext *outerContext,
1260
- ATNConfigSet *configs, size_t startIndex, bool deleteConfigs) {
1261
- return NoViableAltException(parser, input, input->get(startIndex), input->LT(1), configs, outerContext, deleteConfigs);
1262
- }
1263
-
1264
- size_t ParserATNSimulator::getUniqueAlt(ATNConfigSet *configs) {
1265
- size_t alt = ATN::INVALID_ALT_NUMBER;
1266
- for (const auto &c : configs->configs) {
1267
- if (alt == ATN::INVALID_ALT_NUMBER) {
1268
- alt = c->alt; // found first alt
1269
- } else if (c->alt != alt) {
1270
- return ATN::INVALID_ALT_NUMBER;
1271
- }
1272
- }
1273
- return alt;
1274
- }
1275
-
1276
- dfa::DFAState *ParserATNSimulator::addDFAEdge(dfa::DFA &dfa, dfa::DFAState *from, ssize_t t, dfa::DFAState *to) {
1277
- #if DFA_DEBUG == 1
1278
- std::cout << "EDGE " << from << " -> " << to << " upon " << getTokenName(t) << std::endl;
1279
- #endif
1280
-
1281
- if (to == nullptr) {
1282
- return nullptr;
1283
- }
1284
-
1285
- {
1286
- UniqueLock<SharedMutex> stateLock(atn._stateMutex);
1287
- to = addDFAState(dfa, to); // used existing if possible not incoming
1288
- }
1289
- if (from == nullptr || t > (int)atn.maxTokenType) {
1290
- return to;
1291
- }
1292
-
1293
- {
1294
- UniqueLock<SharedMutex> edgeLock(atn._edgeMutex);
1295
- from->edges[t] = to; // connect
1296
- }
1297
-
1298
- #if DFA_DEBUG == 1
1299
- std::string dfaText;
1300
- if (parser != nullptr) {
1301
- dfaText = dfa.toString(parser->getVocabulary());
1302
- } else {
1303
- dfaText = dfa.toString(dfa::Vocabulary());
1304
- }
1305
- std::cout << "DFA=\n" << dfaText << std::endl;
1306
- #endif
1307
-
1308
- return to;
1309
- }
1310
-
1311
- dfa::DFAState *ParserATNSimulator::addDFAState(dfa::DFA &dfa, dfa::DFAState *D) {
1312
- if (D == ERROR.get()) {
1313
- return D;
1314
- }
1315
-
1316
- // Optimizing the configs below should not alter the hash code. Thus we can just do an insert
1317
- // which will only succeed if an equivalent DFAState does not already exist.
1318
- auto [existing, inserted] = dfa.states.insert(D);
1319
- if (!inserted) {
1320
- #if TRACE_ATN_SIM == 1
1321
- std::cout << "addDFAState " << D->toString() << " exists" << std::endl;
1322
- #endif
1323
- return *existing;
1324
- }
1325
-
1326
- // Previously we did a lookup, then set fields, then inserted. It was `dfa.states.size()`, since
1327
- // we already inserted we need to subtract one.
1328
- D->stateNumber = static_cast<int>(dfa.states.size() - 1);
1329
-
1330
- #if TRACE_ATN_SIM == 1
1331
- std::cout << "addDFAState new " << D->toString() << std::endl;
1332
- #endif
1333
-
1334
- if (!D->configs->isReadonly()) {
1335
- D->configs->optimizeConfigs(this);
1336
- D->configs->setReadonly(true);
1337
- }
1338
-
1339
- #if DFA_DEBUG == 1
1340
- std::cout << "adding new DFA state: " << D << std::endl;
1341
- #endif
1342
-
1343
- return D;
1344
- }
1345
-
1346
- void ParserATNSimulator::reportAttemptingFullContext(dfa::DFA &dfa, const antlrcpp::BitSet &conflictingAlts,
1347
- ATNConfigSet *configs, size_t startIndex, size_t stopIndex) {
1348
- #if DFA_DEBUG == 1 || RETRY_DEBUG == 1
1349
- misc::Interval interval = misc::Interval((int)startIndex, (int)stopIndex);
1350
- std::cout << "reportAttemptingFullContext decision=" << dfa.decision << ":" << configs << ", input=" << parser->getTokenStream()->getText(interval) << std::endl;
1351
- #endif
1352
-
1353
- if (parser != nullptr) {
1354
- parser->getErrorListenerDispatch().reportAttemptingFullContext(parser, dfa, startIndex, stopIndex, conflictingAlts, configs);
1355
- }
1356
- }
1357
-
1358
- void ParserATNSimulator::reportContextSensitivity(dfa::DFA &dfa, size_t prediction, ATNConfigSet *configs,
1359
- size_t startIndex, size_t stopIndex) {
1360
- #if DFA_DEBUG == 1 || RETRY_DEBUG == 1
1361
- misc::Interval interval = misc::Interval(startIndex, stopIndex);
1362
- std::cout << "reportContextSensitivity decision=" << dfa.decision << ":" << configs << ", input=" << parser->getTokenStream()->getText(interval) << std::endl;
1363
- #endif
1364
-
1365
- if (parser != nullptr) {
1366
- parser->getErrorListenerDispatch().reportContextSensitivity(parser, dfa, startIndex, stopIndex, prediction, configs);
1367
- }
1368
- }
1369
-
1370
- void ParserATNSimulator::reportAmbiguity(dfa::DFA &dfa, dfa::DFAState * /*D*/, size_t startIndex, size_t stopIndex,
1371
- bool exact, const antlrcpp::BitSet &ambigAlts, ATNConfigSet *configs) {
1372
- #if DFA_DEBUG == 1 || RETRY_DEBUG == 1
1373
- misc::Interval interval = misc::Interval((int)startIndex, (int)stopIndex);
1374
- std::cout << "reportAmbiguity " << ambigAlts << ":" << configs << ", input=" << parser->getTokenStream()->getText(interval) << std::endl;
1375
- #endif
1376
-
1377
- if (parser != nullptr) {
1378
- parser->getErrorListenerDispatch().reportAmbiguity(parser, dfa, startIndex, stopIndex, exact, ambigAlts, configs);
1379
- }
1380
- }
1381
-
1382
- void ParserATNSimulator::setPredictionMode(PredictionMode newMode) {
1383
- _mode = newMode;
1384
- }
1385
-
1386
- atn::PredictionMode ParserATNSimulator::getPredictionMode() {
1387
- return _mode;
1388
- }
1389
-
1390
- Parser* ParserATNSimulator::getParser() {
1391
- return parser;
1392
- }
1393
-
1394
- #ifdef _MSC_VER
1395
- #pragma warning (disable:4996) // 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead.
1396
- #endif
1397
-
1398
- bool ParserATNSimulator::getLrLoopSetting() {
1399
- char *var = std::getenv("TURN_OFF_LR_LOOP_ENTRY_BRANCH_OPT");
1400
- if (var == nullptr)
1401
- return false;
1402
- std::string value(var);
1403
- return value == "true" || value == "1";
1404
- }
1405
-
1406
- #ifdef _MSC_VER
1407
- #pragma warning (default:4996)
1408
- #endif
1409
-
1410
- void ParserATNSimulator::InitializeInstanceFields() {
1411
- _mode = PredictionMode::LL;
1412
- _startIndex = 0;
1413
- }