ruby_parser 3.20.0 → 3.20.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ruby27_parser.y CHANGED
@@ -223,6 +223,7 @@ rule
223
223
  | lhs tEQL mrhs
224
224
  {
225
225
  lhs, _, rhs = val
226
+
226
227
  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
227
228
  }
228
229
  | mlhs tEQL mrhs_arg kRESCUE_MOD stmt
@@ -1043,8 +1044,10 @@ rule
1043
1044
 
1044
1045
  paren_args: tLPAREN2 opt_call_args rparen
1045
1046
  {
1046
- _, args, _ = val
1047
+ _, args, (_, line_max) = val
1048
+
1047
1049
  result = args
1050
+ result.line_max = line_max if args
1048
1051
  }
1049
1052
  | tLPAREN2 args tCOMMA args_forward rparen
1050
1053
  {
@@ -1222,7 +1225,6 @@ rule
1222
1225
  | k_begin
1223
1226
  {
1224
1227
  lexer.cmdarg.push false
1225
- result = self.lexer.lineno
1226
1228
  }
1227
1229
  bodystmt k_end
1228
1230
  {
@@ -1267,12 +1269,14 @@ rule
1267
1269
  {
1268
1270
  result = wrap :colon3, val[1]
1269
1271
  }
1270
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1272
+ | tLBRACK { result = lexer.lineno } aref_args rbracket
1271
1273
  {
1272
- _, line, args, _ = val
1274
+ _, line, args, (_, line_max) = val
1275
+
1273
1276
  result = args || s(:array)
1274
1277
  result.sexp_type = :array # aref_args is :args
1275
1278
  result.line line
1279
+ result.line_max = line_max
1276
1280
  }
1277
1281
  | tLBRACE
1278
1282
  {
@@ -1383,9 +1387,6 @@ rule
1383
1387
  result = new_for iter, var, body
1384
1388
  }
1385
1389
  | k_class
1386
- {
1387
- result = self.lexer.lineno
1388
- }
1389
1390
  cpath superclass
1390
1391
  {
1391
1392
  if (self.in_def || self.in_single > 0) then
@@ -1400,9 +1401,6 @@ rule
1400
1401
  self.lexer.ignore_body_comments
1401
1402
  }
1402
1403
  | k_class tLSHFT
1403
- {
1404
- result = self.lexer.lineno
1405
- }
1406
1404
  expr
1407
1405
  {
1408
1406
  result = self.in_def
@@ -1421,9 +1419,6 @@ rule
1421
1419
  self.lexer.ignore_body_comments
1422
1420
  }
1423
1421
  | k_module
1424
- {
1425
- result = self.lexer.lineno
1426
- }
1427
1422
  cpath
1428
1423
  {
1429
1424
  yyerror "module definition in method body" if
@@ -1870,13 +1865,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1870
1865
  {
1871
1866
  call, args = val
1872
1867
 
1873
- result = call.concat args.sexp_body if args
1868
+ result = call
1869
+
1870
+ if args then
1871
+ call.concat args.sexp_body
1872
+ result.line_max = args.line_max
1873
+ end
1874
1874
  }
1875
1875
  | primary_value call_op operation2 opt_paren_args
1876
1876
  {
1877
- recv, call_op, (op, _line), args = val
1877
+ recv, call_op, (op, op_line), args = val
1878
1878
 
1879
1879
  result = new_call recv, op.to_sym, args, call_op
1880
+ result.line_max = op_line unless args
1880
1881
  }
1881
1882
  | primary_value tCOLON2 operation2 paren_args
1882
1883
  {
@@ -2596,15 +2597,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2596
2597
 
2597
2598
  words: tWORDS_BEG tSPACE tSTRING_END
2598
2599
  {
2599
- (_, line), _, _ = val
2600
+ (_, line), _, (_, line_max) = val
2600
2601
 
2601
2602
  result = s(:array).line line
2603
+ result.line_max = line_max
2602
2604
  }
2603
2605
  | tWORDS_BEG word_list tSTRING_END
2604
2606
  {
2605
- (_, line), list, _ = val
2607
+ (_, line), list, (_, line_max) = val
2606
2608
 
2607
2609
  result = list.line line
2610
+ result.line_max = line_max
2608
2611
  }
2609
2612
 
2610
2613
  word_list: none
@@ -2624,15 +2627,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2624
2627
 
2625
2628
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2626
2629
  {
2627
- (_, line), _, _ = val
2630
+ (_, line), _, (_, line_max) = val
2628
2631
 
2629
2632
  result = s(:array).line line
2633
+ result.line_max = line_max
2630
2634
  }
2631
2635
  | tSYMBOLS_BEG symbol_list tSTRING_END
2632
2636
  {
2633
- (_, line), list, _, = val
2634
- list.line line
2635
- result = list
2637
+ (_, line), list, (_, line_max), = val
2638
+
2639
+ result = list.line line
2640
+ result.line_max = line_max
2636
2641
  }
2637
2642
 
2638
2643
  symbol_list: none
@@ -2647,28 +2652,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2647
2652
 
2648
2653
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2649
2654
  {
2650
- (_, line), _, _ = val
2655
+ (_, line), _, (_, line_max) = val
2651
2656
 
2652
2657
  result = s(:array).line line
2658
+ result.line_max = line_max
2653
2659
  }
2654
2660
  | tQWORDS_BEG qword_list tSTRING_END
2655
2661
  {
2656
- (_, line), list, _ = val
2662
+ (_, line), list, (_, line_max) = val
2657
2663
 
2658
2664
  result = list.line line
2665
+ result.line_max = line_max
2659
2666
  }
2660
2667
 
2661
2668
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2662
2669
  {
2663
- (_, line), _, _ = val
2670
+ (_, line), _, (_, line_max) = val
2664
2671
 
2665
2672
  result = s(:array).line line
2673
+ result.line_max = line_max
2666
2674
  }
2667
2675
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2668
2676
  {
2669
- (_, line), list, _ = val
2677
+ (_, line), list, (_, line_max) = val
2670
2678
 
2671
2679
  result = list.line line
2680
+ result.line_max = line_max
2672
2681
  }
2673
2682
 
2674
2683
  qword_list: none
@@ -3088,7 +3097,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
3088
3097
  result = s(:args, list).line list.line
3089
3098
  end
3090
3099
 
3091
- result << (Sexp === item ? item : item.first)
3100
+ if Sexp === item then
3101
+ line_max = item.line_max
3102
+ else
3103
+ item, line_max = item
3104
+ end
3105
+
3106
+ result << item
3107
+ result.line_max = line_max
3092
3108
  }
3093
3109
 
3094
3110
  f_label: tLABEL
@@ -3310,7 +3326,15 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
3310
3326
  opt_terms: | terms
3311
3327
  opt_nl: | tNL
3312
3328
  rparen: opt_nl tRPAREN
3329
+ {
3330
+ _, close = val
3331
+ result = [close, lexer.lineno]
3332
+ }
3313
3333
  rbracket: opt_nl tRBRACK
3334
+ {
3335
+ _, close = val
3336
+ result = [close, lexer.lineno]
3337
+ }
3314
3338
  rbrace: opt_nl tRCURLY
3315
3339
  trailer: | tNL | tCOMMA
3316
3340