ruby_parser 3.17.0 → 3.18.0

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