ruby_parser 3.17.0 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ruby21_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
 
24
24
  preclow
@@ -77,7 +77,7 @@ rule
77
77
  | klBEGIN
78
78
  {
79
79
  if (self.in_def || self.in_single > 0) then
80
- debug20 1
80
+ debug 11
81
81
  yyerror "BEGIN in method"
82
82
  end
83
83
  self.env.extend
@@ -102,7 +102,9 @@ rule
102
102
  bodystmt: compstmt opt_rescue k_else
103
103
  {
104
104
  res = _values[-2]
105
- yyerror "else without rescue is useless" unless res
105
+ # TODO: move down to main match so I can just use val
106
+
107
+ warn "else without rescue is useless" unless res
106
108
  }
107
109
  compstmt
108
110
  opt_ensure
@@ -132,7 +134,7 @@ rule
132
134
  | error stmt
133
135
  {
134
136
  result = val[1]
135
- debug20 2, val, result
137
+ debug 12
136
138
  }
137
139
 
138
140
  stmt_or_begin: stmt
@@ -140,6 +142,10 @@ rule
140
142
  {
141
143
  yyerror "BEGIN is permitted only at toplevel"
142
144
  }
145
+ begin_block
146
+ {
147
+ result = val[2] # wtf?
148
+ }
143
149
 
144
150
  stmt: kALIAS fitem
145
151
  {
@@ -152,12 +158,12 @@ rule
152
158
  }
153
159
  | kALIAS tGVAR tGVAR
154
160
  {
155
- (_, line), lhs, rhs = val
161
+ (_, line), (lhs, _), (rhs, _) = val
156
162
  result = s(:valias, lhs.to_sym, rhs.to_sym).line line
157
163
  }
158
164
  | kALIAS tGVAR tBACK_REF
159
165
  {
160
- (_, line), lhs, rhs = val
166
+ (_, line), (lhs, _), (rhs, _) = val
161
167
  result = s(:valias, lhs.to_sym, :"$#{rhs}").line line
162
168
  }
163
169
  | kALIAS tGVAR tNTH_REF
@@ -200,7 +206,7 @@ rule
200
206
  (_, line), _, stmt, _ = val
201
207
 
202
208
  if (self.in_def || self.in_single > 0) then
203
- debug20 3
209
+ debug 13
204
210
  yyerror "END in method; use at_exit"
205
211
  end
206
212
 
@@ -240,32 +246,31 @@ rule
240
246
  }
241
247
  | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
242
248
  {
243
- prim, _, id, opasgn, rhs = val
244
- result = s(:op_asgn, prim, rhs, id.to_sym, opasgn.to_sym)
245
- if val[1] == '&.'
246
- result.sexp_type = :safe_op_asgn
247
- end
248
- result.line = val[0].line
249
+ prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
250
+
251
+ result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
252
+ result.sexp_type = :safe_op_asgn if call_op == '&.'
253
+ result.line prim.line
249
254
  }
250
255
  | primary_value call_op tCONSTANT tOP_ASGN command_rhs
251
256
  {
252
- result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
253
- if val[1] == '&.'
254
- result.sexp_type = :safe_op_asgn
255
- end
256
- result.line = val[0].line
257
+ prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
258
+
259
+ result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
260
+ result.sexp_type = :safe_op_asgn if call_op == '&.'
261
+ result.line prim.line
257
262
  }
258
263
  | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
259
264
  {
260
- lhs1, _, lhs2, op, rhs = val
265
+ lhs1, _, (lhs2, line), (id, _), rhs = val
261
266
 
262
- result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, op.to_sym)
267
+ result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
263
268
  }
264
269
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
265
270
  {
266
- lhs1, _, lhs2, op, rhs = val
271
+ lhs1, _, (lhs2, line), (id, _), rhs = val
267
272
 
268
- result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, op.to_sym)
273
+ result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
269
274
  }
270
275
  | backref tOP_ASGN command_rhs
271
276
  {
@@ -303,7 +308,7 @@ rule
303
308
  # TODO: fix line number to tBANG... but causes BAD shift/reduce conflict
304
309
  # REFACTOR: call_uni_op -- see parse26.y
305
310
  }
306
- | arg
311
+ | arg =tLBRACE_ARG
307
312
 
308
313
  expr_value: expr
309
314
  {
@@ -328,7 +333,7 @@ rule
328
333
  block_command: block_call
329
334
  | block_call call_op2 operation2 command_args
330
335
  {
331
- blk, _, msg, args = val
336
+ blk, _, (msg, _line), args = val
332
337
  result = new_call(blk, msg.to_sym, args).line blk.line
333
338
  }
334
339
 
@@ -342,15 +347,15 @@ rule
342
347
  _, line, body, _ = val
343
348
 
344
349
  result = body
345
- result.line = line
350
+ result.line line
346
351
 
347
352
  # self.env.unextend
348
353
  }
349
354
 
350
355
  fcall: operation
351
356
  {
352
- msg, = val
353
- result = new_call(nil, msg.to_sym).line lexer.lineno
357
+ (msg, line), = val
358
+ result = new_call(nil, msg.to_sym).line line
354
359
  }
355
360
 
356
361
  command: fcall command_args =tLOWEST
@@ -373,12 +378,14 @@ rule
373
378
  }
374
379
  | primary_value call_op operation2 command_args =tLOWEST
375
380
  {
376
- lhs, callop, op, args = val
381
+ lhs, callop, (op, _), args = val
382
+
377
383
  result = new_call lhs, op.to_sym, args, callop
384
+ result.line lhs.line
378
385
  }
379
386
  | primary_value call_op operation2 command_args cmd_brace_block
380
387
  {
381
- recv, _, msg, args, block = val
388
+ recv, _, (msg, _line), args, block = val
382
389
  call = new_call recv, msg.to_sym, args, val[1]
383
390
 
384
391
  block_dup_check call, block
@@ -388,11 +395,14 @@ rule
388
395
  }
389
396
  | primary_value tCOLON2 operation2 command_args =tLOWEST
390
397
  {
391
- result = new_call val[0], val[2].to_sym, val[3]
398
+ lhs, _, (id, line), args = val
399
+
400
+ result = new_call lhs, id.to_sym, args
401
+ result.line line
392
402
  }
393
403
  | primary_value tCOLON2 operation2 command_args cmd_brace_block
394
404
  {
395
- recv, _, msg, args, block = val
405
+ recv, _, (msg, _line), args, block = val
396
406
  call = new_call recv, msg.to_sym, args
397
407
 
398
408
  block_dup_check call, block
@@ -550,25 +560,29 @@ rule
550
560
  }
551
561
  | primary_value call_op tIDENTIFIER
552
562
  {
553
- result = new_attrasgn val[0], val[2], val[1]
563
+ lhs, call_op, (id, _line) = val
564
+
565
+ result = new_attrasgn lhs, id, call_op
554
566
  }
555
567
  | primary_value tCOLON2 tIDENTIFIER
556
568
  {
557
- recv, _, id = val
569
+ recv, _, (id, _line) = val
558
570
  result = new_attrasgn recv, id
559
571
  }
560
572
  | primary_value call_op tCONSTANT
561
573
  {
562
- 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
563
577
  }
564
578
  | primary_value tCOLON2 tCONSTANT
565
579
  {
566
580
  if (self.in_def || self.in_single > 0) then
567
- debug20 7
581
+ debug 14
568
582
  yyerror "dynamic constant assignment"
569
583
  end
570
584
 
571
- expr, _, id = val
585
+ expr, _, (id, _line) = val
572
586
  l = expr.line
573
587
 
574
588
  result = s(:const, s(:colon2, expr, id.to_sym).line(l), nil).line l
@@ -576,58 +590,65 @@ rule
576
590
  | tCOLON3 tCONSTANT
577
591
  {
578
592
  if (self.in_def || self.in_single > 0) then
579
- debug20 8
593
+ debug 15
580
594
  yyerror "dynamic constant assignment"
581
595
  end
582
596
 
583
- _, id = val
584
- l = lexer.lineno
597
+ _, (id, l) = val
585
598
 
586
599
  result = s(:const, nil, s(:colon3, id.to_sym).line(l)).line l
587
600
  }
588
601
  | backref
589
602
  {
590
- self.backref_assign_error val[0]
603
+ ref, = val
604
+
605
+ self.backref_assign_error ref
591
606
  }
592
607
 
593
608
  lhs: user_variable
594
609
  {
595
- line = lexer.lineno
596
- result = self.assignable val[0]
597
- result.line = line
610
+ var, = val
611
+
612
+ result = self.assignable var
598
613
  }
599
614
  | keyword_variable
600
615
  {
601
- line = lexer.lineno
602
- result = self.assignable val[0]
603
- result.line = line
604
- debug20 9, val, result
616
+ var, = val
617
+
618
+ result = self.assignable var
619
+
620
+ debug 16
605
621
  }
606
622
  | primary_value tLBRACK2 opt_call_args rbracket
607
623
  {
608
624
  lhs, _, args, _ = val
625
+
609
626
  result = self.aryset lhs, args
610
627
  }
611
628
  | primary_value call_op tIDENTIFIER # REFACTOR
612
629
  {
613
- lhs, op, id = val
630
+ lhs, op, (id, _line) = val
631
+
614
632
  result = new_attrasgn lhs, id, op
615
633
  }
616
634
  | primary_value tCOLON2 tIDENTIFIER
617
635
  {
618
- lhs, _, id = val
636
+ lhs, _, (id, _line) = val
637
+
619
638
  result = new_attrasgn lhs, id
620
639
  }
621
640
  | primary_value call_op tCONSTANT # REFACTOR?
622
641
  {
623
- result = new_attrasgn val[0], val[2], val[1]
642
+ lhs, call_op, (id, _line) = val
643
+
644
+ result = new_attrasgn lhs, id, call_op
624
645
  }
625
646
  | primary_value tCOLON2 tCONSTANT
626
647
  {
627
- expr, _, id = val
648
+ expr, _, (id, _line) = val
628
649
 
629
650
  if (self.in_def || self.in_single > 0) then
630
- debug20 10
651
+ debug 17
631
652
  yyerror "dynamic constant assignment"
632
653
  end
633
654
 
@@ -636,14 +657,13 @@ rule
636
657
  }
637
658
  | tCOLON3 tCONSTANT
638
659
  {
639
- _, id = val
660
+ _, (id, l) = val
640
661
 
641
662
  if (self.in_def || self.in_single > 0) then
642
- debug20 11
663
+ debug 18
643
664
  yyerror "dynamic constant assignment"
644
665
  end
645
666
 
646
- l = lexer.lineno
647
667
  result = s(:const, s(:colon3, id.to_sym).line(l)).line l
648
668
  }
649
669
  | backref
@@ -659,16 +679,17 @@ rule
659
679
 
660
680
  cpath: tCOLON3 cname
661
681
  {
662
- _, name = val
663
- result = s(:colon3, name.to_sym).line lexer.lineno
682
+ _, (name, line) = val
683
+ result = s(:colon3, name.to_sym).line line
664
684
  }
665
685
  | cname
666
686
  {
667
- result = val[0].to_sym
687
+ (id, line), = val
688
+ result = [id.to_sym, line] # TODO: sexp?
668
689
  }
669
690
  | primary_value tCOLON2 cname
670
691
  {
671
- pval, _, name = val
692
+ pval, _, (name, _line) = val
672
693
 
673
694
  result = s(:colon2, pval, name.to_sym)
674
695
  result.line pval.line
@@ -678,24 +699,17 @@ rule
678
699
  | op
679
700
  {
680
701
  lexer.lex_state = EXPR_END
681
- result = val[0]
682
702
  }
683
703
 
684
704
  | reswords
685
- {
686
- (sym, _line), = val
687
- lexer.lex_state = EXPR_END
688
- result = sym
689
- }
690
705
 
691
- fsym: fname | symbol
692
-
693
- fitem: fsym
706
+ fitem: fname
694
707
  {
695
- id, = val
696
- result = s(:lit, id.to_sym).line lexer.lineno
708
+ (id, line), = val
709
+
710
+ result = s(:lit, id.to_sym).line line
697
711
  }
698
- | dsym
712
+ | symbol
699
713
 
700
714
  undef_list: fitem
701
715
  {
@@ -716,8 +730,6 @@ rule
716
730
  | tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
717
731
  | tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
718
732
  | tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
719
- # TODO: tUBANG dead?
720
- | tUBANG
721
733
 
722
734
  reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
723
735
  | kALIAS | kAND | kBEGIN | kBREAK | kCASE
@@ -751,24 +763,20 @@ rule
751
763
  }
752
764
  | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
753
765
  {
754
- lhs, _, id, op, rhs = val
766
+ lhs, _, (id, _line), (op, _), rhs = val
755
767
 
756
768
  result = s(:op_asgn, lhs, rhs, id.to_sym, op.to_sym).line lhs.line
757
769
  }
758
770
  | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
759
771
  {
760
- lhs1, _, lhs2, op, rhs = val
772
+ lhs1, _, (lhs2, _line), op, rhs = val
761
773
 
762
774
  lhs = s(:colon2, lhs1, lhs2.to_sym).line lhs1.line
763
775
  result = new_const_op_asgn [lhs, op, rhs]
764
776
  }
765
- | tCOLON3 tCONSTANT
766
- {
767
- result = self.lexer.lineno
768
- }
769
- tOP_ASGN arg_rhs
777
+ | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
770
778
  {
771
- _, lhs, line, op, rhs = val
779
+ _, (lhs, line), op, rhs = val
772
780
 
773
781
  lhs = s(:colon3, lhs.to_sym).line line
774
782
  result = new_const_op_asgn [lhs, op, rhs]
@@ -782,7 +790,7 @@ rule
782
790
  | arg tDOT2 arg
783
791
  {
784
792
  v1, v2 = val[0], val[2]
785
- if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
793
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
786
794
  result = s(:lit, (v1.last)..(v2.last)).line v1.line
787
795
  else
788
796
  result = s(:dot2, v1, v2).line v1.line
@@ -791,7 +799,7 @@ rule
791
799
  | arg tDOT3 arg
792
800
  {
793
801
  v1, v2 = val[0], val[2]
794
- if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
802
+ if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
795
803
  result = s(:lit, (v1.last)...(v2.last)).line v1.line
796
804
  else
797
805
  result = s(:dot3, v1, v2).line v1.line
@@ -825,8 +833,9 @@ rule
825
833
  }
826
834
  | tUMINUS_NUM simple_numeric tPOW arg
827
835
  {
828
- lit = s(:lit, val[1]).line lexer.lineno
829
- result = new_call(new_call(lit, :"**", argl(val[3])), :"-@")
836
+ _, (num, line), _, arg = val
837
+ lit = s(:lit, num).line line
838
+ result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
830
839
 
831
840
  }
832
841
  | tUPLUS arg
@@ -925,12 +934,12 @@ rule
925
934
 
926
935
  rel_expr: arg relop arg =tGT
927
936
  {
928
- lhs, op, rhs = val
937
+ lhs, (op, _), rhs = val
929
938
  result = new_call lhs, op.to_sym, argl(rhs)
930
939
  }
931
940
  | rel_expr relop arg =tGT
932
941
  {
933
- lhs, op, rhs = val
942
+ lhs, (op, _), rhs = val
934
943
  warn "comparison '%s' after comparison", op
935
944
  result = new_call lhs, op.to_sym, argl(rhs)
936
945
  }
@@ -1121,8 +1130,9 @@ rule
1121
1130
  | backref
1122
1131
  | tFID
1123
1132
  {
1124
- msg, = val
1133
+ (msg, line), = val
1125
1134
  result = new_call nil, msg.to_sym
1135
+ result.line line
1126
1136
  }
1127
1137
  | k_begin
1128
1138
  {
@@ -1164,15 +1174,15 @@ rule
1164
1174
  }
1165
1175
  | primary_value tCOLON2 tCONSTANT
1166
1176
  {
1167
- expr, _, id = val
1177
+ expr, _, (id, _line) = val
1168
1178
 
1169
1179
  result = s(:colon2, expr, id.to_sym).line expr.line
1170
1180
  }
1171
1181
  | tCOLON3 tCONSTANT
1172
1182
  {
1173
- _, id = val
1183
+ _, (id, line) = val
1174
1184
 
1175
- result = s(:colon3, id.to_sym).line lexer.lineno
1185
+ result = s(:colon3, id.to_sym).line line
1176
1186
  }
1177
1187
  | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1178
1188
  {
@@ -1219,7 +1229,7 @@ rule
1219
1229
  }
1220
1230
  | kNOT tLPAREN2 rparen
1221
1231
  {
1222
- debug20 14, val, result
1232
+ debug 20
1223
1233
  }
1224
1234
  | fcall brace_block
1225
1235
  {
@@ -1237,9 +1247,10 @@ rule
1237
1247
  iter.insert 1, call # FIX
1238
1248
  result = iter
1239
1249
  }
1240
- | tLAMBDA lambda
1250
+ | lambda
1241
1251
  {
1242
- result = val[1] # TODO: fix lineno
1252
+ expr, = val
1253
+ result = expr
1243
1254
  }
1244
1255
  | k_if expr_value then compstmt if_tail k_end
1245
1256
  {
@@ -1282,7 +1293,6 @@ rule
1282
1293
  }
1283
1294
  cpath superclass
1284
1295
  {
1285
- self.comments.push self.lexer.comments
1286
1296
  if (self.in_def || self.in_single > 0) then
1287
1297
  yyerror "class definition in method body"
1288
1298
  end
@@ -1292,7 +1302,7 @@ rule
1292
1302
  {
1293
1303
  result = new_class val
1294
1304
  self.env.unextend
1295
- self.lexer.comments # we don't care about comments in the body
1305
+ self.lexer.ignore_body_comments
1296
1306
  }
1297
1307
  | k_class tLSHFT
1298
1308
  {
@@ -1313,7 +1323,7 @@ rule
1313
1323
  {
1314
1324
  result = new_sclass val
1315
1325
  self.env.unextend
1316
- self.lexer.comments # we don't care about comments in the body
1326
+ self.lexer.ignore_body_comments
1317
1327
  }
1318
1328
  | k_module
1319
1329
  {
@@ -1321,7 +1331,6 @@ rule
1321
1331
  }
1322
1332
  cpath
1323
1333
  {
1324
- self.comments.push self.lexer.comments
1325
1334
  yyerror "module definition in method body" if
1326
1335
  self.in_def or self.in_single > 0
1327
1336
 
@@ -1331,7 +1340,7 @@ rule
1331
1340
  {
1332
1341
  result = new_module val
1333
1342
  self.env.unextend
1334
- self.lexer.comments # we don't care about comments in the body
1343
+ self.lexer.ignore_body_comments
1335
1344
  }
1336
1345
  | k_def fname
1337
1346
  {
@@ -1341,21 +1350,17 @@ rule
1341
1350
  self.env.extend
1342
1351
  lexer.cmdarg.push false
1343
1352
  lexer.cond.push false
1344
-
1345
- self.comments.push self.lexer.comments
1346
1353
  }
1347
- f_arglist bodystmt { result = lexer.lineno } k_end
1354
+ f_arglist bodystmt k_end
1348
1355
  {
1349
- in_def = val[2]
1350
-
1351
- result = new_defn val
1356
+ result, in_def = new_defn val
1352
1357
 
1353
1358
  lexer.cond.pop # group = local_pop
1354
1359
  lexer.cmdarg.pop
1355
1360
  self.env.unextend
1356
1361
  self.in_def = in_def
1357
1362
 
1358
- self.lexer.comments # we don't care about comments in the body
1363
+ self.lexer.ignore_body_comments
1359
1364
  }
1360
1365
  | k_def singleton dot_or_colon
1361
1366
  {
@@ -1363,7 +1368,7 @@ rule
1363
1368
  }
1364
1369
  fname
1365
1370
  {
1366
- result = [self.in_def, lexer.lineno]
1371
+ result = self.in_def
1367
1372
 
1368
1373
  self.in_single += 1 # TODO: remove?
1369
1374
 
@@ -1373,13 +1378,18 @@ rule
1373
1378
  lexer.cond.push false
1374
1379
 
1375
1380
  lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
1376
- self.comments.push self.lexer.comments
1377
1381
  }
1378
1382
  f_arglist bodystmt k_end
1379
1383
  {
1380
- _, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
1381
1384
 
1382
- result = new_defs val
1385
+ # [kdef, recv, _, _, (name, line), in_def, args, body, kend]
1386
+ # =>
1387
+ # [kdef, recv, (name, line), in_def, args, body, kend]
1388
+
1389
+ val.delete_at 3
1390
+ val.delete_at 2
1391
+
1392
+ result, in_def = new_defs val
1383
1393
 
1384
1394
  lexer.cond.pop # group = local_pop
1385
1395
  lexer.cmdarg.pop
@@ -1390,7 +1400,7 @@ rule
1390
1400
 
1391
1401
  # TODO: restore cur_arg ? what's cur_arg?
1392
1402
 
1393
- self.lexer.comments # we don't care about comments in the body
1403
+ self.lexer.ignore_body_comments
1394
1404
  }
1395
1405
  | kBREAK
1396
1406
  {
@@ -1427,8 +1437,17 @@ rule
1427
1437
  k_case: kCASE
1428
1438
  k_for: kFOR
1429
1439
  k_class: kCLASS
1440
+ {
1441
+ self.comments.push self.lexer.comments
1442
+ }
1430
1443
  k_module: kMODULE
1444
+ {
1445
+ self.comments.push self.lexer.comments
1446
+ }
1431
1447
  k_def: kDEF
1448
+ {
1449
+ self.comments.push self.lexer.comments
1450
+ }
1432
1451
  k_do: kDO
1433
1452
  k_do_block: kDO_BLOCK
1434
1453
  k_rescue: kRESCUE
@@ -1489,51 +1508,42 @@ rule
1489
1508
 
1490
1509
  result = block_var args
1491
1510
  }
1492
- | f_marg_list tCOMMA tSTAR f_norm_arg
1511
+ | f_marg_list tCOMMA f_rest_marg
1493
1512
  {
1494
- args, _, _, splat = val
1513
+ args, _, rest = val
1495
1514
 
1496
- result = block_var args, "*#{splat}".to_sym
1515
+ result = block_var args, rest
1497
1516
  }
1498
- | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1517
+ | f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
1499
1518
  {
1500
- args, _, _, splat, _, args2 = val
1519
+ lhs, _, splat, _, rhs = val
1501
1520
 
1502
- result = block_var args, "*#{splat}".to_sym, args2
1521
+ result = block_var lhs, splat, rhs
1503
1522
  }
1504
- | f_marg_list tCOMMA tSTAR
1523
+ | f_rest_marg
1505
1524
  {
1506
- args, _, _ = val
1525
+ rest, = val
1507
1526
 
1508
- result = block_var args, :*
1527
+ result = block_var rest
1509
1528
  }
1510
- | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1529
+ | f_rest_marg tCOMMA f_marg_list
1511
1530
  {
1512
- args, _, _, _, args2 = val
1531
+ splat, _, rest = val
1513
1532
 
1514
- result = block_var args, :*, args2
1533
+ result = block_var splat, rest
1515
1534
  }
1516
- | tSTAR f_norm_arg
1517
- {
1518
- _, splat = val
1519
1535
 
1520
- result = block_var :"*#{splat}"
1521
- }
1522
- | tSTAR f_norm_arg tCOMMA f_marg_list
1536
+ f_rest_marg: tSTAR f_norm_arg
1523
1537
  {
1524
- _, splat, _, args = val
1538
+ _, (id, line) = val
1525
1539
 
1526
- result = block_var :"*#{splat}", args
1540
+ result = args ["*#{id}".to_sym]
1541
+ result.line line
1527
1542
  }
1528
1543
  | tSTAR
1529
1544
  {
1530
- result = block_var :*
1531
- }
1532
- | tSTAR tCOMMA f_marg_list
1533
- {
1534
- _, _, args = val
1535
-
1536
- result = block_var :*, args
1545
+ result = args [:*]
1546
+ result.line lexer.lineno # FIX: tSTAR -> line
1537
1547
  }
1538
1548
 
1539
1549
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -1550,8 +1560,8 @@ rule
1550
1560
  }
1551
1561
  | f_block_arg
1552
1562
  {
1553
- line = lexer.lineno
1554
- result = call_args val # TODO: push line down
1563
+ (id, line), = val
1564
+ result = call_args [id]
1555
1565
  result.line line
1556
1566
  }
1557
1567
 
@@ -1660,13 +1670,13 @@ opt_block_args_tail: tCOMMA block_args_tail
1660
1670
 
1661
1671
  bvar: tIDENTIFIER
1662
1672
  {
1663
- id, = val
1664
- line = lexer.lineno
1673
+ (id, line), = val
1665
1674
  result = s(:shadow, id.to_sym).line line
1666
1675
  }
1667
1676
  | f_bad_arg
1668
1677
 
1669
- lambda: {
1678
+ lambda: tLAMBDA
1679
+ {
1670
1680
  self.env.extend :dynamic
1671
1681
  result = [lexer.lineno, lexer.lpar_beg]
1672
1682
  lexer.paren_nest += 1
@@ -1678,14 +1688,14 @@ opt_block_args_tail: tCOMMA block_args_tail
1678
1688
  }
1679
1689
  lambda_body
1680
1690
  {
1681
- (line, lpar), args, _cmdarg, body = val
1691
+ _, (line, lpar), args, _cmdarg, body = val
1682
1692
  lexer.lpar_beg = lpar
1683
1693
 
1684
1694
  lexer.cmdarg.pop
1685
1695
 
1686
1696
  call = s(:lambda).line line
1687
1697
  result = new_iter call, args, body
1688
- result.line = line
1698
+ result.line line
1689
1699
  self.env.unextend # TODO: dynapush & dynapop
1690
1700
  }
1691
1701
 
@@ -1720,23 +1730,28 @@ opt_block_args_tail: tCOMMA block_args_tail
1720
1730
  ## if (nd_type($1) == NODE_YIELD) {
1721
1731
  ## compile_error(PARSER_ARG "block given to yield");
1722
1732
 
1723
- syntax_error "Both block arg and actual block given." if
1724
- val[0].block_pass?
1733
+ cmd, blk = val
1725
1734
 
1726
- val = invert_block_call val if inverted? val
1735
+ syntax_error "Both block arg and actual block given." if
1736
+ cmd.block_pass?
1727
1737
 
1728
- cmd, blk = val
1738
+ if inverted? val then
1739
+ val = invert_block_call val
1740
+ cmd, blk = val
1741
+ end
1729
1742
 
1730
1743
  result = blk
1731
1744
  result.insert 1, cmd
1732
1745
  }
1733
1746
  | block_call call_op2 operation2 opt_paren_args
1734
1747
  {
1735
- result = new_call val[0], val[2].to_sym, val[3]
1748
+ lhs, _, (id, _line), args = val
1749
+
1750
+ result = new_call lhs, id.to_sym, args
1736
1751
  }
1737
1752
  | block_call call_op2 operation2 opt_paren_args brace_block
1738
1753
  {
1739
- iter1, _, name, args, iter2 = val
1754
+ iter1, _, (name, _line), args, iter2 = val
1740
1755
 
1741
1756
  call = new_call iter1, name.to_sym, args
1742
1757
  iter2.insert 1, call
@@ -1745,7 +1760,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1745
1760
  }
1746
1761
  | block_call call_op2 operation2 command_args do_block
1747
1762
  {
1748
- iter1, _, name, args, iter2 = val
1763
+ iter1, _, (name, _line), args, iter2 = val
1749
1764
 
1750
1765
  call = new_call iter1, name.to_sym, args
1751
1766
  iter2.insert 1, call
@@ -1753,28 +1768,29 @@ opt_block_args_tail: tCOMMA block_args_tail
1753
1768
  result = iter2
1754
1769
  }
1755
1770
 
1756
- method_call: fcall
1757
- {
1758
- result = self.lexer.lineno
1759
- }
1760
- paren_args
1771
+ method_call: fcall paren_args
1761
1772
  {
1762
- call, lineno, args = val
1773
+ call, args = val
1763
1774
 
1764
1775
  result = call.concat args.sexp_body if args
1765
- result.line lineno
1766
1776
  }
1767
1777
  | primary_value call_op operation2 opt_paren_args
1768
1778
  {
1769
- result = new_call val[0], val[2].to_sym, val[3], val[1]
1779
+ recv, call_op, (op, _line), args = val
1780
+
1781
+ result = new_call recv, op.to_sym, args, call_op
1770
1782
  }
1771
1783
  | primary_value tCOLON2 operation2 paren_args
1772
1784
  {
1773
- result = new_call val[0], val[2].to_sym, val[3]
1785
+ recv, _, (op, _line), args = val
1786
+
1787
+ result = new_call recv, op.to_sym, args
1774
1788
  }
1775
1789
  | primary_value tCOLON2 operation3
1776
1790
  {
1777
- result = new_call val[0], val[2].to_sym
1791
+ lhs, _, (id, _line) = val
1792
+
1793
+ result = new_call lhs, id.to_sym
1778
1794
  }
1779
1795
  | primary_value call_op paren_args
1780
1796
  {
@@ -1807,7 +1823,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1807
1823
  _, line, body, _ = val
1808
1824
 
1809
1825
  result = body
1810
- result.line = line
1826
+ result.line line
1811
1827
 
1812
1828
  self.env.unextend
1813
1829
  }
@@ -1821,7 +1837,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1821
1837
  _, line, body, _ = val
1822
1838
 
1823
1839
  result = body
1824
- result.line = line
1840
+ result.line line
1825
1841
 
1826
1842
  self.env.unextend
1827
1843
  }
@@ -1850,14 +1866,39 @@ opt_block_args_tail: tCOMMA block_args_tail
1850
1866
  self.env.unextend
1851
1867
  }
1852
1868
 
1869
+ case_args: arg_value
1870
+ {
1871
+ arg, = val
1872
+
1873
+ result = s(:array, arg).line arg.line
1874
+ }
1875
+ | tSTAR arg_value
1876
+ {
1877
+ _, arg = val
1878
+
1879
+ result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
1880
+ }
1881
+ | case_args tCOMMA arg_value
1882
+ {
1883
+ args, _, id = val
1884
+
1885
+ result = self.list_append args, id
1886
+ }
1887
+ | case_args tCOMMA tSTAR arg_value
1888
+ {
1889
+ args, _, _, id = val
1890
+
1891
+ result = self.list_append args, s(:splat, id).line(id.line)
1892
+ }
1893
+
1853
1894
  case_body: k_when
1854
1895
  {
1855
1896
  result = self.lexer.lineno
1856
1897
  }
1857
- args then compstmt cases
1898
+ case_args then compstmt cases
1858
1899
  {
1859
1900
  result = new_when(val[2], val[4])
1860
- result.line = val[1]
1901
+ result.line val[1]
1861
1902
  result << val[5] if val[5]
1862
1903
  }
1863
1904
 
@@ -1903,17 +1944,10 @@ opt_block_args_tail: tCOMMA block_args_tail
1903
1944
 
1904
1945
  literal: numeric
1905
1946
  {
1906
- line = lexer.lineno
1907
- result = s(:lit, val[0])
1908
- result.line = line
1947
+ (lit, line), = val
1948
+ result = s(:lit, lit).line line
1909
1949
  }
1910
1950
  | symbol
1911
- {
1912
- line = lexer.lineno
1913
- result = s(:lit, val[0])
1914
- result.line = line
1915
- }
1916
- | dsym
1917
1951
 
1918
1952
  strings: string
1919
1953
  {
@@ -1924,7 +1958,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1924
1958
 
1925
1959
  string: tCHAR
1926
1960
  {
1927
- debug20 23, val, result
1961
+ debug 37
1928
1962
  }
1929
1963
  | string1
1930
1964
  | string string1
@@ -1934,11 +1968,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1934
1968
 
1935
1969
  string1: tSTRING_BEG string_contents tSTRING_END
1936
1970
  {
1937
- _, str, (_, func) = val
1971
+ (_, line), str, (_, func) = val
1938
1972
 
1939
- str = dedent str if func =~ RubyLexer::STR_FUNC_ICNTNT
1973
+ str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
1940
1974
 
1941
- result = str
1975
+ result = str.line line
1942
1976
  }
1943
1977
  | tSTRING
1944
1978
  {
@@ -1958,11 +1992,15 @@ opt_block_args_tail: tCOMMA block_args_tail
1958
1992
 
1959
1993
  words: tWORDS_BEG tSPACE tSTRING_END
1960
1994
  {
1961
- result = s(:array).line lexer.lineno
1995
+ (_, line), _, _ = val
1996
+
1997
+ result = s(:array).line line
1962
1998
  }
1963
1999
  | tWORDS_BEG word_list tSTRING_END
1964
2000
  {
1965
- result = val[1]
2001
+ (_, line), list, _ = val
2002
+
2003
+ result = list.line line
1966
2004
  }
1967
2005
 
1968
2006
  word_list: none
@@ -1982,18 +2020,20 @@ opt_block_args_tail: tCOMMA block_args_tail
1982
2020
 
1983
2021
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
1984
2022
  {
1985
- result = s(:array).line lexer.lineno
2023
+ (_, line), _, _ = val
2024
+
2025
+ result = s(:array).line line
1986
2026
  }
1987
- | tSYMBOLS_BEG { result = lexer.lineno } symbol_list tSTRING_END
2027
+ | tSYMBOLS_BEG symbol_list tSTRING_END
1988
2028
  {
1989
- _, line, list, _, = val
1990
- list.line = line
2029
+ (_, line), list, _, = val
2030
+ list.line line
1991
2031
  result = list
1992
2032
  }
1993
2033
 
1994
2034
  symbol_list: none
1995
2035
  {
1996
- result = new_symbol_list.line lexer.lineno
2036
+ result = new_symbol_list
1997
2037
  }
1998
2038
  | symbol_list word tSPACE
1999
2039
  {
@@ -2003,20 +2043,28 @@ opt_block_args_tail: tCOMMA block_args_tail
2003
2043
 
2004
2044
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2005
2045
  {
2006
- result = s(:array).line lexer.lineno
2046
+ (_, line), _, _ = val
2047
+
2048
+ result = s(:array).line line
2007
2049
  }
2008
2050
  | tQWORDS_BEG qword_list tSTRING_END
2009
2051
  {
2010
- result = val[1]
2052
+ (_, line), list, _ = val
2053
+
2054
+ result = list.line line
2011
2055
  }
2012
2056
 
2013
2057
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2014
2058
  {
2015
- result = s(:array).line lexer.lineno # FIX
2059
+ (_, line), _, _ = val
2060
+
2061
+ result = s(:array).line line
2016
2062
  }
2017
2063
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2018
2064
  {
2019
- result = val[1]
2065
+ (_, line), list, _ = val
2066
+
2067
+ result = list.line line
2020
2068
  }
2021
2069
 
2022
2070
  qword_list: none
@@ -2039,7 +2087,8 @@ opt_block_args_tail: tCOMMA block_args_tail
2039
2087
 
2040
2088
  string_contents: none
2041
2089
  {
2042
- result = s(:str, "").line lexer.lineno
2090
+ line = prev_value_to_lineno _values.last
2091
+ result = s(:str, +"").line line
2043
2092
  }
2044
2093
  | string_contents string_content
2045
2094
  {
@@ -2114,8 +2163,8 @@ regexp_contents: none
2114
2163
  lexer.brace_nest = brace_nest
2115
2164
  lexer.string_nest = string_nest
2116
2165
 
2117
- lexer.cmdarg.pop
2118
2166
  lexer.cond.pop
2167
+ lexer.cmdarg.pop
2119
2168
 
2120
2169
  lexer.lex_state = oldlex_state
2121
2170
 
@@ -2130,29 +2179,49 @@ regexp_contents: none
2130
2179
  when nil then
2131
2180
  result = s(:evstr).line line
2132
2181
  else
2133
- debug20 25
2182
+ debug 38
2134
2183
  raise "unknown string body: #{stmt.inspect}"
2135
2184
  end
2136
2185
  }
2137
2186
 
2138
- string_dvar: tGVAR { result = s(:gvar, val[0].to_sym).line lexer.lineno }
2139
- | tIVAR { result = s(:ivar, val[0].to_sym).line lexer.lineno }
2140
- | tCVAR { result = s(:cvar, val[0].to_sym).line lexer.lineno }
2187
+ string_dvar: tGVAR
2188
+ {
2189
+ (id, line), = val
2190
+ result = s(:gvar, id.to_sym).line line
2191
+ }
2192
+ | tIVAR
2193
+ {
2194
+ (id, line), = val
2195
+ result = s(:ivar, id.to_sym).line line
2196
+ }
2197
+ | tCVAR
2198
+ {
2199
+ (id, line), = val
2200
+ result = s(:cvar, id.to_sym).line line
2201
+ }
2141
2202
  | backref
2142
2203
 
2143
- symbol: tSYMBEG sym
2204
+ symbol: ssym
2205
+ | dsym
2206
+
2207
+ ssym: tSYMBEG sym
2144
2208
  {
2209
+ _, (id, line) = val
2210
+
2145
2211
  lexer.lex_state = EXPR_END
2146
- result = val[1].to_sym
2212
+ result = s(:lit, id.to_sym).line line
2147
2213
  }
2148
2214
  | tSYMBOL
2149
2215
  {
2150
- result = val[0].to_sym
2216
+ (id, line), = val
2217
+
2218
+ lexer.lex_state = EXPR_END
2219
+ result = s(:lit, id.to_sym).line line
2151
2220
  }
2152
2221
 
2153
2222
  sym: fname | tIVAR | tGVAR | tCVAR
2154
2223
 
2155
- dsym: tSYMBEG xstring_contents tSTRING_END
2224
+ dsym: tSYMBEG string_contents tSTRING_END
2156
2225
  {
2157
2226
  _, result, _ = val
2158
2227
 
@@ -2168,14 +2237,15 @@ regexp_contents: none
2168
2237
  when :evstr then
2169
2238
  result = s(:dsym, "", result).line result.line
2170
2239
  else
2171
- debug20 26, val, result
2240
+ debug 39
2172
2241
  end
2173
2242
  }
2174
2243
 
2175
2244
  numeric: simple_numeric
2176
- | tUMINUS_NUM simple_numeric
2245
+ | tUMINUS_NUM simple_numeric =tLOWEST
2177
2246
  {
2178
- result = -val[1] # TODO: pt_testcase
2247
+ _, (num, line) = val
2248
+ result = [-num, line]
2179
2249
  }
2180
2250
 
2181
2251
  simple_numeric: tINTEGER
@@ -2208,8 +2278,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2208
2278
 
2209
2279
  var_ref: user_variable
2210
2280
  {
2211
- var = val[0]
2281
+ raise "NO: #{val.inspect}" if Sexp === val.first
2282
+ (var, line), = val
2212
2283
  result = Sexp === var ? var : self.gettable(var)
2284
+ result.line line
2213
2285
  }
2214
2286
  | keyword_variable
2215
2287
  {
@@ -2224,11 +2296,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2224
2296
  | keyword_variable
2225
2297
  {
2226
2298
  result = self.assignable val[0]
2227
- debug20 29, val, result
2299
+ debug 40
2228
2300
  }
2229
2301
 
2230
- backref: tNTH_REF { result = s(:nth_ref, val[0]).line lexer.lineno }
2231
- | tBACK_REF { result = s(:back_ref, val[0]).line lexer.lineno }
2302
+ backref: tNTH_REF
2303
+ {
2304
+ (ref, line), = val
2305
+ result = s(:nth_ref, ref).line line
2306
+ }
2307
+ | tBACK_REF
2308
+ {
2309
+ (ref, line), = val
2310
+ result = s(:back_ref, ref).line line
2311
+ }
2232
2312
 
2233
2313
  superclass: tLT
2234
2314
  {
@@ -2246,9 +2326,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2246
2326
 
2247
2327
  f_arglist: tLPAREN2 f_args rparen
2248
2328
  {
2249
- result = val[1]
2250
- self.lexer.lex_state = EXPR_BEG
2251
- self.lexer.command_start = true
2329
+ result = end_args val
2252
2330
  }
2253
2331
  | {
2254
2332
  result = self.in_kwarg
@@ -2257,12 +2335,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2257
2335
  }
2258
2336
  f_args term
2259
2337
  {
2260
- kwarg, args, _ = val
2261
-
2262
- self.in_kwarg = kwarg
2263
- result = args
2264
- lexer.lex_state = EXPR_BEG
2265
- lexer.command_start = true
2338
+ result = end_args val
2266
2339
  }
2267
2340
 
2268
2341
  args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -2347,6 +2420,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2347
2420
  |
2348
2421
  {
2349
2422
  result = args val
2423
+ # result.line lexer.lineno
2350
2424
  }
2351
2425
 
2352
2426
 
@@ -2370,31 +2444,24 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2370
2444
  f_norm_arg: f_bad_arg
2371
2445
  | tIDENTIFIER
2372
2446
  {
2373
- identifier = val[0].to_sym
2447
+ (id, line), = val
2448
+ identifier = id.to_sym
2374
2449
  self.env[identifier] = :lvar
2375
2450
 
2376
- result = identifier
2451
+ result = [identifier, line]
2377
2452
  }
2378
2453
 
2379
2454
  f_arg_item: f_norm_arg
2380
2455
  | tLPAREN f_margs rparen
2381
2456
  {
2382
- result = val[1]
2457
+ _, margs, _ = val
2458
+
2459
+ result = margs
2383
2460
  }
2384
2461
 
2385
2462
  f_arg: f_arg_item
2386
2463
  {
2387
- arg, = val
2388
-
2389
- case arg
2390
- when Symbol then
2391
- result = s(:args, arg).line lexer.lineno
2392
- when Sexp then
2393
- result = arg
2394
- else
2395
- debug20 32
2396
- raise "Unknown f_arg type: #{val.inspect}"
2397
- end
2464
+ result = new_arg val
2398
2465
  }
2399
2466
  | f_arg tCOMMA f_arg_item
2400
2467
  {
@@ -2406,7 +2473,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2406
2473
  result = s(:args, list).line list.line
2407
2474
  end
2408
2475
 
2409
- result << item
2476
+ result << (Sexp === item ? item : item.first)
2410
2477
  }
2411
2478
 
2412
2479
  f_label: tLABEL
@@ -2467,27 +2534,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2467
2534
  kwrest_mark: tPOW
2468
2535
  | tDSTAR
2469
2536
 
2537
+
2470
2538
  f_kwrest: kwrest_mark tIDENTIFIER
2471
2539
  {
2472
- name = val[1].to_sym
2473
- self.assignable name
2474
- result = :"**#{name}"
2540
+ _, (id, line) = val
2541
+
2542
+ name = id.to_sym
2543
+ self.assignable [name, line]
2544
+ result = [:"**#{name}", line]
2475
2545
  }
2476
2546
  | kwrest_mark
2477
2547
  {
2478
- result = :"**"
2479
- self.env[result] = :lvar
2548
+ id = :"**"
2549
+ self.env[id] = :lvar # TODO: needed?!?
2550
+ result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
2480
2551
  }
2481
2552
 
2482
2553
  f_opt: f_norm_arg tEQL arg_value
2483
2554
  {
2484
- result = self.assignable val[0], val[2]
2555
+ lhs, _, rhs = val
2556
+ result = self.assignable lhs, rhs
2485
2557
  # TODO: detect duplicate names
2486
2558
  }
2487
2559
 
2488
2560
  f_block_opt: f_norm_arg tEQL primary_value
2489
2561
  {
2490
- result = self.assignable val[0], val[2]
2562
+ lhs, _, rhs = val
2563
+ result = self.assignable lhs, rhs
2491
2564
  }
2492
2565
 
2493
2566
  f_block_optarg: f_block_opt
@@ -2517,30 +2590,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2517
2590
  f_rest_arg: restarg_mark tIDENTIFIER
2518
2591
  {
2519
2592
  # TODO: differs from parse.y - needs tests
2520
- name = val[1].to_sym
2521
- self.assignable name
2522
- result = :"*#{name}"
2593
+ _, (id, line) = val
2594
+ name = id.to_sym
2595
+ self.assignable [name, line]
2596
+ result = [:"*#{name}", line]
2523
2597
  }
2524
2598
  | restarg_mark
2525
2599
  {
2526
2600
  name = :"*"
2527
2601
  self.env[name] = :lvar
2528
- result = name
2602
+ result = [name, lexer.lineno] # FIX: tSTAR to include lineno
2529
2603
  }
2530
2604
 
2531
2605
  blkarg_mark: tAMPER2 | tAMPER
2532
2606
 
2533
2607
  f_block_arg: blkarg_mark tIDENTIFIER
2534
2608
  {
2535
- identifier = val[1].to_sym
2609
+ _, (id, line) = val
2610
+ identifier = id.to_sym
2536
2611
 
2537
2612
  self.env[identifier] = :lvar
2538
- result = "&#{identifier}".to_sym
2613
+ result = ["&#{identifier}".to_sym, line]
2539
2614
  }
2540
2615
 
2541
2616
  opt_f_block_arg: tCOMMA f_block_arg
2542
2617
  {
2543
- result = val[1]
2618
+ _, arg = val
2619
+ result = arg
2544
2620
  }
2545
2621
  |
2546
2622
  {