ruby_parser 3.20.0 → 3.20.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ruby30_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
@@ -1114,8 +1115,10 @@ rule
1114
1115
 
1115
1116
  paren_args: tLPAREN2 opt_call_args rparen
1116
1117
  {
1117
- _, args, _ = val
1118
+ _, args, (_, line_max) = val
1119
+
1118
1120
  result = args
1121
+ result.line_max = line_max if args
1119
1122
  }
1120
1123
  | tLPAREN2 args tCOMMA args_forward rparen
1121
1124
  {
@@ -1338,12 +1341,14 @@ rule
1338
1341
  {
1339
1342
  result = wrap :colon3, val[1]
1340
1343
  }
1341
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1344
+ | tLBRACK { result = lexer.lineno } aref_args rbracket
1342
1345
  {
1343
- _, line, args, _ = val
1346
+ _, line, args, (_, line_max) = val
1347
+
1344
1348
  result = args || s(:array)
1345
1349
  result.sexp_type = :array # aref_args is :args
1346
1350
  result.line line
1351
+ result.line_max = line_max
1347
1352
  }
1348
1353
  | tLBRACE
1349
1354
  {
@@ -1931,13 +1936,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1931
1936
  {
1932
1937
  call, args = val
1933
1938
 
1934
- result = call.concat args.sexp_body if args
1939
+ result = call
1940
+
1941
+ if args then
1942
+ call.concat args.sexp_body
1943
+ result.line_max = args.line_max
1944
+ end
1935
1945
  }
1936
1946
  | primary_value call_op operation2 opt_paren_args
1937
1947
  {
1938
- recv, call_op, (op, _line), args = val
1948
+ recv, call_op, (op, op_line), args = val
1939
1949
 
1940
1950
  result = new_call recv, op.to_sym, args, call_op
1951
+ result.line_max = op_line unless args
1941
1952
  }
1942
1953
  | primary_value tCOLON2 operation2 paren_args
1943
1954
  {
@@ -2678,15 +2689,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2678
2689
 
2679
2690
  words: tWORDS_BEG tSPACE tSTRING_END
2680
2691
  {
2681
- (_, line), _, _ = val
2692
+ (_, line), _, (_, line_max) = val
2682
2693
 
2683
2694
  result = s(:array).line line
2695
+ result.line_max = line_max
2684
2696
  }
2685
2697
  | tWORDS_BEG word_list tSTRING_END
2686
2698
  {
2687
- (_, line), list, _ = val
2699
+ (_, line), list, (_, line_max) = val
2688
2700
 
2689
2701
  result = list.line line
2702
+ result.line_max = line_max
2690
2703
  }
2691
2704
 
2692
2705
  word_list: none
@@ -2706,15 +2719,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2706
2719
 
2707
2720
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2708
2721
  {
2709
- (_, line), _, _ = val
2722
+ (_, line), _, (_, line_max) = val
2710
2723
 
2711
2724
  result = s(:array).line line
2725
+ result.line_max = line_max
2712
2726
  }
2713
2727
  | tSYMBOLS_BEG symbol_list tSTRING_END
2714
2728
  {
2715
- (_, line), list, _, = val
2716
- list.line line
2717
- result = list
2729
+ (_, line), list, (_, line_max), = val
2730
+
2731
+ result = list.line line
2732
+ result.line_max = line_max
2718
2733
  }
2719
2734
 
2720
2735
  symbol_list: none
@@ -2729,28 +2744,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2729
2744
 
2730
2745
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2731
2746
  {
2732
- (_, line), _, _ = val
2747
+ (_, line), _, (_, line_max) = val
2733
2748
 
2734
2749
  result = s(:array).line line
2750
+ result.line_max = line_max
2735
2751
  }
2736
2752
  | tQWORDS_BEG qword_list tSTRING_END
2737
2753
  {
2738
- (_, line), list, _ = val
2754
+ (_, line), list, (_, line_max) = val
2739
2755
 
2740
2756
  result = list.line line
2757
+ result.line_max = line_max
2741
2758
  }
2742
2759
 
2743
2760
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2744
2761
  {
2745
- (_, line), _, _ = val
2762
+ (_, line), _, (_, line_max) = val
2746
2763
 
2747
2764
  result = s(:array).line line
2765
+ result.line_max = line_max
2748
2766
  }
2749
2767
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2750
2768
  {
2751
- (_, line), list, _ = val
2769
+ (_, line), list, (_, line_max) = val
2752
2770
 
2753
2771
  result = list.line line
2772
+ result.line_max = line_max
2754
2773
  }
2755
2774
 
2756
2775
  qword_list: none
@@ -3176,7 +3195,14 @@ f_opt_paren_args: f_paren_args
3176
3195
  result = s(:args, list).line list.line
3177
3196
  end
3178
3197
 
3179
- result << (Sexp === item ? item : item.first)
3198
+ if Sexp === item then
3199
+ line_max = item.line_max
3200
+ else
3201
+ item, line_max = item
3202
+ end
3203
+
3204
+ result << item
3205
+ result.line_max = line_max
3180
3206
  }
3181
3207
 
3182
3208
  f_label: tLABEL