brakeman 5.1.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +18 -1
  3. data/README.md +1 -1
  4. data/bundle/load.rb +5 -5
  5. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/CHANGELOG.md +8 -0
  6. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/FAQ.md +0 -0
  7. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/Gemfile +0 -0
  8. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/MIT-LICENSE +0 -0
  9. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/README.md +19 -13
  10. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/REFERENCE.md +10 -3
  11. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/TODO +0 -0
  12. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/haml.gemspec +0 -0
  13. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_builder.rb +55 -0
  14. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_compiler.rb +4 -2
  15. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
  16. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
  17. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
  18. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/engine.rb +0 -0
  19. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/error.rb +0 -0
  20. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/escapable.rb +0 -0
  21. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/exec.rb +0 -0
  22. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/filters.rb +0 -0
  23. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/generator.rb +0 -0
  24. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
  25. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
  26. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_xss_mods.rb +0 -0
  27. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
  28. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
  29. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +0 -0
  30. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers.rb +0 -0
  31. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/options.rb +0 -0
  32. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/parser.rb +0 -0
  33. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
  34. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
  35. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
  36. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
  37. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template.rb +0 -0
  38. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
  39. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/util.rb +0 -0
  41. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/version.rb +1 -1
  42. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml.rb +0 -0
  43. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
  44. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/layout/html/footer.erb +0 -0
  45. data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/MIT-LICENSE.txt +0 -0
  46. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/processor_count.rb +45 -0
  47. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +4 -0
  48. data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/lib/parallel.rb +52 -43
  49. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/History.rdoc +88 -0
  50. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/Manifest.txt +3 -0
  51. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/README.rdoc +1 -0
  52. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/compare/normalize.rb +6 -1
  53. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/debugging.md +0 -0
  54. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/gauntlet.md +106 -0
  55. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/rp_extensions.rb +15 -36
  56. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/rp_stringscanner.rb +33 -0
  57. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +7128 -0
  58. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby20_parser.y +335 -252
  59. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +7182 -0
  60. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby21_parser.y +330 -249
  61. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +7228 -0
  62. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby22_parser.y +334 -251
  63. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +7237 -0
  64. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby26_parser.y → ruby_parser-3.18.1/lib/ruby23_parser.y} +336 -276
  65. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +7268 -0
  66. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby24_parser.y +334 -251
  67. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +7268 -0
  68. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby30_parser.y → ruby_parser-3.18.1/lib/ruby25_parser.y} +335 -304
  69. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +7287 -0
  70. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby27_parser.y → ruby_parser-3.18.1/lib/ruby26_parser.y} +334 -288
  71. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +8517 -0
  72. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby_parser.yy → ruby_parser-3.18.1/lib/ruby27_parser.y} +906 -380
  73. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +8751 -0
  74. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.y +3472 -0
  75. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby3_parser.yy +3476 -0
  76. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rb +261 -609
  77. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex +27 -20
  78. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex.rb +59 -23
  79. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_lexer_strings.rb +638 -0
  80. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser.rb +0 -0
  81. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_parser.yy +3487 -0
  82. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser_extras.rb +296 -115
  83. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/tools/munge.rb +34 -6
  84. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/tools/ripper.rb +44 -0
  85. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/History.rdoc +15 -0
  86. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/Manifest.txt +0 -0
  87. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/README.rdoc +0 -0
  88. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
  89. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/pt_testcase.rb +7 -2
  90. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
  91. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +0 -0
  92. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
  93. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
  94. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
  95. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/CHANGELOG.md +4 -0
  96. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
  97. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/README.md +1 -1
  98. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
  99. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/constants.rb +2 -2
  100. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/index.rb +0 -0
  101. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  102. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/string_ext.rb +0 -0
  103. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width.rb +0 -0
  104. data/lib/brakeman/app_tree.rb +1 -1
  105. data/lib/brakeman/checks/base_check.rb +10 -0
  106. data/lib/brakeman/checks/check_eol_rails.rb +23 -0
  107. data/lib/brakeman/checks/check_eol_ruby.rb +26 -0
  108. data/lib/brakeman/checks/check_json_parsing.rb +1 -1
  109. data/lib/brakeman/checks/check_sql.rb +3 -2
  110. data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
  111. data/lib/brakeman/checks/eol_check.rb +47 -0
  112. data/lib/brakeman/options.rb +8 -0
  113. data/lib/brakeman/processors/alias_processor.rb +7 -1
  114. data/lib/brakeman/processors/gem_processor.rb +3 -0
  115. data/lib/brakeman/processors/haml_template_processor.rb +9 -0
  116. data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -0
  117. data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
  118. data/lib/brakeman/processors/model_processor.rb +1 -0
  119. data/lib/brakeman/report/ignore/config.rb +1 -1
  120. data/lib/brakeman/report/report_csv.rb +1 -1
  121. data/lib/brakeman/report/report_sarif.rb +1 -1
  122. data/lib/brakeman/report/report_text.rb +1 -1
  123. data/lib/brakeman/scanner.rb +15 -13
  124. data/lib/brakeman/tracker/config.rb +8 -1
  125. data/lib/brakeman/version.rb +1 -1
  126. data/lib/brakeman/warning_codes.rb +2 -0
  127. data/lib/brakeman.rb +2 -2
  128. data/lib/ruby_parser/bm_sexp.rb +11 -1
  129. metadata +105 -99
  130. data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/processor_count.rb +0 -42
  131. data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/version.rb +0 -3
  132. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
  133. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
  134. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
  135. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
  136. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
  137. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
  138. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
  139. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
  140. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
  141. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
  142. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
  143. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
  144. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
  145. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.7.0/data/display_width.marshal.gz +0 -0
@@ -1,6 +1,6 @@
1
1
  # -*- racc -*-
2
2
 
3
- class Ruby26Parser
3
+ class Ruby23Parser
4
4
 
5
5
  token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
6
6
  kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
@@ -18,11 +18,10 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
18
18
  tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
19
19
  tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
20
20
  tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA
21
- tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND tUBANG
21
+ tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND
22
22
  tRATIONAL tIMAGINARY
23
23
  tLABEL_END
24
24
  tLONELY
25
- tBDOT2 tBDOT3
26
25
 
27
26
  preclow
28
27
  nonassoc tLOWEST
@@ -80,7 +79,7 @@ rule
80
79
  | klBEGIN
81
80
  {
82
81
  if (self.in_def || self.in_single > 0) then
83
- debug20 1
82
+ debug 11
84
83
  yyerror "BEGIN in method"
85
84
  end
86
85
  self.env.extend
@@ -105,7 +104,9 @@ rule
105
104
  bodystmt: compstmt opt_rescue k_else
106
105
  {
107
106
  res = _values[-2]
108
- yyerror "else without rescue is useless" unless res
107
+ # TODO: move down to main match so I can just use val
108
+
109
+ warn "else without rescue is useless" unless res
109
110
  }
110
111
  compstmt
111
112
  opt_ensure
@@ -135,7 +136,7 @@ rule
135
136
  | error stmt
136
137
  {
137
138
  result = val[1]
138
- debug20 2, val, result
139
+ debug 12
139
140
  }
140
141
 
141
142
  stmt_or_begin: stmt
@@ -143,6 +144,10 @@ rule
143
144
  {
144
145
  yyerror "BEGIN is permitted only at toplevel"
145
146
  }
147
+ begin_block
148
+ {
149
+ result = val[2] # wtf?
150
+ }
146
151
 
147
152
  stmt: kALIAS fitem
148
153
  {
@@ -155,12 +160,12 @@ rule
155
160
  }
156
161
  | kALIAS tGVAR tGVAR
157
162
  {
158
- (_, line), lhs, rhs = val
163
+ (_, line), (lhs, _), (rhs, _) = val
159
164
  result = s(:valias, lhs.to_sym, rhs.to_sym).line line
160
165
  }
161
166
  | kALIAS tGVAR tBACK_REF
162
167
  {
163
- (_, line), lhs, rhs = val
168
+ (_, line), (lhs, _), (rhs, _) = val
164
169
  result = s(:valias, lhs.to_sym, :"$#{rhs}").line line
165
170
  }
166
171
  | kALIAS tGVAR tNTH_REF
@@ -203,7 +208,7 @@ rule
203
208
  (_, line), _, stmt, _ = val
204
209
 
205
210
  if (self.in_def || self.in_single > 0) then
206
- debug20 3
211
+ debug 13
207
212
  yyerror "END in method; use at_exit"
208
213
  end
209
214
 
@@ -243,32 +248,31 @@ rule
243
248
  }
244
249
  | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
245
250
  {
246
- prim, _, id, opasgn, rhs = val
247
- result = s(:op_asgn, prim, rhs, id.to_sym, opasgn.to_sym)
248
- if val[1] == '&.'
249
- result.sexp_type = :safe_op_asgn
250
- end
251
- result.line = val[0].line
251
+ prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
252
+
253
+ result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
254
+ result.sexp_type = :safe_op_asgn if call_op == '&.'
255
+ result.line prim.line
252
256
  }
253
257
  | primary_value call_op tCONSTANT tOP_ASGN command_rhs
254
258
  {
255
- result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
256
- if val[1] == '&.'
257
- result.sexp_type = :safe_op_asgn
258
- end
259
- result.line = val[0].line
259
+ prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
260
+
261
+ result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
262
+ result.sexp_type = :safe_op_asgn if call_op == '&.'
263
+ result.line prim.line
260
264
  }
261
265
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
262
266
  {
263
- lhs1, _, lhs2, op, rhs = val
267
+ lhs1, _, (lhs2, line), (id, _), rhs = val
264
268
 
265
- result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, op.to_sym)
269
+ result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
266
270
  }
267
271
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
268
272
  {
269
- lhs1, _, lhs2, op, rhs = val
273
+ lhs1, _, (lhs2, line), (id, _), rhs = val
270
274
 
271
- result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, op.to_sym)
275
+ result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
272
276
  }
273
277
  | backref tOP_ASGN command_rhs
274
278
  {
@@ -280,14 +284,6 @@ rule
280
284
  expr, = val
281
285
  result = value_expr expr
282
286
  }
283
- | command_call kRESCUE_MOD stmt
284
- {
285
- expr, (_, line), resbody = val
286
-
287
- expr = value_expr expr
288
- ary = s(:array).line line
289
- result = new_rescue(expr, new_resbody(ary, resbody))
290
- }
291
287
  | command_asgn
292
288
 
293
289
  expr: command_call
@@ -314,7 +310,7 @@ rule
314
310
  # TODO: fix line number to tBANG... but causes BAD shift/reduce conflict
315
311
  # REFACTOR: call_uni_op -- see parse26.y
316
312
  }
317
- | arg
313
+ | arg =tLBRACE_ARG
318
314
 
319
315
  expr_value: expr
320
316
  {
@@ -339,7 +335,7 @@ rule
339
335
  block_command: block_call
340
336
  | block_call call_op2 operation2 command_args
341
337
  {
342
- blk, _, msg, args = val
338
+ blk, _, (msg, _line), args = val
343
339
  result = new_call(blk, msg.to_sym, args).line blk.line
344
340
  }
345
341
 
@@ -353,15 +349,15 @@ rule
353
349
  _, line, body, _ = val
354
350
 
355
351
  result = body
356
- result.line = line
352
+ result.line line
357
353
 
358
354
  # self.env.unextend
359
355
  }
360
356
 
361
357
  fcall: operation
362
358
  {
363
- msg, = val
364
- result = new_call(nil, msg.to_sym).line lexer.lineno
359
+ (msg, line), = val
360
+ result = new_call(nil, msg.to_sym).line line
365
361
  }
366
362
 
367
363
  command: fcall command_args =tLOWEST
@@ -384,12 +380,14 @@ rule
384
380
  }
385
381
  | primary_value call_op operation2 command_args =tLOWEST
386
382
  {
387
- lhs, callop, op, args = val
383
+ lhs, callop, (op, _), args = val
384
+
388
385
  result = new_call lhs, op.to_sym, args, callop
386
+ result.line lhs.line
389
387
  }
390
388
  | primary_value call_op operation2 command_args cmd_brace_block
391
389
  {
392
- recv, _, msg, args, block = val
390
+ recv, _, (msg, _line), args, block = val
393
391
  call = new_call recv, msg.to_sym, args, val[1]
394
392
 
395
393
  block_dup_check call, block
@@ -399,11 +397,14 @@ rule
399
397
  }
400
398
  | primary_value tCOLON2 operation2 command_args =tLOWEST
401
399
  {
402
- result = new_call val[0], val[2].to_sym, val[3]
400
+ lhs, _, (id, line), args = val
401
+
402
+ result = new_call lhs, id.to_sym, args
403
+ result.line line
403
404
  }
404
405
  | primary_value tCOLON2 operation2 command_args cmd_brace_block
405
406
  {
406
- recv, _, msg, args, block = val
407
+ recv, _, (msg, _line), args, block = val
407
408
  call = new_call recv, msg.to_sym, args
408
409
 
409
410
  block_dup_check call, block
@@ -561,25 +562,29 @@ rule
561
562
  }
562
563
  | primary_value call_op tIDENTIFIER
563
564
  {
564
- result = new_attrasgn val[0], val[2], val[1]
565
+ lhs, call_op, (id, _line) = val
566
+
567
+ result = new_attrasgn lhs, id, call_op
565
568
  }
566
569
  | primary_value tCOLON2 tIDENTIFIER
567
570
  {
568
- recv, _, id = val
571
+ recv, _, (id, _line) = val
569
572
  result = new_attrasgn recv, id
570
573
  }
571
574
  | primary_value call_op tCONSTANT
572
575
  {
573
- result = new_attrasgn val[0], val[2], val[1]
576
+ lhs, call_op, (id, _line) = val
577
+
578
+ result = new_attrasgn lhs, id, call_op
574
579
  }
575
580
  | primary_value tCOLON2 tCONSTANT
576
581
  {
577
582
  if (self.in_def || self.in_single > 0) then
578
- debug20 7
583
+ debug 14
579
584
  yyerror "dynamic constant assignment"
580
585
  end
581
586
 
582
- expr, _, id = val
587
+ expr, _, (id, _line) = val
583
588
  l = expr.line
584
589
 
585
590
  result = s(:const, s(:colon2, expr, id.to_sym).line(l), nil).line l
@@ -587,58 +592,65 @@ rule
587
592
  | tCOLON3 tCONSTANT
588
593
  {
589
594
  if (self.in_def || self.in_single > 0) then
590
- debug20 8
595
+ debug 15
591
596
  yyerror "dynamic constant assignment"
592
597
  end
593
598
 
594
- _, id = val
595
- l = lexer.lineno
599
+ _, (id, l) = val
596
600
 
597
601
  result = s(:const, nil, s(:colon3, id.to_sym).line(l)).line l
598
602
  }
599
603
  | backref
600
604
  {
601
- self.backref_assign_error val[0]
605
+ ref, = val
606
+
607
+ self.backref_assign_error ref
602
608
  }
603
609
 
604
610
  lhs: user_variable
605
611
  {
606
- line = lexer.lineno
607
- result = self.assignable val[0]
608
- result.line = line
612
+ var, = val
613
+
614
+ result = self.assignable var
609
615
  }
610
616
  | keyword_variable
611
617
  {
612
- line = lexer.lineno
613
- result = self.assignable val[0]
614
- result.line = line
615
- debug20 9, val, result
618
+ var, = val
619
+
620
+ result = self.assignable var
621
+
622
+ debug 16
616
623
  }
617
624
  | primary_value tLBRACK2 opt_call_args rbracket
618
625
  {
619
626
  lhs, _, args, _ = val
627
+
620
628
  result = self.aryset lhs, args
621
629
  }
622
630
  | primary_value call_op tIDENTIFIER # REFACTOR
623
631
  {
624
- lhs, op, id = val
632
+ lhs, op, (id, _line) = val
633
+
625
634
  result = new_attrasgn lhs, id, op
626
635
  }
627
636
  | primary_value tCOLON2 tIDENTIFIER
628
637
  {
629
- lhs, _, id = val
638
+ lhs, _, (id, _line) = val
639
+
630
640
  result = new_attrasgn lhs, id
631
641
  }
632
642
  | primary_value call_op tCONSTANT # REFACTOR?
633
643
  {
634
- result = new_attrasgn val[0], val[2], val[1]
644
+ lhs, call_op, (id, _line) = val
645
+
646
+ result = new_attrasgn lhs, id, call_op
635
647
  }
636
648
  | primary_value tCOLON2 tCONSTANT
637
649
  {
638
- expr, _, id = val
650
+ expr, _, (id, _line) = val
639
651
 
640
652
  if (self.in_def || self.in_single > 0) then
641
- debug20 10
653
+ debug 17
642
654
  yyerror "dynamic constant assignment"
643
655
  end
644
656
 
@@ -647,14 +659,13 @@ rule
647
659
  }
648
660
  | tCOLON3 tCONSTANT
649
661
  {
650
- _, id = val
662
+ _, (id, l) = val
651
663
 
652
664
  if (self.in_def || self.in_single > 0) then
653
- debug20 11
665
+ debug 18
654
666
  yyerror "dynamic constant assignment"
655
667
  end
656
668
 
657
- l = lexer.lineno
658
669
  result = s(:const, s(:colon3, id.to_sym).line(l)).line l
659
670
  }
660
671
  | backref
@@ -670,16 +681,17 @@ rule
670
681
 
671
682
  cpath: tCOLON3 cname
672
683
  {
673
- _, name = val
674
- result = s(:colon3, name.to_sym).line lexer.lineno
684
+ _, (name, line) = val
685
+ result = s(:colon3, name.to_sym).line line
675
686
  }
676
687
  | cname
677
688
  {
678
- result = val[0].to_sym
689
+ (id, line), = val
690
+ result = [id.to_sym, line] # TODO: sexp?
679
691
  }
680
692
  | primary_value tCOLON2 cname
681
693
  {
682
- pval, _, name = val
694
+ pval, _, (name, _line) = val
683
695
 
684
696
  result = s(:colon2, pval, name.to_sym)
685
697
  result.line pval.line
@@ -689,24 +701,17 @@ rule
689
701
  | op
690
702
  {
691
703
  lexer.lex_state = EXPR_END
692
- result = val[0]
693
704
  }
694
705
 
695
706
  | reswords
696
- {
697
- (sym, _line), = val
698
- lexer.lex_state = EXPR_END
699
- result = sym
700
- }
701
707
 
702
- fsym: fname | symbol
703
-
704
- fitem: fsym
708
+ fitem: fname
705
709
  {
706
- id, = val
707
- result = s(:lit, id.to_sym).line lexer.lineno
710
+ (id, line), = val
711
+
712
+ result = s(:lit, id.to_sym).line line
708
713
  }
709
- | dsym
714
+ | symbol
710
715
 
711
716
  undef_list: fitem
712
717
  {
@@ -727,8 +732,6 @@ rule
727
732
  | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
728
733
  | tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
729
734
  | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
730
- # TODO: tUBANG dead?
731
- | tUBANG
732
735
 
733
736
  reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
734
737
  | kALIAS | kAND | kBEGIN | kBREAK | kCASE
@@ -762,24 +765,20 @@ rule
762
765
  }
763
766
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
764
767
  {
765
- lhs, _, id, op, rhs = val
768
+ lhs, _, (id, _line), (op, _), rhs = val
766
769
 
767
770
  result = s(:op_asgn, lhs, rhs, id.to_sym, op.to_sym).line lhs.line
768
771
  }
769
772
  | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
770
773
  {
771
- lhs1, _, lhs2, op, rhs = val
774
+ lhs1, _, (lhs2, _line), op, rhs = val
772
775
 
773
776
  lhs = s(:colon2, lhs1, lhs2.to_sym).line lhs1.line
774
777
  result = new_const_op_asgn [lhs, op, rhs]
775
778
  }
776
- | tCOLON3 tCONSTANT
779
+ | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
777
780
  {
778
- result = self.lexer.lineno
779
- }
780
- tOP_ASGN arg_rhs
781
- {
782
- _, lhs, line, op, rhs = val
781
+ _, (lhs, line), op, rhs = val
783
782
 
784
783
  lhs = s(:colon3, lhs.to_sym).line line
785
784
  result = new_const_op_asgn [lhs, op, rhs]
@@ -793,7 +792,7 @@ rule
793
792
  | arg tDOT2 arg
794
793
  {
795
794
  v1, v2 = val[0], val[2]
796
- if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
795
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
797
796
  result = s(:lit, (v1.last)..(v2.last)).line v1.line
798
797
  else
799
798
  result = s(:dot2, v1, v2).line v1.line
@@ -802,26 +801,12 @@ rule
802
801
  | arg tDOT3 arg
803
802
  {
804
803
  v1, v2 = val[0], val[2]
805
- if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
804
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
806
805
  result = s(:lit, (v1.last)...(v2.last)).line v1.line
807
806
  else
808
807
  result = s(:dot3, v1, v2).line v1.line
809
808
  end
810
809
  }
811
- | arg tDOT2
812
- {
813
- v1, _ = val
814
- v2 = nil
815
-
816
- result = s(:dot2, v1, v2).line v1.line
817
- }
818
- | arg tDOT3
819
- {
820
- v1, _ = val
821
- v2 = nil
822
-
823
- result = s(:dot3, v1, v2).line v1.line
824
- }
825
810
 
826
811
 
827
812
  | arg tPLUS arg
@@ -850,8 +835,9 @@ rule
850
835
  }
851
836
  | tUMINUS_NUM simple_numeric tPOW arg
852
837
  {
853
- lit = s(:lit, val[1]).line lexer.lineno
854
- result = new_call(new_call(lit, :"**", argl(val[3])), :"-@")
838
+ _, (num, line), _, arg = val
839
+ lit = s(:lit, num).line line
840
+ result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
855
841
 
856
842
  }
857
843
  | tUPLUS arg
@@ -950,12 +936,12 @@ rule
950
936
 
951
937
  rel_expr: arg relop arg =tGT
952
938
  {
953
- lhs, op, rhs = val
939
+ lhs, (op, _), rhs = val
954
940
  result = new_call lhs, op.to_sym, argl(rhs)
955
941
  }
956
942
  | rel_expr relop arg =tGT
957
943
  {
958
- lhs, op, rhs = val
944
+ lhs, (op, _), rhs = val
959
945
  warn "comparison '%s' after comparison", op
960
946
  result = new_call lhs, op.to_sym, argl(rhs)
961
947
  }
@@ -1146,8 +1132,9 @@ rule
1146
1132
  | backref
1147
1133
  | tFID
1148
1134
  {
1149
- msg, = val
1135
+ (msg, line), = val
1150
1136
  result = new_call nil, msg.to_sym
1137
+ result.line line
1151
1138
  }
1152
1139
  | k_begin
1153
1140
  {
@@ -1189,15 +1176,15 @@ rule
1189
1176
  }
1190
1177
  | primary_value tCOLON2 tCONSTANT
1191
1178
  {
1192
- expr, _, id = val
1179
+ expr, _, (id, _line) = val
1193
1180
 
1194
1181
  result = s(:colon2, expr, id.to_sym).line expr.line
1195
1182
  }
1196
1183
  | tCOLON3 tCONSTANT
1197
1184
  {
1198
- _, id = val
1185
+ _, (id, line) = val
1199
1186
 
1200
- result = s(:colon3, id.to_sym).line lexer.lineno
1187
+ result = s(:colon3, id.to_sym).line line
1201
1188
  }
1202
1189
  | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1203
1190
  {
@@ -1221,15 +1208,21 @@ rule
1221
1208
  }
1222
1209
  | kYIELD tLPAREN2 call_args rparen
1223
1210
  {
1224
- result = new_yield val[2]
1211
+ (_, line), _, args, _ = val
1212
+
1213
+ result = new_yield(args).line line
1225
1214
  }
1226
1215
  | kYIELD tLPAREN2 rparen
1227
1216
  {
1228
- result = new_yield
1217
+ (_, line), _, _ = val
1218
+
1219
+ result = new_yield.line line
1229
1220
  }
1230
1221
  | kYIELD
1231
1222
  {
1232
- result = new_yield
1223
+ (_, line), = val
1224
+
1225
+ result = new_yield.line line
1233
1226
  }
1234
1227
  | kDEFINED opt_nl tLPAREN2 expr rparen
1235
1228
  {
@@ -1244,7 +1237,7 @@ rule
1244
1237
  }
1245
1238
  | kNOT tLPAREN2 rparen
1246
1239
  {
1247
- debug20 14, val, result
1240
+ debug 20
1248
1241
  }
1249
1242
  | fcall brace_block
1250
1243
  {
@@ -1262,9 +1255,10 @@ rule
1262
1255
  iter.insert 1, call # FIX
1263
1256
  result = iter
1264
1257
  }
1265
- | tLAMBDA lambda
1258
+ | lambda
1266
1259
  {
1267
- result = val[1] # TODO: fix lineno
1260
+ expr, = val
1261
+ result = expr
1268
1262
  }
1269
1263
  | k_if expr_value then compstmt if_tail k_end
1270
1264
  {
@@ -1307,7 +1301,6 @@ rule
1307
1301
  }
1308
1302
  cpath superclass
1309
1303
  {
1310
- self.comments.push self.lexer.comments
1311
1304
  if (self.in_def || self.in_single > 0) then
1312
1305
  yyerror "class definition in method body"
1313
1306
  end
@@ -1317,7 +1310,7 @@ rule
1317
1310
  {
1318
1311
  result = new_class val
1319
1312
  self.env.unextend
1320
- self.lexer.comments # we don't care about comments in the body
1313
+ self.lexer.ignore_body_comments
1321
1314
  }
1322
1315
  | k_class tLSHFT
1323
1316
  {
@@ -1338,7 +1331,7 @@ rule
1338
1331
  {
1339
1332
  result = new_sclass val
1340
1333
  self.env.unextend
1341
- self.lexer.comments # we don't care about comments in the body
1334
+ self.lexer.ignore_body_comments
1342
1335
  }
1343
1336
  | k_module
1344
1337
  {
@@ -1346,7 +1339,6 @@ rule
1346
1339
  }
1347
1340
  cpath
1348
1341
  {
1349
- self.comments.push self.lexer.comments
1350
1342
  yyerror "module definition in method body" if
1351
1343
  self.in_def or self.in_single > 0
1352
1344
 
@@ -1356,7 +1348,7 @@ rule
1356
1348
  {
1357
1349
  result = new_module val
1358
1350
  self.env.unextend
1359
- self.lexer.comments # we don't care about comments in the body
1351
+ self.lexer.ignore_body_comments
1360
1352
  }
1361
1353
  | k_def fname
1362
1354
  {
@@ -1366,21 +1358,17 @@ rule
1366
1358
  self.env.extend
1367
1359
  lexer.cmdarg.push false
1368
1360
  lexer.cond.push false
1369
-
1370
- self.comments.push self.lexer.comments
1371
1361
  }
1372
- f_arglist bodystmt { result = lexer.lineno } k_end
1362
+ f_arglist bodystmt k_end
1373
1363
  {
1374
- in_def = val[2]
1375
-
1376
- result = new_defn val
1364
+ result, in_def = new_defn val
1377
1365
 
1378
1366
  lexer.cond.pop # group = local_pop
1379
1367
  lexer.cmdarg.pop
1380
1368
  self.env.unextend
1381
1369
  self.in_def = in_def
1382
1370
 
1383
- self.lexer.comments # we don't care about comments in the body
1371
+ self.lexer.ignore_body_comments
1384
1372
  }
1385
1373
  | k_def singleton dot_or_colon
1386
1374
  {
@@ -1388,7 +1376,7 @@ rule
1388
1376
  }
1389
1377
  fname
1390
1378
  {
1391
- result = [self.in_def, lexer.lineno]
1379
+ result = self.in_def
1392
1380
 
1393
1381
  self.in_single += 1 # TODO: remove?
1394
1382
 
@@ -1398,13 +1386,18 @@ rule
1398
1386
  lexer.cond.push false
1399
1387
 
1400
1388
  lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
1401
- self.comments.push self.lexer.comments
1402
1389
  }
1403
1390
  f_arglist bodystmt k_end
1404
1391
  {
1405
- _, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
1406
1392
 
1407
- result = new_defs val
1393
+ # [kdef, recv, _, _, (name, line), in_def, args, body, kend]
1394
+ # =>
1395
+ # [kdef, recv, (name, line), in_def, args, body, kend]
1396
+
1397
+ val.delete_at 3
1398
+ val.delete_at 2
1399
+
1400
+ result, in_def = new_defs val
1408
1401
 
1409
1402
  lexer.cond.pop # group = local_pop
1410
1403
  lexer.cmdarg.pop
@@ -1415,7 +1408,7 @@ rule
1415
1408
 
1416
1409
  # TODO: restore cur_arg ? what's cur_arg?
1417
1410
 
1418
- self.lexer.comments # we don't care about comments in the body
1411
+ self.lexer.ignore_body_comments
1419
1412
  }
1420
1413
  | kBREAK
1421
1414
  {
@@ -1452,8 +1445,17 @@ rule
1452
1445
  k_case: kCASE
1453
1446
  k_for: kFOR
1454
1447
  k_class: kCLASS
1448
+ {
1449
+ self.comments.push self.lexer.comments
1450
+ }
1455
1451
  k_module: kMODULE
1452
+ {
1453
+ self.comments.push self.lexer.comments
1454
+ }
1456
1455
  k_def: kDEF
1456
+ {
1457
+ self.comments.push self.lexer.comments
1458
+ }
1457
1459
  k_do: kDO
1458
1460
  k_do_block: kDO_BLOCK
1459
1461
  k_rescue: kRESCUE
@@ -1514,51 +1516,42 @@ rule
1514
1516
 
1515
1517
  result = block_var args
1516
1518
  }
1517
- | f_marg_list tCOMMA tSTAR f_norm_arg
1519
+ | f_marg_list tCOMMA f_rest_marg
1518
1520
  {
1519
- args, _, _, splat = val
1521
+ args, _, rest = val
1520
1522
 
1521
- result = block_var args, "*#{splat}".to_sym
1523
+ result = block_var args, rest
1522
1524
  }
1523
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1525
+ | f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
1524
1526
  {
1525
- args, _, _, splat, _, args2 = val
1527
+ lhs, _, splat, _, rhs = val
1526
1528
 
1527
- result = block_var args, "*#{splat}".to_sym, args2
1529
+ result = block_var lhs, splat, rhs
1528
1530
  }
1529
- | f_marg_list tCOMMA tSTAR
1531
+ | f_rest_marg
1530
1532
  {
1531
- args, _, _ = val
1533
+ rest, = val
1532
1534
 
1533
- result = block_var args, :*
1535
+ result = block_var rest
1534
1536
  }
1535
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1537
+ | f_rest_marg tCOMMA f_marg_list
1536
1538
  {
1537
- args, _, _, _, args2 = val
1539
+ splat, _, rest = val
1538
1540
 
1539
- result = block_var args, :*, args2
1541
+ result = block_var splat, rest
1540
1542
  }
1541
- | tSTAR f_norm_arg
1542
- {
1543
- _, splat = val
1544
1543
 
1545
- result = block_var :"*#{splat}"
1546
- }
1547
- | tSTAR f_norm_arg tCOMMA f_marg_list
1544
+ f_rest_marg: tSTAR f_norm_arg
1548
1545
  {
1549
- _, splat, _, args = val
1546
+ _, (id, line) = val
1550
1547
 
1551
- result = block_var :"*#{splat}", args
1548
+ result = args ["*#{id}".to_sym]
1549
+ result.line line
1552
1550
  }
1553
1551
  | tSTAR
1554
1552
  {
1555
- result = block_var :*
1556
- }
1557
- | tSTAR tCOMMA f_marg_list
1558
- {
1559
- _, _, args = val
1560
-
1561
- result = block_var :*, args
1553
+ result = args [:*]
1554
+ result.line lexer.lineno # FIX: tSTAR -> line
1562
1555
  }
1563
1556
 
1564
1557
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -1575,8 +1568,8 @@ rule
1575
1568
  }
1576
1569
  | f_block_arg
1577
1570
  {
1578
- line = lexer.lineno
1579
- result = call_args val # TODO: push line down
1571
+ (id, line), = val
1572
+ result = call_args [id]
1580
1573
  result.line line
1581
1574
  }
1582
1575
 
@@ -1685,13 +1678,13 @@ opt_block_args_tail: tCOMMA block_args_tail
1685
1678
 
1686
1679
  bvar: tIDENTIFIER
1687
1680
  {
1688
- id, = val
1689
- line = lexer.lineno
1681
+ (id, line), = val
1690
1682
  result = s(:shadow, id.to_sym).line line
1691
1683
  }
1692
1684
  | f_bad_arg
1693
1685
 
1694
- lambda: {
1686
+ lambda: tLAMBDA
1687
+ {
1695
1688
  self.env.extend :dynamic
1696
1689
  result = [lexer.lineno, lexer.lpar_beg]
1697
1690
  lexer.paren_nest += 1
@@ -1703,14 +1696,14 @@ opt_block_args_tail: tCOMMA block_args_tail
1703
1696
  }
1704
1697
  lambda_body
1705
1698
  {
1706
- (line, lpar), args, _cmdarg, body = val
1699
+ _, (line, lpar), args, _cmdarg, body = val
1707
1700
  lexer.lpar_beg = lpar
1708
1701
 
1709
1702
  lexer.cmdarg.pop
1710
1703
 
1711
1704
  call = s(:lambda).line line
1712
1705
  result = new_iter call, args, body
1713
- result.line = line
1706
+ result.line line
1714
1707
  self.env.unextend # TODO: dynapush & dynapop
1715
1708
  }
1716
1709
 
@@ -1745,23 +1738,28 @@ opt_block_args_tail: tCOMMA block_args_tail
1745
1738
  ## if (nd_type($1) == NODE_YIELD) {
1746
1739
  ## compile_error(PARSER_ARG "block given to yield");
1747
1740
 
1748
- syntax_error "Both block arg and actual block given." if
1749
- val[0].block_pass?
1741
+ cmd, blk = val
1750
1742
 
1751
- val = invert_block_call val if inverted? val
1743
+ syntax_error "Both block arg and actual block given." if
1744
+ cmd.block_pass?
1752
1745
 
1753
- cmd, blk = val
1746
+ if inverted? val then
1747
+ val = invert_block_call val
1748
+ cmd, blk = val
1749
+ end
1754
1750
 
1755
1751
  result = blk
1756
1752
  result.insert 1, cmd
1757
1753
  }
1758
1754
  | block_call call_op2 operation2 opt_paren_args
1759
1755
  {
1760
- result = new_call val[0], val[2].to_sym, val[3]
1756
+ lhs, _, (id, _line), args = val
1757
+
1758
+ result = new_call lhs, id.to_sym, args
1761
1759
  }
1762
1760
  | block_call call_op2 operation2 opt_paren_args brace_block
1763
1761
  {
1764
- iter1, _, name, args, iter2 = val
1762
+ iter1, _, (name, _line), args, iter2 = val
1765
1763
 
1766
1764
  call = new_call iter1, name.to_sym, args
1767
1765
  iter2.insert 1, call
@@ -1770,7 +1768,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1770
1768
  }
1771
1769
  | block_call call_op2 operation2 command_args do_block
1772
1770
  {
1773
- iter1, _, name, args, iter2 = val
1771
+ iter1, _, (name, _line), args, iter2 = val
1774
1772
 
1775
1773
  call = new_call iter1, name.to_sym, args
1776
1774
  iter2.insert 1, call
@@ -1778,28 +1776,29 @@ opt_block_args_tail: tCOMMA block_args_tail
1778
1776
  result = iter2
1779
1777
  }
1780
1778
 
1781
- method_call: fcall
1779
+ method_call: fcall paren_args
1782
1780
  {
1783
- result = self.lexer.lineno
1784
- }
1785
- paren_args
1786
- {
1787
- call, lineno, args = val
1781
+ call, args = val
1788
1782
 
1789
1783
  result = call.concat args.sexp_body if args
1790
- result.line lineno
1791
1784
  }
1792
1785
  | primary_value call_op operation2 opt_paren_args
1793
1786
  {
1794
- result = new_call val[0], val[2].to_sym, val[3], val[1]
1787
+ recv, call_op, (op, _line), args = val
1788
+
1789
+ result = new_call recv, op.to_sym, args, call_op
1795
1790
  }
1796
1791
  | primary_value tCOLON2 operation2 paren_args
1797
1792
  {
1798
- result = new_call val[0], val[2].to_sym, val[3]
1793
+ recv, _, (op, _line), args = val
1794
+
1795
+ result = new_call recv, op.to_sym, args
1799
1796
  }
1800
1797
  | primary_value tCOLON2 operation3
1801
1798
  {
1802
- result = new_call val[0], val[2].to_sym
1799
+ lhs, _, (id, _line) = val
1800
+
1801
+ result = new_call lhs, id.to_sym
1803
1802
  }
1804
1803
  | primary_value call_op paren_args
1805
1804
  {
@@ -1832,7 +1831,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1832
1831
  _, line, body, _ = val
1833
1832
 
1834
1833
  result = body
1835
- result.line = line
1834
+ result.line line
1836
1835
 
1837
1836
  self.env.unextend
1838
1837
  }
@@ -1846,7 +1845,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1846
1845
  _, line, body, _ = val
1847
1846
 
1848
1847
  result = body
1849
- result.line = line
1848
+ result.line line
1850
1849
 
1851
1850
  self.env.unextend
1852
1851
  }
@@ -1866,7 +1865,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1866
1865
  do_body: { self.env.extend :dynamic; result = self.lexer.lineno }
1867
1866
  { lexer.cmdarg.push false }
1868
1867
  opt_block_param
1869
- bodystmt
1868
+ compstmt
1870
1869
  {
1871
1870
  line, _cmdarg, param, cmpstmt = val
1872
1871
 
@@ -1875,14 +1874,39 @@ opt_block_args_tail: tCOMMA block_args_tail
1875
1874
  self.env.unextend
1876
1875
  }
1877
1876
 
1877
+ case_args: arg_value
1878
+ {
1879
+ arg, = val
1880
+
1881
+ result = s(:array, arg).line arg.line
1882
+ }
1883
+ | tSTAR arg_value
1884
+ {
1885
+ _, arg = val
1886
+
1887
+ result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
1888
+ }
1889
+ | case_args tCOMMA arg_value
1890
+ {
1891
+ args, _, id = val
1892
+
1893
+ result = self.list_append args, id
1894
+ }
1895
+ | case_args tCOMMA tSTAR arg_value
1896
+ {
1897
+ args, _, _, id = val
1898
+
1899
+ result = self.list_append args, s(:splat, id).line(id.line)
1900
+ }
1901
+
1878
1902
  case_body: k_when
1879
1903
  {
1880
1904
  result = self.lexer.lineno
1881
1905
  }
1882
- args then compstmt cases
1906
+ case_args then compstmt cases
1883
1907
  {
1884
1908
  result = new_when(val[2], val[4])
1885
- result.line = val[1]
1909
+ result.line val[1]
1886
1910
  result << val[5] if val[5]
1887
1911
  }
1888
1912
 
@@ -1928,17 +1952,10 @@ opt_block_args_tail: tCOMMA block_args_tail
1928
1952
 
1929
1953
  literal: numeric
1930
1954
  {
1931
- line = lexer.lineno
1932
- result = s(:lit, val[0])
1933
- result.line = line
1955
+ (lit, line), = val
1956
+ result = s(:lit, lit).line line
1934
1957
  }
1935
1958
  | symbol
1936
- {
1937
- line = lexer.lineno
1938
- result = s(:lit, val[0])
1939
- result.line = line
1940
- }
1941
- | dsym
1942
1959
 
1943
1960
  strings: string
1944
1961
  {
@@ -1949,7 +1966,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1949
1966
 
1950
1967
  string: tCHAR
1951
1968
  {
1952
- debug20 23, val, result
1969
+ debug 37
1953
1970
  }
1954
1971
  | string1
1955
1972
  | string string1
@@ -1959,11 +1976,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1959
1976
 
1960
1977
  string1: tSTRING_BEG string_contents tSTRING_END
1961
1978
  {
1962
- _, str, (_, func) = val
1979
+ (_, line), str, (_, func) = val
1963
1980
 
1964
- str = dedent str if func =~ RubyLexer::STR_FUNC_ICNTNT
1981
+ str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
1965
1982
 
1966
- result = str
1983
+ result = str.line line
1967
1984
  }
1968
1985
  | tSTRING
1969
1986
  {
@@ -1983,11 +2000,15 @@ opt_block_args_tail: tCOMMA block_args_tail
1983
2000
 
1984
2001
  words: tWORDS_BEG tSPACE tSTRING_END
1985
2002
  {
1986
- result = s(:array).line lexer.lineno
2003
+ (_, line), _, _ = val
2004
+
2005
+ result = s(:array).line line
1987
2006
  }
1988
2007
  | tWORDS_BEG word_list tSTRING_END
1989
2008
  {
1990
- result = val[1]
2009
+ (_, line), list, _ = val
2010
+
2011
+ result = list.line line
1991
2012
  }
1992
2013
 
1993
2014
  word_list: none
@@ -2007,18 +2028,20 @@ opt_block_args_tail: tCOMMA block_args_tail
2007
2028
 
2008
2029
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2009
2030
  {
2010
- result = s(:array).line lexer.lineno
2031
+ (_, line), _, _ = val
2032
+
2033
+ result = s(:array).line line
2011
2034
  }
2012
- | tSYMBOLS_BEG { result = lexer.lineno } symbol_list tSTRING_END
2035
+ | tSYMBOLS_BEG symbol_list tSTRING_END
2013
2036
  {
2014
- _, line, list, _, = val
2015
- list.line = line
2037
+ (_, line), list, _, = val
2038
+ list.line line
2016
2039
  result = list
2017
2040
  }
2018
2041
 
2019
2042
  symbol_list: none
2020
2043
  {
2021
- result = new_symbol_list.line lexer.lineno
2044
+ result = new_symbol_list
2022
2045
  }
2023
2046
  | symbol_list word tSPACE
2024
2047
  {
@@ -2028,20 +2051,28 @@ opt_block_args_tail: tCOMMA block_args_tail
2028
2051
 
2029
2052
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2030
2053
  {
2031
- result = s(:array).line lexer.lineno
2054
+ (_, line), _, _ = val
2055
+
2056
+ result = s(:array).line line
2032
2057
  }
2033
2058
  | tQWORDS_BEG qword_list tSTRING_END
2034
2059
  {
2035
- result = val[1]
2060
+ (_, line), list, _ = val
2061
+
2062
+ result = list.line line
2036
2063
  }
2037
2064
 
2038
2065
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2039
2066
  {
2040
- result = s(:array).line lexer.lineno # FIX
2067
+ (_, line), _, _ = val
2068
+
2069
+ result = s(:array).line line
2041
2070
  }
2042
2071
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2043
2072
  {
2044
- result = val[1]
2073
+ (_, line), list, _ = val
2074
+
2075
+ result = list.line line
2045
2076
  }
2046
2077
 
2047
2078
  qword_list: none
@@ -2064,7 +2095,8 @@ opt_block_args_tail: tCOMMA block_args_tail
2064
2095
 
2065
2096
  string_contents: none
2066
2097
  {
2067
- result = s(:str, "").line lexer.lineno
2098
+ line = prev_value_to_lineno _values.last
2099
+ result = s(:str, +"").line line
2068
2100
  }
2069
2101
  | string_contents string_content
2070
2102
  {
@@ -2139,8 +2171,8 @@ regexp_contents: none
2139
2171
  lexer.brace_nest = brace_nest
2140
2172
  lexer.string_nest = string_nest
2141
2173
 
2142
- lexer.cmdarg.pop
2143
2174
  lexer.cond.pop
2175
+ lexer.cmdarg.pop
2144
2176
 
2145
2177
  lexer.lex_state = oldlex_state
2146
2178
 
@@ -2155,29 +2187,49 @@ regexp_contents: none
2155
2187
  when nil then
2156
2188
  result = s(:evstr).line line
2157
2189
  else
2158
- debug20 25
2190
+ debug 38
2159
2191
  raise "unknown string body: #{stmt.inspect}"
2160
2192
  end
2161
2193
  }
2162
2194
 
2163
- string_dvar: tGVAR { result = s(:gvar, val[0].to_sym).line lexer.lineno }
2164
- | tIVAR { result = s(:ivar, val[0].to_sym).line lexer.lineno }
2165
- | tCVAR { result = s(:cvar, val[0].to_sym).line lexer.lineno }
2195
+ string_dvar: tGVAR
2196
+ {
2197
+ (id, line), = val
2198
+ result = s(:gvar, id.to_sym).line line
2199
+ }
2200
+ | tIVAR
2201
+ {
2202
+ (id, line), = val
2203
+ result = s(:ivar, id.to_sym).line line
2204
+ }
2205
+ | tCVAR
2206
+ {
2207
+ (id, line), = val
2208
+ result = s(:cvar, id.to_sym).line line
2209
+ }
2166
2210
  | backref
2167
2211
 
2168
- symbol: tSYMBEG sym
2212
+ symbol: ssym
2213
+ | dsym
2214
+
2215
+ ssym: tSYMBEG sym
2169
2216
  {
2217
+ _, (id, line) = val
2218
+
2170
2219
  lexer.lex_state = EXPR_END
2171
- result = val[1].to_sym
2220
+ result = s(:lit, id.to_sym).line line
2172
2221
  }
2173
2222
  | tSYMBOL
2174
2223
  {
2175
- result = val[0].to_sym
2224
+ (id, line), = val
2225
+
2226
+ lexer.lex_state = EXPR_END
2227
+ result = s(:lit, id.to_sym).line line
2176
2228
  }
2177
2229
 
2178
2230
  sym: fname | tIVAR | tGVAR | tCVAR
2179
2231
 
2180
- dsym: tSYMBEG xstring_contents tSTRING_END
2232
+ dsym: tSYMBEG string_contents tSTRING_END
2181
2233
  {
2182
2234
  _, result, _ = val
2183
2235
 
@@ -2193,14 +2245,15 @@ regexp_contents: none
2193
2245
  when :evstr then
2194
2246
  result = s(:dsym, "", result).line result.line
2195
2247
  else
2196
- debug20 26, val, result
2248
+ debug 39
2197
2249
  end
2198
2250
  }
2199
2251
 
2200
2252
  numeric: simple_numeric
2201
- | tUMINUS_NUM simple_numeric
2253
+ | tUMINUS_NUM simple_numeric =tLOWEST
2202
2254
  {
2203
- result = -val[1] # TODO: pt_testcase
2255
+ _, (num, line) = val
2256
+ result = [-num, line]
2204
2257
  }
2205
2258
 
2206
2259
  simple_numeric: tINTEGER
@@ -2233,8 +2286,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2233
2286
 
2234
2287
  var_ref: user_variable
2235
2288
  {
2236
- var = val[0]
2289
+ raise "NO: #{val.inspect}" if Sexp === val.first
2290
+ (var, line), = val
2237
2291
  result = Sexp === var ? var : self.gettable(var)
2292
+ result.line line
2238
2293
  }
2239
2294
  | keyword_variable
2240
2295
  {
@@ -2249,11 +2304,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2249
2304
  | keyword_variable
2250
2305
  {
2251
2306
  result = self.assignable val[0]
2252
- debug20 29, val, result
2307
+ debug 40
2253
2308
  }
2254
2309
 
2255
- backref: tNTH_REF { result = s(:nth_ref, val[0]).line lexer.lineno }
2256
- | tBACK_REF { result = s(:back_ref, val[0]).line lexer.lineno }
2310
+ backref: tNTH_REF
2311
+ {
2312
+ (ref, line), = val
2313
+ result = s(:nth_ref, ref).line line
2314
+ }
2315
+ | tBACK_REF
2316
+ {
2317
+ (ref, line), = val
2318
+ result = s(:back_ref, ref).line line
2319
+ }
2257
2320
 
2258
2321
  superclass: tLT
2259
2322
  {
@@ -2271,9 +2334,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2271
2334
 
2272
2335
  f_arglist: tLPAREN2 f_args rparen
2273
2336
  {
2274
- result = val[1]
2275
- self.lexer.lex_state = EXPR_BEG
2276
- self.lexer.command_start = true
2337
+ result = end_args val
2277
2338
  }
2278
2339
  | {
2279
2340
  result = self.in_kwarg
@@ -2282,12 +2343,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2282
2343
  }
2283
2344
  f_args term
2284
2345
  {
2285
- kwarg, args, _ = val
2286
-
2287
- self.in_kwarg = kwarg
2288
- result = args
2289
- lexer.lex_state = EXPR_BEG
2290
- lexer.command_start = true
2346
+ result = end_args val
2291
2347
  }
2292
2348
 
2293
2349
  args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -2372,9 +2428,9 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2372
2428
  |
2373
2429
  {
2374
2430
  result = args val
2431
+ # result.line lexer.lineno
2375
2432
  }
2376
2433
 
2377
- args_forward: tBDOT3
2378
2434
 
2379
2435
  f_bad_arg: tCONSTANT
2380
2436
  {
@@ -2396,10 +2452,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2396
2452
  f_norm_arg: f_bad_arg
2397
2453
  | tIDENTIFIER
2398
2454
  {
2399
- identifier = val[0].to_sym
2455
+ (id, line), = val
2456
+ identifier = id.to_sym
2400
2457
  self.env[identifier] = :lvar
2401
2458
 
2402
- result = identifier
2459
+ result = [identifier, line]
2403
2460
  }
2404
2461
 
2405
2462
  f_arg_asgn: f_norm_arg
@@ -2407,22 +2464,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2407
2464
  f_arg_item: f_arg_asgn
2408
2465
  | tLPAREN f_margs rparen
2409
2466
  {
2410
- result = val[1]
2467
+ _, margs, _ = val
2468
+
2469
+ result = margs
2411
2470
  }
2412
2471
 
2413
2472
  f_arg: f_arg_item
2414
2473
  {
2415
- arg, = val
2416
-
2417
- case arg
2418
- when Symbol then
2419
- result = s(:args, arg).line lexer.lineno
2420
- when Sexp then
2421
- result = arg
2422
- else
2423
- debug20 32
2424
- raise "Unknown f_arg type: #{val.inspect}"
2425
- end
2474
+ result = new_arg val
2426
2475
  }
2427
2476
  | f_arg tCOMMA f_arg_item
2428
2477
  {
@@ -2434,7 +2483,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2434
2483
  result = s(:args, list).line list.line
2435
2484
  end
2436
2485
 
2437
- result << item
2486
+ result << (Sexp === item ? item : item.first)
2438
2487
  }
2439
2488
 
2440
2489
  f_label: tLABEL
@@ -2495,27 +2544,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2495
2544
  kwrest_mark: tPOW
2496
2545
  | tDSTAR
2497
2546
 
2547
+
2498
2548
  f_kwrest: kwrest_mark tIDENTIFIER
2499
2549
  {
2500
- name = val[1].to_sym
2501
- self.assignable name
2502
- result = :"**#{name}"
2550
+ _, (id, line) = val
2551
+
2552
+ name = id.to_sym
2553
+ self.assignable [name, line]
2554
+ result = [:"**#{name}", line]
2503
2555
  }
2504
2556
  | kwrest_mark
2505
2557
  {
2506
- result = :"**"
2507
- self.env[result] = :lvar
2558
+ id = :"**"
2559
+ self.env[id] = :lvar # TODO: needed?!?
2560
+ result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
2508
2561
  }
2509
2562
 
2510
2563
  f_opt: f_arg_asgn tEQL arg_value
2511
2564
  {
2512
- result = self.assignable val[0], val[2]
2565
+ lhs, _, rhs = val
2566
+ result = self.assignable lhs, rhs
2513
2567
  # TODO: detect duplicate names
2514
2568
  }
2515
2569
 
2516
2570
  f_block_opt: f_arg_asgn tEQL primary_value
2517
2571
  {
2518
- result = self.assignable val[0], val[2]
2572
+ lhs, _, rhs = val
2573
+ result = self.assignable lhs, rhs
2519
2574
  }
2520
2575
 
2521
2576
  f_block_optarg: f_block_opt
@@ -2545,30 +2600,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2545
2600
  f_rest_arg: restarg_mark tIDENTIFIER
2546
2601
  {
2547
2602
  # TODO: differs from parse.y - needs tests
2548
- name = val[1].to_sym
2549
- self.assignable name
2550
- result = :"*#{name}"
2603
+ _, (id, line) = val
2604
+ name = id.to_sym
2605
+ self.assignable [name, line]
2606
+ result = [:"*#{name}", line]
2551
2607
  }
2552
2608
  | restarg_mark
2553
2609
  {
2554
2610
  name = :"*"
2555
2611
  self.env[name] = :lvar
2556
- result = name
2612
+ result = [name, lexer.lineno] # FIX: tSTAR to include lineno
2557
2613
  }
2558
2614
 
2559
2615
  blkarg_mark: tAMPER2 | tAMPER
2560
2616
 
2561
2617
  f_block_arg: blkarg_mark tIDENTIFIER
2562
2618
  {
2563
- identifier = val[1].to_sym
2619
+ _, (id, line) = val
2620
+ identifier = id.to_sym
2564
2621
 
2565
2622
  self.env[identifier] = :lvar
2566
- result = "&#{identifier}".to_sym
2623
+ result = ["&#{identifier}".to_sym, line]
2567
2624
  }
2568
2625
 
2569
2626
  opt_f_block_arg: tCOMMA f_block_arg
2570
2627
  {
2571
- result = val[1]
2628
+ _, arg = val
2629
+ result = arg
2572
2630
  }
2573
2631
  |
2574
2632
  {
@@ -2617,9 +2675,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2617
2675
  }
2618
2676
  | tSTRING_BEG string_contents tLABEL_END arg_value
2619
2677
  {
2620
- _, sym, _, value = val
2678
+ (_, line), sym, _, value = val
2679
+
2621
2680
  sym.sexp_type = :dsym
2622
- result = s(:array, sym, value).line sym.line
2681
+
2682
+ result = s(:array, sym, value).line line
2623
2683
  }
2624
2684
  | tDSTAR arg_value
2625
2685
  {