brakeman 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of brakeman might be problematic. Click here for more details.

Files changed (362) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/bundle/load.rb +7 -8
  4. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/History.rdoc +8 -0
  5. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/Manifest.txt +0 -0
  6. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/README.rdoc +0 -0
  7. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/lib/ruby2ruby.rb +34 -36
  8. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/History.rdoc +47 -0
  9. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/Manifest.txt +5 -4
  10. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/README.rdoc +0 -0
  11. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/compare/normalize.rb +29 -2
  12. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/debugging.md +18 -0
  13. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_extensions.rb +0 -7
  14. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_stringscanner.rb +0 -0
  15. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby20_parser.rb +6874 -0
  16. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby20_parser.y +284 -201
  17. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby21_parser.rb +6952 -0
  18. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby21_parser.y +281 -197
  19. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby22_parser.rb +6983 -0
  20. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib/ruby_parser.yy → ruby_parser-3.13.0/lib/ruby22_parser.y} +280 -306
  21. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby23_parser.rb +6982 -0
  22. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby23_parser.y +282 -203
  23. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby24_parser.rb +6982 -0
  24. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby24_parser.y +282 -203
  25. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby25_parser.rb +6981 -0
  26. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby25_parser.y +282 -203
  27. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.rb +6999 -0
  28. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.y +2469 -0
  29. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rb +116 -118
  30. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex +10 -8
  31. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex.rb +8 -8
  32. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_parser.rb +5 -7
  33. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser.yy +2571 -0
  34. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser_extras.rb +1360 -0
  35. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/munge.rb +216 -0
  36. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/ripper.rb +23 -0
  37. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/History.rdoc +6 -0
  38. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/Manifest.txt +19 -0
  39. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/README.rdoc +54 -0
  40. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy.rb +5 -0
  41. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.rb +7 -6
  42. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.y +5 -4
  43. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.rb +7 -6
  44. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.y +5 -4
  45. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rb +1412 -0
  46. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex +179 -0
  47. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex.rb +323 -0
  48. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser.rb +30 -0
  49. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby_parser_extras.rb +43 -33
  50. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/CHANGES.md +5 -0
  51. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/Gemfile +0 -0
  52. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/LICENSE.txt +0 -0
  53. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/README.md +0 -0
  54. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/bundle_install_all_ruby_versions.sh +0 -0
  55. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml.rb +0 -0
  56. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/deep.rb +0 -0
  57. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/libyaml_checker.rb +0 -0
  58. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/load.rb +0 -0
  59. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/date.rb +2 -0
  60. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/hexadecimal.rb +0 -0
  61. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/sexagesimal.rb +0 -0
  62. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_handler.rb +0 -0
  63. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_resolver.rb +0 -0
  64. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/resolver.rb +0 -0
  65. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -0
  66. data/bundle/ruby/2.5.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +39 -0
  67. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_hack.rb +0 -0
  68. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_node_monkeypatch.rb +0 -0
  69. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_resolver.rb +0 -0
  70. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform.rb +0 -0
  71. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_boolean.rb +0 -0
  72. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_date.rb +0 -0
  73. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_float.rb +0 -0
  74. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_integer.rb +0 -0
  75. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_nil.rb +0 -0
  76. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_symbol.rb +0 -0
  77. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/transformation_map.rb +0 -0
  78. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/version.rb +1 -1
  79. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/run_specs_all_ruby_versions.sh +0 -0
  80. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/safe_yaml.gemspec +0 -0
  81. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/History.rdoc +8 -0
  82. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/Manifest.txt +0 -0
  83. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/README.rdoc +0 -0
  84. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/composite_sexp_processor.rb +0 -0
  85. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/pt_testcase.rb +2 -2
  86. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp.rb +4 -4
  87. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp_processor.rb +1 -1
  88. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/strict_sexp.rb +3 -3
  89. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/unique.rb +0 -0
  90. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/CHANGES +6 -0
  91. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/EXPRESSIONS.md +1 -1
  92. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/Gemfile +0 -0
  93. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/LICENSE +0 -0
  94. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/README.md +1 -1
  95. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple.rb +0 -0
  96. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/engine.rb +0 -0
  97. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/engine.rb +0 -0
  98. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/parser.rb +0 -0
  99. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/template.rb +0 -0
  100. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/trimming.rb +0 -0
  101. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/exceptions.rb +0 -0
  102. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filter.rb +0 -0
  103. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/code_merger.rb +0 -0
  104. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/control_flow.rb +0 -0
  105. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/dynamic_inliner.rb +0 -0
  106. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/encoding.rb +0 -0
  107. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/eraser.rb +0 -0
  108. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/escapable.rb +0 -0
  109. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/multi_flattener.rb +0 -0
  110. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/remove_bom.rb +0 -0
  111. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_analyzer.rb +0 -0
  112. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_merger.rb +0 -0
  113. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/string_splitter.rb +0 -0
  114. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/validator.rb +0 -0
  115. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generator.rb +0 -0
  116. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array.rb +0 -0
  117. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array_buffer.rb +0 -0
  118. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/erb.rb +0 -0
  119. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/rails_output_buffer.rb +0 -0
  120. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/string_buffer.rb +0 -0
  121. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/grammar.rb +0 -0
  122. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_merger.rb +0 -0
  123. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_remover.rb +0 -0
  124. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_sorter.rb +0 -0
  125. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/dispatcher.rb +0 -0
  126. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/fast.rb +0 -0
  127. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/filter.rb +0 -0
  128. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/pretty.rb +0 -0
  129. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/safe.rb +0 -0
  130. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/map.rb +0 -0
  131. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/dispatcher.rb +2 -1
  132. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/engine_dsl.rb +0 -0
  133. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/grammar_dsl.rb +0 -0
  134. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/options.rb +0 -0
  135. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/template.rb +0 -0
  136. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/parser.rb +0 -0
  137. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/static_analyzer.rb +0 -0
  138. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates.rb +0 -0
  139. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/rails.rb +2 -2
  140. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/tilt.rb +0 -0
  141. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/utils.rb +0 -0
  142. data/bundle/ruby/2.5.0/gems/temple-0.8.1/lib/temple/version.rb +3 -0
  143. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/temple.gemspec +0 -0
  144. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/CHANGELOG.md +4 -0
  145. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/MIT-LICENSE.txt +1 -1
  146. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/README.md +10 -10
  147. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.5.0/data/display_width.marshal.gz +0 -0
  148. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width.rb +0 -0
  149. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/constants.rb +2 -2
  150. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/index.rb +0 -0
  151. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  152. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/string_ext.rb +0 -0
  153. data/lib/brakeman/checks/base_check.rb +16 -0
  154. data/lib/brakeman/checks/check_content_tag.rb +12 -0
  155. data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -6
  156. data/lib/brakeman/checks/check_evaluation.rb +0 -1
  157. data/lib/brakeman/checks/check_execute.rb +18 -0
  158. data/lib/brakeman/checks/check_send.rb +0 -1
  159. data/lib/brakeman/checks/check_session_manipulation.rb +0 -1
  160. data/lib/brakeman/checks/check_sql.rb +12 -3
  161. data/lib/brakeman/file_parser.rb +8 -4
  162. data/lib/brakeman/parsers/haml_embedded.rb +44 -0
  163. data/lib/brakeman/parsers/slim_embedded.rb +44 -0
  164. data/lib/brakeman/parsers/template_parser.rb +2 -4
  165. data/lib/brakeman/processors/alias_processor.rb +23 -1
  166. data/lib/brakeman/processors/lib/call_conversion_helper.rb +4 -0
  167. data/lib/brakeman/processors/slim_template_processor.rb +16 -0
  168. data/lib/brakeman/processors/template_alias_processor.rb +2 -2
  169. data/lib/brakeman/scanner.rb +11 -10
  170. data/lib/brakeman/tracker.rb +5 -1
  171. data/lib/brakeman/tracker/config.rb +32 -7
  172. data/lib/brakeman/util.rb +17 -0
  173. data/lib/brakeman/version.rb +1 -1
  174. metadata +157 -320
  175. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby20_parser.rb +0 -6687
  176. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby21_parser.rb +0 -6767
  177. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.rb +0 -6803
  178. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.y +0 -2376
  179. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby23_parser.rb +0 -6818
  180. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby24_parser.rb +0 -6818
  181. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby25_parser.rb +0 -6818
  182. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CODE_OF_CONDUCT.md +0 -10
  183. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CONTRIBUTING.md +0 -148
  184. data/bundle/ruby/2.5.0/gems/sass-3.4.25/MIT-LICENSE +0 -20
  185. data/bundle/ruby/2.5.0/gems/sass-3.4.25/README.md +0 -227
  186. data/bundle/ruby/2.5.0/gems/sass-3.4.25/REVISION +0 -1
  187. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION +0 -1
  188. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_DATE +0 -1
  189. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_NAME +0 -1
  190. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/sass-spec-ref.sh +0 -32
  191. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/update_watch.rb +0 -13
  192. data/bundle/ruby/2.5.0/gems/sass-3.4.25/init.rb +0 -18
  193. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass.rb +0 -109
  194. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores.rb +0 -15
  195. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/base.rb +0 -88
  196. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/chain.rb +0 -34
  197. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/filesystem.rb +0 -60
  198. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/memory.rb +0 -46
  199. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/null.rb +0 -25
  200. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/callbacks.rb +0 -67
  201. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/css.rb +0 -408
  202. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/deprecation.rb +0 -55
  203. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/engine.rb +0 -1226
  204. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/environment.rb +0 -215
  205. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/error.rb +0 -198
  206. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec.rb +0 -9
  207. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/base.rb +0 -199
  208. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_convert.rb +0 -283
  209. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_scss.rb +0 -440
  210. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb +0 -47
  211. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers.rb +0 -23
  212. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/base.rb +0 -182
  213. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/deprecated_path.rb +0 -51
  214. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/filesystem.rb +0 -219
  215. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger.rb +0 -17
  216. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/base.rb +0 -36
  217. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/delayed.rb +0 -50
  218. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/log_level.rb +0 -45
  219. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/media.rb +0 -210
  220. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin.rb +0 -134
  221. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/compiler.rb +0 -582
  222. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/configuration.rb +0 -134
  223. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/generic.rb +0 -15
  224. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/merb.rb +0 -48
  225. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rack.rb +0 -60
  226. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rails.rb +0 -47
  227. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/staleness_checker.rb +0 -199
  228. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/railtie.rb +0 -10
  229. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/repl.rb +0 -57
  230. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/root.rb +0 -7
  231. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script.rb +0 -66
  232. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_lexer.rb +0 -33
  233. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_parser.rb +0 -33
  234. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_variable_warning.rb +0 -52
  235. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/functions.rb +0 -2693
  236. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/lexer.rb +0 -464
  237. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/parser.rb +0 -832
  238. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree.rb +0 -16
  239. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/funcall.rb +0 -313
  240. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/interpolation.rb +0 -223
  241. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/list_literal.rb +0 -104
  242. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/literal.rb +0 -49
  243. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/map_literal.rb +0 -64
  244. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/node.rb +0 -127
  245. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/operation.rb +0 -156
  246. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/selector.rb +0 -26
  247. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/string_interpolation.rb +0 -125
  248. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/unary_operation.rb +0 -69
  249. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/variable.rb +0 -57
  250. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value.rb +0 -11
  251. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/arg_list.rb +0 -36
  252. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/base.rb +0 -241
  253. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/bool.rb +0 -35
  254. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/color.rb +0 -698
  255. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/helpers.rb +0 -272
  256. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/list.rb +0 -113
  257. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/map.rb +0 -70
  258. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/null.rb +0 -44
  259. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/number.rb +0 -563
  260. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/string.rb +0 -138
  261. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss.rb +0 -14
  262. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/css_parser.rb +0 -56
  263. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/parser.rb +0 -1254
  264. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/rx.rb +0 -140
  265. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/static_parser.rb +0 -373
  266. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector.rb +0 -323
  267. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/abstract_sequence.rb +0 -111
  268. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/comma_sequence.rb +0 -191
  269. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/pseudo.rb +0 -266
  270. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/sequence.rb +0 -636
  271. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple.rb +0 -117
  272. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple_sequence.rb +0 -344
  273. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/shared.rb +0 -76
  274. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/map.rb +0 -213
  275. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/position.rb +0 -39
  276. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/range.rb +0 -41
  277. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/stack.rb +0 -120
  278. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/supports.rb +0 -225
  279. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/at_root_node.rb +0 -83
  280. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/charset_node.rb +0 -22
  281. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/comment_node.rb +0 -82
  282. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/content_node.rb +0 -9
  283. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/css_import_node.rb +0 -68
  284. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/debug_node.rb +0 -18
  285. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/directive_node.rb +0 -59
  286. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/each_node.rb +0 -24
  287. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/error_node.rb +0 -18
  288. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/extend_node.rb +0 -43
  289. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/for_node.rb +0 -36
  290. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/function_node.rb +0 -44
  291. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/if_node.rb +0 -52
  292. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/import_node.rb +0 -75
  293. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/keyframe_rule_node.rb +0 -15
  294. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/media_node.rb +0 -48
  295. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_def_node.rb +0 -38
  296. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_node.rb +0 -52
  297. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/node.rb +0 -240
  298. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/prop_node.rb +0 -170
  299. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/return_node.rb +0 -19
  300. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/root_node.rb +0 -44
  301. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/rule_node.rb +0 -155
  302. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/supports_node.rb +0 -38
  303. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/trace_node.rb +0 -33
  304. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/variable_node.rb +0 -36
  305. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/base.rb +0 -72
  306. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/check_nesting.rb +0 -173
  307. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/convert.rb +0 -351
  308. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/cssize.rb +0 -373
  309. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/deep_copy.rb +0 -107
  310. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/extend.rb +0 -70
  311. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/perform.rb +0 -564
  312. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/set_options.rb +0 -139
  313. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/to_css.rb +0 -409
  314. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/warn_node.rb +0 -18
  315. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/while_node.rb +0 -18
  316. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util.rb +0 -1375
  317. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/cross_platform_random.rb +0 -19
  318. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/multibyte_string_scanner.rb +0 -155
  319. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/normalized_map.rb +0 -129
  320. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/ordered_hash.rb +0 -192
  321. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/subset_map.rb +0 -109
  322. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/test.rb +0 -9
  323. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/version.rb +0 -124
  324. data/bundle/ruby/2.5.0/gems/sass-3.4.25/rails/init.rb +0 -1
  325. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CHANGELOG.md +0 -1
  326. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CONTRIBUTING.md +0 -38
  327. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Gemfile +0 -20
  328. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Guardfile +0 -8
  329. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/LICENSE +0 -20
  330. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/README.md +0 -349
  331. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Rakefile +0 -5
  332. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Vagrantfile +0 -96
  333. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen.rb +0 -54
  334. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapter.rb +0 -327
  335. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  336. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  337. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  338. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  339. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  340. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/directory_record.rb +0 -406
  341. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/listener.rb +0 -323
  342. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/turnstile.rb +0 -32
  343. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/version.rb +0 -3
  344. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/listen.gemspec +0 -28
  345. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  346. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  347. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  348. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  349. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  350. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  351. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  352. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/listener_spec.rb +0 -258
  353. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  354. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen_spec.rb +0 -67
  355. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/spec_helper.rb +0 -25
  356. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/adapter_helper.rb +0 -666
  357. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  358. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  359. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/listeners_helper.rb +0 -179
  360. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/platform_helper.rb +0 -15
  361. data/bundle/ruby/2.5.0/gems/temple-0.8.0/lib/temple/version.rb +0 -3
  362. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.4.1/data/display_width.marshal.gz +0 -0
@@ -0,0 +1,2469 @@
1
+ # -*- racc -*-
2
+
3
+ class Ruby26Parser
4
+
5
+ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
6
+ kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
7
+ kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
8
+ kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
9
+ kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
10
+ k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
11
+ tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
12
+ tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
13
+ tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
14
+ tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
15
+ tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
16
+ tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
17
+ tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
18
+ tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
19
+ tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
20
+ tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA
21
+ tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND tUBANG
22
+ tRATIONAL tIMAGINARY
23
+ tLABEL_END
24
+ tLONELY
25
+
26
+ prechigh
27
+ right tBANG tTILDE tUPLUS
28
+ right tPOW
29
+ right tUMINUS_NUM tUMINUS
30
+ left tSTAR2 tDIVIDE tPERCENT
31
+ left tPLUS tMINUS
32
+ left tLSHFT tRSHFT
33
+ left tAMPER2
34
+ left tPIPE tCARET
35
+ left tGT tGEQ tLT tLEQ
36
+ nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
37
+ left tANDOP
38
+ left tOROP
39
+ nonassoc tDOT2 tDOT3
40
+ right tEH tCOLON
41
+ left kRESCUE_MOD
42
+ right tEQL tOP_ASGN
43
+ nonassoc kDEFINED
44
+ right kNOT
45
+ left kOR kAND
46
+ nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
47
+ nonassoc tLBRACE_ARG
48
+ nonassoc tLOWEST
49
+ preclow
50
+
51
+ rule
52
+
53
+ program: {
54
+ self.lexer.lex_state = :expr_beg
55
+ }
56
+ top_compstmt
57
+ {
58
+ result = new_compstmt val
59
+ }
60
+
61
+ top_compstmt: top_stmts opt_terms
62
+ {
63
+ result = val[0]
64
+ }
65
+
66
+ top_stmts: none
67
+ | top_stmt
68
+ | top_stmts terms top_stmt
69
+ {
70
+ result = self.block_append val[0], val[2]
71
+ }
72
+ | error top_stmt
73
+
74
+ top_stmt: stmt
75
+ {
76
+ result = val[0]
77
+
78
+ # TODO: remove once I have more confidence this is fixed
79
+ # result.each_of_type :call_args do |s|
80
+ # debug20 666, s, result
81
+ # end
82
+ }
83
+ | klBEGIN
84
+ {
85
+ if (self.in_def || self.in_single > 0) then
86
+ debug20 1
87
+ yyerror "BEGIN in method"
88
+ end
89
+ self.env.extend
90
+ }
91
+ begin_block
92
+ {
93
+ _, _, block = val
94
+ result = block
95
+ }
96
+
97
+ begin_block: tLCURLY top_compstmt tRCURLY
98
+ {
99
+ _, stmt, _ = val
100
+ result = new_iter s(:preexe), 0, stmt
101
+ }
102
+
103
+ bodystmt: compstmt opt_rescue k_else
104
+ {
105
+ res = _values[-2]
106
+ yyerror "else without rescue is useless" unless res
107
+ }
108
+ compstmt
109
+ opt_ensure
110
+ {
111
+ body, resc, _, _, els, ens = val
112
+
113
+ result = new_body [body, resc, els, ens]
114
+ }
115
+ | compstmt opt_rescue opt_ensure
116
+ {
117
+ body, resc, ens = val
118
+
119
+ result = new_body [body, resc, nil, ens]
120
+ }
121
+
122
+ compstmt: stmts opt_terms
123
+ {
124
+ result = new_compstmt val
125
+ }
126
+
127
+ stmts: none
128
+ | stmt_or_begin # TODO: newline_node ?
129
+ | stmts terms stmt_or_begin
130
+ {
131
+ result = self.block_append val[0], val[2]
132
+ }
133
+ | error stmt
134
+ {
135
+ result = val[1]
136
+ debug20 2, val, result
137
+ }
138
+
139
+ stmt_or_begin: stmt
140
+ | klBEGIN
141
+ {
142
+ if (self.in_def || self.in_single > 0) then
143
+ debug20 1
144
+ yyerror "BEGIN in method"
145
+ end
146
+ self.env.extend
147
+ }
148
+ begin_block
149
+ {
150
+ _, _, stmt = val
151
+ result = stmt
152
+ }
153
+
154
+ stmt: kALIAS fitem
155
+ {
156
+ lexer.lex_state = :expr_fname
157
+ result = self.lexer.lineno
158
+ }
159
+ fitem
160
+ {
161
+ result = s(:alias, val[1], val[3]).line(val[2])
162
+ }
163
+ | kALIAS tGVAR tGVAR
164
+ {
165
+ result = s(:valias, val[1].to_sym, val[2].to_sym)
166
+ }
167
+ | kALIAS tGVAR tBACK_REF
168
+ {
169
+ result = s(:valias, val[1].to_sym, :"$#{val[2]}")
170
+ }
171
+ | kALIAS tGVAR tNTH_REF
172
+ {
173
+ yyerror "can't make alias for the number variables"
174
+ }
175
+ | kUNDEF undef_list
176
+ {
177
+ result = val[1]
178
+ }
179
+ | stmt kIF_MOD expr_value
180
+ {
181
+ result = new_if val[2], val[0], nil
182
+ }
183
+ | stmt kUNLESS_MOD expr_value
184
+ {
185
+ result = new_if val[2], nil, val[0]
186
+ }
187
+ | stmt kWHILE_MOD expr_value
188
+ {
189
+ result = new_while val[0], val[2], true
190
+ }
191
+ | stmt kUNTIL_MOD expr_value
192
+ {
193
+ result = new_until val[0], val[2], true
194
+ }
195
+ | stmt kRESCUE_MOD stmt
196
+ {
197
+ body, _, resbody = val
198
+ result = new_rescue body, new_resbody(s(:array), resbody)
199
+ }
200
+ | klEND tLCURLY compstmt tRCURLY
201
+ {
202
+ if (self.in_def || self.in_single > 0) then
203
+ debug20 3
204
+ yyerror "END in method; use at_exit"
205
+ end
206
+ result = new_iter s(:postexe), 0, val[2]
207
+ }
208
+ | command_asgn
209
+ | mlhs tEQL command_call
210
+ {
211
+ result = new_masgn val[0], val[2], :wrap
212
+ }
213
+ | lhs tEQL mrhs
214
+ {
215
+ result = new_assign val[0], s(:svalue, val[2])
216
+ }
217
+ | mlhs tEQL mrhs_arg
218
+ {
219
+ result = new_masgn val[0], val[2]
220
+ }
221
+ | expr
222
+
223
+ command_asgn: lhs tEQL command_rhs
224
+ {
225
+ result = new_assign val[0], val[2]
226
+ }
227
+ # | lhs tEQL command_asgn
228
+ # {
229
+ # result = new_assign val[0], val[2]
230
+ # }
231
+ | var_lhs tOP_ASGN command_rhs
232
+ {
233
+ result = new_op_asgn val
234
+ }
235
+ | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_rhs
236
+ {
237
+ result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5])
238
+ }
239
+ | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
240
+ {
241
+ result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
242
+ if val[1] == '&.'
243
+ result.sexp_type = :safe_op_asgn
244
+ end
245
+ result.line = val[0].line
246
+ }
247
+ | primary_value call_op tCONSTANT tOP_ASGN command_rhs
248
+ {
249
+ result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
250
+ if val[1] == '&.'
251
+ result.sexp_type = :safe_op_asgn
252
+ end
253
+ result.line = val[0].line
254
+ }
255
+ | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
256
+ {
257
+ result = s(:op_asgn, val[0], val[4], val[2], val[3])
258
+ debug20 4, val, result
259
+ }
260
+ | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
261
+ {
262
+ result = s(:op_asgn, val[0], val[4], val[2], val[3])
263
+ debug20 5, val, result
264
+ }
265
+ | backref tOP_ASGN command_rhs
266
+ {
267
+ self.backref_assign_error val[0]
268
+ }
269
+
270
+ command_rhs: command_call =tOP_ASGN
271
+ {
272
+ expr, = val
273
+ result = value_expr expr
274
+ }
275
+ | command_call kRESCUE_MOD stmt
276
+ {
277
+ expr, _, resbody = val
278
+ expr = value_expr expr
279
+ result = new_rescue(expr, new_resbody(s(:array), resbody))
280
+ }
281
+ | command_asgn
282
+
283
+ expr: command_call
284
+ | expr kAND expr
285
+ {
286
+ result = logical_op :and, val[0], val[2]
287
+ }
288
+ | expr kOR expr
289
+ {
290
+ result = logical_op :or, val[0], val[2]
291
+ }
292
+ | kNOT opt_nl expr
293
+ {
294
+ result = s(:call, val[2], :"!")
295
+ }
296
+ | tBANG command_call
297
+ {
298
+ result = s(:call, val[1], :"!")
299
+ }
300
+ | arg
301
+
302
+ expr_value: expr
303
+ {
304
+ result = value_expr(val[0])
305
+ }
306
+
307
+ expr_value_do: {
308
+ lexer.cond.push true
309
+ }
310
+ expr_value do
311
+ {
312
+ lexer.cond.pop
313
+ }
314
+ {
315
+ _, expr, _, _ = val
316
+ result = expr
317
+ }
318
+
319
+ command_call: command
320
+ | block_command
321
+
322
+ block_command: block_call
323
+ | block_call call_op2 operation2 command_args
324
+ {
325
+ result = new_call val[0], val[2].to_sym, val[3]
326
+ }
327
+
328
+ cmd_brace_block: tLBRACE_ARG
329
+ {
330
+ # self.env.extend(:dynamic)
331
+ result = self.lexer.lineno
332
+ }
333
+ brace_body tRCURLY
334
+ {
335
+ _, line, body, _ = val
336
+
337
+ result = body
338
+ result.line = line
339
+
340
+ # self.env.unextend
341
+ }
342
+
343
+ fcall: operation
344
+ {
345
+ result = new_call nil, val[0].to_sym
346
+ }
347
+
348
+ command: fcall command_args =tLOWEST
349
+ {
350
+ result = val[0].concat val[1].sexp_body # REFACTOR pattern
351
+ }
352
+ | fcall command_args cmd_brace_block
353
+ {
354
+ result = val[0].concat val[1].sexp_body
355
+ if val[2] then
356
+ block_dup_check result, val[2]
357
+
358
+ result, operation = val[2], result
359
+ result.insert 1, operation
360
+ end
361
+ }
362
+ | primary_value call_op operation2 command_args =tLOWEST
363
+ {
364
+ result = new_call val[0], val[2].to_sym, val[3], val[1]
365
+ }
366
+ | primary_value call_op operation2 command_args cmd_brace_block
367
+ {
368
+ recv, _, msg, args, block = val
369
+ call = new_call recv, msg.to_sym, args, val[1]
370
+
371
+ block_dup_check call, block
372
+
373
+ block.insert 1, call
374
+ result = block
375
+ }
376
+ | primary_value tCOLON2 operation2 command_args =tLOWEST
377
+ {
378
+ result = new_call val[0], val[2].to_sym, val[3]
379
+ }
380
+ | primary_value tCOLON2 operation2 command_args cmd_brace_block
381
+ {
382
+ recv, _, msg, args, block = val
383
+ call = new_call recv, msg.to_sym, args
384
+
385
+ block_dup_check call, block
386
+
387
+ block.insert 1, call
388
+ result = block
389
+ }
390
+ | kSUPER command_args
391
+ {
392
+ result = new_super val[1]
393
+ }
394
+ | kYIELD command_args
395
+ {
396
+ result = new_yield val[1]
397
+ }
398
+ | k_return call_args
399
+ {
400
+ line = val[0].last
401
+ result = s(:return, ret_args(val[1])).line(line)
402
+ }
403
+ | kBREAK call_args
404
+ {
405
+ line = val[0].last
406
+ result = s(:break, ret_args(val[1])).line(line)
407
+ }
408
+ | kNEXT call_args
409
+ {
410
+ line = val[0].last
411
+ result = s(:next, ret_args(val[1])).line(line)
412
+ }
413
+
414
+ mlhs: mlhs_basic
415
+ | tLPAREN mlhs_inner rparen
416
+ {
417
+ result = val[1]
418
+ }
419
+
420
+ mlhs_inner: mlhs_basic
421
+ | tLPAREN mlhs_inner rparen
422
+ {
423
+ result = s(:masgn, s(:array, val[1]))
424
+ }
425
+
426
+ mlhs_basic: mlhs_head
427
+ {
428
+ result = s(:masgn, val[0])
429
+ }
430
+ | mlhs_head mlhs_item
431
+ {
432
+ result = s(:masgn, val[0] << val[1].compact)
433
+ }
434
+ | mlhs_head tSTAR mlhs_node
435
+ {
436
+ result = s(:masgn, val[0] << s(:splat, val[2]))
437
+ }
438
+ | mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
439
+ {
440
+ ary1, _, splat, _, ary2 = val
441
+
442
+ result = list_append ary1, s(:splat, splat)
443
+ result.concat ary2.sexp_body
444
+ result = s(:masgn, result)
445
+ }
446
+ | mlhs_head tSTAR
447
+ {
448
+ result = s(:masgn, val[0] << s(:splat))
449
+ }
450
+ | mlhs_head tSTAR tCOMMA mlhs_post
451
+ {
452
+ ary = list_append val[0], s(:splat)
453
+ ary.concat val[3].sexp_body
454
+ result = s(:masgn, ary)
455
+ }
456
+ | tSTAR mlhs_node
457
+ {
458
+ result = s(:masgn, s(:array, s(:splat, val[1])))
459
+ }
460
+ | tSTAR mlhs_node tCOMMA mlhs_post
461
+ {
462
+ ary = s(:array, s(:splat, val[1]))
463
+ ary.concat val[3].sexp_body
464
+ result = s(:masgn, ary)
465
+ }
466
+ | tSTAR
467
+ {
468
+ result = s(:masgn, s(:array, s(:splat)))
469
+ }
470
+ | tSTAR tCOMMA mlhs_post
471
+ {
472
+ result = s(:masgn, s(:array, s(:splat), *val[2].sexp_body))
473
+ }
474
+
475
+ mlhs_item: mlhs_node
476
+ | tLPAREN mlhs_inner rparen
477
+ {
478
+ result = val[1]
479
+ }
480
+
481
+ mlhs_head: mlhs_item tCOMMA
482
+ {
483
+ result = s(:array, val[0])
484
+ }
485
+ | mlhs_head mlhs_item tCOMMA
486
+ {
487
+ result = val[0] << val[1].compact
488
+ }
489
+
490
+ mlhs_post: mlhs_item
491
+ {
492
+ result = s(:array, val[0])
493
+ }
494
+ | mlhs_post tCOMMA mlhs_item
495
+ {
496
+ result = list_append val[0], val[2]
497
+ }
498
+
499
+ mlhs_node: user_variable
500
+ {
501
+ result = self.assignable val[0]
502
+ }
503
+ | keyword_variable
504
+ {
505
+ result = self.assignable val[0]
506
+ }
507
+ | primary_value tLBRACK2 opt_call_args rbracket
508
+ {
509
+ result = self.aryset val[0], val[2]
510
+ }
511
+ | primary_value call_op tIDENTIFIER
512
+ {
513
+ result = new_attrasgn val[0], val[2], val[1]
514
+ }
515
+ | primary_value tCOLON2 tIDENTIFIER
516
+ {
517
+ result = s(:attrasgn, val[0], :"#{val[2]}=")
518
+ }
519
+ | primary_value call_op tCONSTANT
520
+ {
521
+ result = new_attrasgn val[0], val[2], val[1]
522
+ }
523
+ | primary_value tCOLON2 tCONSTANT
524
+ {
525
+ if (self.in_def || self.in_single > 0) then
526
+ debug20 7
527
+ yyerror "dynamic constant assignment"
528
+ end
529
+
530
+ result = s(:const, s(:colon2, val[0], val[2].to_sym), nil)
531
+ }
532
+ | tCOLON3 tCONSTANT
533
+ {
534
+ if (self.in_def || self.in_single > 0) then
535
+ debug20 8
536
+ yyerror "dynamic constant assignment"
537
+ end
538
+
539
+ result = s(:const, nil, s(:colon3, val[1].to_sym))
540
+ }
541
+ | backref
542
+ {
543
+ self.backref_assign_error val[0]
544
+ }
545
+
546
+ lhs: user_variable
547
+ {
548
+ result = self.assignable val[0]
549
+ }
550
+ | keyword_variable
551
+ {
552
+ result = self.assignable val[0]
553
+ debug20 9, val, result
554
+ }
555
+ | primary_value tLBRACK2 opt_call_args rbracket
556
+ {
557
+ result = self.aryset val[0], val[2]
558
+ }
559
+ | primary_value call_op tIDENTIFIER # REFACTOR
560
+ {
561
+ result = new_attrasgn val[0], val[2], val[1]
562
+ }
563
+ | primary_value tCOLON2 tIDENTIFIER
564
+ {
565
+ result = s(:attrasgn, val[0], :"#{val[2]}=")
566
+ }
567
+ | primary_value call_op tCONSTANT # REFACTOR?
568
+ {
569
+ result = new_attrasgn val[0], val[2], val[1]
570
+ }
571
+ | primary_value tCOLON2 tCONSTANT
572
+ {
573
+ if (self.in_def || self.in_single > 0) then
574
+ debug20 10
575
+ yyerror "dynamic constant assignment"
576
+ end
577
+
578
+ result = s(:const, s(:colon2, val[0], val[2].to_sym))
579
+ }
580
+ | tCOLON3 tCONSTANT
581
+ {
582
+ if (self.in_def || self.in_single > 0) then
583
+ debug20 11
584
+ yyerror "dynamic constant assignment"
585
+ end
586
+
587
+ result = s(:const, s(:colon3, val[1].to_sym))
588
+ }
589
+ | backref
590
+ {
591
+ self.backref_assign_error val[0]
592
+ }
593
+
594
+ cname: tIDENTIFIER
595
+ {
596
+ yyerror "class/module name must be CONSTANT"
597
+ }
598
+ | tCONSTANT
599
+
600
+ cpath: tCOLON3 cname
601
+ {
602
+ result = s(:colon3, val[1].to_sym)
603
+ }
604
+ | cname
605
+ {
606
+ result = val[0].to_sym
607
+ }
608
+ | primary_value tCOLON2 cname
609
+ {
610
+ result = s(:colon2, val[0], val[2].to_sym)
611
+ }
612
+
613
+ fname: tIDENTIFIER | tCONSTANT | tFID
614
+ | op
615
+ {
616
+ lexer.lex_state = :expr_end
617
+ result = val[0]
618
+ }
619
+
620
+ | reswords
621
+ {
622
+ (sym, _line), = val
623
+ lexer.lex_state = :expr_end
624
+ result = sym
625
+ }
626
+
627
+ fsym: fname | symbol
628
+
629
+ fitem: fsym
630
+ {
631
+ result = s(:lit, val[0].to_sym)
632
+ }
633
+ | dsym
634
+
635
+ undef_list: fitem
636
+ {
637
+ result = new_undef val[0]
638
+ }
639
+ |
640
+ undef_list tCOMMA
641
+ {
642
+ lexer.lex_state = :expr_fname
643
+ }
644
+ fitem
645
+ {
646
+ result = new_undef val[0], val[3]
647
+ }
648
+
649
+ op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
650
+ | tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
651
+ | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
652
+ | tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
653
+ | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
654
+ | tUBANG
655
+
656
+ reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
657
+ | kALIAS | kAND | kBEGIN | kBREAK | kCASE
658
+ | kCLASS | kDEF | kDEFINED | kDO | kELSE
659
+ | kELSIF | kEND | kENSURE | kFALSE | kFOR
660
+ | kIN | kMODULE | kNEXT | kNIL | kNOT
661
+ | kOR | kREDO | kRESCUE | kRETRY | kRETURN
662
+ | kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
663
+ | kWHEN | kYIELD | kIF | kUNLESS | kWHILE
664
+ | kUNTIL
665
+
666
+ arg: lhs tEQL arg_rhs
667
+ {
668
+ result = new_assign val[0], val[2]
669
+ }
670
+ | var_lhs tOP_ASGN arg_rhs
671
+ {
672
+ result = new_op_asgn val
673
+ }
674
+ | primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg_rhs
675
+ {
676
+ val[2].sexp_type = :arglist if val[2]
677
+ result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5])
678
+ }
679
+ | primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
680
+ {
681
+ result = new_op_asgn2 val
682
+ }
683
+ | primary_value call_op tCONSTANT tOP_ASGN arg_rhs
684
+ {
685
+ result = new_op_asgn2 val
686
+ }
687
+ | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
688
+ {
689
+ result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
690
+ }
691
+ | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
692
+ {
693
+ # TODO: assignment
694
+ raise "not yet: %p" % [val]
695
+ }
696
+ | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
697
+ {
698
+ # TODO: assignment
699
+ raise "not yet: %p" % [val]
700
+ }
701
+ | backref tOP_ASGN arg_rhs
702
+ {
703
+ # TODO: lhs = var_field val[0]
704
+ asgn = new_op_asgn val
705
+ result = self.backref_assign_error asgn
706
+ }
707
+ | arg tDOT2 arg
708
+ {
709
+ v1, v2 = val[0], val[2]
710
+ if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
711
+ result = s(:lit, (v1.last)..(v2.last))
712
+ else
713
+ result = s(:dot2, v1, v2)
714
+ end
715
+ }
716
+ | arg tDOT3 arg
717
+ {
718
+ v1, v2 = val[0], val[2]
719
+ if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
720
+ result = s(:lit, (v1.last)...(v2.last))
721
+ else
722
+ result = s(:dot3, v1, v2)
723
+ end
724
+ }
725
+ | arg tDOT2
726
+ {
727
+ v1, v2 = val[0], nil
728
+
729
+ result = s(:dot2, v1, v2)
730
+ }
731
+ | arg tDOT3
732
+ {
733
+ v1, v2 = val[0], nil
734
+
735
+ result = s(:dot3, v1, v2)
736
+ }
737
+ | arg tPLUS arg
738
+ {
739
+ result = new_call val[0], :+, argl(val[2])
740
+ }
741
+ | arg tMINUS arg
742
+ {
743
+ result = new_call val[0], :-, argl(val[2])
744
+ }
745
+ | arg tSTAR2 arg # TODO: rename
746
+ {
747
+ result = new_call val[0], :*, argl(val[2])
748
+ }
749
+ | arg tDIVIDE arg
750
+ {
751
+ result = new_call val[0], :"/", argl(val[2])
752
+ }
753
+ | arg tPERCENT arg
754
+ {
755
+ result = new_call val[0], :"%", argl(val[2])
756
+ }
757
+ | arg tPOW arg
758
+ {
759
+ result = new_call val[0], :**, argl(val[2])
760
+ }
761
+ | tUMINUS_NUM simple_numeric tPOW arg
762
+ {
763
+ result = new_call(new_call(s(:lit, val[1]), :"**", argl(val[3])), :"-@")
764
+ }
765
+ | tUPLUS arg
766
+ {
767
+ result = new_call val[1], :"+@"
768
+ }
769
+ | tUMINUS arg
770
+ {
771
+ result = new_call val[1], :"-@"
772
+ }
773
+ | arg tPIPE arg
774
+ {
775
+ result = new_call val[0], :"|", argl(val[2])
776
+ }
777
+ | arg tCARET arg
778
+ {
779
+ result = new_call val[0], :"^", argl(val[2])
780
+ }
781
+ | arg tAMPER2 arg
782
+ {
783
+ result = new_call val[0], :"&", argl(val[2])
784
+ }
785
+ | arg tCMP arg
786
+ {
787
+ result = new_call val[0], :"<=>", argl(val[2])
788
+ }
789
+ | rel_expr =tCMP
790
+ | arg tEQ arg
791
+ {
792
+ result = new_call val[0], :"==", argl(val[2])
793
+ }
794
+ | arg tEQQ arg
795
+ {
796
+ result = new_call val[0], :"===", argl(val[2])
797
+ }
798
+ | arg tNEQ arg
799
+ {
800
+ result = new_call val[0], :"!=", argl(val[2])
801
+ }
802
+ | arg tMATCH arg
803
+ {
804
+ result = new_match val[0], val[2]
805
+ }
806
+ | arg tNMATCH arg
807
+ {
808
+ result = s(:not, new_match(val[0], val[2]))
809
+ }
810
+ | tBANG arg
811
+ {
812
+ result = new_call val[1], :"!"
813
+ }
814
+ | tTILDE arg
815
+ {
816
+ result = new_call value_expr(val[1]), :"~"
817
+ }
818
+ | arg tLSHFT arg
819
+ {
820
+ val[0] = value_expr val[0]
821
+ val[2] = value_expr val[2]
822
+ result = new_call val[0], :"\<\<", argl(val[2])
823
+ }
824
+ | arg tRSHFT arg
825
+ {
826
+ val[0] = value_expr val[0]
827
+ val[2] = value_expr val[2]
828
+ result = new_call val[0], :">>", argl(val[2])
829
+ }
830
+ | arg tANDOP arg
831
+ {
832
+ result = logical_op :and, val[0], val[2]
833
+ }
834
+ | arg tOROP arg
835
+ {
836
+ result = logical_op :or, val[0], val[2]
837
+ }
838
+ | kDEFINED opt_nl arg
839
+ {
840
+ result = s(:defined, val[2])
841
+ }
842
+ | arg tEH arg opt_nl tCOLON arg
843
+ {
844
+ result = s(:if, val[0], val[2], val[5])
845
+ }
846
+ | primary
847
+
848
+ relop: tGT
849
+ | tLT
850
+ | tGEQ
851
+ | tLEQ
852
+
853
+ rel_expr: arg relop arg =tGT
854
+ {
855
+ lhs, op, rhs = val
856
+ result = new_call lhs, op.to_sym, argl(rhs)
857
+ }
858
+ | rel_expr relop arg =tGT
859
+ {
860
+ lhs, op, rhs = val
861
+ warn "comparison '%s' after comparison", op
862
+ result = new_call lhs, op.to_sym, argl(rhs)
863
+ }
864
+
865
+ arg_value: arg
866
+ {
867
+ result = value_expr(val[0])
868
+ }
869
+
870
+ aref_args: none
871
+ | args trailer
872
+ {
873
+ result = args [val[0]]
874
+ }
875
+ | args tCOMMA assocs trailer
876
+ {
877
+ result = args [val[0], array_to_hash(val[2])]
878
+ }
879
+ | assocs trailer
880
+ {
881
+ result = args [array_to_hash(val[0])]
882
+ }
883
+
884
+ arg_rhs: arg =tOP_ASGN
885
+ | arg kRESCUE_MOD arg
886
+ {
887
+ body, _, resbody = val
888
+ body = value_expr body
889
+ resbody = remove_begin resbody
890
+ result = new_rescue(body, new_resbody(s(:array), resbody))
891
+ }
892
+
893
+ paren_args: tLPAREN2 opt_call_args rparen
894
+ {
895
+ result = val[1]
896
+ }
897
+
898
+ opt_paren_args: none
899
+ | paren_args
900
+
901
+ opt_call_args: none
902
+ {
903
+ result = val[0]
904
+ }
905
+ | call_args
906
+ {
907
+ result = val[0]
908
+ }
909
+ | args tCOMMA
910
+ {
911
+ result = args val
912
+ }
913
+ | args tCOMMA assocs tCOMMA
914
+ {
915
+ result = args [val[0], array_to_hash(val[2])]
916
+ }
917
+ | assocs tCOMMA
918
+ {
919
+ result = args [array_to_hash(val[0])]
920
+ }
921
+
922
+ call_args: command
923
+ {
924
+ warning "parenthesize argument(s) for future version"
925
+ result = call_args val
926
+ }
927
+ | args opt_block_arg
928
+ {
929
+ result = call_args val
930
+ result = self.arg_blk_pass val[0], val[1]
931
+ }
932
+ | assocs opt_block_arg
933
+ {
934
+ result = call_args [array_to_hash(val[0])]
935
+ result = self.arg_blk_pass result, val[1]
936
+ }
937
+ | args tCOMMA assocs opt_block_arg
938
+ {
939
+ result = call_args [val[0], array_to_hash(val[2])]
940
+ result = self.arg_blk_pass result, val[3]
941
+ }
942
+ | block_arg
943
+ {
944
+ result = call_args val
945
+ }
946
+
947
+ command_args: {
948
+ result = lexer.cmdarg.store true
949
+ }
950
+ call_args
951
+ {
952
+ lexer.cmdarg.restore val[0]
953
+ result = val[1]
954
+ }
955
+
956
+ block_arg: tAMPER arg_value
957
+ {
958
+ result = s(:block_pass, val[1])
959
+ }
960
+
961
+ opt_block_arg: tCOMMA block_arg
962
+ {
963
+ result = val[1]
964
+ }
965
+ | none
966
+
967
+ args: arg_value
968
+ {
969
+ result = s(:array, val[0])
970
+ }
971
+ | tSTAR arg_value
972
+ {
973
+ result = s(:array, s(:splat, val[1]))
974
+ }
975
+ | args tCOMMA arg_value
976
+ {
977
+ result = self.list_append val[0], val[2]
978
+ }
979
+ | args tCOMMA tSTAR arg_value
980
+ {
981
+ result = self.list_append val[0], s(:splat, val[3])
982
+ }
983
+
984
+ mrhs_arg: mrhs
985
+ {
986
+ result = new_masgn_arg val[0]
987
+ }
988
+ | arg_value
989
+ {
990
+ result = new_masgn_arg val[0], :wrap
991
+ }
992
+
993
+ mrhs: args tCOMMA arg_value
994
+ {
995
+ result = val[0] << val[2]
996
+ }
997
+ | args tCOMMA tSTAR arg_value
998
+ {
999
+ result = self.arg_concat val[0], val[3]
1000
+ }
1001
+ | tSTAR arg_value
1002
+ {
1003
+ result = s(:splat, val[1])
1004
+ }
1005
+
1006
+ primary: literal
1007
+ | strings
1008
+ | xstring
1009
+ | regexp
1010
+ | words
1011
+ | qwords
1012
+ | symbols
1013
+ | qsymbols
1014
+ | var_ref
1015
+ | backref
1016
+ | tFID
1017
+ {
1018
+ result = new_call nil, val[0].to_sym
1019
+ }
1020
+ | k_begin
1021
+ {
1022
+ result = self.lexer.lineno
1023
+ # TODO:
1024
+ # $<val>1 = cmdarg_stack;
1025
+ # CMDARG_SET(0);
1026
+ }
1027
+ bodystmt k_end
1028
+ {
1029
+ # TODO: CMDARG_SET($<val>1);
1030
+ unless val[2] then
1031
+ result = s(:nil)
1032
+ else
1033
+ result = s(:begin, val[2])
1034
+ end
1035
+
1036
+ result.line = val[1]
1037
+ }
1038
+ | tLPAREN_ARG rparen
1039
+ {
1040
+ # TODO: lex_state = :expr_endarg in between
1041
+ debug20 13, val, result
1042
+ }
1043
+ | tLPAREN_ARG
1044
+ {
1045
+ result = lexer.cmdarg.store false
1046
+ # result = self.lexer.cmdarg.stack.dup
1047
+ # lexer.cmdarg.stack.replace [false] # TODO add api for these
1048
+ }
1049
+ stmt
1050
+ {
1051
+ lexer.lex_state = :expr_endarg
1052
+ }
1053
+ rparen
1054
+ {
1055
+ _, cmdarg, stmt, _, _, = val
1056
+ warning "(...) interpreted as grouped expression"
1057
+ lexer.cmdarg.restore cmdarg
1058
+ result = stmt
1059
+ }
1060
+ | tLPAREN compstmt tRPAREN
1061
+ {
1062
+ result = val[1] || s(:nil)
1063
+ result.paren = true
1064
+ }
1065
+ | primary_value tCOLON2 tCONSTANT
1066
+ {
1067
+ result = s(:colon2, val[0], val[2].to_sym)
1068
+ }
1069
+ | tCOLON3 tCONSTANT
1070
+ {
1071
+ result = s(:colon3, val[1].to_sym)
1072
+ }
1073
+ | tLBRACK aref_args tRBRACK
1074
+ {
1075
+ result = val[1] || s(:array)
1076
+ result.sexp_type = :array # aref_args is :args
1077
+ }
1078
+ | tLBRACE
1079
+ {
1080
+ result = self.lexer.lineno
1081
+ }
1082
+ assoc_list tRCURLY
1083
+ {
1084
+ result = new_hash val
1085
+ }
1086
+ | k_return
1087
+ {
1088
+ result = s(:return)
1089
+ }
1090
+ | kYIELD tLPAREN2 call_args rparen
1091
+ {
1092
+ result = new_yield val[2]
1093
+ }
1094
+ | kYIELD tLPAREN2 rparen
1095
+ {
1096
+ result = new_yield
1097
+ }
1098
+ | kYIELD
1099
+ {
1100
+ result = new_yield
1101
+ }
1102
+ | kDEFINED opt_nl tLPAREN2 expr rparen
1103
+ {
1104
+ result = s(:defined, val[3])
1105
+ }
1106
+ | kNOT tLPAREN2 expr rparen
1107
+ {
1108
+ result = s(:call, val[2], :"!")
1109
+ }
1110
+ | kNOT tLPAREN2 rparen
1111
+ {
1112
+ debug20 14, val, result
1113
+ }
1114
+ | fcall brace_block
1115
+ {
1116
+ oper, iter = val[0], val[1]
1117
+ call = oper # FIX
1118
+ iter.insert 1, call
1119
+ result = iter
1120
+ call.line = iter.line
1121
+ }
1122
+ | method_call
1123
+ | method_call brace_block
1124
+ {
1125
+ call, iter = val[0], val[1]
1126
+ block_dup_check call, iter
1127
+ iter.insert 1, call # FIX
1128
+ result = iter
1129
+ }
1130
+ | tLAMBDA lambda
1131
+ {
1132
+ result = val[1] # TODO: fix lineno
1133
+ }
1134
+ | k_if expr_value then compstmt if_tail k_end
1135
+ {
1136
+ _, c, _, t, f, _ = val
1137
+ result = new_if c, t, f
1138
+ }
1139
+ | k_unless expr_value then compstmt opt_else k_end
1140
+ {
1141
+ _, c, _, t, f, _ = val
1142
+ result = new_if c, f, t
1143
+ }
1144
+ | k_while expr_value_do compstmt k_end
1145
+ {
1146
+ _, cond, body, _ = val
1147
+ result = new_while body, cond, true
1148
+ }
1149
+ | k_until expr_value_do compstmt k_end
1150
+ {
1151
+ _, cond, body, _ = val
1152
+ result = new_until body, cond, true
1153
+ }
1154
+ | k_case expr_value opt_terms case_body k_end
1155
+ {
1156
+ (_, line), expr, _, body, _ = val
1157
+ result = new_case expr, body, line
1158
+ }
1159
+ | k_case opt_terms case_body k_end
1160
+ {
1161
+ (_, line), _, body, _ = val
1162
+ result = new_case nil, body, line
1163
+ }
1164
+ | k_for for_var kIN expr_value_do compstmt k_end
1165
+ {
1166
+ _, var, _, iter, body, _ = val
1167
+ result = new_for iter, var, body
1168
+ }
1169
+ | k_class
1170
+ {
1171
+ result = self.lexer.lineno
1172
+ }
1173
+ cpath superclass
1174
+ {
1175
+ self.comments.push self.lexer.comments
1176
+ if (self.in_def || self.in_single > 0) then
1177
+ yyerror "class definition in method body"
1178
+ end
1179
+ self.env.extend
1180
+ }
1181
+ bodystmt k_end
1182
+ {
1183
+ result = new_class val
1184
+ self.env.unextend
1185
+ self.lexer.comments # we don't care about comments in the body
1186
+ }
1187
+ | k_class tLSHFT
1188
+ {
1189
+ result = self.lexer.lineno
1190
+ }
1191
+ expr
1192
+ {
1193
+ result = self.in_def
1194
+ self.in_def = false
1195
+ }
1196
+ term
1197
+ {
1198
+ result = self.in_single
1199
+ self.in_single = 0
1200
+ self.env.extend
1201
+ }
1202
+ bodystmt k_end
1203
+ {
1204
+ result = new_sclass val
1205
+ self.env.unextend
1206
+ self.lexer.comments # we don't care about comments in the body
1207
+ }
1208
+ | k_module
1209
+ {
1210
+ result = self.lexer.lineno
1211
+ }
1212
+ cpath
1213
+ {
1214
+ self.comments.push self.lexer.comments
1215
+ yyerror "module definition in method body" if
1216
+ self.in_def or self.in_single > 0
1217
+
1218
+ self.env.extend
1219
+ }
1220
+ bodystmt k_end
1221
+ {
1222
+ result = new_module val
1223
+ self.env.unextend
1224
+ self.lexer.comments # we don't care about comments in the body
1225
+ }
1226
+ | k_def fname
1227
+ {
1228
+ result = [self.in_def, self.lexer.cmdarg.stack.dup]
1229
+
1230
+ self.comments.push self.lexer.comments
1231
+ self.in_def = true
1232
+ self.env.extend
1233
+ # TODO: local->cmdargs = cmdarg_stack;
1234
+ # TODO: port local_push_gen and local_pop_gen
1235
+ lexer.cmdarg.stack.replace [false]
1236
+ }
1237
+ f_arglist bodystmt k_end
1238
+ {
1239
+ in_def, cmdarg = val[2]
1240
+
1241
+ result = new_defn val
1242
+
1243
+ lexer.cmdarg.stack.replace cmdarg
1244
+ self.env.unextend
1245
+ self.in_def = in_def
1246
+ self.lexer.comments # we don't care about comments in the body
1247
+ }
1248
+ | k_def singleton dot_or_colon
1249
+ {
1250
+ self.comments.push self.lexer.comments
1251
+ lexer.lex_state = :expr_fname
1252
+ }
1253
+ fname
1254
+ {
1255
+ self.in_single += 1
1256
+ self.env.extend
1257
+ lexer.lex_state = :expr_endfn # force for args
1258
+ result = [lexer.lineno, self.lexer.cmdarg.stack.dup]
1259
+ lexer.cmdarg.stack.replace [false]
1260
+ }
1261
+ f_arglist bodystmt k_end
1262
+ {
1263
+ line, cmdarg = val[5]
1264
+ result = new_defs val
1265
+ result[3].line line
1266
+
1267
+ lexer.cmdarg.stack.replace cmdarg
1268
+
1269
+ self.env.unextend
1270
+ self.in_single -= 1
1271
+ self.lexer.comments # we don't care about comments in the body
1272
+ }
1273
+ | kBREAK
1274
+ {
1275
+ result = s(:break)
1276
+ }
1277
+ | kNEXT
1278
+ {
1279
+ result = s(:next)
1280
+ }
1281
+ | kREDO
1282
+ {
1283
+ result = s(:redo)
1284
+ }
1285
+ | kRETRY
1286
+ {
1287
+ result = s(:retry)
1288
+ }
1289
+
1290
+ primary_value: primary
1291
+ {
1292
+ result = value_expr(val[0])
1293
+ }
1294
+
1295
+ # These are really stupid
1296
+ k_begin: kBEGIN
1297
+ k_if: kIF
1298
+ k_unless: kUNLESS
1299
+ k_while: kWHILE
1300
+ k_until: kUNTIL
1301
+ k_case: kCASE
1302
+ k_for: kFOR
1303
+ k_class: kCLASS
1304
+ k_module: kMODULE
1305
+ k_def: kDEF
1306
+ k_do: kDO
1307
+ k_do_block: kDO_BLOCK
1308
+ k_rescue: kRESCUE
1309
+ k_ensure: kENSURE
1310
+ k_when: kWHEN
1311
+ k_else: kELSE
1312
+ k_elsif: kELSIF
1313
+ k_end: kEND
1314
+ k_return: kRETURN
1315
+
1316
+ then: term
1317
+ | kTHEN
1318
+ | term kTHEN
1319
+
1320
+ do: term
1321
+ | kDO_COND
1322
+
1323
+ if_tail: opt_else
1324
+ | k_elsif expr_value then compstmt if_tail
1325
+ {
1326
+ result = s(:if, val[1], val[3], val[4])
1327
+ }
1328
+
1329
+ opt_else: none
1330
+ | kELSE compstmt
1331
+ {
1332
+ result = val[1]
1333
+ }
1334
+
1335
+ for_var: lhs
1336
+ | mlhs
1337
+ {
1338
+ val[0].delete_at 1 if val[0][1].nil? # HACK
1339
+ }
1340
+
1341
+ f_marg: f_norm_arg
1342
+ | tLPAREN f_margs rparen
1343
+ {
1344
+ result = val[1]
1345
+ }
1346
+
1347
+ f_marg_list: f_marg
1348
+ {
1349
+ result = s(:array, val[0])
1350
+ }
1351
+ | f_marg_list tCOMMA f_marg
1352
+ {
1353
+ result = list_append val[0], val[2]
1354
+ }
1355
+
1356
+ f_margs: f_marg_list
1357
+ {
1358
+ args, = val
1359
+
1360
+ result = block_var args
1361
+ }
1362
+ | f_marg_list tCOMMA tSTAR f_norm_arg
1363
+ {
1364
+ args, _, _, splat = val
1365
+
1366
+ result = block_var args, "*#{splat}".to_sym
1367
+ }
1368
+ | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1369
+ {
1370
+ args, _, _, splat, _, args2 = val
1371
+
1372
+ result = block_var args, "*#{splat}".to_sym, args2
1373
+ }
1374
+ | f_marg_list tCOMMA tSTAR
1375
+ {
1376
+ args, _, _ = val
1377
+
1378
+ result = block_var args, :*
1379
+ }
1380
+ | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1381
+ {
1382
+ args, _, _, _, args2 = val
1383
+
1384
+ result = block_var args, :*, args2
1385
+ }
1386
+ | tSTAR f_norm_arg
1387
+ {
1388
+ _, splat = val
1389
+
1390
+ result = block_var :"*#{splat}"
1391
+ }
1392
+ | tSTAR f_norm_arg tCOMMA f_marg_list
1393
+ {
1394
+ _, splat, _, args = val
1395
+
1396
+ result = block_var :"*#{splat}", args
1397
+ }
1398
+ | tSTAR
1399
+ {
1400
+ result = block_var :*
1401
+ }
1402
+ | tSTAR tCOMMA f_marg_list
1403
+ {
1404
+ _, _, args = val
1405
+
1406
+ result = block_var :*, args
1407
+ }
1408
+
1409
+ block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
1410
+ {
1411
+ result = call_args val
1412
+ }
1413
+ | f_block_kwarg opt_f_block_arg
1414
+ {
1415
+ result = call_args val
1416
+ }
1417
+ | f_kwrest opt_f_block_arg
1418
+ {
1419
+ result = call_args val
1420
+ }
1421
+ | f_block_arg
1422
+ {
1423
+ result = call_args val
1424
+ }
1425
+
1426
+ opt_block_args_tail: tCOMMA block_args_tail
1427
+ {
1428
+ result = args val
1429
+ }
1430
+ | none
1431
+
1432
+ block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1433
+ {
1434
+ result = args val
1435
+ }
1436
+ | f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1437
+ {
1438
+ result = args val
1439
+ }
1440
+ | f_arg tCOMMA f_block_optarg opt_block_args_tail
1441
+ {
1442
+ result = args val
1443
+ }
1444
+ | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_block_args_tail
1445
+ {
1446
+ result = args val
1447
+ }
1448
+ | f_arg tCOMMA f_rest_arg opt_block_args_tail
1449
+ {
1450
+ result = args val
1451
+ }
1452
+ | f_arg tCOMMA
1453
+ {
1454
+ result = args val
1455
+ }
1456
+ | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1457
+ {
1458
+ result = args val
1459
+ }
1460
+ | f_arg opt_block_args_tail
1461
+ {
1462
+ result = args val
1463
+ }
1464
+ | f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1465
+ {
1466
+ result = args val
1467
+ }
1468
+ | f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1469
+ {
1470
+ result = args val
1471
+ }
1472
+ | f_block_optarg opt_block_args_tail
1473
+ {
1474
+ result = args val
1475
+ }
1476
+ | f_block_optarg tCOMMA f_arg opt_block_args_tail
1477
+ {
1478
+ result = args val
1479
+ }
1480
+ | f_rest_arg opt_block_args_tail
1481
+ {
1482
+ result = args val
1483
+ }
1484
+ | f_rest_arg tCOMMA f_arg opt_block_args_tail
1485
+ {
1486
+ result = args val
1487
+ }
1488
+ | block_args_tail
1489
+ {
1490
+ result = args val
1491
+ }
1492
+
1493
+ opt_block_param: none { result = 0 }
1494
+ | block_param_def
1495
+ {
1496
+ self.lexer.command_start = true
1497
+ }
1498
+
1499
+ block_param_def: tPIPE opt_bv_decl tPIPE
1500
+ {
1501
+ # TODO: current_arg = 0
1502
+ result = args val
1503
+ }
1504
+ | tOROP
1505
+ {
1506
+ result = s(:args)
1507
+ }
1508
+ | tPIPE block_param opt_bv_decl tPIPE
1509
+ {
1510
+ # TODO: current_arg = 0
1511
+ result = args val
1512
+ }
1513
+
1514
+ opt_bv_decl: opt_nl
1515
+ | opt_nl tSEMI bv_decls opt_nl
1516
+ {
1517
+ result = args val
1518
+ }
1519
+
1520
+ bv_decls: bvar
1521
+ {
1522
+ result = args val
1523
+ }
1524
+ | bv_decls tCOMMA bvar
1525
+ {
1526
+ result = args val
1527
+ }
1528
+
1529
+ bvar: tIDENTIFIER
1530
+ {
1531
+ result = s(:shadow, val[0].to_sym)
1532
+ }
1533
+ | f_bad_arg
1534
+
1535
+ lambda: {
1536
+ self.env.extend :dynamic
1537
+ result = self.lexer.lineno
1538
+
1539
+ result = lexer.lpar_beg
1540
+ lexer.paren_nest += 1
1541
+ lexer.lpar_beg = lexer.paren_nest
1542
+ }
1543
+ f_larglist
1544
+ {
1545
+ result = [lexer.cmdarg.store(false), self.lexer.lineno]
1546
+ }
1547
+ lambda_body
1548
+ {
1549
+ lpar, args, (cmdarg, lineno), body = val
1550
+ lexer.lpar_beg = lpar
1551
+
1552
+ lexer.cmdarg.restore cmdarg
1553
+ lexer.cmdarg.lexpop
1554
+
1555
+ call = new_call nil, :lambda
1556
+ result = new_iter call, args, body
1557
+ result.line = lineno
1558
+ self.env.unextend
1559
+ }
1560
+
1561
+ f_larglist: tLPAREN2 f_args opt_bv_decl rparen
1562
+ {
1563
+ result = args val
1564
+ }
1565
+ | f_args
1566
+ {
1567
+ result = val[0]
1568
+ result = 0 if result == s(:args)
1569
+ }
1570
+
1571
+ lambda_body: tLAMBEG compstmt tRCURLY
1572
+ {
1573
+ result = val[1]
1574
+ }
1575
+ | kDO_LAMBDA bodystmt kEND
1576
+ {
1577
+ result = val[1]
1578
+ }
1579
+
1580
+ do_block: k_do_block do_body kEND
1581
+ {
1582
+ # TODO: maybe fix lineno to kDO's lineno?
1583
+ result = val[1]
1584
+ }
1585
+
1586
+ block_call: command do_block
1587
+ {
1588
+ # TODO:
1589
+ ## if (nd_type($1) == NODE_YIELD) {
1590
+ ## compile_error(PARSER_ARG "block given to yield");
1591
+
1592
+ syntax_error "Both block arg and actual block given." if
1593
+ val[0].block_pass?
1594
+
1595
+ val = invert_block_call val if inverted? val
1596
+
1597
+ result = val[1]
1598
+ result.insert 1, val[0]
1599
+ }
1600
+ | block_call call_op2 operation2 opt_paren_args
1601
+ {
1602
+ result = new_call val[0], val[2].to_sym, val[3]
1603
+ }
1604
+ | block_call call_op2 operation2 opt_paren_args brace_block
1605
+ {
1606
+ iter1, _, name, args, iter2 = val
1607
+
1608
+ call = new_call iter1, name.to_sym, args
1609
+ iter2.insert 1, call
1610
+
1611
+ result = iter2
1612
+ }
1613
+ | block_call call_op2 operation2 command_args do_block
1614
+ {
1615
+ iter1, _, name, args, iter2 = val
1616
+
1617
+ call = new_call iter1, name.to_sym, args
1618
+ iter2.insert 1, call
1619
+
1620
+ result = iter2
1621
+ }
1622
+
1623
+ method_call: fcall
1624
+ {
1625
+ result = self.lexer.lineno
1626
+ }
1627
+ paren_args
1628
+ {
1629
+ args = self.call_args val[2..-1]
1630
+ result = val[0].concat args.sexp_body
1631
+ }
1632
+ | primary_value call_op operation2 opt_paren_args
1633
+ {
1634
+ result = new_call val[0], val[2].to_sym, val[3], val[1]
1635
+ }
1636
+ | primary_value tCOLON2 operation2 paren_args
1637
+ {
1638
+ result = new_call val[0], val[2].to_sym, val[3]
1639
+ }
1640
+ | primary_value tCOLON2 operation3
1641
+ {
1642
+ result = new_call val[0], val[2].to_sym
1643
+ }
1644
+ | primary_value call_op paren_args
1645
+ {
1646
+ result = new_call val[0], :call, val[2], val[1]
1647
+ }
1648
+ | primary_value tCOLON2 paren_args
1649
+ {
1650
+ result = new_call val[0], :call, val[2]
1651
+ }
1652
+ | kSUPER paren_args
1653
+ {
1654
+ result = new_super val[1]
1655
+ }
1656
+ | kSUPER
1657
+ {
1658
+ result = s(:zsuper)
1659
+ }
1660
+ | primary_value tLBRACK2 opt_call_args rbracket
1661
+ {
1662
+ result = new_aref val
1663
+ }
1664
+
1665
+ brace_block: tLCURLY
1666
+ {
1667
+ self.env.extend :dynamic
1668
+ result = self.lexer.lineno
1669
+ }
1670
+ brace_body tRCURLY
1671
+ {
1672
+ _, line, body, _ = val
1673
+
1674
+ result = body
1675
+ result.line = line
1676
+
1677
+ self.env.unextend
1678
+ }
1679
+ | k_do
1680
+ {
1681
+ self.env.extend :dynamic
1682
+ result = self.lexer.lineno
1683
+ }
1684
+ do_body kEND
1685
+ {
1686
+ _, line, body, _ = val
1687
+
1688
+ result = body
1689
+ result.line = line
1690
+
1691
+ self.env.unextend
1692
+ }
1693
+
1694
+ brace_body: { self.env.extend :dynamic; result = self.lexer.lineno }
1695
+ { result = lexer.cmdarg.store(false) }
1696
+ opt_block_param compstmt
1697
+ {
1698
+ line, cmdarg, param, cmpstmt = val
1699
+
1700
+ result = new_brace_body param, cmpstmt, line
1701
+ self.env.unextend
1702
+ lexer.cmdarg.restore cmdarg
1703
+ lexer.cmdarg.pop # because of: cmdarg_stack >> 1 ?
1704
+ }
1705
+
1706
+ do_body: { self.env.extend :dynamic; result = self.lexer.lineno }
1707
+ { result = lexer.cmdarg.store(false) }
1708
+ opt_block_param
1709
+ bodystmt
1710
+ {
1711
+ line, cmdarg, param, cmpstmt = val
1712
+
1713
+ result = new_do_body param, cmpstmt, line
1714
+ self.env.unextend
1715
+ lexer.cmdarg.restore cmdarg
1716
+ }
1717
+
1718
+ case_body: k_when
1719
+ {
1720
+ result = self.lexer.lineno
1721
+ }
1722
+ args then compstmt cases
1723
+ {
1724
+ result = new_when(val[2], val[4])
1725
+ result.line = val[1]
1726
+ result << val[5] if val[5]
1727
+ }
1728
+
1729
+ cases: opt_else | case_body
1730
+
1731
+ opt_rescue: k_rescue exc_list exc_var then compstmt opt_rescue
1732
+ {
1733
+ (_, line), klasses, var, _, body, rest = val
1734
+
1735
+ klasses ||= s(:array)
1736
+ klasses << new_assign(var, s(:gvar, :"$!")) if var
1737
+ klasses.line line
1738
+
1739
+ result = new_resbody(klasses, body)
1740
+ result << rest if rest # UGH, rewritten above
1741
+ }
1742
+ |
1743
+ {
1744
+ result = nil
1745
+ }
1746
+
1747
+ exc_list: arg_value
1748
+ {
1749
+ result = s(:array, val[0])
1750
+ }
1751
+ | mrhs
1752
+ | none
1753
+
1754
+ exc_var: tASSOC lhs
1755
+ {
1756
+ result = val[1]
1757
+ }
1758
+ | none
1759
+
1760
+ opt_ensure: k_ensure compstmt
1761
+ {
1762
+ _, body = val
1763
+
1764
+ result = body || s(:nil)
1765
+ }
1766
+ | none
1767
+
1768
+ literal: numeric
1769
+ {
1770
+ result = s(:lit, val[0])
1771
+ }
1772
+ | symbol
1773
+ {
1774
+ result = s(:lit, val[0])
1775
+ }
1776
+ | dsym
1777
+
1778
+ strings: string
1779
+ {
1780
+ val[0] = s(:dstr, val[0].value) if val[0].sexp_type == :evstr
1781
+ result = val[0]
1782
+ }
1783
+
1784
+ string: tCHAR
1785
+ {
1786
+ debug20 23, val, result
1787
+ }
1788
+ | string1
1789
+ | string string1
1790
+ {
1791
+ result = self.literal_concat val[0], val[1]
1792
+ }
1793
+
1794
+ string1: tSTRING_BEG string_contents tSTRING_END
1795
+ {
1796
+ result = val[1]
1797
+ }
1798
+ | tSTRING
1799
+ {
1800
+ result = new_string val
1801
+ }
1802
+
1803
+ xstring: tXSTRING_BEG xstring_contents tSTRING_END
1804
+ {
1805
+ result = new_xstring val[1]
1806
+ }
1807
+
1808
+ regexp: tREGEXP_BEG regexp_contents tREGEXP_END
1809
+ {
1810
+ result = new_regexp val
1811
+ }
1812
+
1813
+ words: tWORDS_BEG tSPACE tSTRING_END
1814
+ {
1815
+ result = s(:array)
1816
+ }
1817
+ | tWORDS_BEG word_list tSTRING_END
1818
+ {
1819
+ result = val[1]
1820
+ }
1821
+
1822
+ word_list: none
1823
+ {
1824
+ result = new_word_list
1825
+ }
1826
+ | word_list word tSPACE
1827
+ {
1828
+ result = val[0].dup << new_word_list_entry(val)
1829
+ }
1830
+
1831
+ word: string_content
1832
+ | word string_content
1833
+ {
1834
+ result = self.literal_concat val[0], val[1]
1835
+ }
1836
+
1837
+ symbols: tSYMBOLS_BEG tSPACE tSTRING_END
1838
+ {
1839
+ result = s(:array)
1840
+ }
1841
+ | tSYMBOLS_BEG symbol_list tSTRING_END
1842
+ {
1843
+ result = val[1]
1844
+ }
1845
+
1846
+ symbol_list: none
1847
+ {
1848
+ result = new_symbol_list
1849
+ }
1850
+ | symbol_list word tSPACE
1851
+ {
1852
+ result = val[0].dup << new_symbol_list_entry(val)
1853
+ }
1854
+
1855
+ qwords: tQWORDS_BEG tSPACE tSTRING_END
1856
+ {
1857
+ result = s(:array)
1858
+ }
1859
+ | tQWORDS_BEG qword_list tSTRING_END
1860
+ {
1861
+ result = val[1]
1862
+ }
1863
+
1864
+ qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
1865
+ {
1866
+ result = s(:array)
1867
+ }
1868
+ | tQSYMBOLS_BEG qsym_list tSTRING_END
1869
+ {
1870
+ result = val[1]
1871
+ }
1872
+
1873
+ qword_list: none
1874
+ {
1875
+ result = new_qword_list
1876
+ }
1877
+ | qword_list tSTRING_CONTENT tSPACE
1878
+ {
1879
+ result = val[0].dup << new_qword_list_entry(val)
1880
+ }
1881
+
1882
+ qsym_list: none
1883
+ {
1884
+ result = new_qsym_list
1885
+ }
1886
+ | qsym_list tSTRING_CONTENT tSPACE
1887
+ {
1888
+ result = val[0].dup << new_qsym_list_entry(val)
1889
+ }
1890
+
1891
+ string_contents: none
1892
+ {
1893
+ result = s(:str, "")
1894
+ }
1895
+ | string_contents string_content
1896
+ {
1897
+ result = literal_concat(val[0], val[1])
1898
+ }
1899
+
1900
+ xstring_contents: none
1901
+ {
1902
+ result = nil
1903
+ }
1904
+ | xstring_contents string_content
1905
+ {
1906
+ result = literal_concat(val[0], val[1])
1907
+ }
1908
+
1909
+ regexp_contents: none
1910
+ {
1911
+ result = nil
1912
+ }
1913
+ | regexp_contents string_content
1914
+ {
1915
+ result = literal_concat(val[0], val[1])
1916
+ }
1917
+
1918
+ string_content: tSTRING_CONTENT
1919
+ {
1920
+ result = new_string val
1921
+ }
1922
+ | tSTRING_DVAR
1923
+ {
1924
+ result = lexer.lex_strterm
1925
+
1926
+ lexer.lex_strterm = nil
1927
+ lexer.lex_state = :expr_beg
1928
+ }
1929
+ string_dvar
1930
+ {
1931
+ lexer.lex_strterm = val[1]
1932
+ result = s(:evstr, val[2])
1933
+ }
1934
+ | tSTRING_DBEG
1935
+ {
1936
+ result = [lexer.lex_strterm,
1937
+ lexer.brace_nest,
1938
+ lexer.string_nest, # TODO: remove
1939
+ lexer.cond.store,
1940
+ lexer.cmdarg.store,
1941
+ lexer.lex_state,
1942
+ ]
1943
+
1944
+ lexer.lex_strterm = nil
1945
+ lexer.brace_nest = 0
1946
+ lexer.string_nest = 0
1947
+
1948
+ lexer.lex_state = :expr_beg
1949
+ }
1950
+ compstmt
1951
+ tSTRING_DEND
1952
+ {
1953
+ _, memo, stmt, _ = val
1954
+
1955
+ lex_strterm, brace_nest, string_nest, oldcond, oldcmdarg, oldlex_state = memo
1956
+
1957
+ lexer.lex_strterm = lex_strterm
1958
+ lexer.brace_nest = brace_nest
1959
+ lexer.string_nest = string_nest
1960
+
1961
+ lexer.cond.restore oldcond
1962
+ lexer.cmdarg.restore oldcmdarg
1963
+
1964
+ lexer.lex_state = oldlex_state
1965
+
1966
+ case stmt
1967
+ when Sexp then
1968
+ case stmt.sexp_type
1969
+ when :str, :dstr, :evstr then
1970
+ result = stmt
1971
+ else
1972
+ result = s(:evstr, stmt)
1973
+ end
1974
+ when nil then
1975
+ result = s(:evstr)
1976
+ else
1977
+ debug20 25
1978
+ raise "unknown string body: #{stmt.inspect}"
1979
+ end
1980
+ }
1981
+
1982
+ string_dvar: tGVAR { result = s(:gvar, val[0].to_sym) }
1983
+ | tIVAR { result = s(:ivar, val[0].to_sym) }
1984
+ | tCVAR { result = s(:cvar, val[0].to_sym) }
1985
+ | backref
1986
+
1987
+ symbol: tSYMBEG sym
1988
+ {
1989
+ lexer.lex_state = :expr_end
1990
+ result = val[1].to_sym
1991
+ }
1992
+ | tSYMBOL
1993
+ {
1994
+ result = val[0].to_sym
1995
+ }
1996
+
1997
+ sym: fname | tIVAR | tGVAR | tCVAR
1998
+
1999
+ dsym: tSYMBEG xstring_contents tSTRING_END
2000
+ {
2001
+ lexer.lex_state = :expr_end
2002
+ result = val[1]
2003
+
2004
+ result ||= s(:str, "")
2005
+
2006
+ case result.sexp_type
2007
+ when :dstr then
2008
+ result.sexp_type = :dsym
2009
+ when :str then
2010
+ result = s(:lit, result.last.to_sym)
2011
+ when :evstr then
2012
+ result = s(:dsym, "", result)
2013
+ else
2014
+ debug20 26, val, result
2015
+ end
2016
+ }
2017
+
2018
+ numeric: simple_numeric
2019
+ | tUMINUS_NUM simple_numeric
2020
+ {
2021
+ result = -val[1] # TODO: pt_testcase
2022
+ }
2023
+
2024
+ simple_numeric: tINTEGER
2025
+ | tFLOAT
2026
+ | tRATIONAL
2027
+ | tIMAGINARY
2028
+
2029
+ user_variable: tIDENTIFIER
2030
+ | tIVAR
2031
+ | tGVAR
2032
+ | tCONSTANT
2033
+ | tCVAR
2034
+
2035
+ keyword_variable: kNIL { result = s(:nil) }
2036
+ | kSELF { result = s(:self) }
2037
+ | kTRUE { result = s(:true) }
2038
+ | kFALSE { result = s(:false) }
2039
+ | k__FILE__ { result = s(:str, self.file) }
2040
+ | k__LINE__ { result = s(:lit, lexer.lineno) }
2041
+ | k__ENCODING__
2042
+ {
2043
+ result =
2044
+ if defined? Encoding then
2045
+ s(:colon2, s(:const, :Encoding), :UTF_8)
2046
+ else
2047
+ s(:str, "Unsupported!")
2048
+ end
2049
+ }
2050
+
2051
+ var_ref: user_variable
2052
+ {
2053
+ var = val[0]
2054
+ result = Sexp === var ? var : self.gettable(var)
2055
+ }
2056
+ | keyword_variable
2057
+ {
2058
+ var = val[0]
2059
+ result = Sexp === var ? var : self.gettable(var)
2060
+ }
2061
+
2062
+ var_lhs: user_variable
2063
+ {
2064
+ result = self.assignable val[0]
2065
+ }
2066
+ | keyword_variable
2067
+ {
2068
+ result = self.assignable val[0]
2069
+ debug20 29, val, result
2070
+ }
2071
+
2072
+ backref: tNTH_REF { result = s(:nth_ref, val[0]) }
2073
+ | tBACK_REF { result = s(:back_ref, val[0]) }
2074
+
2075
+ superclass: tLT
2076
+ {
2077
+ lexer.lex_state = :expr_beg
2078
+ lexer.command_start = true
2079
+ }
2080
+ expr_value term
2081
+ {
2082
+ result = val[2]
2083
+ }
2084
+ | none
2085
+ {
2086
+ result = nil
2087
+ }
2088
+
2089
+ f_arglist: tLPAREN2 f_args rparen
2090
+ {
2091
+ result = val[1]
2092
+ self.lexer.lex_state = :expr_beg
2093
+ self.lexer.command_start = true
2094
+ }
2095
+ | {
2096
+ result = self.in_kwarg
2097
+ self.in_kwarg = true
2098
+ # TODO: self.lexer.lex_state |= :expr_label
2099
+ }
2100
+ f_args term
2101
+ {
2102
+ kwarg, args, _ = val
2103
+
2104
+ self.in_kwarg = kwarg
2105
+ result = args
2106
+ lexer.lex_state = :expr_beg
2107
+ lexer.command_start = true
2108
+ }
2109
+
2110
+ args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
2111
+ {
2112
+ result = args val
2113
+ }
2114
+ | f_kwarg opt_f_block_arg
2115
+ {
2116
+ result = args val
2117
+ }
2118
+ | f_kwrest opt_f_block_arg
2119
+ {
2120
+ result = args val
2121
+ }
2122
+ | f_block_arg
2123
+
2124
+ opt_args_tail: tCOMMA args_tail
2125
+ {
2126
+ result = val[1]
2127
+ }
2128
+ |
2129
+ {
2130
+ result = nil
2131
+ }
2132
+
2133
+ f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
2134
+ {
2135
+ result = args val
2136
+ }
2137
+ | f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2138
+ {
2139
+ result = args val
2140
+ }
2141
+ | f_arg tCOMMA f_optarg opt_args_tail
2142
+ {
2143
+ result = args val
2144
+ }
2145
+ | f_arg tCOMMA f_optarg tCOMMA f_arg opt_args_tail
2146
+ {
2147
+ result = args val
2148
+ }
2149
+ | f_arg tCOMMA f_rest_arg opt_args_tail
2150
+ {
2151
+ result = args val
2152
+ }
2153
+ | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2154
+ {
2155
+ result = args val
2156
+ }
2157
+ | f_arg opt_args_tail
2158
+ {
2159
+ result = args val
2160
+ }
2161
+ | f_optarg tCOMMA f_rest_arg opt_args_tail
2162
+ {
2163
+ result = args val
2164
+ }
2165
+ | f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
2166
+ {
2167
+ result = args val
2168
+ }
2169
+ | f_optarg opt_args_tail
2170
+ {
2171
+ result = args val
2172
+ }
2173
+ | f_optarg tCOMMA f_arg opt_args_tail
2174
+ {
2175
+ result = args val
2176
+ }
2177
+ | f_rest_arg opt_args_tail
2178
+ {
2179
+ result = args val
2180
+ }
2181
+ | f_rest_arg tCOMMA f_arg opt_args_tail
2182
+ {
2183
+ result = args val
2184
+ }
2185
+ | args_tail
2186
+ {
2187
+ result = args val
2188
+ }
2189
+ |
2190
+ {
2191
+ result = args val
2192
+ }
2193
+
2194
+ f_bad_arg: tCONSTANT
2195
+ {
2196
+ yyerror "formal argument cannot be a constant"
2197
+ }
2198
+ | tIVAR
2199
+ {
2200
+ yyerror "formal argument cannot be an instance variable"
2201
+ }
2202
+ | tGVAR
2203
+ {
2204
+ yyerror "formal argument cannot be a global variable"
2205
+ }
2206
+ | tCVAR
2207
+ {
2208
+ yyerror "formal argument cannot be a class variable"
2209
+ }
2210
+
2211
+ f_norm_arg: f_bad_arg
2212
+ | tIDENTIFIER
2213
+ {
2214
+ identifier = val[0].to_sym
2215
+ self.env[identifier] = :lvar
2216
+
2217
+ result = identifier
2218
+ }
2219
+
2220
+ f_arg_asgn: f_norm_arg
2221
+
2222
+ f_arg_item: f_arg_asgn
2223
+ | tLPAREN f_margs rparen
2224
+ {
2225
+ result = val[1]
2226
+ }
2227
+
2228
+ f_arg: f_arg_item
2229
+ {
2230
+ case val[0]
2231
+ when Symbol then
2232
+ result = s(:args)
2233
+ result << val[0]
2234
+ when Sexp then
2235
+ result = val[0]
2236
+ else
2237
+ debug20 32
2238
+ raise "Unknown f_arg type: #{val.inspect}"
2239
+ end
2240
+ }
2241
+ | f_arg tCOMMA f_arg_item
2242
+ {
2243
+ list, _, item = val
2244
+
2245
+ if list.sexp_type == :args then
2246
+ result = list
2247
+ else
2248
+ result = s(:args, list)
2249
+ end
2250
+
2251
+ result << item
2252
+ }
2253
+
2254
+ f_label: tLABEL
2255
+
2256
+ f_kw: f_label arg_value
2257
+ {
2258
+ # TODO: call_args
2259
+ label, _ = val[0] # TODO: fix lineno?
2260
+ identifier = label.to_sym
2261
+ self.env[identifier] = :lvar
2262
+
2263
+ result = s(:array, s(:kwarg, identifier, val[1]))
2264
+ }
2265
+ | f_label
2266
+ {
2267
+ label, _ = val[0] # TODO: fix lineno?
2268
+ identifier = label.to_sym
2269
+ self.env[identifier] = :lvar
2270
+
2271
+ result = s(:array, s(:kwarg, identifier))
2272
+ }
2273
+
2274
+ f_block_kw: f_label primary_value
2275
+ {
2276
+ # TODO: call_args
2277
+ label, _ = val[0] # TODO: fix lineno?
2278
+ identifier = label.to_sym
2279
+ self.env[identifier] = :lvar
2280
+
2281
+ result = s(:array, s(:kwarg, identifier, val[1]))
2282
+ }
2283
+ | f_label
2284
+ {
2285
+ label, _ = val[0] # TODO: fix lineno?
2286
+ identifier = label.to_sym
2287
+ self.env[identifier] = :lvar
2288
+
2289
+ result = s(:array, s(:kwarg, identifier))
2290
+ }
2291
+
2292
+ f_block_kwarg: f_block_kw
2293
+ | f_block_kwarg tCOMMA f_block_kw
2294
+ {
2295
+ list, _, item = val
2296
+ result = list << item.last
2297
+ }
2298
+
2299
+ f_kwarg: f_kw
2300
+ | f_kwarg tCOMMA f_kw
2301
+ {
2302
+ result = args val
2303
+ }
2304
+
2305
+ kwrest_mark: tPOW
2306
+ | tDSTAR
2307
+
2308
+ f_kwrest: kwrest_mark tIDENTIFIER
2309
+ {
2310
+ name = val[1].to_sym
2311
+ self.assignable name
2312
+ result = :"**#{name}"
2313
+ }
2314
+ | kwrest_mark
2315
+ {
2316
+ result = :"**"
2317
+ }
2318
+
2319
+ f_opt: f_arg_asgn tEQL arg_value
2320
+ {
2321
+ result = self.assignable val[0], val[2]
2322
+ # TODO: detect duplicate names
2323
+ }
2324
+
2325
+ f_block_opt: f_arg_asgn tEQL primary_value
2326
+ {
2327
+ result = self.assignable val[0], val[2]
2328
+ }
2329
+
2330
+ f_block_optarg: f_block_opt
2331
+ {
2332
+ result = s(:block, val[0])
2333
+ }
2334
+ | f_block_optarg tCOMMA f_block_opt
2335
+ {
2336
+ result = val[0]
2337
+ result << val[2]
2338
+ }
2339
+
2340
+ f_optarg: f_opt
2341
+ {
2342
+ result = s(:block, val[0])
2343
+ }
2344
+ | f_optarg tCOMMA f_opt
2345
+ {
2346
+ result = self.block_append val[0], val[2]
2347
+ }
2348
+
2349
+ restarg_mark: tSTAR2 | tSTAR
2350
+
2351
+ f_rest_arg: restarg_mark tIDENTIFIER
2352
+ {
2353
+ # TODO: differs from parse.y - needs tests
2354
+ name = val[1].to_sym
2355
+ self.assignable name
2356
+ result = :"*#{name}"
2357
+ }
2358
+ | restarg_mark
2359
+ {
2360
+ name = :"*"
2361
+ self.env[name] = :lvar
2362
+ result = name
2363
+ }
2364
+
2365
+ blkarg_mark: tAMPER2 | tAMPER
2366
+
2367
+ f_block_arg: blkarg_mark tIDENTIFIER
2368
+ {
2369
+ identifier = val[1].to_sym
2370
+
2371
+ self.env[identifier] = :lvar
2372
+ result = "&#{identifier}".to_sym
2373
+ }
2374
+
2375
+ opt_f_block_arg: tCOMMA f_block_arg
2376
+ {
2377
+ result = val[1]
2378
+ }
2379
+ |
2380
+ {
2381
+ result = nil
2382
+ }
2383
+
2384
+ singleton: var_ref
2385
+ | tLPAREN2
2386
+ {
2387
+ lexer.lex_state = :expr_beg
2388
+ }
2389
+ expr rparen
2390
+ {
2391
+ result = val[2]
2392
+ yyerror "Can't define single method for literals." if
2393
+ result.sexp_type == :lit
2394
+ }
2395
+
2396
+ assoc_list: none # [!nil]
2397
+ {
2398
+ result = s(:array)
2399
+ }
2400
+ | assocs trailer # [!nil]
2401
+ {
2402
+ result = val[0]
2403
+ }
2404
+
2405
+ assocs: assoc
2406
+ | assocs tCOMMA assoc
2407
+ {
2408
+ list = val[0].dup
2409
+ more = val[2].sexp_body
2410
+ list.push(*more) unless more.empty?
2411
+ result = list
2412
+ result.sexp_type = :hash
2413
+ }
2414
+
2415
+ assoc: arg_value tASSOC arg_value
2416
+ {
2417
+ result = s(:array, val[0], val[2])
2418
+ }
2419
+ | tLABEL arg_value
2420
+ {
2421
+ (label, _), arg = val
2422
+ result = s(:array, s(:lit, label.to_sym), arg)
2423
+ }
2424
+ | tSTRING_BEG string_contents tLABEL_END arg_value
2425
+ {
2426
+ _, sym, _, value = val
2427
+ sym.sexp_type = :dsym
2428
+ result = s(:array, sym, value)
2429
+ }
2430
+ | tDSTAR arg_value
2431
+ {
2432
+ result = s(:array, s(:kwsplat, val[1]))
2433
+ }
2434
+
2435
+ operation: tIDENTIFIER | tCONSTANT | tFID
2436
+ operation2: tIDENTIFIER | tCONSTANT | tFID | op
2437
+ operation3: tIDENTIFIER | tFID | op
2438
+ dot_or_colon: tDOT | tCOLON2
2439
+ call_op: tDOT
2440
+ | tLONELY # TODO: rename tANDDOT?
2441
+
2442
+ call_op2: call_op
2443
+ | tCOLON2
2444
+
2445
+ opt_terms: | terms
2446
+ opt_nl: | tNL
2447
+ rparen: opt_nl tRPAREN
2448
+ rbracket: opt_nl tRBRACK
2449
+ trailer: | tNL | tCOMMA
2450
+
2451
+ term: tSEMI { yyerrok }
2452
+ | tNL
2453
+
2454
+ terms: term
2455
+ | terms tSEMI { yyerrok }
2456
+
2457
+ none: { result = nil; }
2458
+ end
2459
+
2460
+ ---- inner
2461
+
2462
+ require "ruby_lexer"
2463
+ require "ruby_parser_extras"
2464
+
2465
+ # :stopdoc:
2466
+
2467
+ # Local Variables: **
2468
+ # racc-token-length-max:14 **
2469
+ # End: **