antlr4ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.standard.yml +3 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +12 -0
  7. data/Gemfile.lock +65 -0
  8. data/LICENSE +21 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +39 -0
  11. data/Rakefile +10 -0
  12. data/lib/antlr4ruby/atn/action/lexer_action_executor.rb +75 -0
  13. data/lib/antlr4ruby/atn/action/lexer_action_type.rb +6 -0
  14. data/lib/antlr4ruby/atn/action/lexer_channel_action.rb +41 -0
  15. data/lib/antlr4ruby/atn/action/lexer_custom_action.rb +43 -0
  16. data/lib/antlr4ruby/atn/action/lexer_indexed_custom_action.rb +43 -0
  17. data/lib/antlr4ruby/atn/action/lexer_mode_action.rb +45 -0
  18. data/lib/antlr4ruby/atn/action/lexer_more_action.rb +34 -0
  19. data/lib/antlr4ruby/atn/action/lexer_pop_mode_action.rb +32 -0
  20. data/lib/antlr4ruby/atn/action/lexer_push_mode_action.rb +43 -0
  21. data/lib/antlr4ruby/atn/action/lexer_skip_action.rb +33 -0
  22. data/lib/antlr4ruby/atn/action/lexer_type_action.rb +42 -0
  23. data/lib/antlr4ruby/atn/atn.rb +43 -0
  24. data/lib/antlr4ruby/atn/atn_deserialization_options.rb +49 -0
  25. data/lib/antlr4ruby/atn/atn_deserializer.rb +429 -0
  26. data/lib/antlr4ruby/atn/atn_serializer.rb +4 -0
  27. data/lib/antlr4ruby/atn/atn_simulator.rb +36 -0
  28. data/lib/antlr4ruby/atn/atn_type.rb +6 -0
  29. data/lib/antlr4ruby/atn/config/atn_config.rb +46 -0
  30. data/lib/antlr4ruby/atn/config/atn_config_set.rb +5 -0
  31. data/lib/antlr4ruby/atn/config/lexer_atn_config.rb +47 -0
  32. data/lib/antlr4ruby/atn/config/ordered_atn_config_set.rb +4 -0
  33. data/lib/antlr4ruby/atn/context/array_prediction_context.rb +29 -0
  34. data/lib/antlr4ruby/atn/context/empty_prediction_context.rb +36 -0
  35. data/lib/antlr4ruby/atn/context/prediction_context.rb +111 -0
  36. data/lib/antlr4ruby/atn/context/prediction_context_cache.rb +17 -0
  37. data/lib/antlr4ruby/atn/context/semantic_context.rb +74 -0
  38. data/lib/antlr4ruby/atn/context/singleton_prediction_context.rb +36 -0
  39. data/lib/antlr4ruby/atn/info/accept_state_info.rb +26 -0
  40. data/lib/antlr4ruby/atn/info/ambiguity_info.rb +13 -0
  41. data/lib/antlr4ruby/atn/info/conflict_info.rb +39 -0
  42. data/lib/antlr4ruby/atn/info/context_sensitivity_info.rb +10 -0
  43. data/lib/antlr4ruby/atn/info/decision_event_info.rb +14 -0
  44. data/lib/antlr4ruby/atn/info/decision_info.rb +25 -0
  45. data/lib/antlr4ruby/atn/info/error_info.rb +9 -0
  46. data/lib/antlr4ruby/atn/info/lookahead_event_info.rb +12 -0
  47. data/lib/antlr4ruby/atn/info/parse_info.rb +18 -0
  48. data/lib/antlr4ruby/atn/info/predicate_eval_info.rb +5 -0
  49. data/lib/antlr4ruby/atn/lexer_atn_simulator.rb +150 -0
  50. data/lib/antlr4ruby/atn/ll1_analyzer.rb +4 -0
  51. data/lib/antlr4ruby/atn/parser_atn_simulator.rb +4 -0
  52. data/lib/antlr4ruby/atn/prediction_mode.rb +5 -0
  53. data/lib/antlr4ruby/atn/profiling_atn_simulator.rb +5 -0
  54. data/lib/antlr4ruby/atn/state/atn_state.rb +109 -0
  55. data/lib/antlr4ruby/atn/state/basic_block_start_state.rb +12 -0
  56. data/lib/antlr4ruby/atn/state/basic_state.rb +13 -0
  57. data/lib/antlr4ruby/atn/state/block_end_state.rb +13 -0
  58. data/lib/antlr4ruby/atn/state/block_start_state.rb +14 -0
  59. data/lib/antlr4ruby/atn/state/decision_state.rb +17 -0
  60. data/lib/antlr4ruby/atn/state/invalid_state.rb +12 -0
  61. data/lib/antlr4ruby/atn/state/loop_end_state.rb +14 -0
  62. data/lib/antlr4ruby/atn/state/plus_block_start_state.rb +11 -0
  63. data/lib/antlr4ruby/atn/state/plus_loopback_state.rb +10 -0
  64. data/lib/antlr4ruby/atn/state/rule_start_state.rb +10 -0
  65. data/lib/antlr4ruby/atn/state/rule_stop_state.rb +9 -0
  66. data/lib/antlr4ruby/atn/state/simulator_state.rb +17 -0
  67. data/lib/antlr4ruby/atn/state/star_block_start_state.rb +8 -0
  68. data/lib/antlr4ruby/atn/state/star_loop_entry_state.rb +15 -0
  69. data/lib/antlr4ruby/atn/state/star_loopback_state.rb +10 -0
  70. data/lib/antlr4ruby/atn/state/tokens_start_state.rb +10 -0
  71. data/lib/antlr4ruby/atn/transition/abstract_predicate_transition.rb +11 -0
  72. data/lib/antlr4ruby/atn/transition/action_transition.rb +36 -0
  73. data/lib/antlr4ruby/atn/transition/atom_transition.rb +29 -0
  74. data/lib/antlr4ruby/atn/transition/code_point_transitions.rb +7 -0
  75. data/lib/antlr4ruby/atn/transition/epsilon_transition.rb +35 -0
  76. data/lib/antlr4ruby/atn/transition/not_set_transition.rb +23 -0
  77. data/lib/antlr4ruby/atn/transition/precedence_predicate_transition.rb +34 -0
  78. data/lib/antlr4ruby/atn/transition/predicate_transition.rb +29 -0
  79. data/lib/antlr4ruby/atn/transition/range_transition.rb +30 -0
  80. data/lib/antlr4ruby/atn/transition/rule_transition.rb +29 -0
  81. data/lib/antlr4ruby/atn/transition/set_transition.rb +31 -0
  82. data/lib/antlr4ruby/atn/transition/transition.rb +63 -0
  83. data/lib/antlr4ruby/atn/transition/wildcard_transition.rb +21 -0
  84. data/lib/antlr4ruby/bail_error_strategy.rb +28 -0
  85. data/lib/antlr4ruby/base_error_listener.rb +14 -0
  86. data/lib/antlr4ruby/buffered_token_stream.rb +115 -0
  87. data/lib/antlr4ruby/char_streams.rb +34 -0
  88. data/lib/antlr4ruby/code_point_buffer.rb +31 -0
  89. data/lib/antlr4ruby/code_point_char_stream.rb +88 -0
  90. data/lib/antlr4ruby/common_token.rb +113 -0
  91. data/lib/antlr4ruby/common_token_factory.rb +39 -0
  92. data/lib/antlr4ruby/common_token_stream.rb +62 -0
  93. data/lib/antlr4ruby/console_error_listener.rb +10 -0
  94. data/lib/antlr4ruby/default_error_strategy.rb +108 -0
  95. data/lib/antlr4ruby/dfa/dfa.rb +67 -0
  96. data/lib/antlr4ruby/dfa/dfa_serializer.rb +28 -0
  97. data/lib/antlr4ruby/dfa/dfa_state.rb +80 -0
  98. data/lib/antlr4ruby/dfa/lexer_dfa_serializer.rb +12 -0
  99. data/lib/antlr4ruby/diagnostic_error_listener.rb +18 -0
  100. data/lib/antlr4ruby/exception/failed_predicate_exception.rb +27 -0
  101. data/lib/antlr4ruby/exception/input_mismatch_exception.rb +16 -0
  102. data/lib/antlr4ruby/exception/lexer_no_viable_alt_exception.rb +36 -0
  103. data/lib/antlr4ruby/exception/no_viable_alt_exception.rb +29 -0
  104. data/lib/antlr4ruby/exception/parse_cancellation_exception.rb +10 -0
  105. data/lib/antlr4ruby/exception/recognition_exception.rb +55 -0
  106. data/lib/antlr4ruby/int_stream.rb +11 -0
  107. data/lib/antlr4ruby/interpreter_rule_context.rb +19 -0
  108. data/lib/antlr4ruby/lexer.rb +180 -0
  109. data/lib/antlr4ruby/lexer_interpreter.rb +5 -0
  110. data/lib/antlr4ruby/list_token_source.rb +6 -0
  111. data/lib/antlr4ruby/misc/bit_set.rb +9 -0
  112. data/lib/antlr4ruby/misc/double_key_map.rb +28 -0
  113. data/lib/antlr4ruby/misc/integer_stack.rb +9 -0
  114. data/lib/antlr4ruby/misc/murmur_hash.rb +75 -0
  115. data/lib/antlr4ruby/misc/pair.rb +18 -0
  116. data/lib/antlr4ruby/misc/range_set.rb +223 -0
  117. data/lib/antlr4ruby/parser.rb +225 -0
  118. data/lib/antlr4ruby/parser_interpreter.rb +25 -0
  119. data/lib/antlr4ruby/parser_rule_context.rb +161 -0
  120. data/lib/antlr4ruby/proxy_error_listener.rb +33 -0
  121. data/lib/antlr4ruby/recognizer.rb +133 -0
  122. data/lib/antlr4ruby/rule_context.rb +109 -0
  123. data/lib/antlr4ruby/rule_context_with_alt_num.rb +22 -0
  124. data/lib/antlr4ruby/runtime_meta_data.rb +40 -0
  125. data/lib/antlr4ruby/token.rb +10 -0
  126. data/lib/antlr4ruby/token_stream_rewriter.rb +5 -0
  127. data/lib/antlr4ruby/tree/abstract_parse_tree_visitor.rb +56 -0
  128. data/lib/antlr4ruby/tree/error_node.rb +15 -0
  129. data/lib/antlr4ruby/tree/iterative_parse_tree_walker.rb +10 -0
  130. data/lib/antlr4ruby/tree/parse_tree_property.rb +6 -0
  131. data/lib/antlr4ruby/tree/parse_tree_walker.rb +38 -0
  132. data/lib/antlr4ruby/tree/terminal_node.rb +79 -0
  133. data/lib/antlr4ruby/tree/trees.rb +161 -0
  134. data/lib/antlr4ruby/unbuffered_char_stream.rb +7 -0
  135. data/lib/antlr4ruby/unbuffered_token_stream.rb +8 -0
  136. data/lib/antlr4ruby/version.rb +5 -0
  137. data/lib/antlr4ruby/vocabulary.rb +73 -0
  138. data/lib/antlr4ruby.rb +8 -0
  139. data/lib/example/Hello.g4 +9 -0
  140. data/lib/example/hello_lexer.rb +80 -0
  141. data/lib/example/hello_lexer.rbs +37 -0
  142. data/lib/main.rb +14 -0
  143. data/sig/antlr4ruby/antlr_error_listener.rbs +23 -0
  144. data/sig/antlr4ruby/antlr_error_strategy.rbs +13 -0
  145. data/sig/antlr4ruby/atn/action/lexer_action.rbs +10 -0
  146. data/sig/antlr4ruby/atn/action/lexer_action_executor.rbs +22 -0
  147. data/sig/antlr4ruby/atn/action/lexer_action_type.rbs +6 -0
  148. data/sig/antlr4ruby/atn/action/lexer_channel_action.rbs +15 -0
  149. data/sig/antlr4ruby/atn/action/lexer_custom_action.rbs +17 -0
  150. data/sig/antlr4ruby/atn/action/lexer_indexed_custom_action.rbs +19 -0
  151. data/sig/antlr4ruby/atn/action/lexer_mode_action.rbs +16 -0
  152. data/sig/antlr4ruby/atn/action/lexer_more_action.rbs +9 -0
  153. data/sig/antlr4ruby/atn/action/lexer_pop_mode_action.rbs +10 -0
  154. data/sig/antlr4ruby/atn/action/lexer_push_mode_action.rbs +16 -0
  155. data/sig/antlr4ruby/atn/action/lexer_skip_action.rbs +10 -0
  156. data/sig/antlr4ruby/atn/action/lexer_type_action.rbs +12 -0
  157. data/sig/antlr4ruby/atn/atn.rbs +32 -0
  158. data/sig/antlr4ruby/atn/atn_deserialization_options.rbs +27 -0
  159. data/sig/antlr4ruby/atn/atn_deserializer.rbs +26 -0
  160. data/sig/antlr4ruby/atn/atn_serializer.rbs +5 -0
  161. data/sig/antlr4ruby/atn/atn_simulator.rbs +19 -0
  162. data/sig/antlr4ruby/atn/atn_type.rbs +7 -0
  163. data/sig/antlr4ruby/atn/config/atn_config.rbs +21 -0
  164. data/sig/antlr4ruby/atn/config/atn_config_set.rbs +5 -0
  165. data/sig/antlr4ruby/atn/config/lexer_atn_config.rbs +19 -0
  166. data/sig/antlr4ruby/atn/config/ordered_atn_config_set.rbs +5 -0
  167. data/sig/antlr4ruby/atn/context/array_prediction_context.rbs +11 -0
  168. data/sig/antlr4ruby/atn/context/empty_prediction_context.rbs +6 -0
  169. data/sig/antlr4ruby/atn/context/prediction_context.rbs +52 -0
  170. data/sig/antlr4ruby/atn/context/prediction_context_cache.rbs +12 -0
  171. data/sig/antlr4ruby/atn/context/semantic_context.rbs +36 -0
  172. data/sig/antlr4ruby/atn/context/singleton_prediction_context.rbs +11 -0
  173. data/sig/antlr4ruby/atn/info/accept_state_info.rbs +15 -0
  174. data/sig/antlr4ruby/atn/info/ambiguity_info.rbs +8 -0
  175. data/sig/antlr4ruby/atn/info/conflict_info.rbs +16 -0
  176. data/sig/antlr4ruby/atn/info/context_sensitivity_info.rbs +5 -0
  177. data/sig/antlr4ruby/atn/info/decision_event_info.rbs +14 -0
  178. data/sig/antlr4ruby/atn/info/decision_info.rbs +29 -0
  179. data/sig/antlr4ruby/atn/info/error_info.rbs +5 -0
  180. data/sig/antlr4ruby/atn/info/lookahead_event_info.rbs +8 -0
  181. data/sig/antlr4ruby/atn/info/parse_info.rbs +8 -0
  182. data/sig/antlr4ruby/atn/info/predicate_eval_info.rbs +6 -0
  183. data/sig/antlr4ruby/atn/lexer_atn_simulator.rbs +83 -0
  184. data/sig/antlr4ruby/atn/ll1_analyzer.rbs +5 -0
  185. data/sig/antlr4ruby/atn/parser_atn_simulator.rbs +5 -0
  186. data/sig/antlr4ruby/atn/prediction_mode.rbs +6 -0
  187. data/sig/antlr4ruby/atn/profiling_atn_simulator.rbs +6 -0
  188. data/sig/antlr4ruby/atn/state/atn_state.rbs +50 -0
  189. data/sig/antlr4ruby/atn/state/basic_block_start_state.rbs +6 -0
  190. data/sig/antlr4ruby/atn/state/basic_state.rbs +7 -0
  191. data/sig/antlr4ruby/atn/state/block_end_state.rbs +7 -0
  192. data/sig/antlr4ruby/atn/state/block_start_state.rbs +8 -0
  193. data/sig/antlr4ruby/atn/state/decision_state.rbs +14 -0
  194. data/sig/antlr4ruby/atn/state/invalid_state.rbs +7 -0
  195. data/sig/antlr4ruby/atn/state/loop_end_state.rbs +7 -0
  196. data/sig/antlr4ruby/atn/state/plus_block_start_state.rbs +6 -0
  197. data/sig/antlr4ruby/atn/state/plus_loopback_state.rbs +6 -0
  198. data/sig/antlr4ruby/atn/state/rule_start_state.rbs +7 -0
  199. data/sig/antlr4ruby/atn/state/rule_stop_state.rbs +6 -0
  200. data/sig/antlr4ruby/atn/state/simulator_state.rbs +12 -0
  201. data/sig/antlr4ruby/atn/state/star_block_start_state.rbs +6 -0
  202. data/sig/antlr4ruby/atn/state/star_loop_entry_state.rbs +8 -0
  203. data/sig/antlr4ruby/atn/state/star_loopback_state.rbs +5 -0
  204. data/sig/antlr4ruby/atn/state/tokens_start_state.rbs +6 -0
  205. data/sig/antlr4ruby/atn/transition/abstract_predicate_transition.rbs +10 -0
  206. data/sig/antlr4ruby/atn/transition/action_transition.rbs +15 -0
  207. data/sig/antlr4ruby/atn/transition/atom_transition.rbs +10 -0
  208. data/sig/antlr4ruby/atn/transition/code_point_transitions.rbs +5 -0
  209. data/sig/antlr4ruby/atn/transition/epsilon_transition.rbs +12 -0
  210. data/sig/antlr4ruby/atn/transition/not_set_transition.rbs +7 -0
  211. data/sig/antlr4ruby/atn/transition/precedence_predicate_transition.rbs +10 -0
  212. data/sig/antlr4ruby/atn/transition/predicate_transition.rbs +11 -0
  213. data/sig/antlr4ruby/atn/transition/range_transition.rbs +8 -0
  214. data/sig/antlr4ruby/atn/transition/rule_transition.rbs +10 -0
  215. data/sig/antlr4ruby/atn/transition/set_transition.rbs +8 -0
  216. data/sig/antlr4ruby/atn/transition/transition.rbs +40 -0
  217. data/sig/antlr4ruby/atn/transition/wildcard_transition.rbs +5 -0
  218. data/sig/antlr4ruby/bail_error_strategy.rbs +7 -0
  219. data/sig/antlr4ruby/base_error_listener.rbs +6 -0
  220. data/sig/antlr4ruby/buffered_token_stream.rbs +48 -0
  221. data/sig/antlr4ruby/char_stream.rbs +9 -0
  222. data/sig/antlr4ruby/char_streams.rbs +14 -0
  223. data/sig/antlr4ruby/code_point_buffer.rbs +20 -0
  224. data/sig/antlr4ruby/code_point_char_stream.rbs +19 -0
  225. data/sig/antlr4ruby/common_token.rbs +35 -0
  226. data/sig/antlr4ruby/common_token_factory.rbs +12 -0
  227. data/sig/antlr4ruby/common_token_stream.rbs +9 -0
  228. data/sig/antlr4ruby/console_error_listener.rbs +6 -0
  229. data/sig/antlr4ruby/default_error_strategy.rbs +56 -0
  230. data/sig/antlr4ruby/dfa/dfa.rbs +29 -0
  231. data/sig/antlr4ruby/dfa/dfa_serializer.rbs +11 -0
  232. data/sig/antlr4ruby/dfa/dfa_state.rbs +50 -0
  233. data/sig/antlr4ruby/dfa/lexer_dfa_serializer.rbs +5 -0
  234. data/sig/antlr4ruby/diagnostic_error_listener.rbs +10 -0
  235. data/sig/antlr4ruby/exception/failed_predicate_exception.rbs +23 -0
  236. data/sig/antlr4ruby/exception/input_mismatch_exception.rbs +7 -0
  237. data/sig/antlr4ruby/exception/lexer_no_viable_alt_exception.rbs +15 -0
  238. data/sig/antlr4ruby/exception/no_viable_alt_exception.rbs +14 -0
  239. data/sig/antlr4ruby/exception/recognition_exception.rbs +30 -0
  240. data/sig/antlr4ruby/int_stream.rbs +19 -0
  241. data/sig/antlr4ruby/interpreter_rule_context.rbs +6 -0
  242. data/sig/antlr4ruby/lexer.rbs +88 -0
  243. data/sig/antlr4ruby/lexer_interpreter.rbs +5 -0
  244. data/sig/antlr4ruby/list_token_source.rbs +6 -0
  245. data/sig/antlr4ruby/misc/bit_set.rbs +6 -0
  246. data/sig/antlr4ruby/misc/double_key_map.rbs +11 -0
  247. data/sig/antlr4ruby/misc/equality_comparator.rbs +7 -0
  248. data/sig/antlr4ruby/misc/int_set.rbs +29 -0
  249. data/sig/antlr4ruby/misc/integer_stack.rbs +9 -0
  250. data/sig/antlr4ruby/misc/murmur_hash.rbs +13 -0
  251. data/sig/antlr4ruby/misc/pair.rbs +15 -0
  252. data/sig/antlr4ruby/misc/predicate.rbs +7 -0
  253. data/sig/antlr4ruby/misc/range_set.rbs +49 -0
  254. data/sig/antlr4ruby/parser.rbs +109 -0
  255. data/sig/antlr4ruby/parser_interpreter.rbs +24 -0
  256. data/sig/antlr4ruby/parser_rule_context.rbs +53 -0
  257. data/sig/antlr4ruby/proxy_error_listener.rbs +10 -0
  258. data/sig/antlr4ruby/recognizer.rbs +76 -0
  259. data/sig/antlr4ruby/rule_context.rbs +31 -0
  260. data/sig/antlr4ruby/rule_context_with_alt_num.rbs +8 -0
  261. data/sig/antlr4ruby/runtime_meta_data.rbs +12 -0
  262. data/sig/antlr4ruby/token.rbs +26 -0
  263. data/sig/antlr4ruby/token_factory.rbs +10 -0
  264. data/sig/antlr4ruby/token_source.rbs +12 -0
  265. data/sig/antlr4ruby/token_stream.rbs +13 -0
  266. data/sig/antlr4ruby/token_stream_rewriter.rbs +5 -0
  267. data/sig/antlr4ruby/tree/abstract_parse_tree_visitor.rbs +14 -0
  268. data/sig/antlr4ruby/tree/error_node.rbs +13 -0
  269. data/sig/antlr4ruby/tree/iterative_parse_tree_walker.rbs +7 -0
  270. data/sig/antlr4ruby/tree/parse_tree.rbs +21 -0
  271. data/sig/antlr4ruby/tree/parse_tree_listener.rbs +13 -0
  272. data/sig/antlr4ruby/tree/parse_tree_property.rbs +5 -0
  273. data/sig/antlr4ruby/tree/parse_tree_visitor.rbs +12 -0
  274. data/sig/antlr4ruby/tree/parse_tree_walker.rbs +12 -0
  275. data/sig/antlr4ruby/tree/rule_node.rbs +8 -0
  276. data/sig/antlr4ruby/tree/syntax_tree.rbs +8 -0
  277. data/sig/antlr4ruby/tree/terminal_node.rbs +20 -0
  278. data/sig/antlr4ruby/tree/tree.rbs +15 -0
  279. data/sig/antlr4ruby/tree/trees.rbs +32 -0
  280. data/sig/antlr4ruby/unbuffered_char_stream.rbs +6 -0
  281. data/sig/antlr4ruby/unbuffered_token_stream.rbs +6 -0
  282. data/sig/antlr4ruby/vocabulary.rbs +36 -0
  283. data/sig/antlr4ruby/writable_token.rbs +13 -0
  284. data/sig/antlr4ruby.rbs +4 -0
  285. metadata +328 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 90463d5fe8e370f672d6e2e20cb794b266f5697fda94f6bc456bc8739b79d615
4
+ data.tar.gz: ef7923015bbdb98fee2ca6cc5f37597a97cdf2c6be8eedd7be228af9672bfe21
5
+ SHA512:
6
+ metadata.gz: ad55f7889faccef81223af5a91675cb28a4204de5a13f66dd8cfa3bfee312402f5f756cdd810f8662c64fbe4d16eb2d015645d95b59cdd2c94eec43feb2770a7
7
+ data.tar.gz: 748094736c501ad48ba1e4a743d87379a18252a188d9fb7bf9d4c5b283bb8fbc329ba63ff2394a8189709cb2a5c86a2c77bd12935f0d2258363dd4be0e77a6fe
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-02-18
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 568385476@qq.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in antlr4ruby.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "standard", "~> 1.3"
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ antlr4ruby (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ json (2.6.3)
12
+ language_server-protocol (3.17.0.3)
13
+ parallel (1.22.1)
14
+ parser (3.2.1.0)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.1.1)
17
+ rake (13.0.6)
18
+ regexp_parser (2.7.0)
19
+ rexml (3.2.5)
20
+ rspec (3.12.0)
21
+ rspec-core (~> 3.12.0)
22
+ rspec-expectations (~> 3.12.0)
23
+ rspec-mocks (~> 3.12.0)
24
+ rspec-core (3.12.1)
25
+ rspec-support (~> 3.12.0)
26
+ rspec-expectations (3.12.2)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-mocks (3.12.3)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-support (3.12.0)
33
+ rubocop (1.44.1)
34
+ json (~> 2.3)
35
+ parallel (~> 1.10)
36
+ parser (>= 3.2.0.0)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ regexp_parser (>= 1.8, < 3.0)
39
+ rexml (>= 3.2.5, < 4.0)
40
+ rubocop-ast (>= 1.24.1, < 2.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 2.4.0, < 3.0)
43
+ rubocop-ast (1.26.0)
44
+ parser (>= 3.2.1.0)
45
+ rubocop-performance (1.15.2)
46
+ rubocop (>= 1.7.0, < 2.0)
47
+ rubocop-ast (>= 0.4.0)
48
+ ruby-progressbar (1.11.0)
49
+ standard (1.24.3)
50
+ language_server-protocol (~> 3.17.0.2)
51
+ rubocop (= 1.44.1)
52
+ rubocop-performance (= 1.15.2)
53
+ unicode-display_width (2.4.2)
54
+
55
+ PLATFORMS
56
+ x64-mingw-ucrt
57
+
58
+ DEPENDENCIES
59
+ antlr4ruby!
60
+ rake (~> 13.0)
61
+ rspec (~> 3.0)
62
+ standard (~> 1.3)
63
+
64
+ BUNDLED WITH
65
+ 2.4.7
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 邱维东
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Antlr4ruby
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/antlr4ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/antlr4ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/antlr4ruby/blob/master/CODE_OF_CONDUCT.md).
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the Antlr4ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/antlr4ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
@@ -0,0 +1,75 @@
1
+ module Antlr4ruby
2
+
3
+ class LexerActionExecutor
4
+
5
+ def initialize(lexer_actions)
6
+ @lexer_actions = lexer_actions
7
+
8
+ hash = MurmurHash.init
9
+ lexer_actions.each do |action|
10
+ hash = MurmurHash.update(hash, action)
11
+ end
12
+
13
+ @hash_code = MurmurHash.finish(hash, lexer_actions.length)
14
+ end
15
+
16
+ def self.append(lexer_executor, lexer_action)
17
+ return LexerActionExecutor.new([]) unless lexer_executor
18
+ lexer_actions = lexer_executor.lexer_actions.clone
19
+ lexer_actions << lexer_action
20
+ LexerActionExecutor.new(lexer_actions)
21
+ end
22
+
23
+ def fix_offset_before_match(offset)
24
+ update_lexer_actions = []
25
+
26
+ lexer_actions.length.times do |i|
27
+ if lexer_actions[i].is_position_dependent && !(lexer_actions[i].instance_of?(LexerIndexedCustomAction))
28
+ update_lexer_actions = lexer_actions.clone if update_lexer_actions.length <= 0
29
+ update_lexer_actions[i] = LexerIndexedCustomAction.new(offset, lexer_actions[i])
30
+ end
31
+ end
32
+
33
+ return self if update_lexer_actions.length <= 0
34
+ LexerActionExecutor(update_lexer_actions)
35
+ end
36
+
37
+ def get_lexer_actions
38
+ @lexer_actions
39
+ end
40
+
41
+ def execute(lexer, input, start_index)
42
+ requires_seek = false
43
+ stop_index = input.index
44
+
45
+ begin
46
+ lexer_actions.each do |lexer_action|
47
+ if lexer_action.instance_of?(LexerIndexedCustomAction)
48
+ offset = lexer_action.get_offset
49
+ input.seek(start_index + offset)
50
+ lexer_action = lexer_action.get_action
51
+ requires_seek = (start_index + offset) != stop_index
52
+ elsif lexer_action.is_position_dependent
53
+ input.seek(stop_index)
54
+ requires_seek = false
55
+ end
56
+ lexer_action.execute(lexer)
57
+ end
58
+ ensure
59
+ input.seek(stop_index) if requires_seek
60
+ end
61
+ end
62
+
63
+ def hash
64
+ # todo
65
+ end
66
+
67
+ def eql?(other)
68
+ # todo
69
+ end
70
+
71
+ private
72
+ attr_reader :lexer_actions, :hash_code
73
+ end
74
+
75
+ end
@@ -0,0 +1,6 @@
1
+ module Antlr4ruby
2
+
3
+ class LexerActionType
4
+ end
5
+
6
+ end
@@ -0,0 +1,41 @@
1
+ module Antlr4ruby
2
+
3
+ # @final 实现接口 LexerAction
4
+ class LexerChannelAction
5
+
6
+ def initialize(channel)
7
+ @channel = channel
8
+ end
9
+
10
+ def get_channel
11
+ @channel
12
+ end
13
+
14
+ def get_action_type
15
+ :CHANNEL
16
+ end
17
+
18
+ def is_position_dependent
19
+ false
20
+ end
21
+
22
+ def execute(lexer)
23
+ lexer.set_channel(channel)
24
+ end
25
+
26
+ def hash
27
+ # todo
28
+ end
29
+ def eql?(other)
30
+ # todo
31
+ end
32
+
33
+ def to_s
34
+ "channel(#{channel})"
35
+ end
36
+
37
+ private
38
+ attr_reader :channel
39
+ end
40
+
41
+ end
@@ -0,0 +1,43 @@
1
+ module Antlr4ruby
2
+
3
+ # @final LexerAction
4
+ class LexerCustomAction
5
+
6
+ def initialize(rule_index, action_index)
7
+ @rule_index, @action_index = rule_index, action_index
8
+ end
9
+
10
+ def get_rule_index
11
+ @rule_index
12
+ end
13
+
14
+ def get_action_index
15
+ @action_index
16
+ end
17
+
18
+ def get_action_type
19
+ :CUSTOM
20
+ end
21
+
22
+ def is_position_dependent
23
+ true
24
+ end
25
+
26
+ def execute(lexer)
27
+ lexer.action(nil, rule_index, action_index)
28
+ end
29
+
30
+ def hash
31
+ # todo
32
+ end
33
+
34
+ def eql?(other)
35
+ # todo
36
+ end
37
+
38
+ private
39
+ attr_reader :rule_index, :action_index
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,43 @@
1
+ module Antlr4ruby
2
+
3
+ # @final LexerAction
4
+ class LexerIndexedCustomAction
5
+
6
+ def initialize(offset, action)
7
+ @offset, @action = offset, action
8
+ end
9
+
10
+ def get_offset
11
+ @offset
12
+ end
13
+
14
+ def get_action
15
+ @action
16
+ end
17
+
18
+ def get_action_type
19
+ action.get_action_type
20
+ end
21
+
22
+ def is_position_dependent
23
+ true
24
+ end
25
+
26
+ def execute(lexer)
27
+ action.execute(lexer)
28
+ end
29
+
30
+ def hash
31
+ # todo
32
+ end
33
+
34
+ def eql?(other)
35
+ # todo
36
+ end
37
+
38
+
39
+ private
40
+ attr_reader :offset, :action
41
+ end
42
+
43
+ end
@@ -0,0 +1,45 @@
1
+ module Antlr4ruby
2
+
3
+ # @final LexerAction
4
+ class LexerModeAction
5
+
6
+ def initialize(mode)
7
+ @mode = mode
8
+ end
9
+
10
+
11
+ def get_mode
12
+ @mode
13
+ end
14
+
15
+ def get_action_type
16
+ :MODE
17
+ end
18
+
19
+ def is_position_dependent
20
+ false
21
+ end
22
+
23
+ def execute(lexer)
24
+ lexer.mode = mode
25
+ end
26
+
27
+ def hash
28
+ # todo
29
+ end
30
+
31
+ def eql?(other)
32
+ # todo
33
+ end
34
+
35
+ def to_s
36
+ "mode(#{mode})"
37
+ end
38
+
39
+
40
+
41
+ private
42
+ attr_reader :mode
43
+ end
44
+
45
+ end
@@ -0,0 +1,34 @@
1
+ module Antlr4ruby
2
+
3
+ # @final LexerAction
4
+ class LexerMoreAction
5
+ INSTANCE = LexerMoreAction.new
6
+
7
+ def get_action_type
8
+ :MORE
9
+ end
10
+
11
+ def is_position_dependent
12
+ false
13
+ end
14
+
15
+ def execute(lexer)
16
+ lexer.mode
17
+ end
18
+
19
+ def hash
20
+ # todo
21
+ end
22
+
23
+ def eql?(other)
24
+ # todo
25
+ end
26
+
27
+ def to_s
28
+ 'more'
29
+ end
30
+
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,32 @@
1
+ module Antlr4ruby
2
+ # @final LexerAction
3
+ class LexerPopModeAction
4
+ INSTANCE = LexerPopModeAction.new
5
+
6
+ def get_action_type
7
+ :POP_MODE
8
+ end
9
+
10
+ def is_position_dependent
11
+ false
12
+ end
13
+
14
+ def execute(lexer)
15
+ lexer.pop_mode
16
+ end
17
+
18
+ def hash
19
+ # todo
20
+ end
21
+
22
+ def eql?(other)
23
+ # todo
24
+ end
25
+
26
+ def to_s
27
+ 'pop_mode'
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,43 @@
1
+ module Antlr4ruby
2
+
3
+ # @final LexerAction
4
+ class LexerPushModeAction
5
+ def initialize(mode)
6
+ @mode = mode
7
+ end
8
+
9
+ def get_mode
10
+ @mode
11
+ end
12
+
13
+
14
+ def get_action_type
15
+ :PUSH_MODE
16
+ end
17
+
18
+ def is_position_dependent
19
+ false
20
+ end
21
+
22
+ def execute(lexer)
23
+ lexer.push_mode(mode)
24
+ end
25
+
26
+ def hash
27
+ # todo
28
+ end
29
+
30
+ def eql?(other)
31
+ # todo
32
+ end
33
+
34
+ def to_s
35
+ "push_mode(#{mode})"
36
+ end
37
+
38
+ private
39
+ attr_reader :mode
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,33 @@
1
+ module Antlr4ruby
2
+
3
+ # @final LexerAction
4
+ class LexerSkipAction
5
+ INSTANCE = LexerSkipAction.new
6
+
7
+ def get_action_type
8
+ :SKIP
9
+ end
10
+
11
+ def is_position_dependent
12
+ false
13
+ end
14
+
15
+ def execute(lexer)
16
+ lexer.skip
17
+ end
18
+
19
+ def hash
20
+ # todo
21
+ end
22
+
23
+ def eql?(other)
24
+ # todo
25
+ end
26
+
27
+ def to_s
28
+ 'skip'
29
+ end
30
+
31
+ end
32
+
33
+ end