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