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