ruby_parser 3.20.0 → 3.20.1

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/ruby31_parser.y CHANGED
@@ -221,6 +221,7 @@ rule
221
221
  | lhs tEQL mrhs
222
222
  {
223
223
  lhs, _, rhs = val
224
+
224
225
  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
225
226
  }
226
227
  | mlhs tEQL mrhs_arg kRESCUE_MOD stmt
@@ -1130,8 +1131,10 @@ rule
1130
1131
 
1131
1132
  paren_args: tLPAREN2 opt_call_args rparen
1132
1133
  {
1133
- _, args, _ = val
1134
+ _, args, (_, line_max) = val
1135
+
1134
1136
  result = args
1137
+ result.line_max = line_max if args
1135
1138
  }
1136
1139
  | tLPAREN2 args tCOMMA args_forward rparen
1137
1140
  {
@@ -1359,12 +1362,14 @@ rule
1359
1362
  {
1360
1363
  result = wrap :colon3, val[1]
1361
1364
  }
1362
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1365
+ | tLBRACK { result = lexer.lineno } aref_args rbracket
1363
1366
  {
1364
- _, line, args, _ = val
1367
+ _, line, args, (_, line_max) = val
1368
+
1365
1369
  result = args || s(:array)
1366
1370
  result.sexp_type = :array # aref_args is :args
1367
1371
  result.line line
1372
+ result.line_max = line_max
1368
1373
  }
1369
1374
  | tLBRACE
1370
1375
  {
@@ -1953,13 +1958,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1953
1958
  {
1954
1959
  call, args = val
1955
1960
 
1956
- result = call.concat args.sexp_body if args
1961
+ result = call
1962
+
1963
+ if args then
1964
+ call.concat args.sexp_body
1965
+ result.line_max = args.line_max
1966
+ end
1957
1967
  }
1958
1968
  | primary_value call_op operation2 opt_paren_args
1959
1969
  {
1960
- recv, call_op, (op, _line), args = val
1970
+ recv, call_op, (op, op_line), args = val
1961
1971
 
1962
1972
  result = new_call recv, op.to_sym, args, call_op
1973
+ result.line_max = op_line unless args
1963
1974
  }
1964
1975
  | primary_value tCOLON2 operation2 paren_args
1965
1976
  {
@@ -2716,15 +2727,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2716
2727
 
2717
2728
  words: tWORDS_BEG tSPACE tSTRING_END
2718
2729
  {
2719
- (_, line), _, _ = val
2730
+ (_, line), _, (_, line_max) = val
2720
2731
 
2721
2732
  result = s(:array).line line
2733
+ result.line_max = line_max
2722
2734
  }
2723
2735
  | tWORDS_BEG word_list tSTRING_END
2724
2736
  {
2725
- (_, line), list, _ = val
2737
+ (_, line), list, (_, line_max) = val
2726
2738
 
2727
2739
  result = list.line line
2740
+ result.line_max = line_max
2728
2741
  }
2729
2742
 
2730
2743
  word_list: none
@@ -2744,15 +2757,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2744
2757
 
2745
2758
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2746
2759
  {
2747
- (_, line), _, _ = val
2760
+ (_, line), _, (_, line_max) = val
2748
2761
 
2749
2762
  result = s(:array).line line
2763
+ result.line_max = line_max
2750
2764
  }
2751
2765
  | tSYMBOLS_BEG symbol_list tSTRING_END
2752
2766
  {
2753
- (_, line), list, _, = val
2754
- list.line line
2755
- result = list
2767
+ (_, line), list, (_, line_max), = val
2768
+
2769
+ result = list.line line
2770
+ result.line_max = line_max
2756
2771
  }
2757
2772
 
2758
2773
  symbol_list: none
@@ -2767,28 +2782,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2767
2782
 
2768
2783
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2769
2784
  {
2770
- (_, line), _, _ = val
2785
+ (_, line), _, (_, line_max) = val
2771
2786
 
2772
2787
  result = s(:array).line line
2788
+ result.line_max = line_max
2773
2789
  }
2774
2790
  | tQWORDS_BEG qword_list tSTRING_END
2775
2791
  {
2776
- (_, line), list, _ = val
2792
+ (_, line), list, (_, line_max) = val
2777
2793
 
2778
2794
  result = list.line line
2795
+ result.line_max = line_max
2779
2796
  }
2780
2797
 
2781
2798
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2782
2799
  {
2783
- (_, line), _, _ = val
2800
+ (_, line), _, (_, line_max) = val
2784
2801
 
2785
2802
  result = s(:array).line line
2803
+ result.line_max = line_max
2786
2804
  }
2787
2805
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2788
2806
  {
2789
- (_, line), list, _ = val
2807
+ (_, line), list, (_, line_max) = val
2790
2808
 
2791
2809
  result = list.line line
2810
+ result.line_max = line_max
2792
2811
  }
2793
2812
 
2794
2813
  qword_list: none
@@ -3210,7 +3229,14 @@ f_opt_paren_args: f_paren_args
3210
3229
  result = s(:args, list).line list.line
3211
3230
  end
3212
3231
 
3213
- result << (Sexp === item ? item : item.first)
3232
+ if Sexp === item then
3233
+ line_max = item.line_max
3234
+ else
3235
+ item, line_max = item
3236
+ end
3237
+
3238
+ result << item
3239
+ result.line_max = line_max
3214
3240
  }
3215
3241
 
3216
3242
  f_label: tLABEL