@appthreat/atom-parsetools 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/README.md +111 -14
  2. package/package.json +2 -1
  3. package/plugins/composer/installed.php +6 -6
  4. package/plugins/rubyastgen/Gemfile +6 -4
  5. package/plugins/rubyastgen/Gemfile.lock +5 -8
  6. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/Gemfile +11 -0
  7. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/exe/ruby_ast_gen +55 -0
  8. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/lib/ruby_ast_gen/cli.rb +133 -0
  9. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/lib/ruby_ast_gen/node_handling.rb +449 -0
  10. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/lib/ruby_ast_gen/version.rb +1 -1
  11. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/lib/ruby_ast_gen.rb +888 -0
  12. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-4ac84327b3af/ruby_ast_gen.gemspec +25 -0
  13. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/current.rb +1 -1
  14. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/version.rb +1 -1
  15. package/plugins/rubyastgen/bundle/ruby/4.0.0/specifications/ast-2.4.3.gemspec +29 -0
  16. package/plugins/rubyastgen/bundle/ruby/4.0.0/specifications/bundler-2.6.9.gemspec +25 -0
  17. package/plugins/rubyastgen/bundle/ruby/4.0.0/specifications/ostruct-0.6.3.gemspec +22 -0
  18. package/plugins/rubyastgen/bundle/ruby/4.0.0/specifications/parser-3.3.12.0.gemspec +37 -0
  19. package/rbastgen.js +102 -13
  20. package/scalasem.js +11 -2
  21. package/plugins/bin/bundler +0 -14
  22. package/plugins/bin/ruby_ast_gen +0 -14
  23. package/plugins/rubyastgen/bundle/bundler/setup.rb +0 -44
  24. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-cc312ebf06b4/exe/ruby_ast_gen +0 -63
  25. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-cc312ebf06b4/lib/ruby_ast_gen/node_handling.rb +0 -269
  26. package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/ruby_ast_gen-cc312ebf06b4/lib/ruby_ast_gen.rb +0 -218
  27. package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/prism-1.9.0/gem.build_complete +0 -0
  28. package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/prism-1.9.0/gem_make.out +0 -44
  29. package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/prism-1.9.0/mkmf.log +0 -74
  30. package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/prism-1.9.0/prism/prism.so +0 -0
  31. package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/racc-1.8.1/gem.build_complete +0 -0
  32. package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/racc-1.8.1/gem_make.out +0 -18
  33. package/plugins/rubyastgen/bundle/ruby/4.0.0/extensions/x86_64-linux/4.0.0/racc-1.8.1/racc/cparse.so +0 -0
  34. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/BSDmakefile +0 -58
  35. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/Makefile +0 -116
  36. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/Makefile +0 -273
  37. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/api_node.c +0 -6945
  38. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/api_pack.c +0 -276
  39. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extconf.rb +0 -127
  40. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extension.c +0 -1427
  41. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extension.h +0 -19
  42. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/ast.h +0 -8254
  43. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/defines.h +0 -260
  44. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/diagnostic.h +0 -458
  45. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/encoding.h +0 -283
  46. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/node.h +0 -129
  47. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/options.h +0 -488
  48. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/pack.h +0 -163
  49. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/parser.h +0 -936
  50. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/prettyprint.h +0 -34
  51. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/regexp.h +0 -43
  52. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/static_literals.h +0 -121
  53. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_buffer.h +0 -236
  54. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_char.h +0 -204
  55. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_constant_pool.h +0 -218
  56. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_integer.h +0 -130
  57. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_list.h +0 -103
  58. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_memchr.h +0 -29
  59. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_newline_list.h +0 -113
  60. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_string.h +0 -200
  61. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_strncasecmp.h +0 -32
  62. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/util/pm_strpbrk.h +0 -46
  63. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism/version.h +0 -29
  64. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/include/prism.h +0 -408
  65. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/compiler.rb +0 -801
  66. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/desugar_compiler.rb +0 -392
  67. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/dispatcher.rb +0 -2210
  68. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/dot_visitor.rb +0 -4767
  69. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/dsl.rb +0 -1003
  70. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/ffi.rb +0 -578
  71. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/inspect_visitor.rb +0 -2393
  72. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/lex_compat.rb +0 -911
  73. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/mutation_compiler.rb +0 -772
  74. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/node.rb +0 -19966
  75. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/node_ext.rb +0 -511
  76. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/pack.rb +0 -230
  77. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/parse_result/comments.rb +0 -188
  78. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/parse_result/errors.rb +0 -66
  79. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/parse_result/newlines.rb +0 -155
  80. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/parse_result.rb +0 -907
  81. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/pattern.rb +0 -269
  82. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/append_as_bytes.rb +0 -15
  83. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/byteindex.rb +0 -13
  84. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/scan_byte.rb +0 -14
  85. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/unpack1.rb +0 -14
  86. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/polyfill/warn.rb +0 -36
  87. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/prism.so +0 -0
  88. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/reflection.rb +0 -416
  89. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/relocation.rb +0 -505
  90. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/serialize.rb +0 -2400
  91. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/string_query.rb +0 -31
  92. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser/builder.rb +0 -62
  93. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser/compiler.rb +0 -2234
  94. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser/lexer.rb +0 -820
  95. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser.rb +0 -376
  96. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser_current.rb +0 -26
  97. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/parser_versions.rb +0 -36
  98. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper/filter.rb +0 -53
  99. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper/lexer.rb +0 -135
  100. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper/sexp.rb +0 -126
  101. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper/shim.rb +0 -5
  102. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ripper.rb +0 -3520
  103. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation/ruby_parser.rb +0 -1964
  104. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/translation.rb +0 -18
  105. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism/visitor.rb +0 -813
  106. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/lib/prism.rb +0 -98
  107. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/compiler.rbi +0 -12
  108. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/dsl.rbi +0 -524
  109. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/inspect_visitor.rbi +0 -12
  110. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/node.rbi +0 -8750
  111. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/node_ext.rbi +0 -107
  112. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/parse_result.rbi +0 -404
  113. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/reflection.rbi +0 -58
  114. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/string_query.rbi +0 -12
  115. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/translation/parser.rbi +0 -11
  116. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/translation/parser_versions.rbi +0 -23
  117. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/translation/ripper.rbi +0 -15
  118. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism/visitor.rbi +0 -473
  119. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/rbi/prism.rbi +0 -63
  120. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/compiler.rbs +0 -9
  121. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/dispatcher.rbs +0 -19
  122. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/dot_visitor.rbs +0 -6
  123. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/dsl.rbs +0 -351
  124. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/inspect_visitor.rbs +0 -22
  125. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/lex_compat.rbs +0 -10
  126. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/mutation_compiler.rbs +0 -159
  127. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/node.rbs +0 -4042
  128. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/node_ext.rbs +0 -149
  129. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/pack.rbs +0 -43
  130. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/parse_result/comments.rbs +0 -38
  131. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/parse_result.rbs +0 -197
  132. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/pattern.rbs +0 -13
  133. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/reflection.rbs +0 -50
  134. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/relocation.rbs +0 -185
  135. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/serialize.rbs +0 -8
  136. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/string_query.rbs +0 -11
  137. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism/visitor.rbs +0 -169
  138. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/sig/prism.rbs +0 -272
  139. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/diagnostic.c +0 -854
  140. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/encoding.c +0 -5340
  141. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/node.c +0 -8685
  142. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/options.c +0 -338
  143. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/pack.c +0 -509
  144. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/prettyprint.c +0 -8957
  145. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/prism.c +0 -22679
  146. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/regexp.c +0 -790
  147. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/serialize.c +0 -2274
  148. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/static_literals.c +0 -617
  149. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/token_type.c +0 -703
  150. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_buffer.c +0 -357
  151. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_char.c +0 -318
  152. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_constant_pool.c +0 -342
  153. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_integer.c +0 -670
  154. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_list.c +0 -49
  155. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_memchr.c +0 -35
  156. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_newline_list.c +0 -125
  157. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_string.c +0 -381
  158. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_strncasecmp.c +0 -36
  159. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/prism-1.9.0/src/util/pm_strpbrk.c +0 -206
  160. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/BSDL +0 -22
  161. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/COPYING +0 -56
  162. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ChangeLog +0 -846
  163. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/README.ja.rdoc +0 -58
  164. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/README.rdoc +0 -60
  165. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/TODO +0 -5
  166. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/bin/racc +0 -320
  167. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse/Makefile +0 -273
  168. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse/cparse.c +0 -840
  169. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/ext/racc/cparse/extconf.rb +0 -8
  170. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/compat.rb +0 -33
  171. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/cparse.so +0 -0
  172. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/debugflags.rb +0 -60
  173. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/exception.rb +0 -16
  174. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/grammar.rb +0 -1191
  175. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/grammarfileparser.rb +0 -667
  176. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/info.rb +0 -18
  177. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/iset.rb +0 -92
  178. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/logfilegenerator.rb +0 -212
  179. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/parser-text.rb +0 -644
  180. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/parser.rb +0 -630
  181. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/parserfilegenerator.rb +0 -473
  182. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/sourcetext.rb +0 -35
  183. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/state.rb +0 -976
  184. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/statetransitiontable.rb +0 -311
  185. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc/static.rb +0 -5
  186. package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/racc-1.8.1/lib/racc.rb +0 -6
  187. /package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/.rspec +0 -0
  188. /package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/bin/console +0 -0
  189. /package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/bin/setup +0 -0
  190. /package/plugins/rubyastgen/bundle/ruby/4.0.0/bundler/gems/{ruby_ast_gen-cc312ebf06b4 → ruby_ast_gen-4ac84327b3af}/update_version.rb +0 -0
  191. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/bin/ruby-parse +0 -0
  192. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/bin/ruby-rewrite +0 -0
  193. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/gauntlet_parser.rb +0 -0
  194. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/all.rb +0 -0
  195. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ast/node.rb +0 -0
  196. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ast/processor.rb +0 -0
  197. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/base.rb +0 -0
  198. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/builders/default.rb +0 -0
  199. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/clobbering_error.rb +0 -0
  200. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/color.rb +0 -0
  201. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/context.rb +0 -0
  202. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/current_arg_stack.rb +0 -0
  203. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/deprecation.rb +0 -0
  204. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/diagnostic/engine.rb +0 -0
  205. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/diagnostic.rb +0 -0
  206. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer/dedenter.rb +0 -0
  207. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer/explanation.rb +0 -0
  208. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer/literal.rb +0 -0
  209. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer/stack_state.rb +0 -0
  210. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer-F0.rb +0 -0
  211. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer-F1.rb +0 -0
  212. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/lexer-strings.rb +0 -0
  213. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/macruby.rb +0 -0
  214. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/max_numparam_stack.rb +0 -0
  215. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/messages.rb +0 -0
  216. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/meta.rb +0 -0
  217. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/rewriter.rb +0 -0
  218. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby18.rb +0 -0
  219. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby19.rb +0 -0
  220. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby20.rb +0 -0
  221. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby21.rb +0 -0
  222. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby22.rb +0 -0
  223. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby23.rb +0 -0
  224. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby24.rb +0 -0
  225. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby25.rb +0 -0
  226. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby26.rb +0 -0
  227. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby27.rb +0 -0
  228. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby30.rb +0 -0
  229. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby31.rb +0 -0
  230. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby32.rb +0 -0
  231. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby33.rb +0 -0
  232. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/ruby34.rb +0 -0
  233. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/rubymotion.rb +0 -0
  234. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/runner/ruby_parse.rb +0 -0
  235. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/runner/ruby_rewrite.rb +0 -0
  236. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/runner.rb +0 -0
  237. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/buffer.rb +0 -0
  238. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/comment/associator.rb +0 -0
  239. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/comment.rb +0 -0
  240. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/collection.rb +0 -0
  241. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/condition.rb +0 -0
  242. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/constant.rb +0 -0
  243. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/definition.rb +0 -0
  244. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/for.rb +0 -0
  245. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/heredoc.rb +0 -0
  246. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/index.rb +0 -0
  247. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/keyword.rb +0 -0
  248. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/method_definition.rb +0 -0
  249. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/objc_kwarg.rb +0 -0
  250. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/operator.rb +0 -0
  251. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/rescue_body.rb +0 -0
  252. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/send.rb +0 -0
  253. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/ternary.rb +0 -0
  254. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map/variable.rb +0 -0
  255. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/map.rb +0 -0
  256. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/range.rb +0 -0
  257. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/rewriter/action.rb +0 -0
  258. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/rewriter.rb +0 -0
  259. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/tree_rewriter/action.rb +0 -0
  260. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/source/tree_rewriter.rb +0 -0
  261. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/static_environment.rb +0 -0
  262. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/syntax_error.rb +0 -0
  263. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/tree_rewriter.rb +0 -0
  264. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/unknown_encoding_in_magic_comment_error.rb +0 -0
  265. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser/variables_stack.rb +0 -0
  266. /package/plugins/rubyastgen/bundle/ruby/4.0.0/gems/{parser-3.3.11.1 → parser-3.3.12.0}/lib/parser.rb +0 -0
@@ -1,578 +0,0 @@
1
- # frozen_string_literal: true
2
- # :markup: markdown
3
- # typed: ignore
4
-
5
- # This file is responsible for mirroring the API provided by the C extension by
6
- # using FFI to call into the shared library.
7
-
8
- require "rbconfig"
9
- require "ffi"
10
-
11
- # We want to eagerly load this file if there are Ractors so that it does not get
12
- # autoloaded from within a non-main Ractor.
13
- require "prism/serialize" if defined?(Ractor)
14
-
15
- module Prism
16
- module LibRubyParser # :nodoc:
17
- extend FFI::Library
18
-
19
- # Define the library that we will be pulling functions from. Note that this
20
- # must align with the build shared library from make/rake.
21
- libprism_in_build = File.expand_path("../../build/libprism.#{RbConfig::CONFIG["SOEXT"]}", __dir__)
22
- libprism_in_libdir = "#{RbConfig::CONFIG["libdir"]}/prism/libprism.#{RbConfig::CONFIG["SOEXT"]}"
23
-
24
- if File.exist?(libprism_in_build)
25
- INCLUDE_DIR = File.expand_path("../../include", __dir__)
26
- ffi_lib libprism_in_build
27
- else
28
- INCLUDE_DIR = "#{RbConfig::CONFIG["libdir"]}/prism/include"
29
- ffi_lib libprism_in_libdir
30
- end
31
-
32
- # Convert a native C type declaration into a symbol that FFI understands.
33
- # For example:
34
- #
35
- # const char * -> :pointer
36
- # bool -> :bool
37
- # size_t -> :size_t
38
- # void -> :void
39
- #
40
- def self.resolve_type(type, callbacks)
41
- type = type.strip
42
-
43
- if !type.end_with?("*")
44
- type.delete_prefix("const ").to_sym
45
- else
46
- type = type.delete_suffix("*").rstrip
47
- callbacks.include?(type.to_sym) ? type.to_sym : :pointer
48
- end
49
- end
50
-
51
- # Read through the given header file and find the declaration of each of the
52
- # given functions. For each one, define a function with the same name and
53
- # signature as the C function.
54
- def self.load_exported_functions_from(header, *functions, callbacks)
55
- File.foreach("#{INCLUDE_DIR}/#{header}") do |line|
56
- # We only want to attempt to load exported functions.
57
- next unless line.start_with?("PRISM_EXPORTED_FUNCTION ")
58
-
59
- # We only want to load the functions that we are interested in.
60
- next unless functions.any? { |function| line.include?(function) }
61
-
62
- # Parse the function declaration.
63
- unless /^PRISM_EXPORTED_FUNCTION (?<return_type>.+) (?<name>\w+)\((?<arg_types>.+)\);$/ =~ line
64
- raise "Could not parse #{line}"
65
- end
66
-
67
- # Delete the function from the list of functions we are looking for to
68
- # mark it as having been found.
69
- functions.delete(name)
70
-
71
- # Split up the argument types into an array, ensure we handle the case
72
- # where there are no arguments (by explicit void).
73
- arg_types = arg_types.split(",").map(&:strip)
74
- arg_types = [] if arg_types == %w[void]
75
-
76
- # Resolve the type of the argument by dropping the name of the argument
77
- # first if it is present.
78
- arg_types.map! { |type| resolve_type(type.sub(/\w+$/, ""), callbacks) }
79
-
80
- # Attach the function using the FFI library.
81
- attach_function name, arg_types, resolve_type(return_type, [])
82
- end
83
-
84
- # If we didn't find all of the functions, raise an error.
85
- raise "Could not find functions #{functions.inspect}" unless functions.empty?
86
- end
87
-
88
- callback :pm_parse_stream_fgets_t, [:pointer, :int, :pointer], :pointer
89
- callback :pm_parse_stream_feof_t, [:pointer], :int
90
- enum :pm_string_init_result_t, %i[PM_STRING_INIT_SUCCESS PM_STRING_INIT_ERROR_GENERIC PM_STRING_INIT_ERROR_DIRECTORY]
91
- enum :pm_string_query_t, [:PM_STRING_QUERY_ERROR, -1, :PM_STRING_QUERY_FALSE, :PM_STRING_QUERY_TRUE]
92
-
93
- load_exported_functions_from(
94
- "prism.h",
95
- "pm_version",
96
- "pm_serialize_parse",
97
- "pm_serialize_parse_stream",
98
- "pm_serialize_parse_comments",
99
- "pm_serialize_lex",
100
- "pm_serialize_parse_lex",
101
- "pm_parse_success_p",
102
- "pm_string_query_local",
103
- "pm_string_query_constant",
104
- "pm_string_query_method_name",
105
- [:pm_parse_stream_fgets_t, :pm_parse_stream_feof_t]
106
- )
107
-
108
- load_exported_functions_from(
109
- "prism/util/pm_buffer.h",
110
- "pm_buffer_sizeof",
111
- "pm_buffer_init",
112
- "pm_buffer_value",
113
- "pm_buffer_length",
114
- "pm_buffer_free",
115
- []
116
- )
117
-
118
- load_exported_functions_from(
119
- "prism/util/pm_string.h",
120
- "pm_string_mapped_init",
121
- "pm_string_free",
122
- "pm_string_source",
123
- "pm_string_length",
124
- "pm_string_sizeof",
125
- []
126
- )
127
-
128
- # This object represents a pm_buffer_t. We only use it as an opaque pointer,
129
- # so it doesn't need to know the fields of pm_buffer_t.
130
- class PrismBuffer # :nodoc:
131
- SIZEOF = LibRubyParser.pm_buffer_sizeof
132
-
133
- attr_reader :pointer
134
-
135
- def initialize(pointer)
136
- @pointer = pointer
137
- end
138
-
139
- def value
140
- LibRubyParser.pm_buffer_value(pointer)
141
- end
142
-
143
- def length
144
- LibRubyParser.pm_buffer_length(pointer)
145
- end
146
-
147
- def read
148
- value.read_string(length)
149
- end
150
-
151
- # Initialize a new buffer and yield it to the block. The buffer will be
152
- # automatically freed when the block returns.
153
- def self.with
154
- FFI::MemoryPointer.new(SIZEOF) do |pointer|
155
- raise unless LibRubyParser.pm_buffer_init(pointer)
156
- return yield new(pointer)
157
- ensure
158
- LibRubyParser.pm_buffer_free(pointer)
159
- end
160
- end
161
- end
162
-
163
- # This object represents a pm_string_t. We only use it as an opaque pointer,
164
- # so it doesn't have to be an FFI::Struct.
165
- class PrismString # :nodoc:
166
- SIZEOF = LibRubyParser.pm_string_sizeof
167
-
168
- PLATFORM_EXPECTS_UTF8 =
169
- RbConfig::CONFIG["host_os"].match?(/bccwin|cygwin|djgpp|mingw|mswin|wince|darwin/i)
170
-
171
- attr_reader :pointer, :length
172
-
173
- def initialize(pointer, length, from_string)
174
- @pointer = pointer
175
- @length = length
176
- @from_string = from_string
177
- end
178
-
179
- def read
180
- raise "should use the original String instead" if @from_string
181
- @pointer.read_string(@length)
182
- end
183
-
184
- # Yields a pm_string_t pointer to the given block.
185
- def self.with_string(string)
186
- raise TypeError unless string.is_a?(String)
187
-
188
- length = string.bytesize
189
- # + 1 to never get an address of 0, which pm_parser_init() asserts
190
- FFI::MemoryPointer.new(:char, length + 1, false) do |pointer|
191
- pointer.write_string(string)
192
- # since we have the extra byte we might as well \0-terminate
193
- pointer.put_char(length, 0)
194
- return yield new(pointer, length, true)
195
- end
196
- end
197
-
198
- # Yields a pm_string_t pointer to the given block.
199
- def self.with_file(filepath)
200
- raise TypeError unless filepath.is_a?(String)
201
-
202
- # On Windows and Mac, it's expected that filepaths will be encoded in
203
- # UTF-8. If they are not, we need to convert them to UTF-8 before
204
- # passing them into pm_string_mapped_init.
205
- if PLATFORM_EXPECTS_UTF8 && (encoding = filepath.encoding) != Encoding::ASCII_8BIT && encoding != Encoding::UTF_8
206
- filepath = filepath.encode(Encoding::UTF_8)
207
- end
208
-
209
- FFI::MemoryPointer.new(SIZEOF) do |pm_string|
210
- case (result = LibRubyParser.pm_string_mapped_init(pm_string, filepath))
211
- when :PM_STRING_INIT_SUCCESS
212
- pointer = LibRubyParser.pm_string_source(pm_string)
213
- length = LibRubyParser.pm_string_length(pm_string)
214
- return yield new(pointer, length, false)
215
- when :PM_STRING_INIT_ERROR_GENERIC
216
- raise SystemCallError.new(filepath, FFI.errno)
217
- when :PM_STRING_INIT_ERROR_DIRECTORY
218
- raise Errno::EISDIR.new(filepath)
219
- else
220
- raise "Unknown error initializing pm_string_t: #{result.inspect}"
221
- end
222
- ensure
223
- LibRubyParser.pm_string_free(pm_string)
224
- end
225
- end
226
- end
227
- end
228
-
229
- # Mark the LibRubyParser module as private as it should only be called through
230
- # the prism module.
231
- private_constant :LibRubyParser
232
-
233
- # The version constant is set by reading the result of calling pm_version.
234
- VERSION = LibRubyParser.pm_version.read_string.freeze
235
-
236
- class << self
237
- # Mirror the Prism.dump API by using the serialization API.
238
- def dump(source, **options)
239
- LibRubyParser::PrismString.with_string(source) { |string| dump_common(string, options) }
240
- end
241
-
242
- # Mirror the Prism.dump_file API by using the serialization API.
243
- def dump_file(filepath, **options)
244
- options[:filepath] = filepath
245
- LibRubyParser::PrismString.with_file(filepath) { |string| dump_common(string, options) }
246
- end
247
-
248
- # Mirror the Prism.lex API by using the serialization API.
249
- def lex(code, **options)
250
- LibRubyParser::PrismString.with_string(code) { |string| lex_common(string, code, options) }
251
- end
252
-
253
- # Mirror the Prism.lex_file API by using the serialization API.
254
- def lex_file(filepath, **options)
255
- options[:filepath] = filepath
256
- LibRubyParser::PrismString.with_file(filepath) { |string| lex_common(string, string.read, options) }
257
- end
258
-
259
- # Mirror the Prism.parse API by using the serialization API.
260
- def parse(code, **options)
261
- LibRubyParser::PrismString.with_string(code) { |string| parse_common(string, code, options) }
262
- end
263
-
264
- # Mirror the Prism.parse_file API by using the serialization API. This uses
265
- # native strings instead of Ruby strings because it allows us to use mmap
266
- # when it is available.
267
- def parse_file(filepath, **options)
268
- options[:filepath] = filepath
269
- LibRubyParser::PrismString.with_file(filepath) { |string| parse_common(string, string.read, options) }
270
- end
271
-
272
- # Mirror the Prism.parse_stream API by using the serialization API.
273
- def parse_stream(stream, **options)
274
- LibRubyParser::PrismBuffer.with do |buffer|
275
- source = +""
276
- callback = -> (string, size, _) {
277
- raise "Expected size to be >= 0, got: #{size}" if size <= 0
278
-
279
- if !(line = stream.gets(size - 1)).nil?
280
- source << line
281
- string.write_string("#{line}\x00", line.bytesize + 1)
282
- end
283
- }
284
-
285
- eof_callback = -> (_) { stream.eof? }
286
-
287
- # In the pm_serialize_parse_stream function it accepts a pointer to the
288
- # IO object as a void* and then passes it through to the callback as the
289
- # third argument, but it never touches it itself. As such, since we have
290
- # access to the IO object already through the closure of the lambda, we
291
- # can pass a null pointer here and not worry.
292
- LibRubyParser.pm_serialize_parse_stream(buffer.pointer, nil, callback, eof_callback, dump_options(options))
293
- Prism.load(source, buffer.read, options.fetch(:freeze, false))
294
- end
295
- end
296
-
297
- # Mirror the Prism.parse_comments API by using the serialization API.
298
- def parse_comments(code, **options)
299
- LibRubyParser::PrismString.with_string(code) { |string| parse_comments_common(string, code, options) }
300
- end
301
-
302
- # Mirror the Prism.parse_file_comments API by using the serialization
303
- # API. This uses native strings instead of Ruby strings because it allows us
304
- # to use mmap when it is available.
305
- def parse_file_comments(filepath, **options)
306
- options[:filepath] = filepath
307
- LibRubyParser::PrismString.with_file(filepath) { |string| parse_comments_common(string, string.read, options) }
308
- end
309
-
310
- # Mirror the Prism.parse_lex API by using the serialization API.
311
- def parse_lex(code, **options)
312
- LibRubyParser::PrismString.with_string(code) { |string| parse_lex_common(string, code, options) }
313
- end
314
-
315
- # Mirror the Prism.parse_lex_file API by using the serialization API.
316
- def parse_lex_file(filepath, **options)
317
- options[:filepath] = filepath
318
- LibRubyParser::PrismString.with_file(filepath) { |string| parse_lex_common(string, string.read, options) }
319
- end
320
-
321
- # Mirror the Prism.parse_success? API by using the serialization API.
322
- def parse_success?(code, **options)
323
- LibRubyParser::PrismString.with_string(code) { |string| parse_file_success_common(string, options) }
324
- end
325
-
326
- # Mirror the Prism.parse_failure? API by using the serialization API.
327
- def parse_failure?(code, **options)
328
- !parse_success?(code, **options)
329
- end
330
-
331
- # Mirror the Prism.parse_file_success? API by using the serialization API.
332
- def parse_file_success?(filepath, **options)
333
- options[:filepath] = filepath
334
- LibRubyParser::PrismString.with_file(filepath) { |string| parse_file_success_common(string, options) }
335
- end
336
-
337
- # Mirror the Prism.parse_file_failure? API by using the serialization API.
338
- def parse_file_failure?(filepath, **options)
339
- !parse_file_success?(filepath, **options)
340
- end
341
-
342
- # Mirror the Prism.profile API by using the serialization API.
343
- def profile(source, **options)
344
- LibRubyParser::PrismString.with_string(source) do |string|
345
- LibRubyParser::PrismBuffer.with do |buffer|
346
- LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options))
347
- nil
348
- end
349
- end
350
- end
351
-
352
- # Mirror the Prism.profile_file API by using the serialization API.
353
- def profile_file(filepath, **options)
354
- LibRubyParser::PrismString.with_file(filepath) do |string|
355
- LibRubyParser::PrismBuffer.with do |buffer|
356
- options[:filepath] = filepath
357
- LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options))
358
- nil
359
- end
360
- end
361
- end
362
-
363
- private
364
-
365
- def dump_common(string, options) # :nodoc:
366
- LibRubyParser::PrismBuffer.with do |buffer|
367
- LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options))
368
-
369
- dumped = buffer.read
370
- dumped.freeze if options.fetch(:freeze, false)
371
-
372
- dumped
373
- end
374
- end
375
-
376
- def lex_common(string, code, options) # :nodoc:
377
- LibRubyParser::PrismBuffer.with do |buffer|
378
- LibRubyParser.pm_serialize_lex(buffer.pointer, string.pointer, string.length, dump_options(options))
379
- Serialize.load_lex(code, buffer.read, options.fetch(:freeze, false))
380
- end
381
- end
382
-
383
- def parse_common(string, code, options) # :nodoc:
384
- serialized = dump_common(string, options)
385
- Serialize.load_parse(code, serialized, options.fetch(:freeze, false))
386
- end
387
-
388
- def parse_comments_common(string, code, options) # :nodoc:
389
- LibRubyParser::PrismBuffer.with do |buffer|
390
- LibRubyParser.pm_serialize_parse_comments(buffer.pointer, string.pointer, string.length, dump_options(options))
391
- Serialize.load_parse_comments(code, buffer.read, options.fetch(:freeze, false))
392
- end
393
- end
394
-
395
- def parse_lex_common(string, code, options) # :nodoc:
396
- LibRubyParser::PrismBuffer.with do |buffer|
397
- LibRubyParser.pm_serialize_parse_lex(buffer.pointer, string.pointer, string.length, dump_options(options))
398
- Serialize.load_parse_lex(code, buffer.read, options.fetch(:freeze, false))
399
- end
400
- end
401
-
402
- def parse_file_success_common(string, options) # :nodoc:
403
- LibRubyParser.pm_parse_success_p(string.pointer, string.length, dump_options(options))
404
- end
405
-
406
- # Return the value that should be dumped for the command_line option.
407
- def dump_options_command_line(options)
408
- command_line = options.fetch(:command_line, "")
409
- raise ArgumentError, "command_line must be a string" unless command_line.is_a?(String)
410
-
411
- command_line.each_char.inject(0) do |value, char|
412
- case char
413
- when "a" then value | 0b000001
414
- when "e" then value | 0b000010
415
- when "l" then value | 0b000100
416
- when "n" then value | 0b001000
417
- when "p" then value | 0b010000
418
- when "x" then value | 0b100000
419
- else raise ArgumentError, "invalid command_line option: #{char}"
420
- end
421
- end
422
- end
423
-
424
- # Return the value that should be dumped for the version option.
425
- def dump_options_version(version)
426
- current = version == "current"
427
-
428
- case current ? RUBY_VERSION : version
429
- when nil, "latest"
430
- 0 # Handled in pm_parser_init
431
- when /\A3\.3(\.\d+)?\z/
432
- 1
433
- when /\A3\.4(\.\d+)?\z/
434
- 2
435
- when /\A3\.5(\.\d+)?\z/, /\A4\.0(\.\d+)?\z/
436
- 3
437
- when /\A4\.1(\.\d+)?\z/
438
- 4
439
- else
440
- if current
441
- raise CurrentVersionError, RUBY_VERSION
442
- else
443
- raise ArgumentError, "invalid version: #{version}"
444
- end
445
- end
446
- end
447
-
448
- # Convert the given options into a serialized options string.
449
- def dump_options(options)
450
- template = +""
451
- values = []
452
-
453
- template << "L"
454
- if (filepath = options[:filepath])
455
- values.push(filepath.bytesize, filepath.b)
456
- template << "A*"
457
- else
458
- values << 0
459
- end
460
-
461
- template << "l"
462
- values << options.fetch(:line, 1)
463
-
464
- template << "L"
465
- if (encoding = options[:encoding])
466
- name = encoding.is_a?(Encoding) ? encoding.name : encoding
467
- values.push(name.bytesize, name.b)
468
- template << "A*"
469
- else
470
- values << 0
471
- end
472
-
473
- template << "C"
474
- values << (options.fetch(:frozen_string_literal, false) ? 1 : 0)
475
-
476
- template << "C"
477
- values << dump_options_command_line(options)
478
-
479
- template << "C"
480
- values << dump_options_version(options[:version])
481
-
482
- template << "C"
483
- values << (options[:encoding] == false ? 1 : 0)
484
-
485
- template << "C"
486
- values << (options.fetch(:main_script, false) ? 1 : 0)
487
-
488
- template << "C"
489
- values << (options.fetch(:partial_script, false) ? 1 : 0)
490
-
491
- template << "C"
492
- values << (options.fetch(:freeze, false) ? 1 : 0)
493
-
494
- template << "L"
495
- if (scopes = options[:scopes])
496
- values << scopes.length
497
-
498
- scopes.each do |scope|
499
- locals = nil
500
- forwarding = 0
501
-
502
- case scope
503
- when Array
504
- locals = scope
505
- when Scope
506
- locals = scope.locals
507
-
508
- scope.forwarding.each do |forward|
509
- case forward
510
- when :* then forwarding |= 0x1
511
- when :** then forwarding |= 0x2
512
- when :& then forwarding |= 0x4
513
- when :"..." then forwarding |= 0x8
514
- else raise ArgumentError, "invalid forwarding value: #{forward}"
515
- end
516
- end
517
- else
518
- raise TypeError, "wrong argument type #{scope.class.inspect} (expected Array or Prism::Scope)"
519
- end
520
-
521
- template << "L"
522
- values << locals.length
523
-
524
- template << "C"
525
- values << forwarding
526
-
527
- locals.each do |local|
528
- name = local.name
529
- template << "L"
530
- values << name.bytesize
531
-
532
- template << "A*"
533
- values << name.b
534
- end
535
- end
536
- else
537
- values << 0
538
- end
539
-
540
- values.pack(template)
541
- end
542
- end
543
-
544
- # Here we are going to patch StringQuery to put in the class-level methods so
545
- # that it can maintain a consistent interface
546
- class StringQuery
547
- class << self
548
- # Mirrors the C extension's StringQuery::local? method.
549
- def local?(string)
550
- query(LibRubyParser.pm_string_query_local(string, string.bytesize, string.encoding.name))
551
- end
552
-
553
- # Mirrors the C extension's StringQuery::constant? method.
554
- def constant?(string)
555
- query(LibRubyParser.pm_string_query_constant(string, string.bytesize, string.encoding.name))
556
- end
557
-
558
- # Mirrors the C extension's StringQuery::method_name? method.
559
- def method_name?(string)
560
- query(LibRubyParser.pm_string_query_method_name(string, string.bytesize, string.encoding.name))
561
- end
562
-
563
- private
564
-
565
- # Parse the enum result and return an appropriate boolean.
566
- def query(result)
567
- case result
568
- when :PM_STRING_QUERY_ERROR
569
- raise ArgumentError, "Invalid or non ascii-compatible encoding"
570
- when :PM_STRING_QUERY_FALSE
571
- false
572
- when :PM_STRING_QUERY_TRUE
573
- true
574
- end
575
- end
576
- end
577
- end
578
- end