brakeman 5.1.0 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +26 -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/commandline.rb +1 -1
  113. data/lib/brakeman/options.rb +8 -0
  114. data/lib/brakeman/processors/alias_processor.rb +7 -1
  115. data/lib/brakeman/processors/gem_processor.rb +3 -0
  116. data/lib/brakeman/processors/haml_template_processor.rb +9 -0
  117. data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -0
  118. data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
  119. data/lib/brakeman/processors/model_processor.rb +1 -0
  120. data/lib/brakeman/report/ignore/config.rb +5 -5
  121. data/lib/brakeman/report/report_csv.rb +1 -1
  122. data/lib/brakeman/report/report_sarif.rb +2 -2
  123. data/lib/brakeman/report/report_text.rb +1 -1
  124. data/lib/brakeman/scanner.rb +15 -13
  125. data/lib/brakeman/tracker/config.rb +8 -1
  126. data/lib/brakeman/version.rb +1 -1
  127. data/lib/brakeman/warning_codes.rb +4 -0
  128. data/lib/brakeman.rb +6 -8
  129. data/lib/ruby_parser/bm_sexp.rb +11 -1
  130. metadata +105 -99
  131. data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/processor_count.rb +0 -42
  132. data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/version.rb +0 -3
  133. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
  134. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
  135. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
  136. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
  137. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
  138. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
  139. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
  140. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
  141. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
  142. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
  143. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
  144. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
  145. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
  146. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.7.0/data/display_width.marshal.gz +0 -0
@@ -18,7 +18,7 @@ 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
@@ -79,7 +79,7 @@ rule
79
79
  | klBEGIN
80
80
  {
81
81
  if (self.in_def || self.in_single > 0) then
82
- debug20 1
82
+ debug 11
83
83
  yyerror "BEGIN in method"
84
84
  end
85
85
  self.env.extend
@@ -104,7 +104,9 @@ rule
104
104
  bodystmt: compstmt opt_rescue k_else
105
105
  {
106
106
  res = _values[-2]
107
- 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
108
110
  }
109
111
  compstmt
110
112
  opt_ensure
@@ -134,7 +136,7 @@ rule
134
136
  | error stmt
135
137
  {
136
138
  result = val[1]
137
- debug20 2, val, result
139
+ debug 12
138
140
  }
139
141
 
140
142
  stmt_or_begin: stmt
@@ -142,6 +144,10 @@ rule
142
144
  {
143
145
  yyerror "BEGIN is permitted only at toplevel"
144
146
  }
147
+ begin_block
148
+ {
149
+ result = val[2] # wtf?
150
+ }
145
151
 
146
152
  stmt: kALIAS fitem
147
153
  {
@@ -154,12 +160,12 @@ rule
154
160
  }
155
161
  | kALIAS tGVAR tGVAR
156
162
  {
157
- (_, line), lhs, rhs = val
163
+ (_, line), (lhs, _), (rhs, _) = val
158
164
  result = s(:valias, lhs.to_sym, rhs.to_sym).line line
159
165
  }
160
166
  | kALIAS tGVAR tBACK_REF
161
167
  {
162
- (_, line), lhs, rhs = val
168
+ (_, line), (lhs, _), (rhs, _) = val
163
169
  result = s(:valias, lhs.to_sym, :"$#{rhs}").line line
164
170
  }
165
171
  | kALIAS tGVAR tNTH_REF
@@ -202,7 +208,7 @@ rule
202
208
  (_, line), _, stmt, _ = val
203
209
 
204
210
  if (self.in_def || self.in_single > 0) then
205
- debug20 3
211
+ debug 13
206
212
  yyerror "END in method; use at_exit"
207
213
  end
208
214
 
@@ -242,32 +248,31 @@ rule
242
248
  }
243
249
  | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
244
250
  {
245
- prim, _, id, opasgn, rhs = val
246
- result = s(:op_asgn, prim, rhs, id.to_sym, opasgn.to_sym)
247
- if val[1] == '&.'
248
- result.sexp_type = :safe_op_asgn
249
- end
250
- 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
251
256
  }
252
257
  | primary_value call_op tCONSTANT tOP_ASGN command_rhs
253
258
  {
254
- result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
255
- if val[1] == '&.'
256
- result.sexp_type = :safe_op_asgn
257
- end
258
- 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
259
264
  }
260
265
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
261
266
  {
262
- lhs1, _, lhs2, op, rhs = val
267
+ lhs1, _, (lhs2, line), (id, _), rhs = val
263
268
 
264
- 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
265
270
  }
266
271
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
267
272
  {
268
- lhs1, _, lhs2, op, rhs = val
273
+ lhs1, _, (lhs2, line), (id, _), rhs = val
269
274
 
270
- 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
271
276
  }
272
277
  | backref tOP_ASGN command_rhs
273
278
  {
@@ -313,7 +318,7 @@ rule
313
318
  # TODO: fix line number to tBANG... but causes BAD shift/reduce conflict
314
319
  # REFACTOR: call_uni_op -- see parse26.y
315
320
  }
316
- | arg
321
+ | arg =tLBRACE_ARG
317
322
 
318
323
  expr_value: expr
319
324
  {
@@ -338,7 +343,7 @@ rule
338
343
  block_command: block_call
339
344
  | block_call call_op2 operation2 command_args
340
345
  {
341
- blk, _, msg, args = val
346
+ blk, _, (msg, _line), args = val
342
347
  result = new_call(blk, msg.to_sym, args).line blk.line
343
348
  }
344
349
 
@@ -352,15 +357,15 @@ rule
352
357
  _, line, body, _ = val
353
358
 
354
359
  result = body
355
- result.line = line
360
+ result.line line
356
361
 
357
362
  # self.env.unextend
358
363
  }
359
364
 
360
365
  fcall: operation
361
366
  {
362
- msg, = val
363
- result = new_call(nil, msg.to_sym).line lexer.lineno
367
+ (msg, line), = val
368
+ result = new_call(nil, msg.to_sym).line line
364
369
  }
365
370
 
366
371
  command: fcall command_args =tLOWEST
@@ -383,12 +388,14 @@ rule
383
388
  }
384
389
  | primary_value call_op operation2 command_args =tLOWEST
385
390
  {
386
- lhs, callop, op, args = val
391
+ lhs, callop, (op, _), args = val
392
+
387
393
  result = new_call lhs, op.to_sym, args, callop
394
+ result.line lhs.line
388
395
  }
389
396
  | primary_value call_op operation2 command_args cmd_brace_block
390
397
  {
391
- recv, _, msg, args, block = val
398
+ recv, _, (msg, _line), args, block = val
392
399
  call = new_call recv, msg.to_sym, args, val[1]
393
400
 
394
401
  block_dup_check call, block
@@ -398,11 +405,14 @@ rule
398
405
  }
399
406
  | primary_value tCOLON2 operation2 command_args =tLOWEST
400
407
  {
401
- result = new_call val[0], val[2].to_sym, val[3]
408
+ lhs, _, (id, line), args = val
409
+
410
+ result = new_call lhs, id.to_sym, args
411
+ result.line line
402
412
  }
403
413
  | primary_value tCOLON2 operation2 command_args cmd_brace_block
404
414
  {
405
- recv, _, msg, args, block = val
415
+ recv, _, (msg, _line), args, block = val
406
416
  call = new_call recv, msg.to_sym, args
407
417
 
408
418
  block_dup_check call, block
@@ -560,25 +570,29 @@ rule
560
570
  }
561
571
  | primary_value call_op tIDENTIFIER
562
572
  {
563
- result = new_attrasgn val[0], val[2], val[1]
573
+ lhs, call_op, (id, _line) = val
574
+
575
+ result = new_attrasgn lhs, id, call_op
564
576
  }
565
577
  | primary_value tCOLON2 tIDENTIFIER
566
578
  {
567
- recv, _, id = val
579
+ recv, _, (id, _line) = val
568
580
  result = new_attrasgn recv, id
569
581
  }
570
582
  | primary_value call_op tCONSTANT
571
583
  {
572
- result = new_attrasgn val[0], val[2], val[1]
584
+ lhs, call_op, (id, _line) = val
585
+
586
+ result = new_attrasgn lhs, id, call_op
573
587
  }
574
588
  | primary_value tCOLON2 tCONSTANT
575
589
  {
576
590
  if (self.in_def || self.in_single > 0) then
577
- debug20 7
591
+ debug 14
578
592
  yyerror "dynamic constant assignment"
579
593
  end
580
594
 
581
- expr, _, id = val
595
+ expr, _, (id, _line) = val
582
596
  l = expr.line
583
597
 
584
598
  result = s(:const, s(:colon2, expr, id.to_sym).line(l), nil).line l
@@ -586,58 +600,65 @@ rule
586
600
  | tCOLON3 tCONSTANT
587
601
  {
588
602
  if (self.in_def || self.in_single > 0) then
589
- debug20 8
603
+ debug 15
590
604
  yyerror "dynamic constant assignment"
591
605
  end
592
606
 
593
- _, id = val
594
- l = lexer.lineno
607
+ _, (id, l) = val
595
608
 
596
609
  result = s(:const, nil, s(:colon3, id.to_sym).line(l)).line l
597
610
  }
598
611
  | backref
599
612
  {
600
- self.backref_assign_error val[0]
613
+ ref, = val
614
+
615
+ self.backref_assign_error ref
601
616
  }
602
617
 
603
618
  lhs: user_variable
604
619
  {
605
- line = lexer.lineno
606
- result = self.assignable val[0]
607
- result.line = line
620
+ var, = val
621
+
622
+ result = self.assignable var
608
623
  }
609
624
  | keyword_variable
610
625
  {
611
- line = lexer.lineno
612
- result = self.assignable val[0]
613
- result.line = line
614
- debug20 9, val, result
626
+ var, = val
627
+
628
+ result = self.assignable var
629
+
630
+ debug 16
615
631
  }
616
632
  | primary_value tLBRACK2 opt_call_args rbracket
617
633
  {
618
634
  lhs, _, args, _ = val
635
+
619
636
  result = self.aryset lhs, args
620
637
  }
621
638
  | primary_value call_op tIDENTIFIER # REFACTOR
622
639
  {
623
- lhs, op, id = val
640
+ lhs, op, (id, _line) = val
641
+
624
642
  result = new_attrasgn lhs, id, op
625
643
  }
626
644
  | primary_value tCOLON2 tIDENTIFIER
627
645
  {
628
- lhs, _, id = val
646
+ lhs, _, (id, _line) = val
647
+
629
648
  result = new_attrasgn lhs, id
630
649
  }
631
650
  | primary_value call_op tCONSTANT # REFACTOR?
632
651
  {
633
- result = new_attrasgn val[0], val[2], val[1]
652
+ lhs, call_op, (id, _line) = val
653
+
654
+ result = new_attrasgn lhs, id, call_op
634
655
  }
635
656
  | primary_value tCOLON2 tCONSTANT
636
657
  {
637
- expr, _, id = val
658
+ expr, _, (id, _line) = val
638
659
 
639
660
  if (self.in_def || self.in_single > 0) then
640
- debug20 10
661
+ debug 17
641
662
  yyerror "dynamic constant assignment"
642
663
  end
643
664
 
@@ -646,14 +667,13 @@ rule
646
667
  }
647
668
  | tCOLON3 tCONSTANT
648
669
  {
649
- _, id = val
670
+ _, (id, l) = val
650
671
 
651
672
  if (self.in_def || self.in_single > 0) then
652
- debug20 11
673
+ debug 18
653
674
  yyerror "dynamic constant assignment"
654
675
  end
655
676
 
656
- l = lexer.lineno
657
677
  result = s(:const, s(:colon3, id.to_sym).line(l)).line l
658
678
  }
659
679
  | backref
@@ -669,16 +689,17 @@ rule
669
689
 
670
690
  cpath: tCOLON3 cname
671
691
  {
672
- _, name = val
673
- result = s(:colon3, name.to_sym).line lexer.lineno
692
+ _, (name, line) = val
693
+ result = s(:colon3, name.to_sym).line line
674
694
  }
675
695
  | cname
676
696
  {
677
- result = val[0].to_sym
697
+ (id, line), = val
698
+ result = [id.to_sym, line] # TODO: sexp?
678
699
  }
679
700
  | primary_value tCOLON2 cname
680
701
  {
681
- pval, _, name = val
702
+ pval, _, (name, _line) = val
682
703
 
683
704
  result = s(:colon2, pval, name.to_sym)
684
705
  result.line pval.line
@@ -688,24 +709,17 @@ rule
688
709
  | op
689
710
  {
690
711
  lexer.lex_state = EXPR_END
691
- result = val[0]
692
712
  }
693
713
 
694
714
  | reswords
695
- {
696
- (sym, _line), = val
697
- lexer.lex_state = EXPR_END
698
- result = sym
699
- }
700
-
701
- fsym: fname | symbol
702
715
 
703
- fitem: fsym
716
+ fitem: fname
704
717
  {
705
- id, = val
706
- result = s(:lit, id.to_sym).line lexer.lineno
718
+ (id, line), = val
719
+
720
+ result = s(:lit, id.to_sym).line line
707
721
  }
708
- | dsym
722
+ | symbol
709
723
 
710
724
  undef_list: fitem
711
725
  {
@@ -726,8 +740,6 @@ rule
726
740
  | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
727
741
  | tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
728
742
  | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
729
- # TODO: tUBANG dead?
730
- | tUBANG
731
743
 
732
744
  reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
733
745
  | kALIAS | kAND | kBEGIN | kBREAK | kCASE
@@ -761,24 +773,20 @@ rule
761
773
  }
762
774
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
763
775
  {
764
- lhs, _, id, op, rhs = val
776
+ lhs, _, (id, _line), (op, _), rhs = val
765
777
 
766
778
  result = s(:op_asgn, lhs, rhs, id.to_sym, op.to_sym).line lhs.line
767
779
  }
768
780
  | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
769
781
  {
770
- lhs1, _, lhs2, op, rhs = val
782
+ lhs1, _, (lhs2, _line), op, rhs = val
771
783
 
772
784
  lhs = s(:colon2, lhs1, lhs2.to_sym).line lhs1.line
773
785
  result = new_const_op_asgn [lhs, op, rhs]
774
786
  }
775
- | tCOLON3 tCONSTANT
787
+ | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
776
788
  {
777
- result = self.lexer.lineno
778
- }
779
- tOP_ASGN arg_rhs
780
- {
781
- _, lhs, line, op, rhs = val
789
+ _, (lhs, line), op, rhs = val
782
790
 
783
791
  lhs = s(:colon3, lhs.to_sym).line line
784
792
  result = new_const_op_asgn [lhs, op, rhs]
@@ -792,7 +800,7 @@ rule
792
800
  | arg tDOT2 arg
793
801
  {
794
802
  v1, v2 = val[0], val[2]
795
- if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
803
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
796
804
  result = s(:lit, (v1.last)..(v2.last)).line v1.line
797
805
  else
798
806
  result = s(:dot2, v1, v2).line v1.line
@@ -801,7 +809,7 @@ rule
801
809
  | arg tDOT3 arg
802
810
  {
803
811
  v1, v2 = val[0], val[2]
804
- if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
812
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
805
813
  result = s(:lit, (v1.last)...(v2.last)).line v1.line
806
814
  else
807
815
  result = s(:dot3, v1, v2).line v1.line
@@ -835,8 +843,9 @@ rule
835
843
  }
836
844
  | tUMINUS_NUM simple_numeric tPOW arg
837
845
  {
838
- lit = s(:lit, val[1]).line lexer.lineno
839
- result = new_call(new_call(lit, :"**", argl(val[3])), :"-@")
846
+ _, (num, line), _, arg = val
847
+ lit = s(:lit, num).line line
848
+ result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
840
849
 
841
850
  }
842
851
  | tUPLUS arg
@@ -935,12 +944,12 @@ rule
935
944
 
936
945
  rel_expr: arg relop arg =tGT
937
946
  {
938
- lhs, op, rhs = val
947
+ lhs, (op, _), rhs = val
939
948
  result = new_call lhs, op.to_sym, argl(rhs)
940
949
  }
941
950
  | rel_expr relop arg =tGT
942
951
  {
943
- lhs, op, rhs = val
952
+ lhs, (op, _), rhs = val
944
953
  warn "comparison '%s' after comparison", op
945
954
  result = new_call lhs, op.to_sym, argl(rhs)
946
955
  }
@@ -1131,8 +1140,9 @@ rule
1131
1140
  | backref
1132
1141
  | tFID
1133
1142
  {
1134
- msg, = val
1143
+ (msg, line), = val
1135
1144
  result = new_call nil, msg.to_sym
1145
+ result.line line
1136
1146
  }
1137
1147
  | k_begin
1138
1148
  {
@@ -1174,15 +1184,15 @@ rule
1174
1184
  }
1175
1185
  | primary_value tCOLON2 tCONSTANT
1176
1186
  {
1177
- expr, _, id = val
1187
+ expr, _, (id, _line) = val
1178
1188
 
1179
1189
  result = s(:colon2, expr, id.to_sym).line expr.line
1180
1190
  }
1181
1191
  | tCOLON3 tCONSTANT
1182
1192
  {
1183
- _, id = val
1193
+ _, (id, line) = val
1184
1194
 
1185
- result = s(:colon3, id.to_sym).line lexer.lineno
1195
+ result = s(:colon3, id.to_sym).line line
1186
1196
  }
1187
1197
  | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1188
1198
  {
@@ -1206,15 +1216,21 @@ rule
1206
1216
  }
1207
1217
  | kYIELD tLPAREN2 call_args rparen
1208
1218
  {
1209
- result = new_yield val[2]
1219
+ (_, line), _, args, _ = val
1220
+
1221
+ result = new_yield(args).line line
1210
1222
  }
1211
1223
  | kYIELD tLPAREN2 rparen
1212
1224
  {
1213
- result = new_yield
1225
+ (_, line), _, _ = val
1226
+
1227
+ result = new_yield.line line
1214
1228
  }
1215
1229
  | kYIELD
1216
1230
  {
1217
- result = new_yield
1231
+ (_, line), = val
1232
+
1233
+ result = new_yield.line line
1218
1234
  }
1219
1235
  | kDEFINED opt_nl tLPAREN2 expr rparen
1220
1236
  {
@@ -1229,7 +1245,7 @@ rule
1229
1245
  }
1230
1246
  | kNOT tLPAREN2 rparen
1231
1247
  {
1232
- debug20 14, val, result
1248
+ debug 20
1233
1249
  }
1234
1250
  | fcall brace_block
1235
1251
  {
@@ -1247,9 +1263,10 @@ rule
1247
1263
  iter.insert 1, call # FIX
1248
1264
  result = iter
1249
1265
  }
1250
- | tLAMBDA lambda
1266
+ | lambda
1251
1267
  {
1252
- result = val[1] # TODO: fix lineno
1268
+ expr, = val
1269
+ result = expr
1253
1270
  }
1254
1271
  | k_if expr_value then compstmt if_tail k_end
1255
1272
  {
@@ -1292,7 +1309,6 @@ rule
1292
1309
  }
1293
1310
  cpath superclass
1294
1311
  {
1295
- self.comments.push self.lexer.comments
1296
1312
  if (self.in_def || self.in_single > 0) then
1297
1313
  yyerror "class definition in method body"
1298
1314
  end
@@ -1302,7 +1318,7 @@ rule
1302
1318
  {
1303
1319
  result = new_class val
1304
1320
  self.env.unextend
1305
- self.lexer.comments # we don't care about comments in the body
1321
+ self.lexer.ignore_body_comments
1306
1322
  }
1307
1323
  | k_class tLSHFT
1308
1324
  {
@@ -1323,7 +1339,7 @@ rule
1323
1339
  {
1324
1340
  result = new_sclass val
1325
1341
  self.env.unextend
1326
- self.lexer.comments # we don't care about comments in the body
1342
+ self.lexer.ignore_body_comments
1327
1343
  }
1328
1344
  | k_module
1329
1345
  {
@@ -1331,7 +1347,6 @@ rule
1331
1347
  }
1332
1348
  cpath
1333
1349
  {
1334
- self.comments.push self.lexer.comments
1335
1350
  yyerror "module definition in method body" if
1336
1351
  self.in_def or self.in_single > 0
1337
1352
 
@@ -1341,7 +1356,7 @@ rule
1341
1356
  {
1342
1357
  result = new_module val
1343
1358
  self.env.unextend
1344
- self.lexer.comments # we don't care about comments in the body
1359
+ self.lexer.ignore_body_comments
1345
1360
  }
1346
1361
  | k_def fname
1347
1362
  {
@@ -1351,21 +1366,17 @@ rule
1351
1366
  self.env.extend
1352
1367
  lexer.cmdarg.push false
1353
1368
  lexer.cond.push false
1354
-
1355
- self.comments.push self.lexer.comments
1356
1369
  }
1357
- f_arglist bodystmt { result = lexer.lineno } k_end
1370
+ f_arglist bodystmt k_end
1358
1371
  {
1359
- in_def = val[2]
1360
-
1361
- result = new_defn val
1372
+ result, in_def = new_defn val
1362
1373
 
1363
1374
  lexer.cond.pop # group = local_pop
1364
1375
  lexer.cmdarg.pop
1365
1376
  self.env.unextend
1366
1377
  self.in_def = in_def
1367
1378
 
1368
- self.lexer.comments # we don't care about comments in the body
1379
+ self.lexer.ignore_body_comments
1369
1380
  }
1370
1381
  | k_def singleton dot_or_colon
1371
1382
  {
@@ -1373,7 +1384,7 @@ rule
1373
1384
  }
1374
1385
  fname
1375
1386
  {
1376
- result = [self.in_def, lexer.lineno]
1387
+ result = self.in_def
1377
1388
 
1378
1389
  self.in_single += 1 # TODO: remove?
1379
1390
 
@@ -1383,13 +1394,18 @@ rule
1383
1394
  lexer.cond.push false
1384
1395
 
1385
1396
  lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
1386
- self.comments.push self.lexer.comments
1387
1397
  }
1388
1398
  f_arglist bodystmt k_end
1389
1399
  {
1390
- _, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
1391
1400
 
1392
- result = new_defs val
1401
+ # [kdef, recv, _, _, (name, line), in_def, args, body, kend]
1402
+ # =>
1403
+ # [kdef, recv, (name, line), in_def, args, body, kend]
1404
+
1405
+ val.delete_at 3
1406
+ val.delete_at 2
1407
+
1408
+ result, in_def = new_defs val
1393
1409
 
1394
1410
  lexer.cond.pop # group = local_pop
1395
1411
  lexer.cmdarg.pop
@@ -1400,7 +1416,7 @@ rule
1400
1416
 
1401
1417
  # TODO: restore cur_arg ? what's cur_arg?
1402
1418
 
1403
- self.lexer.comments # we don't care about comments in the body
1419
+ self.lexer.ignore_body_comments
1404
1420
  }
1405
1421
  | kBREAK
1406
1422
  {
@@ -1437,8 +1453,17 @@ rule
1437
1453
  k_case: kCASE
1438
1454
  k_for: kFOR
1439
1455
  k_class: kCLASS
1456
+ {
1457
+ self.comments.push self.lexer.comments
1458
+ }
1440
1459
  k_module: kMODULE
1460
+ {
1461
+ self.comments.push self.lexer.comments
1462
+ }
1441
1463
  k_def: kDEF
1464
+ {
1465
+ self.comments.push self.lexer.comments
1466
+ }
1442
1467
  k_do: kDO
1443
1468
  k_do_block: kDO_BLOCK
1444
1469
  k_rescue: kRESCUE
@@ -1499,51 +1524,42 @@ rule
1499
1524
 
1500
1525
  result = block_var args
1501
1526
  }
1502
- | f_marg_list tCOMMA tSTAR f_norm_arg
1527
+ | f_marg_list tCOMMA f_rest_marg
1503
1528
  {
1504
- args, _, _, splat = val
1529
+ args, _, rest = val
1505
1530
 
1506
- result = block_var args, "*#{splat}".to_sym
1531
+ result = block_var args, rest
1507
1532
  }
1508
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1533
+ | f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
1509
1534
  {
1510
- args, _, _, splat, _, args2 = val
1535
+ lhs, _, splat, _, rhs = val
1511
1536
 
1512
- result = block_var args, "*#{splat}".to_sym, args2
1537
+ result = block_var lhs, splat, rhs
1513
1538
  }
1514
- | f_marg_list tCOMMA tSTAR
1539
+ | f_rest_marg
1515
1540
  {
1516
- args, _, _ = val
1541
+ rest, = val
1517
1542
 
1518
- result = block_var args, :*
1543
+ result = block_var rest
1519
1544
  }
1520
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1545
+ | f_rest_marg tCOMMA f_marg_list
1521
1546
  {
1522
- args, _, _, _, args2 = val
1547
+ splat, _, rest = val
1523
1548
 
1524
- result = block_var args, :*, args2
1549
+ result = block_var splat, rest
1525
1550
  }
1526
- | tSTAR f_norm_arg
1527
- {
1528
- _, splat = val
1529
1551
 
1530
- result = block_var :"*#{splat}"
1531
- }
1532
- | tSTAR f_norm_arg tCOMMA f_marg_list
1552
+ f_rest_marg: tSTAR f_norm_arg
1533
1553
  {
1534
- _, splat, _, args = val
1554
+ _, (id, line) = val
1535
1555
 
1536
- result = block_var :"*#{splat}", args
1556
+ result = args ["*#{id}".to_sym]
1557
+ result.line line
1537
1558
  }
1538
1559
  | tSTAR
1539
1560
  {
1540
- result = block_var :*
1541
- }
1542
- | tSTAR tCOMMA f_marg_list
1543
- {
1544
- _, _, args = val
1545
-
1546
- result = block_var :*, args
1561
+ result = args [:*]
1562
+ result.line lexer.lineno # FIX: tSTAR -> line
1547
1563
  }
1548
1564
 
1549
1565
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -1560,8 +1576,8 @@ rule
1560
1576
  }
1561
1577
  | f_block_arg
1562
1578
  {
1563
- line = lexer.lineno
1564
- result = call_args val # TODO: push line down
1579
+ (id, line), = val
1580
+ result = call_args [id]
1565
1581
  result.line line
1566
1582
  }
1567
1583
 
@@ -1670,13 +1686,13 @@ opt_block_args_tail: tCOMMA block_args_tail
1670
1686
 
1671
1687
  bvar: tIDENTIFIER
1672
1688
  {
1673
- id, = val
1674
- line = lexer.lineno
1689
+ (id, line), = val
1675
1690
  result = s(:shadow, id.to_sym).line line
1676
1691
  }
1677
1692
  | f_bad_arg
1678
1693
 
1679
- lambda: {
1694
+ lambda: tLAMBDA
1695
+ {
1680
1696
  self.env.extend :dynamic
1681
1697
  result = [lexer.lineno, lexer.lpar_beg]
1682
1698
  lexer.paren_nest += 1
@@ -1688,14 +1704,14 @@ opt_block_args_tail: tCOMMA block_args_tail
1688
1704
  }
1689
1705
  lambda_body
1690
1706
  {
1691
- (line, lpar), args, _cmdarg, body = val
1707
+ _, (line, lpar), args, _cmdarg, body = val
1692
1708
  lexer.lpar_beg = lpar
1693
1709
 
1694
1710
  lexer.cmdarg.pop
1695
1711
 
1696
1712
  call = s(:lambda).line line
1697
1713
  result = new_iter call, args, body
1698
- result.line = line
1714
+ result.line line
1699
1715
  self.env.unextend # TODO: dynapush & dynapop
1700
1716
  }
1701
1717
 
@@ -1730,23 +1746,28 @@ opt_block_args_tail: tCOMMA block_args_tail
1730
1746
  ## if (nd_type($1) == NODE_YIELD) {
1731
1747
  ## compile_error(PARSER_ARG "block given to yield");
1732
1748
 
1733
- syntax_error "Both block arg and actual block given." if
1734
- val[0].block_pass?
1749
+ cmd, blk = val
1735
1750
 
1736
- val = invert_block_call val if inverted? val
1751
+ syntax_error "Both block arg and actual block given." if
1752
+ cmd.block_pass?
1737
1753
 
1738
- cmd, blk = val
1754
+ if inverted? val then
1755
+ val = invert_block_call val
1756
+ cmd, blk = val
1757
+ end
1739
1758
 
1740
1759
  result = blk
1741
1760
  result.insert 1, cmd
1742
1761
  }
1743
1762
  | block_call call_op2 operation2 opt_paren_args
1744
1763
  {
1745
- result = new_call val[0], val[2].to_sym, val[3]
1764
+ lhs, _, (id, _line), args = val
1765
+
1766
+ result = new_call lhs, id.to_sym, args
1746
1767
  }
1747
1768
  | block_call call_op2 operation2 opt_paren_args brace_block
1748
1769
  {
1749
- iter1, _, name, args, iter2 = val
1770
+ iter1, _, (name, _line), args, iter2 = val
1750
1771
 
1751
1772
  call = new_call iter1, name.to_sym, args
1752
1773
  iter2.insert 1, call
@@ -1755,7 +1776,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1755
1776
  }
1756
1777
  | block_call call_op2 operation2 command_args do_block
1757
1778
  {
1758
- iter1, _, name, args, iter2 = val
1779
+ iter1, _, (name, _line), args, iter2 = val
1759
1780
 
1760
1781
  call = new_call iter1, name.to_sym, args
1761
1782
  iter2.insert 1, call
@@ -1763,28 +1784,29 @@ opt_block_args_tail: tCOMMA block_args_tail
1763
1784
  result = iter2
1764
1785
  }
1765
1786
 
1766
- method_call: fcall
1787
+ method_call: fcall paren_args
1767
1788
  {
1768
- result = self.lexer.lineno
1769
- }
1770
- paren_args
1771
- {
1772
- call, lineno, args = val
1789
+ call, args = val
1773
1790
 
1774
1791
  result = call.concat args.sexp_body if args
1775
- result.line lineno
1776
1792
  }
1777
1793
  | primary_value call_op operation2 opt_paren_args
1778
1794
  {
1779
- result = new_call val[0], val[2].to_sym, val[3], val[1]
1795
+ recv, call_op, (op, _line), args = val
1796
+
1797
+ result = new_call recv, op.to_sym, args, call_op
1780
1798
  }
1781
1799
  | primary_value tCOLON2 operation2 paren_args
1782
1800
  {
1783
- result = new_call val[0], val[2].to_sym, val[3]
1801
+ recv, _, (op, _line), args = val
1802
+
1803
+ result = new_call recv, op.to_sym, args
1784
1804
  }
1785
1805
  | primary_value tCOLON2 operation3
1786
1806
  {
1787
- result = new_call val[0], val[2].to_sym
1807
+ lhs, _, (id, _line) = val
1808
+
1809
+ result = new_call lhs, id.to_sym
1788
1810
  }
1789
1811
  | primary_value call_op paren_args
1790
1812
  {
@@ -1817,7 +1839,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1817
1839
  _, line, body, _ = val
1818
1840
 
1819
1841
  result = body
1820
- result.line = line
1842
+ result.line line
1821
1843
 
1822
1844
  self.env.unextend
1823
1845
  }
@@ -1831,7 +1853,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1831
1853
  _, line, body, _ = val
1832
1854
 
1833
1855
  result = body
1834
- result.line = line
1856
+ result.line line
1835
1857
 
1836
1858
  self.env.unextend
1837
1859
  }
@@ -1860,14 +1882,39 @@ opt_block_args_tail: tCOMMA block_args_tail
1860
1882
  self.env.unextend
1861
1883
  }
1862
1884
 
1885
+ case_args: arg_value
1886
+ {
1887
+ arg, = val
1888
+
1889
+ result = s(:array, arg).line arg.line
1890
+ }
1891
+ | tSTAR arg_value
1892
+ {
1893
+ _, arg = val
1894
+
1895
+ result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
1896
+ }
1897
+ | case_args tCOMMA arg_value
1898
+ {
1899
+ args, _, id = val
1900
+
1901
+ result = self.list_append args, id
1902
+ }
1903
+ | case_args tCOMMA tSTAR arg_value
1904
+ {
1905
+ args, _, _, id = val
1906
+
1907
+ result = self.list_append args, s(:splat, id).line(id.line)
1908
+ }
1909
+
1863
1910
  case_body: k_when
1864
1911
  {
1865
1912
  result = self.lexer.lineno
1866
1913
  }
1867
- args then compstmt cases
1914
+ case_args then compstmt cases
1868
1915
  {
1869
1916
  result = new_when(val[2], val[4])
1870
- result.line = val[1]
1917
+ result.line val[1]
1871
1918
  result << val[5] if val[5]
1872
1919
  }
1873
1920
 
@@ -1913,17 +1960,10 @@ opt_block_args_tail: tCOMMA block_args_tail
1913
1960
 
1914
1961
  literal: numeric
1915
1962
  {
1916
- line = lexer.lineno
1917
- result = s(:lit, val[0])
1918
- result.line = line
1963
+ (lit, line), = val
1964
+ result = s(:lit, lit).line line
1919
1965
  }
1920
1966
  | symbol
1921
- {
1922
- line = lexer.lineno
1923
- result = s(:lit, val[0])
1924
- result.line = line
1925
- }
1926
- | dsym
1927
1967
 
1928
1968
  strings: string
1929
1969
  {
@@ -1934,7 +1974,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1934
1974
 
1935
1975
  string: tCHAR
1936
1976
  {
1937
- debug20 23, val, result
1977
+ debug 37
1938
1978
  }
1939
1979
  | string1
1940
1980
  | string string1
@@ -1944,11 +1984,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1944
1984
 
1945
1985
  string1: tSTRING_BEG string_contents tSTRING_END
1946
1986
  {
1947
- _, str, (_, func) = val
1987
+ (_, line), str, (_, func) = val
1948
1988
 
1949
- str = dedent str if func =~ RubyLexer::STR_FUNC_ICNTNT
1989
+ str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
1950
1990
 
1951
- result = str
1991
+ result = str.line line
1952
1992
  }
1953
1993
  | tSTRING
1954
1994
  {
@@ -1968,11 +2008,15 @@ opt_block_args_tail: tCOMMA block_args_tail
1968
2008
 
1969
2009
  words: tWORDS_BEG tSPACE tSTRING_END
1970
2010
  {
1971
- result = s(:array).line lexer.lineno
2011
+ (_, line), _, _ = val
2012
+
2013
+ result = s(:array).line line
1972
2014
  }
1973
2015
  | tWORDS_BEG word_list tSTRING_END
1974
2016
  {
1975
- result = val[1]
2017
+ (_, line), list, _ = val
2018
+
2019
+ result = list.line line
1976
2020
  }
1977
2021
 
1978
2022
  word_list: none
@@ -1992,18 +2036,20 @@ opt_block_args_tail: tCOMMA block_args_tail
1992
2036
 
1993
2037
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
1994
2038
  {
1995
- result = s(:array).line lexer.lineno
2039
+ (_, line), _, _ = val
2040
+
2041
+ result = s(:array).line line
1996
2042
  }
1997
- | tSYMBOLS_BEG { result = lexer.lineno } symbol_list tSTRING_END
2043
+ | tSYMBOLS_BEG symbol_list tSTRING_END
1998
2044
  {
1999
- _, line, list, _, = val
2000
- list.line = line
2045
+ (_, line), list, _, = val
2046
+ list.line line
2001
2047
  result = list
2002
2048
  }
2003
2049
 
2004
2050
  symbol_list: none
2005
2051
  {
2006
- result = new_symbol_list.line lexer.lineno
2052
+ result = new_symbol_list
2007
2053
  }
2008
2054
  | symbol_list word tSPACE
2009
2055
  {
@@ -2013,20 +2059,28 @@ opt_block_args_tail: tCOMMA block_args_tail
2013
2059
 
2014
2060
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2015
2061
  {
2016
- result = s(:array).line lexer.lineno
2062
+ (_, line), _, _ = val
2063
+
2064
+ result = s(:array).line line
2017
2065
  }
2018
2066
  | tQWORDS_BEG qword_list tSTRING_END
2019
2067
  {
2020
- result = val[1]
2068
+ (_, line), list, _ = val
2069
+
2070
+ result = list.line line
2021
2071
  }
2022
2072
 
2023
2073
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2024
2074
  {
2025
- result = s(:array).line lexer.lineno # FIX
2075
+ (_, line), _, _ = val
2076
+
2077
+ result = s(:array).line line
2026
2078
  }
2027
2079
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2028
2080
  {
2029
- result = val[1]
2081
+ (_, line), list, _ = val
2082
+
2083
+ result = list.line line
2030
2084
  }
2031
2085
 
2032
2086
  qword_list: none
@@ -2049,7 +2103,8 @@ opt_block_args_tail: tCOMMA block_args_tail
2049
2103
 
2050
2104
  string_contents: none
2051
2105
  {
2052
- result = s(:str, "").line lexer.lineno
2106
+ line = prev_value_to_lineno _values.last
2107
+ result = s(:str, +"").line line
2053
2108
  }
2054
2109
  | string_contents string_content
2055
2110
  {
@@ -2124,8 +2179,8 @@ regexp_contents: none
2124
2179
  lexer.brace_nest = brace_nest
2125
2180
  lexer.string_nest = string_nest
2126
2181
 
2127
- lexer.cmdarg.pop
2128
2182
  lexer.cond.pop
2183
+ lexer.cmdarg.pop
2129
2184
 
2130
2185
  lexer.lex_state = oldlex_state
2131
2186
 
@@ -2140,29 +2195,49 @@ regexp_contents: none
2140
2195
  when nil then
2141
2196
  result = s(:evstr).line line
2142
2197
  else
2143
- debug20 25
2198
+ debug 38
2144
2199
  raise "unknown string body: #{stmt.inspect}"
2145
2200
  end
2146
2201
  }
2147
2202
 
2148
- string_dvar: tGVAR { result = s(:gvar, val[0].to_sym).line lexer.lineno }
2149
- | tIVAR { result = s(:ivar, val[0].to_sym).line lexer.lineno }
2150
- | tCVAR { result = s(:cvar, val[0].to_sym).line lexer.lineno }
2203
+ string_dvar: tGVAR
2204
+ {
2205
+ (id, line), = val
2206
+ result = s(:gvar, id.to_sym).line line
2207
+ }
2208
+ | tIVAR
2209
+ {
2210
+ (id, line), = val
2211
+ result = s(:ivar, id.to_sym).line line
2212
+ }
2213
+ | tCVAR
2214
+ {
2215
+ (id, line), = val
2216
+ result = s(:cvar, id.to_sym).line line
2217
+ }
2151
2218
  | backref
2152
2219
 
2153
- symbol: tSYMBEG sym
2220
+ symbol: ssym
2221
+ | dsym
2222
+
2223
+ ssym: tSYMBEG sym
2154
2224
  {
2225
+ _, (id, line) = val
2226
+
2155
2227
  lexer.lex_state = EXPR_END
2156
- result = val[1].to_sym
2228
+ result = s(:lit, id.to_sym).line line
2157
2229
  }
2158
2230
  | tSYMBOL
2159
2231
  {
2160
- result = val[0].to_sym
2232
+ (id, line), = val
2233
+
2234
+ lexer.lex_state = EXPR_END
2235
+ result = s(:lit, id.to_sym).line line
2161
2236
  }
2162
2237
 
2163
2238
  sym: fname | tIVAR | tGVAR | tCVAR
2164
2239
 
2165
- dsym: tSYMBEG xstring_contents tSTRING_END
2240
+ dsym: tSYMBEG string_contents tSTRING_END
2166
2241
  {
2167
2242
  _, result, _ = val
2168
2243
 
@@ -2178,14 +2253,15 @@ regexp_contents: none
2178
2253
  when :evstr then
2179
2254
  result = s(:dsym, "", result).line result.line
2180
2255
  else
2181
- debug20 26, val, result
2256
+ debug 39
2182
2257
  end
2183
2258
  }
2184
2259
 
2185
2260
  numeric: simple_numeric
2186
- | tUMINUS_NUM simple_numeric
2261
+ | tUMINUS_NUM simple_numeric =tLOWEST
2187
2262
  {
2188
- result = -val[1] # TODO: pt_testcase
2263
+ _, (num, line) = val
2264
+ result = [-num, line]
2189
2265
  }
2190
2266
 
2191
2267
  simple_numeric: tINTEGER
@@ -2218,8 +2294,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2218
2294
 
2219
2295
  var_ref: user_variable
2220
2296
  {
2221
- var = val[0]
2297
+ raise "NO: #{val.inspect}" if Sexp === val.first
2298
+ (var, line), = val
2222
2299
  result = Sexp === var ? var : self.gettable(var)
2300
+ result.line line
2223
2301
  }
2224
2302
  | keyword_variable
2225
2303
  {
@@ -2234,11 +2312,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2234
2312
  | keyword_variable
2235
2313
  {
2236
2314
  result = self.assignable val[0]
2237
- debug20 29, val, result
2315
+ debug 40
2238
2316
  }
2239
2317
 
2240
- backref: tNTH_REF { result = s(:nth_ref, val[0]).line lexer.lineno }
2241
- | tBACK_REF { result = s(:back_ref, val[0]).line lexer.lineno }
2318
+ backref: tNTH_REF
2319
+ {
2320
+ (ref, line), = val
2321
+ result = s(:nth_ref, ref).line line
2322
+ }
2323
+ | tBACK_REF
2324
+ {
2325
+ (ref, line), = val
2326
+ result = s(:back_ref, ref).line line
2327
+ }
2242
2328
 
2243
2329
  superclass: tLT
2244
2330
  {
@@ -2256,9 +2342,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2256
2342
 
2257
2343
  f_arglist: tLPAREN2 f_args rparen
2258
2344
  {
2259
- result = val[1]
2260
- self.lexer.lex_state = EXPR_BEG
2261
- self.lexer.command_start = true
2345
+ result = end_args val
2262
2346
  }
2263
2347
  | {
2264
2348
  result = self.in_kwarg
@@ -2267,12 +2351,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2267
2351
  }
2268
2352
  f_args term
2269
2353
  {
2270
- kwarg, args, _ = val
2271
-
2272
- self.in_kwarg = kwarg
2273
- result = args
2274
- lexer.lex_state = EXPR_BEG
2275
- lexer.command_start = true
2354
+ result = end_args val
2276
2355
  }
2277
2356
 
2278
2357
  args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -2357,9 +2436,9 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2357
2436
  |
2358
2437
  {
2359
2438
  result = args val
2439
+ # result.line lexer.lineno
2360
2440
  }
2361
2441
 
2362
- args_forward: tBDOT3
2363
2442
 
2364
2443
  f_bad_arg: tCONSTANT
2365
2444
  {
@@ -2381,10 +2460,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2381
2460
  f_norm_arg: f_bad_arg
2382
2461
  | tIDENTIFIER
2383
2462
  {
2384
- identifier = val[0].to_sym
2463
+ (id, line), = val
2464
+ identifier = id.to_sym
2385
2465
  self.env[identifier] = :lvar
2386
2466
 
2387
- result = identifier
2467
+ result = [identifier, line]
2388
2468
  }
2389
2469
 
2390
2470
  f_arg_asgn: f_norm_arg
@@ -2392,22 +2472,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2392
2472
  f_arg_item: f_arg_asgn
2393
2473
  | tLPAREN f_margs rparen
2394
2474
  {
2395
- result = val[1]
2475
+ _, margs, _ = val
2476
+
2477
+ result = margs
2396
2478
  }
2397
2479
 
2398
2480
  f_arg: f_arg_item
2399
2481
  {
2400
- arg, = val
2401
-
2402
- case arg
2403
- when Symbol then
2404
- result = s(:args, arg).line lexer.lineno
2405
- when Sexp then
2406
- result = arg
2407
- else
2408
- debug20 32
2409
- raise "Unknown f_arg type: #{val.inspect}"
2410
- end
2482
+ result = new_arg val
2411
2483
  }
2412
2484
  | f_arg tCOMMA f_arg_item
2413
2485
  {
@@ -2419,7 +2491,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2419
2491
  result = s(:args, list).line list.line
2420
2492
  end
2421
2493
 
2422
- result << item
2494
+ result << (Sexp === item ? item : item.first)
2423
2495
  }
2424
2496
 
2425
2497
  f_label: tLABEL
@@ -2480,27 +2552,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2480
2552
  kwrest_mark: tPOW
2481
2553
  | tDSTAR
2482
2554
 
2555
+
2483
2556
  f_kwrest: kwrest_mark tIDENTIFIER
2484
2557
  {
2485
- name = val[1].to_sym
2486
- self.assignable name
2487
- result = :"**#{name}"
2558
+ _, (id, line) = val
2559
+
2560
+ name = id.to_sym
2561
+ self.assignable [name, line]
2562
+ result = [:"**#{name}", line]
2488
2563
  }
2489
2564
  | kwrest_mark
2490
2565
  {
2491
- result = :"**"
2492
- self.env[result] = :lvar
2566
+ id = :"**"
2567
+ self.env[id] = :lvar # TODO: needed?!?
2568
+ result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
2493
2569
  }
2494
2570
 
2495
2571
  f_opt: f_arg_asgn tEQL arg_value
2496
2572
  {
2497
- result = self.assignable val[0], val[2]
2573
+ lhs, _, rhs = val
2574
+ result = self.assignable lhs, rhs
2498
2575
  # TODO: detect duplicate names
2499
2576
  }
2500
2577
 
2501
2578
  f_block_opt: f_arg_asgn tEQL primary_value
2502
2579
  {
2503
- result = self.assignable val[0], val[2]
2580
+ lhs, _, rhs = val
2581
+ result = self.assignable lhs, rhs
2504
2582
  }
2505
2583
 
2506
2584
  f_block_optarg: f_block_opt
@@ -2530,30 +2608,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2530
2608
  f_rest_arg: restarg_mark tIDENTIFIER
2531
2609
  {
2532
2610
  # TODO: differs from parse.y - needs tests
2533
- name = val[1].to_sym
2534
- self.assignable name
2535
- result = :"*#{name}"
2611
+ _, (id, line) = val
2612
+ name = id.to_sym
2613
+ self.assignable [name, line]
2614
+ result = [:"*#{name}", line]
2536
2615
  }
2537
2616
  | restarg_mark
2538
2617
  {
2539
2618
  name = :"*"
2540
2619
  self.env[name] = :lvar
2541
- result = name
2620
+ result = [name, lexer.lineno] # FIX: tSTAR to include lineno
2542
2621
  }
2543
2622
 
2544
2623
  blkarg_mark: tAMPER2 | tAMPER
2545
2624
 
2546
2625
  f_block_arg: blkarg_mark tIDENTIFIER
2547
2626
  {
2548
- identifier = val[1].to_sym
2627
+ _, (id, line) = val
2628
+ identifier = id.to_sym
2549
2629
 
2550
2630
  self.env[identifier] = :lvar
2551
- result = "&#{identifier}".to_sym
2631
+ result = ["&#{identifier}".to_sym, line]
2552
2632
  }
2553
2633
 
2554
2634
  opt_f_block_arg: tCOMMA f_block_arg
2555
2635
  {
2556
- result = val[1]
2636
+ _, arg = val
2637
+ result = arg
2557
2638
  }
2558
2639
  |
2559
2640
  {
@@ -2602,9 +2683,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2602
2683
  }
2603
2684
  | tSTRING_BEG string_contents tLABEL_END arg_value
2604
2685
  {
2605
- _, sym, _, value = val
2686
+ (_, line), sym, _, value = val
2687
+
2606
2688
  sym.sexp_type = :dsym
2607
- result = s(:array, sym, value).line sym.line
2689
+
2690
+ result = s(:array, sym, value).line line
2608
2691
  }
2609
2692
  | tDSTAR arg_value
2610
2693
  {