brakeman 5.1.1 → 5.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +9 -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.0}/History.rdoc +76 -0
  50. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/Manifest.txt +3 -0
  51. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/README.rdoc +1 -0
  52. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/compare/normalize.rb +6 -1
  53. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/debugging.md +0 -0
  54. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/gauntlet.md +106 -0
  55. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/rp_extensions.rb +15 -36
  56. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/rp_stringscanner.rb +33 -0
  57. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby20_parser.rb +7122 -0
  58. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby20_parser.y +326 -249
  59. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby21_parser.rb +7176 -0
  60. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby21_parser.y +321 -246
  61. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby22_parser.rb +7222 -0
  62. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby22_parser.y +325 -248
  63. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby23_parser.rb +7231 -0
  64. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby24_parser.y → ruby_parser-3.18.0/lib/ruby23_parser.y} +326 -257
  65. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby24_parser.rb +7262 -0
  66. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby30_parser.y → ruby_parser-3.18.0/lib/ruby24_parser.y} +327 -302
  67. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby25_parser.rb +7262 -0
  68. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby26_parser.y → ruby_parser-3.18.0/lib/ruby25_parser.y} +326 -264
  69. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby26_parser.rb +7281 -0
  70. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby27_parser.y → ruby_parser-3.18.0/lib/ruby26_parser.y} +325 -285
  71. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby27_parser.rb +8511 -0
  72. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby_parser.yy → ruby_parser-3.18.0/lib/ruby27_parser.y} +897 -377
  73. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby30_parser.rb +8741 -0
  74. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby30_parser.y +3463 -0
  75. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby3_parser.yy +3467 -0
  76. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rb +261 -609
  77. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rex +27 -20
  78. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rex.rb +59 -23
  79. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby_lexer_strings.rb +638 -0
  80. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_parser.rb +0 -0
  81. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby_parser.yy +3481 -0
  82. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_parser_extras.rb +296 -115
  83. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/tools/munge.rb +34 -6
  84. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/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/check_json_parsing.rb +1 -1
  106. data/lib/brakeman/processors/alias_processor.rb +7 -1
  107. data/lib/brakeman/processors/haml_template_processor.rb +9 -0
  108. data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -0
  109. data/lib/brakeman/processors/model_processor.rb +1 -0
  110. data/lib/brakeman/report/ignore/config.rb +1 -1
  111. data/lib/brakeman/report/report_csv.rb +1 -1
  112. data/lib/brakeman/report/report_sarif.rb +1 -1
  113. data/lib/brakeman/report/report_text.rb +1 -1
  114. data/lib/brakeman/scanner.rb +12 -12
  115. data/lib/brakeman/version.rb +1 -1
  116. data/lib/brakeman.rb +2 -2
  117. data/lib/ruby_parser/bm_sexp.rb +11 -1
  118. metadata +101 -98
  119. data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/processor_count.rb +0 -42
  120. data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/version.rb +0 -3
  121. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
  122. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
  123. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
  124. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
  125. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
  126. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
  127. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
  128. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
  129. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
  130. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
  131. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
  132. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
  133. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
  134. 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 Ruby27Parser
3
+ class Ruby26Parser
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,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
@@ -80,7 +80,7 @@ rule
80
80
  | klBEGIN
81
81
  {
82
82
  if (self.in_def || self.in_single > 0) then
83
- debug20 1
83
+ debug 11
84
84
  yyerror "BEGIN in method"
85
85
  end
86
86
  self.env.extend
@@ -105,6 +105,8 @@ rule
105
105
  bodystmt: compstmt opt_rescue k_else
106
106
  {
107
107
  res = _values[-2]
108
+ # TODO: move down to main match so I can just use val
109
+
108
110
  yyerror "else without rescue is useless" unless res
109
111
  }
110
112
  compstmt
@@ -135,7 +137,7 @@ rule
135
137
  | error stmt
136
138
  {
137
139
  result = val[1]
138
- debug20 2, val, result
140
+ debug 12
139
141
  }
140
142
 
141
143
  stmt_or_begin: stmt
@@ -143,6 +145,10 @@ rule
143
145
  {
144
146
  yyerror "BEGIN is permitted only at toplevel"
145
147
  }
148
+ begin_block
149
+ {
150
+ result = val[2] # wtf?
151
+ }
146
152
 
147
153
  stmt: kALIAS fitem
148
154
  {
@@ -155,12 +161,12 @@ rule
155
161
  }
156
162
  | kALIAS tGVAR tGVAR
157
163
  {
158
- (_, line), lhs, rhs = val
164
+ (_, line), (lhs, _), (rhs, _) = val
159
165
  result = s(:valias, lhs.to_sym, rhs.to_sym).line line
160
166
  }
161
167
  | kALIAS tGVAR tBACK_REF
162
168
  {
163
- (_, line), lhs, rhs = val
169
+ (_, line), (lhs, _), (rhs, _) = val
164
170
  result = s(:valias, lhs.to_sym, :"$#{rhs}").line line
165
171
  }
166
172
  | kALIAS tGVAR tNTH_REF
@@ -203,7 +209,7 @@ rule
203
209
  (_, line), _, stmt, _ = val
204
210
 
205
211
  if (self.in_def || self.in_single > 0) then
206
- debug20 3
212
+ debug 13
207
213
  yyerror "END in method; use at_exit"
208
214
  end
209
215
 
@@ -243,32 +249,31 @@ rule
243
249
  }
244
250
  | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
245
251
  {
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
252
+ prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
253
+
254
+ result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
255
+ result.sexp_type = :safe_op_asgn if call_op == '&.'
256
+ result.line prim.line
252
257
  }
253
258
  | primary_value call_op tCONSTANT tOP_ASGN command_rhs
254
259
  {
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
260
+ prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
261
+
262
+ result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
263
+ result.sexp_type = :safe_op_asgn if call_op == '&.'
264
+ result.line prim.line
260
265
  }
261
266
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
262
267
  {
263
- lhs1, _, lhs2, op, rhs = val
268
+ lhs1, _, (lhs2, line), (id, _), rhs = val
264
269
 
265
- result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, op.to_sym)
270
+ result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
266
271
  }
267
272
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
268
273
  {
269
- lhs1, _, lhs2, op, rhs = val
274
+ lhs1, _, (lhs2, line), (id, _), rhs = val
270
275
 
271
- result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, op.to_sym)
276
+ result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
272
277
  }
273
278
  | backref tOP_ASGN command_rhs
274
279
  {
@@ -314,7 +319,7 @@ rule
314
319
  # TODO: fix line number to tBANG... but causes BAD shift/reduce conflict
315
320
  # REFACTOR: call_uni_op -- see parse26.y
316
321
  }
317
- | arg
322
+ | arg =tLBRACE_ARG
318
323
 
319
324
  expr_value: expr
320
325
  {
@@ -339,7 +344,7 @@ rule
339
344
  block_command: block_call
340
345
  | block_call call_op2 operation2 command_args
341
346
  {
342
- blk, _, msg, args = val
347
+ blk, _, (msg, _line), args = val
343
348
  result = new_call(blk, msg.to_sym, args).line blk.line
344
349
  }
345
350
 
@@ -353,15 +358,15 @@ rule
353
358
  _, line, body, _ = val
354
359
 
355
360
  result = body
356
- result.line = line
361
+ result.line line
357
362
 
358
363
  # self.env.unextend
359
364
  }
360
365
 
361
366
  fcall: operation
362
367
  {
363
- msg, = val
364
- result = new_call(nil, msg.to_sym).line lexer.lineno
368
+ (msg, line), = val
369
+ result = new_call(nil, msg.to_sym).line line
365
370
  }
366
371
 
367
372
  command: fcall command_args =tLOWEST
@@ -384,12 +389,14 @@ rule
384
389
  }
385
390
  | primary_value call_op operation2 command_args =tLOWEST
386
391
  {
387
- lhs, callop, op, args = val
392
+ lhs, callop, (op, _), args = val
393
+
388
394
  result = new_call lhs, op.to_sym, args, callop
395
+ result.line lhs.line
389
396
  }
390
397
  | primary_value call_op operation2 command_args cmd_brace_block
391
398
  {
392
- recv, _, msg, args, block = val
399
+ recv, _, (msg, _line), args, block = val
393
400
  call = new_call recv, msg.to_sym, args, val[1]
394
401
 
395
402
  block_dup_check call, block
@@ -399,11 +406,14 @@ rule
399
406
  }
400
407
  | primary_value tCOLON2 operation2 command_args =tLOWEST
401
408
  {
402
- result = new_call val[0], val[2].to_sym, val[3]
409
+ lhs, _, (id, line), args = val
410
+
411
+ result = new_call lhs, id.to_sym, args
412
+ result.line line
403
413
  }
404
414
  | primary_value tCOLON2 operation2 command_args cmd_brace_block
405
415
  {
406
- recv, _, msg, args, block = val
416
+ recv, _, (msg, _line), args, block = val
407
417
  call = new_call recv, msg.to_sym, args
408
418
 
409
419
  block_dup_check call, block
@@ -561,25 +571,29 @@ rule
561
571
  }
562
572
  | primary_value call_op tIDENTIFIER
563
573
  {
564
- result = new_attrasgn val[0], val[2], val[1]
574
+ lhs, call_op, (id, _line) = val
575
+
576
+ result = new_attrasgn lhs, id, call_op
565
577
  }
566
578
  | primary_value tCOLON2 tIDENTIFIER
567
579
  {
568
- recv, _, id = val
580
+ recv, _, (id, _line) = val
569
581
  result = new_attrasgn recv, id
570
582
  }
571
583
  | primary_value call_op tCONSTANT
572
584
  {
573
- result = new_attrasgn val[0], val[2], val[1]
585
+ lhs, call_op, (id, _line) = val
586
+
587
+ result = new_attrasgn lhs, id, call_op
574
588
  }
575
589
  | primary_value tCOLON2 tCONSTANT
576
590
  {
577
591
  if (self.in_def || self.in_single > 0) then
578
- debug20 7
592
+ debug 14
579
593
  yyerror "dynamic constant assignment"
580
594
  end
581
595
 
582
- expr, _, id = val
596
+ expr, _, (id, _line) = val
583
597
  l = expr.line
584
598
 
585
599
  result = s(:const, s(:colon2, expr, id.to_sym).line(l), nil).line l
@@ -587,58 +601,65 @@ rule
587
601
  | tCOLON3 tCONSTANT
588
602
  {
589
603
  if (self.in_def || self.in_single > 0) then
590
- debug20 8
604
+ debug 15
591
605
  yyerror "dynamic constant assignment"
592
606
  end
593
607
 
594
- _, id = val
595
- l = lexer.lineno
608
+ _, (id, l) = val
596
609
 
597
610
  result = s(:const, nil, s(:colon3, id.to_sym).line(l)).line l
598
611
  }
599
612
  | backref
600
613
  {
601
- self.backref_assign_error val[0]
614
+ ref, = val
615
+
616
+ self.backref_assign_error ref
602
617
  }
603
618
 
604
619
  lhs: user_variable
605
620
  {
606
- line = lexer.lineno
607
- result = self.assignable val[0]
608
- result.line = line
621
+ var, = val
622
+
623
+ result = self.assignable var
609
624
  }
610
625
  | keyword_variable
611
626
  {
612
- line = lexer.lineno
613
- result = self.assignable val[0]
614
- result.line = line
615
- debug20 9, val, result
627
+ var, = val
628
+
629
+ result = self.assignable var
630
+
631
+ debug 16
616
632
  }
617
633
  | primary_value tLBRACK2 opt_call_args rbracket
618
634
  {
619
635
  lhs, _, args, _ = val
636
+
620
637
  result = self.aryset lhs, args
621
638
  }
622
639
  | primary_value call_op tIDENTIFIER # REFACTOR
623
640
  {
624
- lhs, op, id = val
641
+ lhs, op, (id, _line) = val
642
+
625
643
  result = new_attrasgn lhs, id, op
626
644
  }
627
645
  | primary_value tCOLON2 tIDENTIFIER
628
646
  {
629
- lhs, _, id = val
647
+ lhs, _, (id, _line) = val
648
+
630
649
  result = new_attrasgn lhs, id
631
650
  }
632
651
  | primary_value call_op tCONSTANT # REFACTOR?
633
652
  {
634
- result = new_attrasgn val[0], val[2], val[1]
653
+ lhs, call_op, (id, _line) = val
654
+
655
+ result = new_attrasgn lhs, id, call_op
635
656
  }
636
657
  | primary_value tCOLON2 tCONSTANT
637
658
  {
638
- expr, _, id = val
659
+ expr, _, (id, _line) = val
639
660
 
640
661
  if (self.in_def || self.in_single > 0) then
641
- debug20 10
662
+ debug 17
642
663
  yyerror "dynamic constant assignment"
643
664
  end
644
665
 
@@ -647,14 +668,13 @@ rule
647
668
  }
648
669
  | tCOLON3 tCONSTANT
649
670
  {
650
- _, id = val
671
+ _, (id, l) = val
651
672
 
652
673
  if (self.in_def || self.in_single > 0) then
653
- debug20 11
674
+ debug 18
654
675
  yyerror "dynamic constant assignment"
655
676
  end
656
677
 
657
- l = lexer.lineno
658
678
  result = s(:const, s(:colon3, id.to_sym).line(l)).line l
659
679
  }
660
680
  | backref
@@ -670,16 +690,17 @@ rule
670
690
 
671
691
  cpath: tCOLON3 cname
672
692
  {
673
- _, name = val
674
- result = s(:colon3, name.to_sym).line lexer.lineno
693
+ _, (name, line) = val
694
+ result = s(:colon3, name.to_sym).line line
675
695
  }
676
696
  | cname
677
697
  {
678
- result = val[0].to_sym
698
+ (id, line), = val
699
+ result = [id.to_sym, line] # TODO: sexp?
679
700
  }
680
701
  | primary_value tCOLON2 cname
681
702
  {
682
- pval, _, name = val
703
+ pval, _, (name, _line) = val
683
704
 
684
705
  result = s(:colon2, pval, name.to_sym)
685
706
  result.line pval.line
@@ -689,24 +710,17 @@ rule
689
710
  | op
690
711
  {
691
712
  lexer.lex_state = EXPR_END
692
- result = val[0]
693
713
  }
694
714
 
695
715
  | reswords
696
- {
697
- (sym, _line), = val
698
- lexer.lex_state = EXPR_END
699
- result = sym
700
- }
701
716
 
702
- fsym: fname | symbol
703
-
704
- fitem: fsym
717
+ fitem: fname
705
718
  {
706
- id, = val
707
- result = s(:lit, id.to_sym).line lexer.lineno
719
+ (id, line), = val
720
+
721
+ result = s(:lit, id.to_sym).line line
708
722
  }
709
- | dsym
723
+ | symbol
710
724
 
711
725
  undef_list: fitem
712
726
  {
@@ -727,8 +741,6 @@ rule
727
741
  | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
728
742
  | tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
729
743
  | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
730
- # TODO: tUBANG dead?
731
- | tUBANG
732
744
 
733
745
  reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
734
746
  | kALIAS | kAND | kBEGIN | kBREAK | kCASE
@@ -762,24 +774,20 @@ rule
762
774
  }
763
775
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
764
776
  {
765
- lhs, _, id, op, rhs = val
777
+ lhs, _, (id, _line), (op, _), rhs = val
766
778
 
767
779
  result = s(:op_asgn, lhs, rhs, id.to_sym, op.to_sym).line lhs.line
768
780
  }
769
781
  | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
770
782
  {
771
- lhs1, _, lhs2, op, rhs = val
783
+ lhs1, _, (lhs2, _line), op, rhs = val
772
784
 
773
785
  lhs = s(:colon2, lhs1, lhs2.to_sym).line lhs1.line
774
786
  result = new_const_op_asgn [lhs, op, rhs]
775
787
  }
776
- | tCOLON3 tCONSTANT
777
- {
778
- result = self.lexer.lineno
779
- }
780
- tOP_ASGN arg_rhs
788
+ | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
781
789
  {
782
- _, lhs, line, op, rhs = val
790
+ _, (lhs, line), op, rhs = val
783
791
 
784
792
  lhs = s(:colon3, lhs.to_sym).line line
785
793
  result = new_const_op_asgn [lhs, op, rhs]
@@ -793,7 +801,7 @@ rule
793
801
  | arg tDOT2 arg
794
802
  {
795
803
  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
804
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
797
805
  result = s(:lit, (v1.last)..(v2.last)).line v1.line
798
806
  else
799
807
  result = s(:dot2, v1, v2).line v1.line
@@ -802,7 +810,7 @@ rule
802
810
  | arg tDOT3 arg
803
811
  {
804
812
  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
813
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
806
814
  result = s(:lit, (v1.last)...(v2.last)).line v1.line
807
815
  else
808
816
  result = s(:dot3, v1, v2).line v1.line
@@ -823,20 +831,6 @@ rule
823
831
  result = s(:dot3, v1, v2).line v1.line
824
832
  }
825
833
 
826
- | tBDOT2 arg
827
- {
828
- _, v2, = val
829
- v1 = nil
830
-
831
- result = s(:dot2, v1, v2).line v2.line
832
- }
833
- | tBDOT3 arg
834
- {
835
- _, v2 = val
836
- v1 = nil
837
-
838
- result = s(:dot3, v1, v2).line v2.line
839
- }
840
834
 
841
835
  | arg tPLUS arg
842
836
  {
@@ -864,8 +858,9 @@ rule
864
858
  }
865
859
  | tUMINUS_NUM simple_numeric tPOW arg
866
860
  {
867
- lit = s(:lit, val[1]).line lexer.lineno
868
- result = new_call(new_call(lit, :"**", argl(val[3])), :"-@")
861
+ _, (num, line), _, arg = val
862
+ lit = s(:lit, num).line line
863
+ result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
869
864
 
870
865
  }
871
866
  | tUPLUS arg
@@ -964,12 +959,12 @@ rule
964
959
 
965
960
  rel_expr: arg relop arg =tGT
966
961
  {
967
- lhs, op, rhs = val
962
+ lhs, (op, _), rhs = val
968
963
  result = new_call lhs, op.to_sym, argl(rhs)
969
964
  }
970
965
  | rel_expr relop arg =tGT
971
966
  {
972
- lhs, op, rhs = val
967
+ lhs, (op, _), rhs = val
973
968
  warn "comparison '%s' after comparison", op
974
969
  result = new_call lhs, op.to_sym, argl(rhs)
975
970
  }
@@ -1009,16 +1004,6 @@ rule
1009
1004
  _, args, _ = val
1010
1005
  result = args
1011
1006
  }
1012
- | tLPAREN2 args_forward rparen
1013
- {
1014
- if (!self.lexer.is_local_id(:"*") ||
1015
- !self.lexer.is_local_id(:"**") ||
1016
- !self.lexer.is_local_id(:"&")) then
1017
-
1018
- yyerror("Invalid argument forwarding")
1019
- end
1020
- result = call_args [s(:forward_args).line(lexer.lineno)]
1021
- }
1022
1007
 
1023
1008
  opt_paren_args: none
1024
1009
  | paren_args
@@ -1170,8 +1155,9 @@ rule
1170
1155
  | backref
1171
1156
  | tFID
1172
1157
  {
1173
- msg, = val
1158
+ (msg, line), = val
1174
1159
  result = new_call nil, msg.to_sym
1160
+ result.line line
1175
1161
  }
1176
1162
  | k_begin
1177
1163
  {
@@ -1213,15 +1199,15 @@ rule
1213
1199
  }
1214
1200
  | primary_value tCOLON2 tCONSTANT
1215
1201
  {
1216
- expr, _, id = val
1202
+ expr, _, (id, _line) = val
1217
1203
 
1218
1204
  result = s(:colon2, expr, id.to_sym).line expr.line
1219
1205
  }
1220
1206
  | tCOLON3 tCONSTANT
1221
1207
  {
1222
- _, id = val
1208
+ _, (id, line) = val
1223
1209
 
1224
- result = s(:colon3, id.to_sym).line lexer.lineno
1210
+ result = s(:colon3, id.to_sym).line line
1225
1211
  }
1226
1212
  | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1227
1213
  {
@@ -1268,7 +1254,7 @@ rule
1268
1254
  }
1269
1255
  | kNOT tLPAREN2 rparen
1270
1256
  {
1271
- debug20 14, val, result
1257
+ debug 20
1272
1258
  }
1273
1259
  | fcall brace_block
1274
1260
  {
@@ -1286,9 +1272,10 @@ rule
1286
1272
  iter.insert 1, call # FIX
1287
1273
  result = iter
1288
1274
  }
1289
- | tLAMBDA lambda
1275
+ | lambda
1290
1276
  {
1291
- result = val[1] # TODO: fix lineno
1277
+ expr, = val
1278
+ result = expr
1292
1279
  }
1293
1280
  | k_if expr_value then compstmt if_tail k_end
1294
1281
  {
@@ -1331,7 +1318,6 @@ rule
1331
1318
  }
1332
1319
  cpath superclass
1333
1320
  {
1334
- self.comments.push self.lexer.comments
1335
1321
  if (self.in_def || self.in_single > 0) then
1336
1322
  yyerror "class definition in method body"
1337
1323
  end
@@ -1341,7 +1327,7 @@ rule
1341
1327
  {
1342
1328
  result = new_class val
1343
1329
  self.env.unextend
1344
- self.lexer.comments # we don't care about comments in the body
1330
+ self.lexer.ignore_body_comments
1345
1331
  }
1346
1332
  | k_class tLSHFT
1347
1333
  {
@@ -1362,7 +1348,7 @@ rule
1362
1348
  {
1363
1349
  result = new_sclass val
1364
1350
  self.env.unextend
1365
- self.lexer.comments # we don't care about comments in the body
1351
+ self.lexer.ignore_body_comments
1366
1352
  }
1367
1353
  | k_module
1368
1354
  {
@@ -1370,7 +1356,6 @@ rule
1370
1356
  }
1371
1357
  cpath
1372
1358
  {
1373
- self.comments.push self.lexer.comments
1374
1359
  yyerror "module definition in method body" if
1375
1360
  self.in_def or self.in_single > 0
1376
1361
 
@@ -1380,7 +1365,7 @@ rule
1380
1365
  {
1381
1366
  result = new_module val
1382
1367
  self.env.unextend
1383
- self.lexer.comments # we don't care about comments in the body
1368
+ self.lexer.ignore_body_comments
1384
1369
  }
1385
1370
  | k_def fname
1386
1371
  {
@@ -1390,21 +1375,17 @@ rule
1390
1375
  self.env.extend
1391
1376
  lexer.cmdarg.push false
1392
1377
  lexer.cond.push false
1393
-
1394
- self.comments.push self.lexer.comments
1395
1378
  }
1396
- f_arglist bodystmt { result = lexer.lineno } k_end
1379
+ f_arglist bodystmt k_end
1397
1380
  {
1398
- in_def = val[2]
1399
-
1400
- result = new_defn val
1381
+ result, in_def = new_defn val
1401
1382
 
1402
1383
  lexer.cond.pop # group = local_pop
1403
1384
  lexer.cmdarg.pop
1404
1385
  self.env.unextend
1405
1386
  self.in_def = in_def
1406
1387
 
1407
- self.lexer.comments # we don't care about comments in the body
1388
+ self.lexer.ignore_body_comments
1408
1389
  }
1409
1390
  | k_def singleton dot_or_colon
1410
1391
  {
@@ -1412,7 +1393,7 @@ rule
1412
1393
  }
1413
1394
  fname
1414
1395
  {
1415
- result = [self.in_def, lexer.lineno]
1396
+ result = self.in_def
1416
1397
 
1417
1398
  self.in_single += 1 # TODO: remove?
1418
1399
 
@@ -1422,13 +1403,18 @@ rule
1422
1403
  lexer.cond.push false
1423
1404
 
1424
1405
  lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
1425
- self.comments.push self.lexer.comments
1426
1406
  }
1427
1407
  f_arglist bodystmt k_end
1428
1408
  {
1429
- _, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
1430
1409
 
1431
- result = new_defs val
1410
+ # [kdef, recv, _, _, (name, line), in_def, args, body, kend]
1411
+ # =>
1412
+ # [kdef, recv, (name, line), in_def, args, body, kend]
1413
+
1414
+ val.delete_at 3
1415
+ val.delete_at 2
1416
+
1417
+ result, in_def = new_defs val
1432
1418
 
1433
1419
  lexer.cond.pop # group = local_pop
1434
1420
  lexer.cmdarg.pop
@@ -1439,7 +1425,7 @@ rule
1439
1425
 
1440
1426
  # TODO: restore cur_arg ? what's cur_arg?
1441
1427
 
1442
- self.lexer.comments # we don't care about comments in the body
1428
+ self.lexer.ignore_body_comments
1443
1429
  }
1444
1430
  | kBREAK
1445
1431
  {
@@ -1476,8 +1462,17 @@ rule
1476
1462
  k_case: kCASE
1477
1463
  k_for: kFOR
1478
1464
  k_class: kCLASS
1465
+ {
1466
+ self.comments.push self.lexer.comments
1467
+ }
1479
1468
  k_module: kMODULE
1469
+ {
1470
+ self.comments.push self.lexer.comments
1471
+ }
1480
1472
  k_def: kDEF
1473
+ {
1474
+ self.comments.push self.lexer.comments
1475
+ }
1481
1476
  k_do: kDO
1482
1477
  k_do_block: kDO_BLOCK
1483
1478
  k_rescue: kRESCUE
@@ -1538,51 +1533,42 @@ rule
1538
1533
 
1539
1534
  result = block_var args
1540
1535
  }
1541
- | f_marg_list tCOMMA tSTAR f_norm_arg
1536
+ | f_marg_list tCOMMA f_rest_marg
1542
1537
  {
1543
- args, _, _, splat = val
1538
+ args, _, rest = val
1544
1539
 
1545
- result = block_var args, "*#{splat}".to_sym
1540
+ result = block_var args, rest
1546
1541
  }
1547
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1542
+ | f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
1548
1543
  {
1549
- args, _, _, splat, _, args2 = val
1544
+ lhs, _, splat, _, rhs = val
1550
1545
 
1551
- result = block_var args, "*#{splat}".to_sym, args2
1546
+ result = block_var lhs, splat, rhs
1552
1547
  }
1553
- | f_marg_list tCOMMA tSTAR
1548
+ | f_rest_marg
1554
1549
  {
1555
- args, _, _ = val
1550
+ rest, = val
1556
1551
 
1557
- result = block_var args, :*
1552
+ result = block_var rest
1558
1553
  }
1559
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1554
+ | f_rest_marg tCOMMA f_marg_list
1560
1555
  {
1561
- args, _, _, _, args2 = val
1556
+ splat, _, rest = val
1562
1557
 
1563
- result = block_var args, :*, args2
1558
+ result = block_var splat, rest
1564
1559
  }
1565
- | tSTAR f_norm_arg
1566
- {
1567
- _, splat = val
1568
1560
 
1569
- result = block_var :"*#{splat}"
1570
- }
1571
- | tSTAR f_norm_arg tCOMMA f_marg_list
1561
+ f_rest_marg: tSTAR f_norm_arg
1572
1562
  {
1573
- _, splat, _, args = val
1563
+ _, (id, line) = val
1574
1564
 
1575
- result = block_var :"*#{splat}", args
1565
+ result = args ["*#{id}".to_sym]
1566
+ result.line line
1576
1567
  }
1577
1568
  | tSTAR
1578
1569
  {
1579
- result = block_var :*
1580
- }
1581
- | tSTAR tCOMMA f_marg_list
1582
- {
1583
- _, _, args = val
1584
-
1585
- result = block_var :*, args
1570
+ result = args [:*]
1571
+ result.line lexer.lineno # FIX: tSTAR -> line
1586
1572
  }
1587
1573
 
1588
1574
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -1599,8 +1585,8 @@ rule
1599
1585
  }
1600
1586
  | f_block_arg
1601
1587
  {
1602
- line = lexer.lineno
1603
- result = call_args val # TODO: push line down
1588
+ (id, line), = val
1589
+ result = call_args [id]
1604
1590
  result.line line
1605
1591
  }
1606
1592
 
@@ -1709,13 +1695,13 @@ opt_block_args_tail: tCOMMA block_args_tail
1709
1695
 
1710
1696
  bvar: tIDENTIFIER
1711
1697
  {
1712
- id, = val
1713
- line = lexer.lineno
1698
+ (id, line), = val
1714
1699
  result = s(:shadow, id.to_sym).line line
1715
1700
  }
1716
1701
  | f_bad_arg
1717
1702
 
1718
- lambda: {
1703
+ lambda: tLAMBDA
1704
+ {
1719
1705
  self.env.extend :dynamic
1720
1706
  result = [lexer.lineno, lexer.lpar_beg]
1721
1707
  lexer.paren_nest += 1
@@ -1727,14 +1713,14 @@ opt_block_args_tail: tCOMMA block_args_tail
1727
1713
  }
1728
1714
  lambda_body
1729
1715
  {
1730
- (line, lpar), args, _cmdarg, body = val
1716
+ _, (line, lpar), args, _cmdarg, body = val
1731
1717
  lexer.lpar_beg = lpar
1732
1718
 
1733
1719
  lexer.cmdarg.pop
1734
1720
 
1735
1721
  call = s(:lambda).line line
1736
1722
  result = new_iter call, args, body
1737
- result.line = line
1723
+ result.line line
1738
1724
  self.env.unextend # TODO: dynapush & dynapop
1739
1725
  }
1740
1726
 
@@ -1769,23 +1755,28 @@ opt_block_args_tail: tCOMMA block_args_tail
1769
1755
  ## if (nd_type($1) == NODE_YIELD) {
1770
1756
  ## compile_error(PARSER_ARG "block given to yield");
1771
1757
 
1772
- syntax_error "Both block arg and actual block given." if
1773
- val[0].block_pass?
1758
+ cmd, blk = val
1774
1759
 
1775
- val = invert_block_call val if inverted? val
1760
+ syntax_error "Both block arg and actual block given." if
1761
+ cmd.block_pass?
1776
1762
 
1777
- cmd, blk = val
1763
+ if inverted? val then
1764
+ val = invert_block_call val
1765
+ cmd, blk = val
1766
+ end
1778
1767
 
1779
1768
  result = blk
1780
1769
  result.insert 1, cmd
1781
1770
  }
1782
1771
  | block_call call_op2 operation2 opt_paren_args
1783
1772
  {
1784
- result = new_call val[0], val[2].to_sym, val[3]
1773
+ lhs, _, (id, _line), args = val
1774
+
1775
+ result = new_call lhs, id.to_sym, args
1785
1776
  }
1786
1777
  | block_call call_op2 operation2 opt_paren_args brace_block
1787
1778
  {
1788
- iter1, _, name, args, iter2 = val
1779
+ iter1, _, (name, _line), args, iter2 = val
1789
1780
 
1790
1781
  call = new_call iter1, name.to_sym, args
1791
1782
  iter2.insert 1, call
@@ -1794,7 +1785,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1794
1785
  }
1795
1786
  | block_call call_op2 operation2 command_args do_block
1796
1787
  {
1797
- iter1, _, name, args, iter2 = val
1788
+ iter1, _, (name, _line), args, iter2 = val
1798
1789
 
1799
1790
  call = new_call iter1, name.to_sym, args
1800
1791
  iter2.insert 1, call
@@ -1802,28 +1793,29 @@ opt_block_args_tail: tCOMMA block_args_tail
1802
1793
  result = iter2
1803
1794
  }
1804
1795
 
1805
- method_call: fcall
1796
+ method_call: fcall paren_args
1806
1797
  {
1807
- result = self.lexer.lineno
1808
- }
1809
- paren_args
1810
- {
1811
- call, lineno, args = val
1798
+ call, args = val
1812
1799
 
1813
1800
  result = call.concat args.sexp_body if args
1814
- result.line lineno
1815
1801
  }
1816
1802
  | primary_value call_op operation2 opt_paren_args
1817
1803
  {
1818
- result = new_call val[0], val[2].to_sym, val[3], val[1]
1804
+ recv, call_op, (op, _line), args = val
1805
+
1806
+ result = new_call recv, op.to_sym, args, call_op
1819
1807
  }
1820
1808
  | primary_value tCOLON2 operation2 paren_args
1821
1809
  {
1822
- result = new_call val[0], val[2].to_sym, val[3]
1810
+ recv, _, (op, _line), args = val
1811
+
1812
+ result = new_call recv, op.to_sym, args
1823
1813
  }
1824
1814
  | primary_value tCOLON2 operation3
1825
1815
  {
1826
- result = new_call val[0], val[2].to_sym
1816
+ lhs, _, (id, _line) = val
1817
+
1818
+ result = new_call lhs, id.to_sym
1827
1819
  }
1828
1820
  | primary_value call_op paren_args
1829
1821
  {
@@ -1856,7 +1848,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1856
1848
  _, line, body, _ = val
1857
1849
 
1858
1850
  result = body
1859
- result.line = line
1851
+ result.line line
1860
1852
 
1861
1853
  self.env.unextend
1862
1854
  }
@@ -1870,7 +1862,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1870
1862
  _, line, body, _ = val
1871
1863
 
1872
1864
  result = body
1873
- result.line = line
1865
+ result.line line
1874
1866
 
1875
1867
  self.env.unextend
1876
1868
  }
@@ -1899,14 +1891,39 @@ opt_block_args_tail: tCOMMA block_args_tail
1899
1891
  self.env.unextend
1900
1892
  }
1901
1893
 
1894
+ case_args: arg_value
1895
+ {
1896
+ arg, = val
1897
+
1898
+ result = s(:array, arg).line arg.line
1899
+ }
1900
+ | tSTAR arg_value
1901
+ {
1902
+ _, arg = val
1903
+
1904
+ result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
1905
+ }
1906
+ | case_args tCOMMA arg_value
1907
+ {
1908
+ args, _, id = val
1909
+
1910
+ result = self.list_append args, id
1911
+ }
1912
+ | case_args tCOMMA tSTAR arg_value
1913
+ {
1914
+ args, _, _, id = val
1915
+
1916
+ result = self.list_append args, s(:splat, id).line(id.line)
1917
+ }
1918
+
1902
1919
  case_body: k_when
1903
1920
  {
1904
1921
  result = self.lexer.lineno
1905
1922
  }
1906
- args then compstmt cases
1923
+ case_args then compstmt cases
1907
1924
  {
1908
1925
  result = new_when(val[2], val[4])
1909
- result.line = val[1]
1926
+ result.line val[1]
1910
1927
  result << val[5] if val[5]
1911
1928
  }
1912
1929
 
@@ -1952,17 +1969,10 @@ opt_block_args_tail: tCOMMA block_args_tail
1952
1969
 
1953
1970
  literal: numeric
1954
1971
  {
1955
- line = lexer.lineno
1956
- result = s(:lit, val[0])
1957
- result.line = line
1972
+ (lit, line), = val
1973
+ result = s(:lit, lit).line line
1958
1974
  }
1959
1975
  | symbol
1960
- {
1961
- line = lexer.lineno
1962
- result = s(:lit, val[0])
1963
- result.line = line
1964
- }
1965
- | dsym
1966
1976
 
1967
1977
  strings: string
1968
1978
  {
@@ -1973,7 +1983,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1973
1983
 
1974
1984
  string: tCHAR
1975
1985
  {
1976
- debug20 23, val, result
1986
+ debug 37
1977
1987
  }
1978
1988
  | string1
1979
1989
  | string string1
@@ -1983,11 +1993,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1983
1993
 
1984
1994
  string1: tSTRING_BEG string_contents tSTRING_END
1985
1995
  {
1986
- _, str, (_, func) = val
1996
+ (_, line), str, (_, func) = val
1987
1997
 
1988
- str = dedent str if func =~ RubyLexer::STR_FUNC_ICNTNT
1998
+ str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
1989
1999
 
1990
- result = str
2000
+ result = str.line line
1991
2001
  }
1992
2002
  | tSTRING
1993
2003
  {
@@ -2007,11 +2017,15 @@ opt_block_args_tail: tCOMMA block_args_tail
2007
2017
 
2008
2018
  words: tWORDS_BEG tSPACE tSTRING_END
2009
2019
  {
2010
- result = s(:array).line lexer.lineno
2020
+ (_, line), _, _ = val
2021
+
2022
+ result = s(:array).line line
2011
2023
  }
2012
2024
  | tWORDS_BEG word_list tSTRING_END
2013
2025
  {
2014
- result = val[1]
2026
+ (_, line), list, _ = val
2027
+
2028
+ result = list.line line
2015
2029
  }
2016
2030
 
2017
2031
  word_list: none
@@ -2031,18 +2045,20 @@ opt_block_args_tail: tCOMMA block_args_tail
2031
2045
 
2032
2046
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2033
2047
  {
2034
- result = s(:array).line lexer.lineno
2048
+ (_, line), _, _ = val
2049
+
2050
+ result = s(:array).line line
2035
2051
  }
2036
- | tSYMBOLS_BEG { result = lexer.lineno } symbol_list tSTRING_END
2052
+ | tSYMBOLS_BEG symbol_list tSTRING_END
2037
2053
  {
2038
- _, line, list, _, = val
2039
- list.line = line
2054
+ (_, line), list, _, = val
2055
+ list.line line
2040
2056
  result = list
2041
2057
  }
2042
2058
 
2043
2059
  symbol_list: none
2044
2060
  {
2045
- result = new_symbol_list.line lexer.lineno
2061
+ result = new_symbol_list
2046
2062
  }
2047
2063
  | symbol_list word tSPACE
2048
2064
  {
@@ -2052,20 +2068,28 @@ opt_block_args_tail: tCOMMA block_args_tail
2052
2068
 
2053
2069
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2054
2070
  {
2055
- result = s(:array).line lexer.lineno
2071
+ (_, line), _, _ = val
2072
+
2073
+ result = s(:array).line line
2056
2074
  }
2057
2075
  | tQWORDS_BEG qword_list tSTRING_END
2058
2076
  {
2059
- result = val[1]
2077
+ (_, line), list, _ = val
2078
+
2079
+ result = list.line line
2060
2080
  }
2061
2081
 
2062
2082
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2063
2083
  {
2064
- result = s(:array).line lexer.lineno # FIX
2084
+ (_, line), _, _ = val
2085
+
2086
+ result = s(:array).line line
2065
2087
  }
2066
2088
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2067
2089
  {
2068
- result = val[1]
2090
+ (_, line), list, _ = val
2091
+
2092
+ result = list.line line
2069
2093
  }
2070
2094
 
2071
2095
  qword_list: none
@@ -2088,7 +2112,8 @@ opt_block_args_tail: tCOMMA block_args_tail
2088
2112
 
2089
2113
  string_contents: none
2090
2114
  {
2091
- result = s(:str, "").line lexer.lineno
2115
+ line = prev_value_to_lineno _values.last
2116
+ result = s(:str, +"").line line
2092
2117
  }
2093
2118
  | string_contents string_content
2094
2119
  {
@@ -2163,8 +2188,8 @@ regexp_contents: none
2163
2188
  lexer.brace_nest = brace_nest
2164
2189
  lexer.string_nest = string_nest
2165
2190
 
2166
- lexer.cmdarg.pop
2167
2191
  lexer.cond.pop
2192
+ lexer.cmdarg.pop
2168
2193
 
2169
2194
  lexer.lex_state = oldlex_state
2170
2195
 
@@ -2179,29 +2204,49 @@ regexp_contents: none
2179
2204
  when nil then
2180
2205
  result = s(:evstr).line line
2181
2206
  else
2182
- debug20 25
2207
+ debug 38
2183
2208
  raise "unknown string body: #{stmt.inspect}"
2184
2209
  end
2185
2210
  }
2186
2211
 
2187
- string_dvar: tGVAR { result = s(:gvar, val[0].to_sym).line lexer.lineno }
2188
- | tIVAR { result = s(:ivar, val[0].to_sym).line lexer.lineno }
2189
- | tCVAR { result = s(:cvar, val[0].to_sym).line lexer.lineno }
2212
+ string_dvar: tGVAR
2213
+ {
2214
+ (id, line), = val
2215
+ result = s(:gvar, id.to_sym).line line
2216
+ }
2217
+ | tIVAR
2218
+ {
2219
+ (id, line), = val
2220
+ result = s(:ivar, id.to_sym).line line
2221
+ }
2222
+ | tCVAR
2223
+ {
2224
+ (id, line), = val
2225
+ result = s(:cvar, id.to_sym).line line
2226
+ }
2190
2227
  | backref
2191
2228
 
2192
- symbol: tSYMBEG sym
2229
+ symbol: ssym
2230
+ | dsym
2231
+
2232
+ ssym: tSYMBEG sym
2193
2233
  {
2234
+ _, (id, line) = val
2235
+
2194
2236
  lexer.lex_state = EXPR_END
2195
- result = val[1].to_sym
2237
+ result = s(:lit, id.to_sym).line line
2196
2238
  }
2197
2239
  | tSYMBOL
2198
2240
  {
2199
- result = val[0].to_sym
2241
+ (id, line), = val
2242
+
2243
+ lexer.lex_state = EXPR_END
2244
+ result = s(:lit, id.to_sym).line line
2200
2245
  }
2201
2246
 
2202
2247
  sym: fname | tIVAR | tGVAR | tCVAR
2203
2248
 
2204
- dsym: tSYMBEG xstring_contents tSTRING_END
2249
+ dsym: tSYMBEG string_contents tSTRING_END
2205
2250
  {
2206
2251
  _, result, _ = val
2207
2252
 
@@ -2217,14 +2262,15 @@ regexp_contents: none
2217
2262
  when :evstr then
2218
2263
  result = s(:dsym, "", result).line result.line
2219
2264
  else
2220
- debug20 26, val, result
2265
+ debug 39
2221
2266
  end
2222
2267
  }
2223
2268
 
2224
2269
  numeric: simple_numeric
2225
- | tUMINUS_NUM simple_numeric
2270
+ | tUMINUS_NUM simple_numeric =tLOWEST
2226
2271
  {
2227
- result = -val[1] # TODO: pt_testcase
2272
+ _, (num, line) = val
2273
+ result = [-num, line]
2228
2274
  }
2229
2275
 
2230
2276
  simple_numeric: tINTEGER
@@ -2257,8 +2303,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2257
2303
 
2258
2304
  var_ref: user_variable
2259
2305
  {
2260
- var = val[0]
2306
+ raise "NO: #{val.inspect}" if Sexp === val.first
2307
+ (var, line), = val
2261
2308
  result = Sexp === var ? var : self.gettable(var)
2309
+ result.line line
2262
2310
  }
2263
2311
  | keyword_variable
2264
2312
  {
@@ -2273,11 +2321,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2273
2321
  | keyword_variable
2274
2322
  {
2275
2323
  result = self.assignable val[0]
2276
- debug20 29, val, result
2324
+ debug 40
2277
2325
  }
2278
2326
 
2279
- backref: tNTH_REF { result = s(:nth_ref, val[0]).line lexer.lineno }
2280
- | tBACK_REF { result = s(:back_ref, val[0]).line lexer.lineno }
2327
+ backref: tNTH_REF
2328
+ {
2329
+ (ref, line), = val
2330
+ result = s(:nth_ref, ref).line line
2331
+ }
2332
+ | tBACK_REF
2333
+ {
2334
+ (ref, line), = val
2335
+ result = s(:back_ref, ref).line line
2336
+ }
2281
2337
 
2282
2338
  superclass: tLT
2283
2339
  {
@@ -2295,22 +2351,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2295
2351
 
2296
2352
  f_arglist: tLPAREN2 f_args rparen
2297
2353
  {
2298
- result = val[1]
2299
- self.lexer.lex_state = EXPR_BEG
2300
- self.lexer.command_start = true
2301
- }
2302
- | tLPAREN2 args_forward rparen
2303
- {
2304
- args_rest = :"*"
2305
- kwargs_rest = :"**"
2306
- block_fwd = :"&"
2307
- self.env[args_rest] = :lvar
2308
- self.env[kwargs_rest] = :lvar
2309
- self.env[block_fwd] = :lvar
2310
-
2311
- result = s(:args, s(:forward_args)).line lexer.lineno
2312
- self.lexer.lex_state = EXPR_BEG
2313
- self.lexer.command_start = true
2354
+ result = end_args val
2314
2355
  }
2315
2356
  | {
2316
2357
  result = self.in_kwarg
@@ -2319,12 +2360,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2319
2360
  }
2320
2361
  f_args term
2321
2362
  {
2322
- kwarg, args, _ = val
2323
-
2324
- self.in_kwarg = kwarg
2325
- result = args
2326
- lexer.lex_state = EXPR_BEG
2327
- lexer.command_start = true
2363
+ result = end_args val
2328
2364
  }
2329
2365
 
2330
2366
  args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -2409,9 +2445,9 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2409
2445
  |
2410
2446
  {
2411
2447
  result = args val
2448
+ # result.line lexer.lineno
2412
2449
  }
2413
2450
 
2414
- args_forward: tBDOT3
2415
2451
 
2416
2452
  f_bad_arg: tCONSTANT
2417
2453
  {
@@ -2433,10 +2469,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2433
2469
  f_norm_arg: f_bad_arg
2434
2470
  | tIDENTIFIER
2435
2471
  {
2436
- identifier = val[0].to_sym
2472
+ (id, line), = val
2473
+ identifier = id.to_sym
2437
2474
  self.env[identifier] = :lvar
2438
2475
 
2439
- result = identifier
2476
+ result = [identifier, line]
2440
2477
  }
2441
2478
 
2442
2479
  f_arg_asgn: f_norm_arg
@@ -2444,22 +2481,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2444
2481
  f_arg_item: f_arg_asgn
2445
2482
  | tLPAREN f_margs rparen
2446
2483
  {
2447
- result = val[1]
2484
+ _, margs, _ = val
2485
+
2486
+ result = margs
2448
2487
  }
2449
2488
 
2450
2489
  f_arg: f_arg_item
2451
2490
  {
2452
- arg, = val
2453
-
2454
- case arg
2455
- when Symbol then
2456
- result = s(:args, arg).line lexer.lineno
2457
- when Sexp then
2458
- result = arg
2459
- else
2460
- debug20 32
2461
- raise "Unknown f_arg type: #{val.inspect}"
2462
- end
2491
+ result = new_arg val
2463
2492
  }
2464
2493
  | f_arg tCOMMA f_arg_item
2465
2494
  {
@@ -2471,7 +2500,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2471
2500
  result = s(:args, list).line list.line
2472
2501
  end
2473
2502
 
2474
- result << item
2503
+ result << (Sexp === item ? item : item.first)
2475
2504
  }
2476
2505
 
2477
2506
  f_label: tLABEL
@@ -2532,27 +2561,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2532
2561
  kwrest_mark: tPOW
2533
2562
  | tDSTAR
2534
2563
 
2564
+
2535
2565
  f_kwrest: kwrest_mark tIDENTIFIER
2536
2566
  {
2537
- name = val[1].to_sym
2538
- self.assignable name
2539
- result = :"**#{name}"
2567
+ _, (id, line) = val
2568
+
2569
+ name = id.to_sym
2570
+ self.assignable [name, line]
2571
+ result = [:"**#{name}", line]
2540
2572
  }
2541
2573
  | kwrest_mark
2542
2574
  {
2543
- result = :"**"
2544
- self.env[result] = :lvar
2575
+ id = :"**"
2576
+ self.env[id] = :lvar # TODO: needed?!?
2577
+ result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
2545
2578
  }
2546
2579
 
2547
2580
  f_opt: f_arg_asgn tEQL arg_value
2548
2581
  {
2549
- result = self.assignable val[0], val[2]
2582
+ lhs, _, rhs = val
2583
+ result = self.assignable lhs, rhs
2550
2584
  # TODO: detect duplicate names
2551
2585
  }
2552
2586
 
2553
2587
  f_block_opt: f_arg_asgn tEQL primary_value
2554
2588
  {
2555
- result = self.assignable val[0], val[2]
2589
+ lhs, _, rhs = val
2590
+ result = self.assignable lhs, rhs
2556
2591
  }
2557
2592
 
2558
2593
  f_block_optarg: f_block_opt
@@ -2582,30 +2617,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2582
2617
  f_rest_arg: restarg_mark tIDENTIFIER
2583
2618
  {
2584
2619
  # TODO: differs from parse.y - needs tests
2585
- name = val[1].to_sym
2586
- self.assignable name
2587
- result = :"*#{name}"
2620
+ _, (id, line) = val
2621
+ name = id.to_sym
2622
+ self.assignable [name, line]
2623
+ result = [:"*#{name}", line]
2588
2624
  }
2589
2625
  | restarg_mark
2590
2626
  {
2591
2627
  name = :"*"
2592
2628
  self.env[name] = :lvar
2593
- result = name
2629
+ result = [name, lexer.lineno] # FIX: tSTAR to include lineno
2594
2630
  }
2595
2631
 
2596
2632
  blkarg_mark: tAMPER2 | tAMPER
2597
2633
 
2598
2634
  f_block_arg: blkarg_mark tIDENTIFIER
2599
2635
  {
2600
- identifier = val[1].to_sym
2636
+ _, (id, line) = val
2637
+ identifier = id.to_sym
2601
2638
 
2602
2639
  self.env[identifier] = :lvar
2603
- result = "&#{identifier}".to_sym
2640
+ result = ["&#{identifier}".to_sym, line]
2604
2641
  }
2605
2642
 
2606
2643
  opt_f_block_arg: tCOMMA f_block_arg
2607
2644
  {
2608
- result = val[1]
2645
+ _, arg = val
2646
+ result = arg
2609
2647
  }
2610
2648
  |
2611
2649
  {
@@ -2654,9 +2692,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2654
2692
  }
2655
2693
  | tSTRING_BEG string_contents tLABEL_END arg_value
2656
2694
  {
2657
- _, sym, _, value = val
2695
+ (_, line), sym, _, value = val
2696
+
2658
2697
  sym.sexp_type = :dsym
2659
- result = s(:array, sym, value).line sym.line
2698
+
2699
+ result = s(:array, sym, value).line line
2660
2700
  }
2661
2701
  | tDSTAR arg_value
2662
2702
  {