expressir 0.2.5-x64-mingw32 → 0.2.11-x64-mingw32

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