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/ruby26_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
@@ -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
-
702
- fsym: fname | symbol
703
716
 
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
@@ -850,8 +858,9 @@ rule
850
858
  }
851
859
  | tUMINUS_NUM simple_numeric tPOW arg
852
860
  {
853
- lit = s(:lit, val[1]).line lexer.lineno
854
- 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)), :"-@")
855
864
 
856
865
  }
857
866
  | tUPLUS arg
@@ -950,12 +959,12 @@ rule
950
959
 
951
960
  rel_expr: arg relop arg =tGT
952
961
  {
953
- lhs, op, rhs = val
962
+ lhs, (op, _), rhs = val
954
963
  result = new_call lhs, op.to_sym, argl(rhs)
955
964
  }
956
965
  | rel_expr relop arg =tGT
957
966
  {
958
- lhs, op, rhs = val
967
+ lhs, (op, _), rhs = val
959
968
  warn "comparison '%s' after comparison", op
960
969
  result = new_call lhs, op.to_sym, argl(rhs)
961
970
  }
@@ -1146,8 +1155,9 @@ rule
1146
1155
  | backref
1147
1156
  | tFID
1148
1157
  {
1149
- msg, = val
1158
+ (msg, line), = val
1150
1159
  result = new_call nil, msg.to_sym
1160
+ result.line line
1151
1161
  }
1152
1162
  | k_begin
1153
1163
  {
@@ -1189,15 +1199,15 @@ rule
1189
1199
  }
1190
1200
  | primary_value tCOLON2 tCONSTANT
1191
1201
  {
1192
- expr, _, id = val
1202
+ expr, _, (id, _line) = val
1193
1203
 
1194
1204
  result = s(:colon2, expr, id.to_sym).line expr.line
1195
1205
  }
1196
1206
  | tCOLON3 tCONSTANT
1197
1207
  {
1198
- _, id = val
1208
+ _, (id, line) = val
1199
1209
 
1200
- result = s(:colon3, id.to_sym).line lexer.lineno
1210
+ result = s(:colon3, id.to_sym).line line
1201
1211
  }
1202
1212
  | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1203
1213
  {
@@ -1244,7 +1254,7 @@ rule
1244
1254
  }
1245
1255
  | kNOT tLPAREN2 rparen
1246
1256
  {
1247
- debug20 14, val, result
1257
+ debug 20
1248
1258
  }
1249
1259
  | fcall brace_block
1250
1260
  {
@@ -1262,9 +1272,10 @@ rule
1262
1272
  iter.insert 1, call # FIX
1263
1273
  result = iter
1264
1274
  }
1265
- | tLAMBDA lambda
1275
+ | lambda
1266
1276
  {
1267
- result = val[1] # TODO: fix lineno
1277
+ expr, = val
1278
+ result = expr
1268
1279
  }
1269
1280
  | k_if expr_value then compstmt if_tail k_end
1270
1281
  {
@@ -1307,7 +1318,6 @@ rule
1307
1318
  }
1308
1319
  cpath superclass
1309
1320
  {
1310
- self.comments.push self.lexer.comments
1311
1321
  if (self.in_def || self.in_single > 0) then
1312
1322
  yyerror "class definition in method body"
1313
1323
  end
@@ -1317,7 +1327,7 @@ rule
1317
1327
  {
1318
1328
  result = new_class val
1319
1329
  self.env.unextend
1320
- self.lexer.comments # we don't care about comments in the body
1330
+ self.lexer.ignore_body_comments
1321
1331
  }
1322
1332
  | k_class tLSHFT
1323
1333
  {
@@ -1338,7 +1348,7 @@ rule
1338
1348
  {
1339
1349
  result = new_sclass val
1340
1350
  self.env.unextend
1341
- self.lexer.comments # we don't care about comments in the body
1351
+ self.lexer.ignore_body_comments
1342
1352
  }
1343
1353
  | k_module
1344
1354
  {
@@ -1346,7 +1356,6 @@ rule
1346
1356
  }
1347
1357
  cpath
1348
1358
  {
1349
- self.comments.push self.lexer.comments
1350
1359
  yyerror "module definition in method body" if
1351
1360
  self.in_def or self.in_single > 0
1352
1361
 
@@ -1356,7 +1365,7 @@ rule
1356
1365
  {
1357
1366
  result = new_module val
1358
1367
  self.env.unextend
1359
- self.lexer.comments # we don't care about comments in the body
1368
+ self.lexer.ignore_body_comments
1360
1369
  }
1361
1370
  | k_def fname
1362
1371
  {
@@ -1366,21 +1375,17 @@ rule
1366
1375
  self.env.extend
1367
1376
  lexer.cmdarg.push false
1368
1377
  lexer.cond.push false
1369
-
1370
- self.comments.push self.lexer.comments
1371
1378
  }
1372
- f_arglist bodystmt { result = lexer.lineno } k_end
1379
+ f_arglist bodystmt k_end
1373
1380
  {
1374
- in_def = val[2]
1375
-
1376
- result = new_defn val
1381
+ result, in_def = new_defn val
1377
1382
 
1378
1383
  lexer.cond.pop # group = local_pop
1379
1384
  lexer.cmdarg.pop
1380
1385
  self.env.unextend
1381
1386
  self.in_def = in_def
1382
1387
 
1383
- self.lexer.comments # we don't care about comments in the body
1388
+ self.lexer.ignore_body_comments
1384
1389
  }
1385
1390
  | k_def singleton dot_or_colon
1386
1391
  {
@@ -1388,7 +1393,7 @@ rule
1388
1393
  }
1389
1394
  fname
1390
1395
  {
1391
- result = [self.in_def, lexer.lineno]
1396
+ result = self.in_def
1392
1397
 
1393
1398
  self.in_single += 1 # TODO: remove?
1394
1399
 
@@ -1398,13 +1403,18 @@ rule
1398
1403
  lexer.cond.push false
1399
1404
 
1400
1405
  lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
1401
- self.comments.push self.lexer.comments
1402
1406
  }
1403
1407
  f_arglist bodystmt k_end
1404
1408
  {
1405
- _, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
1406
1409
 
1407
- 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
1408
1418
 
1409
1419
  lexer.cond.pop # group = local_pop
1410
1420
  lexer.cmdarg.pop
@@ -1415,7 +1425,7 @@ rule
1415
1425
 
1416
1426
  # TODO: restore cur_arg ? what's cur_arg?
1417
1427
 
1418
- self.lexer.comments # we don't care about comments in the body
1428
+ self.lexer.ignore_body_comments
1419
1429
  }
1420
1430
  | kBREAK
1421
1431
  {
@@ -1452,8 +1462,17 @@ rule
1452
1462
  k_case: kCASE
1453
1463
  k_for: kFOR
1454
1464
  k_class: kCLASS
1465
+ {
1466
+ self.comments.push self.lexer.comments
1467
+ }
1455
1468
  k_module: kMODULE
1469
+ {
1470
+ self.comments.push self.lexer.comments
1471
+ }
1456
1472
  k_def: kDEF
1473
+ {
1474
+ self.comments.push self.lexer.comments
1475
+ }
1457
1476
  k_do: kDO
1458
1477
  k_do_block: kDO_BLOCK
1459
1478
  k_rescue: kRESCUE
@@ -1514,51 +1533,42 @@ rule
1514
1533
 
1515
1534
  result = block_var args
1516
1535
  }
1517
- | f_marg_list tCOMMA tSTAR f_norm_arg
1536
+ | f_marg_list tCOMMA f_rest_marg
1518
1537
  {
1519
- args, _, _, splat = val
1538
+ args, _, rest = val
1520
1539
 
1521
- result = block_var args, "*#{splat}".to_sym
1540
+ result = block_var args, rest
1522
1541
  }
1523
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1542
+ | f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
1524
1543
  {
1525
- args, _, _, splat, _, args2 = val
1544
+ lhs, _, splat, _, rhs = val
1526
1545
 
1527
- result = block_var args, "*#{splat}".to_sym, args2
1546
+ result = block_var lhs, splat, rhs
1528
1547
  }
1529
- | f_marg_list tCOMMA tSTAR
1548
+ | f_rest_marg
1530
1549
  {
1531
- args, _, _ = val
1550
+ rest, = val
1532
1551
 
1533
- result = block_var args, :*
1552
+ result = block_var rest
1534
1553
  }
1535
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1554
+ | f_rest_marg tCOMMA f_marg_list
1536
1555
  {
1537
- args, _, _, _, args2 = val
1556
+ splat, _, rest = val
1538
1557
 
1539
- result = block_var args, :*, args2
1558
+ result = block_var splat, rest
1540
1559
  }
1541
- | tSTAR f_norm_arg
1542
- {
1543
- _, splat = val
1544
1560
 
1545
- result = block_var :"*#{splat}"
1546
- }
1547
- | tSTAR f_norm_arg tCOMMA f_marg_list
1561
+ f_rest_marg: tSTAR f_norm_arg
1548
1562
  {
1549
- _, splat, _, args = val
1563
+ _, (id, line) = val
1550
1564
 
1551
- result = block_var :"*#{splat}", args
1565
+ result = args ["*#{id}".to_sym]
1566
+ result.line line
1552
1567
  }
1553
1568
  | tSTAR
1554
1569
  {
1555
- result = block_var :*
1556
- }
1557
- | tSTAR tCOMMA f_marg_list
1558
- {
1559
- _, _, args = val
1560
-
1561
- result = block_var :*, args
1570
+ result = args [:*]
1571
+ result.line lexer.lineno # FIX: tSTAR -> line
1562
1572
  }
1563
1573
 
1564
1574
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -1575,8 +1585,8 @@ rule
1575
1585
  }
1576
1586
  | f_block_arg
1577
1587
  {
1578
- line = lexer.lineno
1579
- result = call_args val # TODO: push line down
1588
+ (id, line), = val
1589
+ result = call_args [id]
1580
1590
  result.line line
1581
1591
  }
1582
1592
 
@@ -1685,13 +1695,13 @@ opt_block_args_tail: tCOMMA block_args_tail
1685
1695
 
1686
1696
  bvar: tIDENTIFIER
1687
1697
  {
1688
- id, = val
1689
- line = lexer.lineno
1698
+ (id, line), = val
1690
1699
  result = s(:shadow, id.to_sym).line line
1691
1700
  }
1692
1701
  | f_bad_arg
1693
1702
 
1694
- lambda: {
1703
+ lambda: tLAMBDA
1704
+ {
1695
1705
  self.env.extend :dynamic
1696
1706
  result = [lexer.lineno, lexer.lpar_beg]
1697
1707
  lexer.paren_nest += 1
@@ -1703,14 +1713,14 @@ opt_block_args_tail: tCOMMA block_args_tail
1703
1713
  }
1704
1714
  lambda_body
1705
1715
  {
1706
- (line, lpar), args, _cmdarg, body = val
1716
+ _, (line, lpar), args, _cmdarg, body = val
1707
1717
  lexer.lpar_beg = lpar
1708
1718
 
1709
1719
  lexer.cmdarg.pop
1710
1720
 
1711
1721
  call = s(:lambda).line line
1712
1722
  result = new_iter call, args, body
1713
- result.line = line
1723
+ result.line line
1714
1724
  self.env.unextend # TODO: dynapush & dynapop
1715
1725
  }
1716
1726
 
@@ -1745,23 +1755,28 @@ opt_block_args_tail: tCOMMA block_args_tail
1745
1755
  ## if (nd_type($1) == NODE_YIELD) {
1746
1756
  ## compile_error(PARSER_ARG "block given to yield");
1747
1757
 
1748
- syntax_error "Both block arg and actual block given." if
1749
- val[0].block_pass?
1758
+ cmd, blk = val
1750
1759
 
1751
- val = invert_block_call val if inverted? val
1760
+ syntax_error "Both block arg and actual block given." if
1761
+ cmd.block_pass?
1752
1762
 
1753
- cmd, blk = val
1763
+ if inverted? val then
1764
+ val = invert_block_call val
1765
+ cmd, blk = val
1766
+ end
1754
1767
 
1755
1768
  result = blk
1756
1769
  result.insert 1, cmd
1757
1770
  }
1758
1771
  | block_call call_op2 operation2 opt_paren_args
1759
1772
  {
1760
- 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
1761
1776
  }
1762
1777
  | block_call call_op2 operation2 opt_paren_args brace_block
1763
1778
  {
1764
- iter1, _, name, args, iter2 = val
1779
+ iter1, _, (name, _line), args, iter2 = val
1765
1780
 
1766
1781
  call = new_call iter1, name.to_sym, args
1767
1782
  iter2.insert 1, call
@@ -1770,7 +1785,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1770
1785
  }
1771
1786
  | block_call call_op2 operation2 command_args do_block
1772
1787
  {
1773
- iter1, _, name, args, iter2 = val
1788
+ iter1, _, (name, _line), args, iter2 = val
1774
1789
 
1775
1790
  call = new_call iter1, name.to_sym, args
1776
1791
  iter2.insert 1, call
@@ -1778,28 +1793,29 @@ opt_block_args_tail: tCOMMA block_args_tail
1778
1793
  result = iter2
1779
1794
  }
1780
1795
 
1781
- method_call: fcall
1782
- {
1783
- result = self.lexer.lineno
1784
- }
1785
- paren_args
1796
+ method_call: fcall paren_args
1786
1797
  {
1787
- call, lineno, args = val
1798
+ call, args = val
1788
1799
 
1789
1800
  result = call.concat args.sexp_body if args
1790
- result.line lineno
1791
1801
  }
1792
1802
  | primary_value call_op operation2 opt_paren_args
1793
1803
  {
1794
- 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
1795
1807
  }
1796
1808
  | primary_value tCOLON2 operation2 paren_args
1797
1809
  {
1798
- 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
1799
1813
  }
1800
1814
  | primary_value tCOLON2 operation3
1801
1815
  {
1802
- result = new_call val[0], val[2].to_sym
1816
+ lhs, _, (id, _line) = val
1817
+
1818
+ result = new_call lhs, id.to_sym
1803
1819
  }
1804
1820
  | primary_value call_op paren_args
1805
1821
  {
@@ -1832,7 +1848,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1832
1848
  _, line, body, _ = val
1833
1849
 
1834
1850
  result = body
1835
- result.line = line
1851
+ result.line line
1836
1852
 
1837
1853
  self.env.unextend
1838
1854
  }
@@ -1846,7 +1862,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1846
1862
  _, line, body, _ = val
1847
1863
 
1848
1864
  result = body
1849
- result.line = line
1865
+ result.line line
1850
1866
 
1851
1867
  self.env.unextend
1852
1868
  }
@@ -1875,14 +1891,39 @@ opt_block_args_tail: tCOMMA block_args_tail
1875
1891
  self.env.unextend
1876
1892
  }
1877
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
+
1878
1919
  case_body: k_when
1879
1920
  {
1880
1921
  result = self.lexer.lineno
1881
1922
  }
1882
- args then compstmt cases
1923
+ case_args then compstmt cases
1883
1924
  {
1884
1925
  result = new_when(val[2], val[4])
1885
- result.line = val[1]
1926
+ result.line val[1]
1886
1927
  result << val[5] if val[5]
1887
1928
  }
1888
1929
 
@@ -1928,17 +1969,10 @@ opt_block_args_tail: tCOMMA block_args_tail
1928
1969
 
1929
1970
  literal: numeric
1930
1971
  {
1931
- line = lexer.lineno
1932
- result = s(:lit, val[0])
1933
- result.line = line
1972
+ (lit, line), = val
1973
+ result = s(:lit, lit).line line
1934
1974
  }
1935
1975
  | symbol
1936
- {
1937
- line = lexer.lineno
1938
- result = s(:lit, val[0])
1939
- result.line = line
1940
- }
1941
- | dsym
1942
1976
 
1943
1977
  strings: string
1944
1978
  {
@@ -1949,7 +1983,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1949
1983
 
1950
1984
  string: tCHAR
1951
1985
  {
1952
- debug20 23, val, result
1986
+ debug 37
1953
1987
  }
1954
1988
  | string1
1955
1989
  | string string1
@@ -1959,11 +1993,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1959
1993
 
1960
1994
  string1: tSTRING_BEG string_contents tSTRING_END
1961
1995
  {
1962
- _, str, (_, func) = val
1996
+ (_, line), str, (_, func) = val
1963
1997
 
1964
- str = dedent str if func =~ RubyLexer::STR_FUNC_ICNTNT
1998
+ str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
1965
1999
 
1966
- result = str
2000
+ result = str.line line
1967
2001
  }
1968
2002
  | tSTRING
1969
2003
  {
@@ -1983,11 +2017,15 @@ opt_block_args_tail: tCOMMA block_args_tail
1983
2017
 
1984
2018
  words: tWORDS_BEG tSPACE tSTRING_END
1985
2019
  {
1986
- result = s(:array).line lexer.lineno
2020
+ (_, line), _, _ = val
2021
+
2022
+ result = s(:array).line line
1987
2023
  }
1988
2024
  | tWORDS_BEG word_list tSTRING_END
1989
2025
  {
1990
- result = val[1]
2026
+ (_, line), list, _ = val
2027
+
2028
+ result = list.line line
1991
2029
  }
1992
2030
 
1993
2031
  word_list: none
@@ -2007,18 +2045,20 @@ opt_block_args_tail: tCOMMA block_args_tail
2007
2045
 
2008
2046
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2009
2047
  {
2010
- result = s(:array).line lexer.lineno
2048
+ (_, line), _, _ = val
2049
+
2050
+ result = s(:array).line line
2011
2051
  }
2012
- | tSYMBOLS_BEG { result = lexer.lineno } symbol_list tSTRING_END
2052
+ | tSYMBOLS_BEG symbol_list tSTRING_END
2013
2053
  {
2014
- _, line, list, _, = val
2015
- list.line = line
2054
+ (_, line), list, _, = val
2055
+ list.line line
2016
2056
  result = list
2017
2057
  }
2018
2058
 
2019
2059
  symbol_list: none
2020
2060
  {
2021
- result = new_symbol_list.line lexer.lineno
2061
+ result = new_symbol_list
2022
2062
  }
2023
2063
  | symbol_list word tSPACE
2024
2064
  {
@@ -2028,20 +2068,28 @@ opt_block_args_tail: tCOMMA block_args_tail
2028
2068
 
2029
2069
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2030
2070
  {
2031
- result = s(:array).line lexer.lineno
2071
+ (_, line), _, _ = val
2072
+
2073
+ result = s(:array).line line
2032
2074
  }
2033
2075
  | tQWORDS_BEG qword_list tSTRING_END
2034
2076
  {
2035
- result = val[1]
2077
+ (_, line), list, _ = val
2078
+
2079
+ result = list.line line
2036
2080
  }
2037
2081
 
2038
2082
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2039
2083
  {
2040
- result = s(:array).line lexer.lineno # FIX
2084
+ (_, line), _, _ = val
2085
+
2086
+ result = s(:array).line line
2041
2087
  }
2042
2088
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2043
2089
  {
2044
- result = val[1]
2090
+ (_, line), list, _ = val
2091
+
2092
+ result = list.line line
2045
2093
  }
2046
2094
 
2047
2095
  qword_list: none
@@ -2064,7 +2112,8 @@ opt_block_args_tail: tCOMMA block_args_tail
2064
2112
 
2065
2113
  string_contents: none
2066
2114
  {
2067
- result = s(:str, "").line lexer.lineno
2115
+ line = prev_value_to_lineno _values.last
2116
+ result = s(:str, +"").line line
2068
2117
  }
2069
2118
  | string_contents string_content
2070
2119
  {
@@ -2139,8 +2188,8 @@ regexp_contents: none
2139
2188
  lexer.brace_nest = brace_nest
2140
2189
  lexer.string_nest = string_nest
2141
2190
 
2142
- lexer.cmdarg.pop
2143
2191
  lexer.cond.pop
2192
+ lexer.cmdarg.pop
2144
2193
 
2145
2194
  lexer.lex_state = oldlex_state
2146
2195
 
@@ -2155,29 +2204,49 @@ regexp_contents: none
2155
2204
  when nil then
2156
2205
  result = s(:evstr).line line
2157
2206
  else
2158
- debug20 25
2207
+ debug 38
2159
2208
  raise "unknown string body: #{stmt.inspect}"
2160
2209
  end
2161
2210
  }
2162
2211
 
2163
- string_dvar: tGVAR { result = s(:gvar, val[0].to_sym).line lexer.lineno }
2164
- | tIVAR { result = s(:ivar, val[0].to_sym).line lexer.lineno }
2165
- | tCVAR { result = s(:cvar, val[0].to_sym).line lexer.lineno }
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
+ }
2166
2227
  | backref
2167
2228
 
2168
- symbol: tSYMBEG sym
2229
+ symbol: ssym
2230
+ | dsym
2231
+
2232
+ ssym: tSYMBEG sym
2169
2233
  {
2234
+ _, (id, line) = val
2235
+
2170
2236
  lexer.lex_state = EXPR_END
2171
- result = val[1].to_sym
2237
+ result = s(:lit, id.to_sym).line line
2172
2238
  }
2173
2239
  | tSYMBOL
2174
2240
  {
2175
- 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
2176
2245
  }
2177
2246
 
2178
2247
  sym: fname | tIVAR | tGVAR | tCVAR
2179
2248
 
2180
- dsym: tSYMBEG xstring_contents tSTRING_END
2249
+ dsym: tSYMBEG string_contents tSTRING_END
2181
2250
  {
2182
2251
  _, result, _ = val
2183
2252
 
@@ -2193,14 +2262,15 @@ regexp_contents: none
2193
2262
  when :evstr then
2194
2263
  result = s(:dsym, "", result).line result.line
2195
2264
  else
2196
- debug20 26, val, result
2265
+ debug 39
2197
2266
  end
2198
2267
  }
2199
2268
 
2200
2269
  numeric: simple_numeric
2201
- | tUMINUS_NUM simple_numeric
2270
+ | tUMINUS_NUM simple_numeric =tLOWEST
2202
2271
  {
2203
- result = -val[1] # TODO: pt_testcase
2272
+ _, (num, line) = val
2273
+ result = [-num, line]
2204
2274
  }
2205
2275
 
2206
2276
  simple_numeric: tINTEGER
@@ -2233,8 +2303,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2233
2303
 
2234
2304
  var_ref: user_variable
2235
2305
  {
2236
- var = val[0]
2306
+ raise "NO: #{val.inspect}" if Sexp === val.first
2307
+ (var, line), = val
2237
2308
  result = Sexp === var ? var : self.gettable(var)
2309
+ result.line line
2238
2310
  }
2239
2311
  | keyword_variable
2240
2312
  {
@@ -2249,11 +2321,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2249
2321
  | keyword_variable
2250
2322
  {
2251
2323
  result = self.assignable val[0]
2252
- debug20 29, val, result
2324
+ debug 40
2253
2325
  }
2254
2326
 
2255
- backref: tNTH_REF { result = s(:nth_ref, val[0]).line lexer.lineno }
2256
- | tBACK_REF { result = s(:back_ref, val[0]).line lexer.lineno }
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
+ }
2257
2337
 
2258
2338
  superclass: tLT
2259
2339
  {
@@ -2271,9 +2351,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2271
2351
 
2272
2352
  f_arglist: tLPAREN2 f_args rparen
2273
2353
  {
2274
- result = val[1]
2275
- self.lexer.lex_state = EXPR_BEG
2276
- self.lexer.command_start = true
2354
+ result = end_args val
2277
2355
  }
2278
2356
  | {
2279
2357
  result = self.in_kwarg
@@ -2282,12 +2360,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2282
2360
  }
2283
2361
  f_args term
2284
2362
  {
2285
- kwarg, args, _ = val
2286
-
2287
- self.in_kwarg = kwarg
2288
- result = args
2289
- lexer.lex_state = EXPR_BEG
2290
- lexer.command_start = true
2363
+ result = end_args val
2291
2364
  }
2292
2365
 
2293
2366
  args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -2372,6 +2445,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2372
2445
  |
2373
2446
  {
2374
2447
  result = args val
2448
+ # result.line lexer.lineno
2375
2449
  }
2376
2450
 
2377
2451
 
@@ -2395,10 +2469,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2395
2469
  f_norm_arg: f_bad_arg
2396
2470
  | tIDENTIFIER
2397
2471
  {
2398
- identifier = val[0].to_sym
2472
+ (id, line), = val
2473
+ identifier = id.to_sym
2399
2474
  self.env[identifier] = :lvar
2400
2475
 
2401
- result = identifier
2476
+ result = [identifier, line]
2402
2477
  }
2403
2478
 
2404
2479
  f_arg_asgn: f_norm_arg
@@ -2406,22 +2481,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2406
2481
  f_arg_item: f_arg_asgn
2407
2482
  | tLPAREN f_margs rparen
2408
2483
  {
2409
- result = val[1]
2484
+ _, margs, _ = val
2485
+
2486
+ result = margs
2410
2487
  }
2411
2488
 
2412
2489
  f_arg: f_arg_item
2413
2490
  {
2414
- arg, = val
2415
-
2416
- case arg
2417
- when Symbol then
2418
- result = s(:args, arg).line lexer.lineno
2419
- when Sexp then
2420
- result = arg
2421
- else
2422
- debug20 32
2423
- raise "Unknown f_arg type: #{val.inspect}"
2424
- end
2491
+ result = new_arg val
2425
2492
  }
2426
2493
  | f_arg tCOMMA f_arg_item
2427
2494
  {
@@ -2433,7 +2500,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2433
2500
  result = s(:args, list).line list.line
2434
2501
  end
2435
2502
 
2436
- result << item
2503
+ result << (Sexp === item ? item : item.first)
2437
2504
  }
2438
2505
 
2439
2506
  f_label: tLABEL
@@ -2494,27 +2561,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2494
2561
  kwrest_mark: tPOW
2495
2562
  | tDSTAR
2496
2563
 
2564
+
2497
2565
  f_kwrest: kwrest_mark tIDENTIFIER
2498
2566
  {
2499
- name = val[1].to_sym
2500
- self.assignable name
2501
- result = :"**#{name}"
2567
+ _, (id, line) = val
2568
+
2569
+ name = id.to_sym
2570
+ self.assignable [name, line]
2571
+ result = [:"**#{name}", line]
2502
2572
  }
2503
2573
  | kwrest_mark
2504
2574
  {
2505
- result = :"**"
2506
- self.env[result] = :lvar
2575
+ id = :"**"
2576
+ self.env[id] = :lvar # TODO: needed?!?
2577
+ result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
2507
2578
  }
2508
2579
 
2509
2580
  f_opt: f_arg_asgn tEQL arg_value
2510
2581
  {
2511
- result = self.assignable val[0], val[2]
2582
+ lhs, _, rhs = val
2583
+ result = self.assignable lhs, rhs
2512
2584
  # TODO: detect duplicate names
2513
2585
  }
2514
2586
 
2515
2587
  f_block_opt: f_arg_asgn tEQL primary_value
2516
2588
  {
2517
- result = self.assignable val[0], val[2]
2589
+ lhs, _, rhs = val
2590
+ result = self.assignable lhs, rhs
2518
2591
  }
2519
2592
 
2520
2593
  f_block_optarg: f_block_opt
@@ -2544,30 +2617,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2544
2617
  f_rest_arg: restarg_mark tIDENTIFIER
2545
2618
  {
2546
2619
  # TODO: differs from parse.y - needs tests
2547
- name = val[1].to_sym
2548
- self.assignable name
2549
- result = :"*#{name}"
2620
+ _, (id, line) = val
2621
+ name = id.to_sym
2622
+ self.assignable [name, line]
2623
+ result = [:"*#{name}", line]
2550
2624
  }
2551
2625
  | restarg_mark
2552
2626
  {
2553
2627
  name = :"*"
2554
2628
  self.env[name] = :lvar
2555
- result = name
2629
+ result = [name, lexer.lineno] # FIX: tSTAR to include lineno
2556
2630
  }
2557
2631
 
2558
2632
  blkarg_mark: tAMPER2 | tAMPER
2559
2633
 
2560
2634
  f_block_arg: blkarg_mark tIDENTIFIER
2561
2635
  {
2562
- identifier = val[1].to_sym
2636
+ _, (id, line) = val
2637
+ identifier = id.to_sym
2563
2638
 
2564
2639
  self.env[identifier] = :lvar
2565
- result = "&#{identifier}".to_sym
2640
+ result = ["&#{identifier}".to_sym, line]
2566
2641
  }
2567
2642
 
2568
2643
  opt_f_block_arg: tCOMMA f_block_arg
2569
2644
  {
2570
- result = val[1]
2645
+ _, arg = val
2646
+ result = arg
2571
2647
  }
2572
2648
  |
2573
2649
  {
@@ -2616,9 +2692,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2616
2692
  }
2617
2693
  | tSTRING_BEG string_contents tLABEL_END arg_value
2618
2694
  {
2619
- _, sym, _, value = val
2695
+ (_, line), sym, _, value = val
2696
+
2620
2697
  sym.sexp_type = :dsym
2621
- result = s(:array, sym, value).line sym.line
2698
+
2699
+ result = s(:array, sym, value).line line
2622
2700
  }
2623
2701
  | tDSTAR arg_value
2624
2702
  {