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 Ruby24Parser
3
+ class Ruby23Parser
4
4
 
5
5
  token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
6
6
  kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
@@ -18,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
  {
@@ -279,14 +284,6 @@ rule
279
284
  expr, = val
280
285
  result = value_expr expr
281
286
  }
282
- | command_call kRESCUE_MOD stmt
283
- {
284
- expr, (_, line), resbody = val
285
-
286
- expr = value_expr expr
287
- ary = s(:array).line line
288
- result = new_rescue(expr, new_resbody(ary, resbody))
289
- }
290
287
  | command_asgn
291
288
 
292
289
  expr: command_call
@@ -313,7 +310,7 @@ rule
313
310
  # TODO: fix line number to tBANG... but causes BAD shift/reduce conflict
314
311
  # REFACTOR: call_uni_op -- see parse26.y
315
312
  }
316
- | arg
313
+ | arg =tLBRACE_ARG
317
314
 
318
315
  expr_value: expr
319
316
  {
@@ -338,7 +335,7 @@ rule
338
335
  block_command: block_call
339
336
  | block_call call_op2 operation2 command_args
340
337
  {
341
- blk, _, msg, args = val
338
+ blk, _, (msg, _line), args = val
342
339
  result = new_call(blk, msg.to_sym, args).line blk.line
343
340
  }
344
341
 
@@ -352,15 +349,15 @@ rule
352
349
  _, line, body, _ = val
353
350
 
354
351
  result = body
355
- result.line = line
352
+ result.line line
356
353
 
357
354
  # self.env.unextend
358
355
  }
359
356
 
360
357
  fcall: operation
361
358
  {
362
- msg, = val
363
- result = new_call(nil, msg.to_sym).line lexer.lineno
359
+ (msg, line), = val
360
+ result = new_call(nil, msg.to_sym).line line
364
361
  }
365
362
 
366
363
  command: fcall command_args =tLOWEST
@@ -383,12 +380,14 @@ rule
383
380
  }
384
381
  | primary_value call_op operation2 command_args =tLOWEST
385
382
  {
386
- lhs, callop, op, args = val
383
+ lhs, callop, (op, _), args = val
384
+
387
385
  result = new_call lhs, op.to_sym, args, callop
386
+ result.line lhs.line
388
387
  }
389
388
  | primary_value call_op operation2 command_args cmd_brace_block
390
389
  {
391
- recv, _, msg, args, block = val
390
+ recv, _, (msg, _line), args, block = val
392
391
  call = new_call recv, msg.to_sym, args, val[1]
393
392
 
394
393
  block_dup_check call, block
@@ -398,11 +397,14 @@ rule
398
397
  }
399
398
  | primary_value tCOLON2 operation2 command_args =tLOWEST
400
399
  {
401
- result = new_call val[0], val[2].to_sym, val[3]
400
+ lhs, _, (id, line), args = val
401
+
402
+ result = new_call lhs, id.to_sym, args
403
+ result.line line
402
404
  }
403
405
  | primary_value tCOLON2 operation2 command_args cmd_brace_block
404
406
  {
405
- recv, _, msg, args, block = val
407
+ recv, _, (msg, _line), args, block = val
406
408
  call = new_call recv, msg.to_sym, args
407
409
 
408
410
  block_dup_check call, block
@@ -560,25 +562,29 @@ rule
560
562
  }
561
563
  | primary_value call_op tIDENTIFIER
562
564
  {
563
- result = new_attrasgn val[0], val[2], val[1]
565
+ lhs, call_op, (id, _line) = val
566
+
567
+ result = new_attrasgn lhs, id, call_op
564
568
  }
565
569
  | primary_value tCOLON2 tIDENTIFIER
566
570
  {
567
- recv, _, id = val
571
+ recv, _, (id, _line) = val
568
572
  result = new_attrasgn recv, id
569
573
  }
570
574
  | primary_value call_op tCONSTANT
571
575
  {
572
- result = new_attrasgn val[0], val[2], val[1]
576
+ lhs, call_op, (id, _line) = val
577
+
578
+ result = new_attrasgn lhs, id, call_op
573
579
  }
574
580
  | primary_value tCOLON2 tCONSTANT
575
581
  {
576
582
  if (self.in_def || self.in_single > 0) then
577
- debug20 7
583
+ debug 14
578
584
  yyerror "dynamic constant assignment"
579
585
  end
580
586
 
581
- expr, _, id = val
587
+ expr, _, (id, _line) = val
582
588
  l = expr.line
583
589
 
584
590
  result = s(:const, s(:colon2, expr, id.to_sym).line(l), nil).line l
@@ -586,58 +592,65 @@ rule
586
592
  | tCOLON3 tCONSTANT
587
593
  {
588
594
  if (self.in_def || self.in_single > 0) then
589
- debug20 8
595
+ debug 15
590
596
  yyerror "dynamic constant assignment"
591
597
  end
592
598
 
593
- _, id = val
594
- l = lexer.lineno
599
+ _, (id, l) = val
595
600
 
596
601
  result = s(:const, nil, s(:colon3, id.to_sym).line(l)).line l
597
602
  }
598
603
  | backref
599
604
  {
600
- self.backref_assign_error val[0]
605
+ ref, = val
606
+
607
+ self.backref_assign_error ref
601
608
  }
602
609
 
603
610
  lhs: user_variable
604
611
  {
605
- line = lexer.lineno
606
- result = self.assignable val[0]
607
- result.line = line
612
+ var, = val
613
+
614
+ result = self.assignable var
608
615
  }
609
616
  | keyword_variable
610
617
  {
611
- line = lexer.lineno
612
- result = self.assignable val[0]
613
- result.line = line
614
- debug20 9, val, result
618
+ var, = val
619
+
620
+ result = self.assignable var
621
+
622
+ debug 16
615
623
  }
616
624
  | primary_value tLBRACK2 opt_call_args rbracket
617
625
  {
618
626
  lhs, _, args, _ = val
627
+
619
628
  result = self.aryset lhs, args
620
629
  }
621
630
  | primary_value call_op tIDENTIFIER # REFACTOR
622
631
  {
623
- lhs, op, id = val
632
+ lhs, op, (id, _line) = val
633
+
624
634
  result = new_attrasgn lhs, id, op
625
635
  }
626
636
  | primary_value tCOLON2 tIDENTIFIER
627
637
  {
628
- lhs, _, id = val
638
+ lhs, _, (id, _line) = val
639
+
629
640
  result = new_attrasgn lhs, id
630
641
  }
631
642
  | primary_value call_op tCONSTANT # REFACTOR?
632
643
  {
633
- result = new_attrasgn val[0], val[2], val[1]
644
+ lhs, call_op, (id, _line) = val
645
+
646
+ result = new_attrasgn lhs, id, call_op
634
647
  }
635
648
  | primary_value tCOLON2 tCONSTANT
636
649
  {
637
- expr, _, id = val
650
+ expr, _, (id, _line) = val
638
651
 
639
652
  if (self.in_def || self.in_single > 0) then
640
- debug20 10
653
+ debug 17
641
654
  yyerror "dynamic constant assignment"
642
655
  end
643
656
 
@@ -646,14 +659,13 @@ rule
646
659
  }
647
660
  | tCOLON3 tCONSTANT
648
661
  {
649
- _, id = val
662
+ _, (id, l) = val
650
663
 
651
664
  if (self.in_def || self.in_single > 0) then
652
- debug20 11
665
+ debug 18
653
666
  yyerror "dynamic constant assignment"
654
667
  end
655
668
 
656
- l = lexer.lineno
657
669
  result = s(:const, s(:colon3, id.to_sym).line(l)).line l
658
670
  }
659
671
  | backref
@@ -669,16 +681,17 @@ rule
669
681
 
670
682
  cpath: tCOLON3 cname
671
683
  {
672
- _, name = val
673
- result = s(:colon3, name.to_sym).line lexer.lineno
684
+ _, (name, line) = val
685
+ result = s(:colon3, name.to_sym).line line
674
686
  }
675
687
  | cname
676
688
  {
677
- result = val[0].to_sym
689
+ (id, line), = val
690
+ result = [id.to_sym, line] # TODO: sexp?
678
691
  }
679
692
  | primary_value tCOLON2 cname
680
693
  {
681
- pval, _, name = val
694
+ pval, _, (name, _line) = val
682
695
 
683
696
  result = s(:colon2, pval, name.to_sym)
684
697
  result.line pval.line
@@ -688,24 +701,17 @@ rule
688
701
  | op
689
702
  {
690
703
  lexer.lex_state = EXPR_END
691
- result = val[0]
692
704
  }
693
705
 
694
706
  | reswords
695
- {
696
- (sym, _line), = val
697
- lexer.lex_state = EXPR_END
698
- result = sym
699
- }
700
-
701
- fsym: fname | symbol
702
707
 
703
- fitem: fsym
708
+ fitem: fname
704
709
  {
705
- id, = val
706
- result = s(:lit, id.to_sym).line lexer.lineno
710
+ (id, line), = val
711
+
712
+ result = s(:lit, id.to_sym).line line
707
713
  }
708
- | dsym
714
+ | symbol
709
715
 
710
716
  undef_list: fitem
711
717
  {
@@ -726,8 +732,6 @@ rule
726
732
  | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
727
733
  | tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
728
734
  | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
729
- # TODO: tUBANG dead?
730
- | tUBANG
731
735
 
732
736
  reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
733
737
  | kALIAS | kAND | kBEGIN | kBREAK | kCASE
@@ -761,24 +765,20 @@ rule
761
765
  }
762
766
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
763
767
  {
764
- lhs, _, id, op, rhs = val
768
+ lhs, _, (id, _line), (op, _), rhs = val
765
769
 
766
770
  result = s(:op_asgn, lhs, rhs, id.to_sym, op.to_sym).line lhs.line
767
771
  }
768
772
  | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
769
773
  {
770
- lhs1, _, lhs2, op, rhs = val
774
+ lhs1, _, (lhs2, _line), op, rhs = val
771
775
 
772
776
  lhs = s(:colon2, lhs1, lhs2.to_sym).line lhs1.line
773
777
  result = new_const_op_asgn [lhs, op, rhs]
774
778
  }
775
- | tCOLON3 tCONSTANT
776
- {
777
- result = self.lexer.lineno
778
- }
779
- tOP_ASGN arg_rhs
779
+ | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
780
780
  {
781
- _, lhs, line, op, rhs = val
781
+ _, (lhs, line), op, rhs = val
782
782
 
783
783
  lhs = s(:colon3, lhs.to_sym).line line
784
784
  result = new_const_op_asgn [lhs, op, rhs]
@@ -792,7 +792,7 @@ rule
792
792
  | arg tDOT2 arg
793
793
  {
794
794
  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
795
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
796
796
  result = s(:lit, (v1.last)..(v2.last)).line v1.line
797
797
  else
798
798
  result = s(:dot2, v1, v2).line v1.line
@@ -801,7 +801,7 @@ rule
801
801
  | arg tDOT3 arg
802
802
  {
803
803
  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
804
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
805
805
  result = s(:lit, (v1.last)...(v2.last)).line v1.line
806
806
  else
807
807
  result = s(:dot3, v1, v2).line v1.line
@@ -835,8 +835,9 @@ rule
835
835
  }
836
836
  | tUMINUS_NUM simple_numeric tPOW arg
837
837
  {
838
- lit = s(:lit, val[1]).line lexer.lineno
839
- result = new_call(new_call(lit, :"**", argl(val[3])), :"-@")
838
+ _, (num, line), _, arg = val
839
+ lit = s(:lit, num).line line
840
+ result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
840
841
 
841
842
  }
842
843
  | tUPLUS arg
@@ -935,12 +936,12 @@ rule
935
936
 
936
937
  rel_expr: arg relop arg =tGT
937
938
  {
938
- lhs, op, rhs = val
939
+ lhs, (op, _), rhs = val
939
940
  result = new_call lhs, op.to_sym, argl(rhs)
940
941
  }
941
942
  | rel_expr relop arg =tGT
942
943
  {
943
- lhs, op, rhs = val
944
+ lhs, (op, _), rhs = val
944
945
  warn "comparison '%s' after comparison", op
945
946
  result = new_call lhs, op.to_sym, argl(rhs)
946
947
  }
@@ -1131,8 +1132,9 @@ rule
1131
1132
  | backref
1132
1133
  | tFID
1133
1134
  {
1134
- msg, = val
1135
+ (msg, line), = val
1135
1136
  result = new_call nil, msg.to_sym
1137
+ result.line line
1136
1138
  }
1137
1139
  | k_begin
1138
1140
  {
@@ -1174,15 +1176,15 @@ rule
1174
1176
  }
1175
1177
  | primary_value tCOLON2 tCONSTANT
1176
1178
  {
1177
- expr, _, id = val
1179
+ expr, _, (id, _line) = val
1178
1180
 
1179
1181
  result = s(:colon2, expr, id.to_sym).line expr.line
1180
1182
  }
1181
1183
  | tCOLON3 tCONSTANT
1182
1184
  {
1183
- _, id = val
1185
+ _, (id, line) = val
1184
1186
 
1185
- result = s(:colon3, id.to_sym).line lexer.lineno
1187
+ result = s(:colon3, id.to_sym).line line
1186
1188
  }
1187
1189
  | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1188
1190
  {
@@ -1229,7 +1231,7 @@ rule
1229
1231
  }
1230
1232
  | kNOT tLPAREN2 rparen
1231
1233
  {
1232
- debug20 14, val, result
1234
+ debug 20
1233
1235
  }
1234
1236
  | fcall brace_block
1235
1237
  {
@@ -1247,9 +1249,10 @@ rule
1247
1249
  iter.insert 1, call # FIX
1248
1250
  result = iter
1249
1251
  }
1250
- | tLAMBDA lambda
1252
+ | lambda
1251
1253
  {
1252
- result = val[1] # TODO: fix lineno
1254
+ expr, = val
1255
+ result = expr
1253
1256
  }
1254
1257
  | k_if expr_value then compstmt if_tail k_end
1255
1258
  {
@@ -1292,7 +1295,6 @@ rule
1292
1295
  }
1293
1296
  cpath superclass
1294
1297
  {
1295
- self.comments.push self.lexer.comments
1296
1298
  if (self.in_def || self.in_single > 0) then
1297
1299
  yyerror "class definition in method body"
1298
1300
  end
@@ -1302,7 +1304,7 @@ rule
1302
1304
  {
1303
1305
  result = new_class val
1304
1306
  self.env.unextend
1305
- self.lexer.comments # we don't care about comments in the body
1307
+ self.lexer.ignore_body_comments
1306
1308
  }
1307
1309
  | k_class tLSHFT
1308
1310
  {
@@ -1323,7 +1325,7 @@ rule
1323
1325
  {
1324
1326
  result = new_sclass val
1325
1327
  self.env.unextend
1326
- self.lexer.comments # we don't care about comments in the body
1328
+ self.lexer.ignore_body_comments
1327
1329
  }
1328
1330
  | k_module
1329
1331
  {
@@ -1331,7 +1333,6 @@ rule
1331
1333
  }
1332
1334
  cpath
1333
1335
  {
1334
- self.comments.push self.lexer.comments
1335
1336
  yyerror "module definition in method body" if
1336
1337
  self.in_def or self.in_single > 0
1337
1338
 
@@ -1341,7 +1342,7 @@ rule
1341
1342
  {
1342
1343
  result = new_module val
1343
1344
  self.env.unextend
1344
- self.lexer.comments # we don't care about comments in the body
1345
+ self.lexer.ignore_body_comments
1345
1346
  }
1346
1347
  | k_def fname
1347
1348
  {
@@ -1351,21 +1352,17 @@ rule
1351
1352
  self.env.extend
1352
1353
  lexer.cmdarg.push false
1353
1354
  lexer.cond.push false
1354
-
1355
- self.comments.push self.lexer.comments
1356
1355
  }
1357
- f_arglist bodystmt { result = lexer.lineno } k_end
1356
+ f_arglist bodystmt k_end
1358
1357
  {
1359
- in_def = val[2]
1360
-
1361
- result = new_defn val
1358
+ result, in_def = new_defn val
1362
1359
 
1363
1360
  lexer.cond.pop # group = local_pop
1364
1361
  lexer.cmdarg.pop
1365
1362
  self.env.unextend
1366
1363
  self.in_def = in_def
1367
1364
 
1368
- self.lexer.comments # we don't care about comments in the body
1365
+ self.lexer.ignore_body_comments
1369
1366
  }
1370
1367
  | k_def singleton dot_or_colon
1371
1368
  {
@@ -1373,7 +1370,7 @@ rule
1373
1370
  }
1374
1371
  fname
1375
1372
  {
1376
- result = [self.in_def, lexer.lineno]
1373
+ result = self.in_def
1377
1374
 
1378
1375
  self.in_single += 1 # TODO: remove?
1379
1376
 
@@ -1383,13 +1380,18 @@ rule
1383
1380
  lexer.cond.push false
1384
1381
 
1385
1382
  lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
1386
- self.comments.push self.lexer.comments
1387
1383
  }
1388
1384
  f_arglist bodystmt k_end
1389
1385
  {
1390
- _, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
1391
1386
 
1392
- result = new_defs val
1387
+ # [kdef, recv, _, _, (name, line), in_def, args, body, kend]
1388
+ # =>
1389
+ # [kdef, recv, (name, line), in_def, args, body, kend]
1390
+
1391
+ val.delete_at 3
1392
+ val.delete_at 2
1393
+
1394
+ result, in_def = new_defs val
1393
1395
 
1394
1396
  lexer.cond.pop # group = local_pop
1395
1397
  lexer.cmdarg.pop
@@ -1400,7 +1402,7 @@ rule
1400
1402
 
1401
1403
  # TODO: restore cur_arg ? what's cur_arg?
1402
1404
 
1403
- self.lexer.comments # we don't care about comments in the body
1405
+ self.lexer.ignore_body_comments
1404
1406
  }
1405
1407
  | kBREAK
1406
1408
  {
@@ -1437,8 +1439,17 @@ rule
1437
1439
  k_case: kCASE
1438
1440
  k_for: kFOR
1439
1441
  k_class: kCLASS
1442
+ {
1443
+ self.comments.push self.lexer.comments
1444
+ }
1440
1445
  k_module: kMODULE
1446
+ {
1447
+ self.comments.push self.lexer.comments
1448
+ }
1441
1449
  k_def: kDEF
1450
+ {
1451
+ self.comments.push self.lexer.comments
1452
+ }
1442
1453
  k_do: kDO
1443
1454
  k_do_block: kDO_BLOCK
1444
1455
  k_rescue: kRESCUE
@@ -1499,51 +1510,42 @@ rule
1499
1510
 
1500
1511
  result = block_var args
1501
1512
  }
1502
- | f_marg_list tCOMMA tSTAR f_norm_arg
1513
+ | f_marg_list tCOMMA f_rest_marg
1503
1514
  {
1504
- args, _, _, splat = val
1515
+ args, _, rest = val
1505
1516
 
1506
- result = block_var args, "*#{splat}".to_sym
1517
+ result = block_var args, rest
1507
1518
  }
1508
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1519
+ | f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
1509
1520
  {
1510
- args, _, _, splat, _, args2 = val
1521
+ lhs, _, splat, _, rhs = val
1511
1522
 
1512
- result = block_var args, "*#{splat}".to_sym, args2
1523
+ result = block_var lhs, splat, rhs
1513
1524
  }
1514
- | f_marg_list tCOMMA tSTAR
1525
+ | f_rest_marg
1515
1526
  {
1516
- args, _, _ = val
1527
+ rest, = val
1517
1528
 
1518
- result = block_var args, :*
1529
+ result = block_var rest
1519
1530
  }
1520
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1531
+ | f_rest_marg tCOMMA f_marg_list
1521
1532
  {
1522
- args, _, _, _, args2 = val
1533
+ splat, _, rest = val
1523
1534
 
1524
- result = block_var args, :*, args2
1535
+ result = block_var splat, rest
1525
1536
  }
1526
- | tSTAR f_norm_arg
1527
- {
1528
- _, splat = val
1529
1537
 
1530
- result = block_var :"*#{splat}"
1531
- }
1532
- | tSTAR f_norm_arg tCOMMA f_marg_list
1538
+ f_rest_marg: tSTAR f_norm_arg
1533
1539
  {
1534
- _, splat, _, args = val
1540
+ _, (id, line) = val
1535
1541
 
1536
- result = block_var :"*#{splat}", args
1542
+ result = args ["*#{id}".to_sym]
1543
+ result.line line
1537
1544
  }
1538
1545
  | tSTAR
1539
1546
  {
1540
- result = block_var :*
1541
- }
1542
- | tSTAR tCOMMA f_marg_list
1543
- {
1544
- _, _, args = val
1545
-
1546
- result = block_var :*, args
1547
+ result = args [:*]
1548
+ result.line lexer.lineno # FIX: tSTAR -> line
1547
1549
  }
1548
1550
 
1549
1551
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -1560,8 +1562,8 @@ rule
1560
1562
  }
1561
1563
  | f_block_arg
1562
1564
  {
1563
- line = lexer.lineno
1564
- result = call_args val # TODO: push line down
1565
+ (id, line), = val
1566
+ result = call_args [id]
1565
1567
  result.line line
1566
1568
  }
1567
1569
 
@@ -1670,13 +1672,13 @@ opt_block_args_tail: tCOMMA block_args_tail
1670
1672
 
1671
1673
  bvar: tIDENTIFIER
1672
1674
  {
1673
- id, = val
1674
- line = lexer.lineno
1675
+ (id, line), = val
1675
1676
  result = s(:shadow, id.to_sym).line line
1676
1677
  }
1677
1678
  | f_bad_arg
1678
1679
 
1679
- lambda: {
1680
+ lambda: tLAMBDA
1681
+ {
1680
1682
  self.env.extend :dynamic
1681
1683
  result = [lexer.lineno, lexer.lpar_beg]
1682
1684
  lexer.paren_nest += 1
@@ -1688,14 +1690,14 @@ opt_block_args_tail: tCOMMA block_args_tail
1688
1690
  }
1689
1691
  lambda_body
1690
1692
  {
1691
- (line, lpar), args, _cmdarg, body = val
1693
+ _, (line, lpar), args, _cmdarg, body = val
1692
1694
  lexer.lpar_beg = lpar
1693
1695
 
1694
1696
  lexer.cmdarg.pop
1695
1697
 
1696
1698
  call = s(:lambda).line line
1697
1699
  result = new_iter call, args, body
1698
- result.line = line
1700
+ result.line line
1699
1701
  self.env.unextend # TODO: dynapush & dynapop
1700
1702
  }
1701
1703
 
@@ -1730,23 +1732,28 @@ opt_block_args_tail: tCOMMA block_args_tail
1730
1732
  ## if (nd_type($1) == NODE_YIELD) {
1731
1733
  ## compile_error(PARSER_ARG "block given to yield");
1732
1734
 
1733
- syntax_error "Both block arg and actual block given." if
1734
- val[0].block_pass?
1735
+ cmd, blk = val
1735
1736
 
1736
- val = invert_block_call val if inverted? val
1737
+ syntax_error "Both block arg and actual block given." if
1738
+ cmd.block_pass?
1737
1739
 
1738
- cmd, blk = val
1740
+ if inverted? val then
1741
+ val = invert_block_call val
1742
+ cmd, blk = val
1743
+ end
1739
1744
 
1740
1745
  result = blk
1741
1746
  result.insert 1, cmd
1742
1747
  }
1743
1748
  | block_call call_op2 operation2 opt_paren_args
1744
1749
  {
1745
- result = new_call val[0], val[2].to_sym, val[3]
1750
+ lhs, _, (id, _line), args = val
1751
+
1752
+ result = new_call lhs, id.to_sym, args
1746
1753
  }
1747
1754
  | block_call call_op2 operation2 opt_paren_args brace_block
1748
1755
  {
1749
- iter1, _, name, args, iter2 = val
1756
+ iter1, _, (name, _line), args, iter2 = val
1750
1757
 
1751
1758
  call = new_call iter1, name.to_sym, args
1752
1759
  iter2.insert 1, call
@@ -1755,7 +1762,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1755
1762
  }
1756
1763
  | block_call call_op2 operation2 command_args do_block
1757
1764
  {
1758
- iter1, _, name, args, iter2 = val
1765
+ iter1, _, (name, _line), args, iter2 = val
1759
1766
 
1760
1767
  call = new_call iter1, name.to_sym, args
1761
1768
  iter2.insert 1, call
@@ -1763,28 +1770,29 @@ opt_block_args_tail: tCOMMA block_args_tail
1763
1770
  result = iter2
1764
1771
  }
1765
1772
 
1766
- method_call: fcall
1773
+ method_call: fcall paren_args
1767
1774
  {
1768
- result = self.lexer.lineno
1769
- }
1770
- paren_args
1771
- {
1772
- call, lineno, args = val
1775
+ call, args = val
1773
1776
 
1774
1777
  result = call.concat args.sexp_body if args
1775
- result.line lineno
1776
1778
  }
1777
1779
  | primary_value call_op operation2 opt_paren_args
1778
1780
  {
1779
- result = new_call val[0], val[2].to_sym, val[3], val[1]
1781
+ recv, call_op, (op, _line), args = val
1782
+
1783
+ result = new_call recv, op.to_sym, args, call_op
1780
1784
  }
1781
1785
  | primary_value tCOLON2 operation2 paren_args
1782
1786
  {
1783
- result = new_call val[0], val[2].to_sym, val[3]
1787
+ recv, _, (op, _line), args = val
1788
+
1789
+ result = new_call recv, op.to_sym, args
1784
1790
  }
1785
1791
  | primary_value tCOLON2 operation3
1786
1792
  {
1787
- result = new_call val[0], val[2].to_sym
1793
+ lhs, _, (id, _line) = val
1794
+
1795
+ result = new_call lhs, id.to_sym
1788
1796
  }
1789
1797
  | primary_value call_op paren_args
1790
1798
  {
@@ -1817,7 +1825,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1817
1825
  _, line, body, _ = val
1818
1826
 
1819
1827
  result = body
1820
- result.line = line
1828
+ result.line line
1821
1829
 
1822
1830
  self.env.unextend
1823
1831
  }
@@ -1831,7 +1839,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1831
1839
  _, line, body, _ = val
1832
1840
 
1833
1841
  result = body
1834
- result.line = line
1842
+ result.line line
1835
1843
 
1836
1844
  self.env.unextend
1837
1845
  }
@@ -1860,14 +1868,39 @@ opt_block_args_tail: tCOMMA block_args_tail
1860
1868
  self.env.unextend
1861
1869
  }
1862
1870
 
1871
+ case_args: arg_value
1872
+ {
1873
+ arg, = val
1874
+
1875
+ result = s(:array, arg).line arg.line
1876
+ }
1877
+ | tSTAR arg_value
1878
+ {
1879
+ _, arg = val
1880
+
1881
+ result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
1882
+ }
1883
+ | case_args tCOMMA arg_value
1884
+ {
1885
+ args, _, id = val
1886
+
1887
+ result = self.list_append args, id
1888
+ }
1889
+ | case_args tCOMMA tSTAR arg_value
1890
+ {
1891
+ args, _, _, id = val
1892
+
1893
+ result = self.list_append args, s(:splat, id).line(id.line)
1894
+ }
1895
+
1863
1896
  case_body: k_when
1864
1897
  {
1865
1898
  result = self.lexer.lineno
1866
1899
  }
1867
- args then compstmt cases
1900
+ case_args then compstmt cases
1868
1901
  {
1869
1902
  result = new_when(val[2], val[4])
1870
- result.line = val[1]
1903
+ result.line val[1]
1871
1904
  result << val[5] if val[5]
1872
1905
  }
1873
1906
 
@@ -1913,17 +1946,10 @@ opt_block_args_tail: tCOMMA block_args_tail
1913
1946
 
1914
1947
  literal: numeric
1915
1948
  {
1916
- line = lexer.lineno
1917
- result = s(:lit, val[0])
1918
- result.line = line
1949
+ (lit, line), = val
1950
+ result = s(:lit, lit).line line
1919
1951
  }
1920
1952
  | symbol
1921
- {
1922
- line = lexer.lineno
1923
- result = s(:lit, val[0])
1924
- result.line = line
1925
- }
1926
- | dsym
1927
1953
 
1928
1954
  strings: string
1929
1955
  {
@@ -1934,7 +1960,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1934
1960
 
1935
1961
  string: tCHAR
1936
1962
  {
1937
- debug20 23, val, result
1963
+ debug 37
1938
1964
  }
1939
1965
  | string1
1940
1966
  | string string1
@@ -1944,11 +1970,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1944
1970
 
1945
1971
  string1: tSTRING_BEG string_contents tSTRING_END
1946
1972
  {
1947
- _, str, (_, func) = val
1973
+ (_, line), str, (_, func) = val
1948
1974
 
1949
- str = dedent str if func =~ RubyLexer::STR_FUNC_ICNTNT
1975
+ str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
1950
1976
 
1951
- result = str
1977
+ result = str.line line
1952
1978
  }
1953
1979
  | tSTRING
1954
1980
  {
@@ -1968,11 +1994,15 @@ opt_block_args_tail: tCOMMA block_args_tail
1968
1994
 
1969
1995
  words: tWORDS_BEG tSPACE tSTRING_END
1970
1996
  {
1971
- result = s(:array).line lexer.lineno
1997
+ (_, line), _, _ = val
1998
+
1999
+ result = s(:array).line line
1972
2000
  }
1973
2001
  | tWORDS_BEG word_list tSTRING_END
1974
2002
  {
1975
- result = val[1]
2003
+ (_, line), list, _ = val
2004
+
2005
+ result = list.line line
1976
2006
  }
1977
2007
 
1978
2008
  word_list: none
@@ -1992,18 +2022,20 @@ opt_block_args_tail: tCOMMA block_args_tail
1992
2022
 
1993
2023
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
1994
2024
  {
1995
- result = s(:array).line lexer.lineno
2025
+ (_, line), _, _ = val
2026
+
2027
+ result = s(:array).line line
1996
2028
  }
1997
- | tSYMBOLS_BEG { result = lexer.lineno } symbol_list tSTRING_END
2029
+ | tSYMBOLS_BEG symbol_list tSTRING_END
1998
2030
  {
1999
- _, line, list, _, = val
2000
- list.line = line
2031
+ (_, line), list, _, = val
2032
+ list.line line
2001
2033
  result = list
2002
2034
  }
2003
2035
 
2004
2036
  symbol_list: none
2005
2037
  {
2006
- result = new_symbol_list.line lexer.lineno
2038
+ result = new_symbol_list
2007
2039
  }
2008
2040
  | symbol_list word tSPACE
2009
2041
  {
@@ -2013,20 +2045,28 @@ opt_block_args_tail: tCOMMA block_args_tail
2013
2045
 
2014
2046
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2015
2047
  {
2016
- result = s(:array).line lexer.lineno
2048
+ (_, line), _, _ = val
2049
+
2050
+ result = s(:array).line line
2017
2051
  }
2018
2052
  | tQWORDS_BEG qword_list tSTRING_END
2019
2053
  {
2020
- result = val[1]
2054
+ (_, line), list, _ = val
2055
+
2056
+ result = list.line line
2021
2057
  }
2022
2058
 
2023
2059
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2024
2060
  {
2025
- result = s(:array).line lexer.lineno # FIX
2061
+ (_, line), _, _ = val
2062
+
2063
+ result = s(:array).line line
2026
2064
  }
2027
2065
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2028
2066
  {
2029
- result = val[1]
2067
+ (_, line), list, _ = val
2068
+
2069
+ result = list.line line
2030
2070
  }
2031
2071
 
2032
2072
  qword_list: none
@@ -2049,7 +2089,8 @@ opt_block_args_tail: tCOMMA block_args_tail
2049
2089
 
2050
2090
  string_contents: none
2051
2091
  {
2052
- result = s(:str, "").line lexer.lineno
2092
+ line = prev_value_to_lineno _values.last
2093
+ result = s(:str, +"").line line
2053
2094
  }
2054
2095
  | string_contents string_content
2055
2096
  {
@@ -2124,8 +2165,8 @@ regexp_contents: none
2124
2165
  lexer.brace_nest = brace_nest
2125
2166
  lexer.string_nest = string_nest
2126
2167
 
2127
- lexer.cmdarg.pop
2128
2168
  lexer.cond.pop
2169
+ lexer.cmdarg.pop
2129
2170
 
2130
2171
  lexer.lex_state = oldlex_state
2131
2172
 
@@ -2140,29 +2181,49 @@ regexp_contents: none
2140
2181
  when nil then
2141
2182
  result = s(:evstr).line line
2142
2183
  else
2143
- debug20 25
2184
+ debug 38
2144
2185
  raise "unknown string body: #{stmt.inspect}"
2145
2186
  end
2146
2187
  }
2147
2188
 
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 }
2189
+ string_dvar: tGVAR
2190
+ {
2191
+ (id, line), = val
2192
+ result = s(:gvar, id.to_sym).line line
2193
+ }
2194
+ | tIVAR
2195
+ {
2196
+ (id, line), = val
2197
+ result = s(:ivar, id.to_sym).line line
2198
+ }
2199
+ | tCVAR
2200
+ {
2201
+ (id, line), = val
2202
+ result = s(:cvar, id.to_sym).line line
2203
+ }
2151
2204
  | backref
2152
2205
 
2153
- symbol: tSYMBEG sym
2206
+ symbol: ssym
2207
+ | dsym
2208
+
2209
+ ssym: tSYMBEG sym
2154
2210
  {
2211
+ _, (id, line) = val
2212
+
2155
2213
  lexer.lex_state = EXPR_END
2156
- result = val[1].to_sym
2214
+ result = s(:lit, id.to_sym).line line
2157
2215
  }
2158
2216
  | tSYMBOL
2159
2217
  {
2160
- result = val[0].to_sym
2218
+ (id, line), = val
2219
+
2220
+ lexer.lex_state = EXPR_END
2221
+ result = s(:lit, id.to_sym).line line
2161
2222
  }
2162
2223
 
2163
2224
  sym: fname | tIVAR | tGVAR | tCVAR
2164
2225
 
2165
- dsym: tSYMBEG xstring_contents tSTRING_END
2226
+ dsym: tSYMBEG string_contents tSTRING_END
2166
2227
  {
2167
2228
  _, result, _ = val
2168
2229
 
@@ -2178,14 +2239,15 @@ regexp_contents: none
2178
2239
  when :evstr then
2179
2240
  result = s(:dsym, "", result).line result.line
2180
2241
  else
2181
- debug20 26, val, result
2242
+ debug 39
2182
2243
  end
2183
2244
  }
2184
2245
 
2185
2246
  numeric: simple_numeric
2186
- | tUMINUS_NUM simple_numeric
2247
+ | tUMINUS_NUM simple_numeric =tLOWEST
2187
2248
  {
2188
- result = -val[1] # TODO: pt_testcase
2249
+ _, (num, line) = val
2250
+ result = [-num, line]
2189
2251
  }
2190
2252
 
2191
2253
  simple_numeric: tINTEGER
@@ -2218,8 +2280,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2218
2280
 
2219
2281
  var_ref: user_variable
2220
2282
  {
2221
- var = val[0]
2283
+ raise "NO: #{val.inspect}" if Sexp === val.first
2284
+ (var, line), = val
2222
2285
  result = Sexp === var ? var : self.gettable(var)
2286
+ result.line line
2223
2287
  }
2224
2288
  | keyword_variable
2225
2289
  {
@@ -2234,11 +2298,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2234
2298
  | keyword_variable
2235
2299
  {
2236
2300
  result = self.assignable val[0]
2237
- debug20 29, val, result
2301
+ debug 40
2238
2302
  }
2239
2303
 
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 }
2304
+ backref: tNTH_REF
2305
+ {
2306
+ (ref, line), = val
2307
+ result = s(:nth_ref, ref).line line
2308
+ }
2309
+ | tBACK_REF
2310
+ {
2311
+ (ref, line), = val
2312
+ result = s(:back_ref, ref).line line
2313
+ }
2242
2314
 
2243
2315
  superclass: tLT
2244
2316
  {
@@ -2256,9 +2328,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2256
2328
 
2257
2329
  f_arglist: tLPAREN2 f_args rparen
2258
2330
  {
2259
- result = val[1]
2260
- self.lexer.lex_state = EXPR_BEG
2261
- self.lexer.command_start = true
2331
+ result = end_args val
2262
2332
  }
2263
2333
  | {
2264
2334
  result = self.in_kwarg
@@ -2267,12 +2337,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2267
2337
  }
2268
2338
  f_args term
2269
2339
  {
2270
- kwarg, args, _ = val
2271
-
2272
- self.in_kwarg = kwarg
2273
- result = args
2274
- lexer.lex_state = EXPR_BEG
2275
- lexer.command_start = true
2340
+ result = end_args val
2276
2341
  }
2277
2342
 
2278
2343
  args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -2357,9 +2422,9 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2357
2422
  |
2358
2423
  {
2359
2424
  result = args val
2425
+ # result.line lexer.lineno
2360
2426
  }
2361
2427
 
2362
- args_forward: tBDOT3
2363
2428
 
2364
2429
  f_bad_arg: tCONSTANT
2365
2430
  {
@@ -2381,10 +2446,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2381
2446
  f_norm_arg: f_bad_arg
2382
2447
  | tIDENTIFIER
2383
2448
  {
2384
- identifier = val[0].to_sym
2449
+ (id, line), = val
2450
+ identifier = id.to_sym
2385
2451
  self.env[identifier] = :lvar
2386
2452
 
2387
- result = identifier
2453
+ result = [identifier, line]
2388
2454
  }
2389
2455
 
2390
2456
  f_arg_asgn: f_norm_arg
@@ -2392,22 +2458,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2392
2458
  f_arg_item: f_arg_asgn
2393
2459
  | tLPAREN f_margs rparen
2394
2460
  {
2395
- result = val[1]
2461
+ _, margs, _ = val
2462
+
2463
+ result = margs
2396
2464
  }
2397
2465
 
2398
2466
  f_arg: f_arg_item
2399
2467
  {
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
2468
+ result = new_arg val
2411
2469
  }
2412
2470
  | f_arg tCOMMA f_arg_item
2413
2471
  {
@@ -2419,7 +2477,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2419
2477
  result = s(:args, list).line list.line
2420
2478
  end
2421
2479
 
2422
- result << item
2480
+ result << (Sexp === item ? item : item.first)
2423
2481
  }
2424
2482
 
2425
2483
  f_label: tLABEL
@@ -2480,27 +2538,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2480
2538
  kwrest_mark: tPOW
2481
2539
  | tDSTAR
2482
2540
 
2541
+
2483
2542
  f_kwrest: kwrest_mark tIDENTIFIER
2484
2543
  {
2485
- name = val[1].to_sym
2486
- self.assignable name
2487
- result = :"**#{name}"
2544
+ _, (id, line) = val
2545
+
2546
+ name = id.to_sym
2547
+ self.assignable [name, line]
2548
+ result = [:"**#{name}", line]
2488
2549
  }
2489
2550
  | kwrest_mark
2490
2551
  {
2491
- result = :"**"
2492
- self.env[result] = :lvar
2552
+ id = :"**"
2553
+ self.env[id] = :lvar # TODO: needed?!?
2554
+ result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
2493
2555
  }
2494
2556
 
2495
2557
  f_opt: f_arg_asgn tEQL arg_value
2496
2558
  {
2497
- result = self.assignable val[0], val[2]
2559
+ lhs, _, rhs = val
2560
+ result = self.assignable lhs, rhs
2498
2561
  # TODO: detect duplicate names
2499
2562
  }
2500
2563
 
2501
2564
  f_block_opt: f_arg_asgn tEQL primary_value
2502
2565
  {
2503
- result = self.assignable val[0], val[2]
2566
+ lhs, _, rhs = val
2567
+ result = self.assignable lhs, rhs
2504
2568
  }
2505
2569
 
2506
2570
  f_block_optarg: f_block_opt
@@ -2530,30 +2594,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2530
2594
  f_rest_arg: restarg_mark tIDENTIFIER
2531
2595
  {
2532
2596
  # TODO: differs from parse.y - needs tests
2533
- name = val[1].to_sym
2534
- self.assignable name
2535
- result = :"*#{name}"
2597
+ _, (id, line) = val
2598
+ name = id.to_sym
2599
+ self.assignable [name, line]
2600
+ result = [:"*#{name}", line]
2536
2601
  }
2537
2602
  | restarg_mark
2538
2603
  {
2539
2604
  name = :"*"
2540
2605
  self.env[name] = :lvar
2541
- result = name
2606
+ result = [name, lexer.lineno] # FIX: tSTAR to include lineno
2542
2607
  }
2543
2608
 
2544
2609
  blkarg_mark: tAMPER2 | tAMPER
2545
2610
 
2546
2611
  f_block_arg: blkarg_mark tIDENTIFIER
2547
2612
  {
2548
- identifier = val[1].to_sym
2613
+ _, (id, line) = val
2614
+ identifier = id.to_sym
2549
2615
 
2550
2616
  self.env[identifier] = :lvar
2551
- result = "&#{identifier}".to_sym
2617
+ result = ["&#{identifier}".to_sym, line]
2552
2618
  }
2553
2619
 
2554
2620
  opt_f_block_arg: tCOMMA f_block_arg
2555
2621
  {
2556
- result = val[1]
2622
+ _, arg = val
2623
+ result = arg
2557
2624
  }
2558
2625
  |
2559
2626
  {
@@ -2602,9 +2669,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2602
2669
  }
2603
2670
  | tSTRING_BEG string_contents tLABEL_END arg_value
2604
2671
  {
2605
- _, sym, _, value = val
2672
+ (_, line), sym, _, value = val
2673
+
2606
2674
  sym.sexp_type = :dsym
2607
- result = s(:array, sym, value).line sym.line
2675
+
2676
+ result = s(:array, sym, value).line line
2608
2677
  }
2609
2678
  | tDSTAR arg_value
2610
2679
  {