ruby_parser 3.20.0 → 3.20.3

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/ruby3_parser.yy CHANGED
@@ -104,9 +104,9 @@ rule
104
104
  result = iter
105
105
  }
106
106
 
107
- begin_block: tLCURLY { result = lexer.lineno } top_compstmt tRCURLY
107
+ begin_block: tLCURLY top_compstmt tRCURLY
108
108
  {
109
- _, line, stmt, _ = val
109
+ (_, line), stmt, _ = val
110
110
  result = new_iter s(:preexe).line(line), 0, stmt
111
111
  }
112
112
 
@@ -229,6 +229,7 @@ rule
229
229
  | lhs tEQL mrhs
230
230
  {
231
231
  lhs, _, rhs = val
232
+
232
233
  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
233
234
  }
234
235
  | mlhs tEQL mrhs_arg kRESCUE_MOD stmt
@@ -425,6 +426,7 @@ rule
425
426
  defs_head: k_def singleton dot_or_colon
426
427
  {
427
428
  lexer.lex_state = EXPR_FNAME
429
+ self.in_argdef = true
428
430
  }
429
431
  def_name
430
432
  {
@@ -638,7 +640,7 @@ rule
638
640
  }
639
641
  | tSTAR
640
642
  {
641
- l = lexer.lineno
643
+ (_, l), = val
642
644
  result = s(:masgn, s(:array, s(:splat).line(l)).line(l)).line l
643
645
  }
644
646
  | tSTAR tCOMMA mlhs_post
@@ -1148,8 +1150,10 @@ rule
1148
1150
 
1149
1151
  paren_args: tLPAREN2 opt_call_args rparen
1150
1152
  {
1151
- _, args, _ = val
1153
+ _, args, (_, line_max) = val
1154
+
1152
1155
  result = args
1156
+ result.line_max = line_max if args
1153
1157
  }
1154
1158
  | tLPAREN2 args tCOMMA args_forward rparen
1155
1159
  {
@@ -1268,7 +1272,7 @@ rule
1268
1272
  args: arg_value
1269
1273
  {
1270
1274
  arg, = val
1271
- lineno = arg.line || lexer.lineno # HACK
1275
+ lineno = arg.line
1272
1276
 
1273
1277
  result = s(:array, arg).line lineno
1274
1278
  }
@@ -1277,6 +1281,13 @@ rule
1277
1281
  _, arg = val
1278
1282
  result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
1279
1283
  }
1284
+ #if V >= 32
1285
+ | tSTAR
1286
+ {
1287
+ (_, line), = val
1288
+ result = s(:array, s(:splat).line(line)).line line
1289
+ }
1290
+ #endif
1280
1291
  | args tCOMMA arg_value
1281
1292
  {
1282
1293
  args, _, id = val
@@ -1284,11 +1295,16 @@ rule
1284
1295
  }
1285
1296
  | args tCOMMA tSTAR arg_value
1286
1297
  {
1287
- # TODO: the line number from tSTAR has been dropped
1288
- args, _, _, id = val
1289
- line = lexer.lineno
1298
+ args, _, (_, line), id = val
1290
1299
  result = self.list_append args, s(:splat, id).line(line)
1291
1300
  }
1301
+ #if V >= 32
1302
+ | args tCOMMA tSTAR
1303
+ {
1304
+ args, _, (_, line) = val
1305
+ result = self.list_append args, s(:splat).line(line)
1306
+ }
1307
+ #endif
1292
1308
 
1293
1309
  mrhs_arg: mrhs
1294
1310
  {
@@ -1305,7 +1321,6 @@ rule
1305
1321
  }
1306
1322
  | args tCOMMA tSTAR arg_value
1307
1323
  {
1308
- # TODO: make all tXXXX terminals include lexer.lineno
1309
1324
  arg, _, _, splat = val
1310
1325
  result = self.arg_concat arg, splat
1311
1326
  }
@@ -1334,7 +1349,6 @@ rule
1334
1349
  | k_begin
1335
1350
  {
1336
1351
  lexer.cmdarg.push false
1337
- result = self.lexer.lineno
1338
1352
  }
1339
1353
  bodystmt k_end
1340
1354
  {
@@ -1344,11 +1358,10 @@ rule
1344
1358
  | tLPAREN_ARG
1345
1359
  {
1346
1360
  lexer.lex_state = EXPR_ENDARG
1347
- result = lexer.lineno
1348
1361
  }
1349
1362
  rparen
1350
1363
  {
1351
- _, line, _ = val
1364
+ (_, line), _, _ = val
1352
1365
  result = s(:begin).line line
1353
1366
  }
1354
1367
  | tLPAREN_ARG
@@ -1364,9 +1377,8 @@ rule
1364
1377
  }
1365
1378
  | tLPAREN compstmt tRPAREN
1366
1379
  {
1367
- _, stmt, _ = val
1368
- result = stmt
1369
- result ||= s(:nil).line lexer.lineno
1380
+ (_, line), stmt, _ = val
1381
+ result = stmt || s(:nil).line(line)
1370
1382
  result.paren = true
1371
1383
  }
1372
1384
  | primary_value tCOLON2 tCONSTANT
@@ -1379,12 +1391,14 @@ rule
1379
1391
  {
1380
1392
  result = wrap :colon3, val[1]
1381
1393
  }
1382
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1394
+ | tLBRACK aref_args rbracket
1383
1395
  {
1384
- _, line, args, _ = val
1396
+ (_, line), args, (_, line_max) = val
1397
+
1385
1398
  result = args || s(:array)
1386
1399
  result.sexp_type = :array # aref_args is :args
1387
1400
  result.line line
1401
+ result.line_max = line_max
1388
1402
  }
1389
1403
  | tLBRACE
1390
1404
  {
@@ -1495,9 +1509,6 @@ rule
1495
1509
  result = new_for iter, var, body
1496
1510
  }
1497
1511
  | k_class
1498
- {
1499
- result = self.lexer.lineno
1500
- }
1501
1512
  cpath superclass
1502
1513
  {
1503
1514
  if (self.in_def || self.in_single > 0) then
@@ -1512,9 +1523,6 @@ rule
1512
1523
  self.lexer.ignore_body_comments
1513
1524
  }
1514
1525
  | k_class tLSHFT
1515
- {
1516
- result = self.lexer.lineno
1517
- }
1518
1526
  expr
1519
1527
  {
1520
1528
  result = self.in_def
@@ -1526,16 +1534,14 @@ rule
1526
1534
  self.in_single = 0
1527
1535
  self.env.extend
1528
1536
  }
1529
- bodystmt k_end
1537
+ bodystmt
1538
+ k_end
1530
1539
  {
1531
1540
  result = new_sclass val
1532
1541
  self.env.unextend
1533
1542
  self.lexer.ignore_body_comments
1534
1543
  }
1535
1544
  | k_module
1536
- {
1537
- result = self.lexer.lineno
1538
- }
1539
1545
  cpath
1540
1546
  {
1541
1547
  yyerror "module definition in method body" if
@@ -1638,6 +1644,7 @@ rule
1638
1644
  k_def: kDEF
1639
1645
  {
1640
1646
  self.comments.push self.lexer.comments
1647
+ self.in_argdef = true
1641
1648
  }
1642
1649
  k_do: kDO
1643
1650
  k_do_block: kDO_BLOCK
@@ -1677,20 +1684,33 @@ rule
1677
1684
  }
1678
1685
 
1679
1686
  f_marg: f_norm_arg
1687
+ {
1688
+ (sym, line), = val
1689
+
1690
+ result = s(:dummy, sym).line line
1691
+ }
1680
1692
  | tLPAREN f_margs rparen
1681
1693
  {
1682
- result = val[1]
1694
+ _, args, _ = val
1695
+ result = args
1683
1696
  }
1684
1697
 
1685
1698
  f_marg_list: f_marg
1686
1699
  {
1687
- sym, = val
1700
+ arg, = val
1701
+ line = arg.line
1702
+
1703
+ arg = arg.last if arg.sexp_type == :dummy
1688
1704
 
1689
- result = s(:array, sym).line lexer.lineno
1705
+ result = s(:array, arg).line line
1690
1706
  }
1691
1707
  | f_marg_list tCOMMA f_marg
1692
1708
  {
1693
- result = list_append val[0], val[2]
1709
+ args, _, arg = val
1710
+
1711
+ arg = arg.last if arg.sexp_type == :dummy
1712
+
1713
+ result = list_append args, arg
1694
1714
  }
1695
1715
 
1696
1716
  f_margs: f_marg_list
@@ -1733,15 +1753,15 @@ rule
1733
1753
  }
1734
1754
  | tSTAR
1735
1755
  {
1736
- result = args [:*]
1737
- result.line lexer.lineno # FIX: tSTAR -> line
1756
+ (_, line), = val
1757
+ result = args([:*]).line line
1738
1758
  }
1739
1759
 
1740
1760
  f_any_kwrest: f_kwrest
1741
1761
  | f_no_kwarg
1742
1762
 
1743
1763
  #if V > 30
1744
- f_eq: tEQL # TODO: self.in_argdef = false
1764
+ f_eq: { self.in_argdef = false } tEQL
1745
1765
  #endif
1746
1766
 
1747
1767
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -1846,15 +1866,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1846
1866
  {
1847
1867
  # TODO: current_arg = 0
1848
1868
  result = args val
1869
+ self.in_argdef = false
1849
1870
  }
1850
1871
  | tOROP
1851
1872
  {
1852
- result = s(:args).line lexer.lineno
1873
+ (_, line), = val
1874
+
1875
+ result = s(:args).line line
1853
1876
  }
1854
1877
  | tPIPE block_param opt_bv_decl tPIPE
1855
1878
  {
1856
1879
  # TODO: current_arg = 0
1857
1880
  result = args val
1881
+ self.in_argdef = false
1858
1882
  }
1859
1883
 
1860
1884
  opt_bv_decl: opt_nl
@@ -1881,7 +1905,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1881
1905
  lambda: tLAMBDA
1882
1906
  {
1883
1907
  self.env.extend :dynamic
1884
- result = [lexer.lineno, lexer.lpar_beg]
1908
+ result = lexer.lpar_beg
1885
1909
  lexer.paren_nest += 1
1886
1910
  lexer.lpar_beg = lexer.paren_nest
1887
1911
  }
@@ -1891,7 +1915,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1891
1915
  }
1892
1916
  lambda_body
1893
1917
  {
1894
- _, (line, lpar), args, _cmdarg, body = val
1918
+ (_, line), lpar, args, _cmdarg, body = val
1895
1919
  lexer.lpar_beg = lpar
1896
1920
 
1897
1921
  lexer.cmdarg.pop
@@ -1904,10 +1928,12 @@ opt_block_args_tail: tCOMMA block_args_tail
1904
1928
 
1905
1929
  f_larglist: tLPAREN2 f_args opt_bv_decl rparen
1906
1930
  {
1931
+ self.in_argdef = false
1907
1932
  result = args val
1908
1933
  }
1909
1934
  | f_args
1910
1935
  {
1936
+ self.in_argdef = false
1911
1937
  result = val[0]
1912
1938
  result = 0 if result == s(:args)
1913
1939
  }
@@ -1975,13 +2001,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1975
2001
  {
1976
2002
  call, args = val
1977
2003
 
1978
- result = call.concat args.sexp_body if args
2004
+ result = call
2005
+
2006
+ if args then
2007
+ call.concat args.sexp_body
2008
+ result.line_max = args.line_max
2009
+ end
1979
2010
  }
1980
2011
  | primary_value call_op operation2 opt_paren_args
1981
2012
  {
1982
- recv, call_op, (op, _line), args = val
2013
+ recv, call_op, (op, op_line), args = val
1983
2014
 
1984
2015
  result = new_call recv, op.to_sym, args, call_op
2016
+ result.line_max = op_line unless args
1985
2017
  }
1986
2018
  | primary_value tCOLON2 operation2 paren_args
1987
2019
  {
@@ -2009,7 +2041,8 @@ opt_block_args_tail: tCOMMA block_args_tail
2009
2041
  }
2010
2042
  | kSUPER
2011
2043
  {
2012
- result = s(:zsuper).line lexer.lineno
2044
+ (_, line), = val
2045
+ result = s(:zsuper).line line
2013
2046
  }
2014
2047
  | primary_value tLBRACK2 opt_call_args rbracket
2015
2048
  {
@@ -2019,11 +2052,11 @@ opt_block_args_tail: tCOMMA block_args_tail
2019
2052
  brace_block: tLCURLY
2020
2053
  {
2021
2054
  self.env.extend :dynamic
2022
- result = self.lexer.lineno
2023
2055
  }
2024
- brace_body tRCURLY
2056
+ brace_body
2057
+ tRCURLY
2025
2058
  {
2026
- _, line, body, _ = val
2059
+ (_, line), _, body, _ = val
2027
2060
 
2028
2061
  result = body
2029
2062
  result.line line
@@ -2033,11 +2066,11 @@ opt_block_args_tail: tCOMMA block_args_tail
2033
2066
  | k_do
2034
2067
  {
2035
2068
  self.env.extend :dynamic
2036
- result = self.lexer.lineno
2037
2069
  }
2038
- do_body kEND
2070
+ do_body
2071
+ kEND
2039
2072
  {
2040
- _, line, body, _ = val
2073
+ (_, line), _, body, _ = val
2041
2074
 
2042
2075
  result = body
2043
2076
  result.line line
@@ -2095,14 +2128,13 @@ opt_block_args_tail: tCOMMA block_args_tail
2095
2128
  }
2096
2129
 
2097
2130
  case_body: k_when
2098
- {
2099
- result = self.lexer.lineno
2100
- }
2101
2131
  case_args then compstmt cases
2102
2132
  {
2103
- result = new_when(val[2], val[4])
2104
- result.line val[1]
2105
- result << val[5] if val[5]
2133
+ (_, line), case_args, _then, body, cases = val
2134
+
2135
+ result = new_when case_args, body
2136
+ result.line line
2137
+ result << cases if cases
2106
2138
  }
2107
2139
 
2108
2140
  cases: opt_else | case_body
@@ -2341,6 +2373,7 @@ opt_block_args_tail: tCOMMA block_args_tail
2341
2373
  result = new_array_pattern_tail both, nil, nil, nil
2342
2374
  result.line head.line
2343
2375
  }
2376
+ #if V < 32
2344
2377
  | p_args_head tSTAR tIDENTIFIER
2345
2378
  {
2346
2379
  head, _, (id, _line) = val
@@ -2367,6 +2400,20 @@ opt_block_args_tail: tCOMMA block_args_tail
2367
2400
 
2368
2401
  result = new_array_pattern_tail(head, true, nil, post).line head.line
2369
2402
  }
2403
+ #else
2404
+ | p_args_head p_rest
2405
+ {
2406
+ head, (rest, _) = val
2407
+
2408
+ result = new_array_pattern_tail(head, true, rest, nil).line head.line
2409
+ }
2410
+ | p_args_head p_rest tCOMMA p_args_post
2411
+ {
2412
+ head, (rest, _), _, post = val
2413
+
2414
+ result = new_array_pattern_tail(head, true, rest, post).line head.line
2415
+ }
2416
+ #endif
2370
2417
  | p_args_tail
2371
2418
 
2372
2419
  p_args_head: p_arg tCOMMA
@@ -2751,15 +2798,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2751
2798
 
2752
2799
  words: tWORDS_BEG tSPACE tSTRING_END
2753
2800
  {
2754
- (_, line), _, _ = val
2801
+ (_, line), _, (_, line_max) = val
2755
2802
 
2756
2803
  result = s(:array).line line
2804
+ result.line_max = line_max
2757
2805
  }
2758
2806
  | tWORDS_BEG word_list tSTRING_END
2759
2807
  {
2760
- (_, line), list, _ = val
2808
+ (_, line), list, (_, line_max) = val
2761
2809
 
2762
2810
  result = list.line line
2811
+ result.line_max = line_max
2763
2812
  }
2764
2813
 
2765
2814
  word_list: none
@@ -2779,15 +2828,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2779
2828
 
2780
2829
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2781
2830
  {
2782
- (_, line), _, _ = val
2831
+ (_, line), _, (_, line_max) = val
2783
2832
 
2784
2833
  result = s(:array).line line
2834
+ result.line_max = line_max
2785
2835
  }
2786
2836
  | tSYMBOLS_BEG symbol_list tSTRING_END
2787
2837
  {
2788
- (_, line), list, _, = val
2789
- list.line line
2790
- result = list
2838
+ (_, line), list, (_, line_max), = val
2839
+
2840
+ result = list.line line
2841
+ result.line_max = line_max
2791
2842
  }
2792
2843
 
2793
2844
  symbol_list: none
@@ -2802,28 +2853,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2802
2853
 
2803
2854
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2804
2855
  {
2805
- (_, line), _, _ = val
2856
+ (_, line), _, (_, line_max) = val
2806
2857
 
2807
2858
  result = s(:array).line line
2859
+ result.line_max = line_max
2808
2860
  }
2809
2861
  | tQWORDS_BEG qword_list tSTRING_END
2810
2862
  {
2811
- (_, line), list, _ = val
2863
+ (_, line), list, (_, line_max) = val
2812
2864
 
2813
2865
  result = list.line line
2866
+ result.line_max = line_max
2814
2867
  }
2815
2868
 
2816
2869
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2817
2870
  {
2818
- (_, line), _, _ = val
2871
+ (_, line), _, (_, line_max) = val
2819
2872
 
2820
2873
  result = s(:array).line line
2874
+ result.line_max = line_max
2821
2875
  }
2822
2876
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2823
2877
  {
2824
- (_, line), list, _ = val
2878
+ (_, line), list, (_, line_max) = val
2825
2879
 
2826
2880
  result = list.line line
2881
+ result.line_max = line_max
2827
2882
  }
2828
2883
 
2829
2884
  qword_list: none
@@ -2898,7 +2953,6 @@ regexp_contents: none
2898
2953
  lexer.brace_nest,
2899
2954
  lexer.string_nest, # TODO: remove
2900
2955
  lexer.lex_state,
2901
- lexer.lineno,
2902
2956
  ]
2903
2957
 
2904
2958
  lexer.cmdarg.push false
@@ -2913,9 +2967,9 @@ regexp_contents: none
2913
2967
  compstmt
2914
2968
  tSTRING_DEND
2915
2969
  {
2916
- _, memo, stmt, _ = val
2970
+ (_, line), memo, stmt, _ = val
2917
2971
 
2918
- lex_strterm, brace_nest, string_nest, oldlex_state, line = memo
2972
+ lex_strterm, brace_nest, string_nest, oldlex_state = memo
2919
2973
  # TODO: heredoc_indent
2920
2974
 
2921
2975
  lexer.lex_strterm = lex_strterm
@@ -2975,11 +3029,11 @@ regexp_contents: none
2975
3029
 
2976
3030
  dsym: tSYMBEG string_contents tSTRING_END
2977
3031
  {
2978
- _, result, _ = val
3032
+ (_, line), result, _ = val
2979
3033
 
2980
3034
  lexer.lex_state = EXPR_END
2981
3035
 
2982
- result ||= s(:str, "").line lexer.lineno
3036
+ result ||= s(:str, "").line line
2983
3037
 
2984
3038
  case result.sexp_type
2985
3039
  when :dstr then
@@ -3017,15 +3071,15 @@ regexp_contents: none
3017
3071
  | tCONSTANT
3018
3072
  | tCVAR
3019
3073
 
3020
- keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
3021
- | kSELF { result = s(:self).line lexer.lineno }
3022
- | kTRUE { result = s(:true).line lexer.lineno }
3023
- | kFALSE { result = s(:false).line lexer.lineno }
3024
- | k__FILE__ { result = s(:str, self.file).line lexer.lineno }
3025
- | k__LINE__ { result = s(:lit, lexer.lineno).line lexer.lineno }
3074
+ keyword_variable: kNIL { (_, line), = val; result = s(:nil).line line }
3075
+ | kSELF { (_, line), = val; result = s(:self).line line }
3076
+ | kTRUE { (_, line), = val; result = s(:true).line line }
3077
+ | kFALSE { (_, line), = val; result = s(:false).line line }
3078
+ | k__FILE__ { (_, line), = val; result = s(:str, self.file).line line }
3079
+ | k__LINE__ { (_, line), = val; result = s(:lit, line).line line }
3026
3080
  | k__ENCODING__
3027
3081
  {
3028
- l = lexer.lineno
3082
+ (_, l), = val
3029
3083
  result =
3030
3084
  if defined? Encoding then
3031
3085
  s(:colon2, s(:const, :Encoding).line(l), :UTF_8).line l
@@ -3086,11 +3140,13 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
3086
3140
  f_opt_paren_args: f_paren_args
3087
3141
  | none
3088
3142
  {
3143
+ self.in_argdef = false
3089
3144
  result = end_args val
3090
3145
  }
3091
3146
 
3092
3147
  f_paren_args: tLPAREN2 f_args rparen
3093
3148
  {
3149
+ self.in_argdef = false
3094
3150
  result = end_args val
3095
3151
  }
3096
3152
  #if V == 30
@@ -3108,10 +3164,12 @@ f_opt_paren_args: f_paren_args
3108
3164
  | {
3109
3165
  result = self.in_kwarg
3110
3166
  self.in_kwarg = true
3167
+ self.in_argdef = true
3111
3168
  self.lexer.lex_state |= EXPR_LABEL
3112
3169
  }
3113
3170
  f_args term
3114
3171
  {
3172
+ self.in_argdef = false
3115
3173
  result = end_args val
3116
3174
  }
3117
3175
 
@@ -3200,12 +3258,12 @@ f_opt_paren_args: f_paren_args
3200
3258
  |
3201
3259
  {
3202
3260
  result = args val
3203
- # result.line lexer.lineno
3204
3261
  }
3205
3262
 
3206
3263
  args_forward: tBDOT3
3207
3264
  {
3208
- result = s(:forward_args).line lexer.lineno
3265
+ (_, line), = val
3266
+ result = s(:forward_args).line line
3209
3267
  }
3210
3268
 
3211
3269
  f_bad_arg: tCONSTANT
@@ -3259,10 +3317,25 @@ f_opt_paren_args: f_paren_args
3259
3317
  result = s(:args, list).line list.line
3260
3318
  end
3261
3319
 
3262
- result << (Sexp === item ? item : item.first)
3320
+ if Sexp === item then
3321
+ line_max = item.line_max
3322
+ else
3323
+ item, line_max = item
3324
+ end
3325
+
3326
+ result << item
3327
+ result.line_max = line_max
3263
3328
  }
3264
3329
 
3265
3330
  f_label: tLABEL
3331
+ {
3332
+ label, = val
3333
+ # arg_var(p, formal_argument(p, $1));
3334
+ # p->cur_arg = get_id($1);
3335
+ # p->max_numparam = ORDINAL_PARAM;
3336
+ self.in_argdef = false
3337
+ result = label
3338
+ }
3266
3339
 
3267
3340
  f_kw: f_label arg_value
3268
3341
  {
@@ -3271,6 +3344,7 @@ f_opt_paren_args: f_paren_args
3271
3344
 
3272
3345
  identifier = label.to_sym
3273
3346
  self.env[identifier] = :lvar
3347
+ self.in_argdef = true
3274
3348
 
3275
3349
  kwarg = s(:kwarg, identifier, arg).line line
3276
3350
  result = s(:array, kwarg).line line
@@ -3281,6 +3355,7 @@ f_opt_paren_args: f_paren_args
3281
3355
 
3282
3356
  id = label.to_sym
3283
3357
  self.env[id] = :lvar
3358
+ self.in_argdef = true
3284
3359
 
3285
3360
  result = s(:array, s(:kwarg, id).line(line)).line line
3286
3361
  }
@@ -3291,6 +3366,7 @@ f_opt_paren_args: f_paren_args
3291
3366
  (label, line), expr = val
3292
3367
  id = label.to_sym
3293
3368
  self.env[id] = :lvar
3369
+ self.in_argdef = true
3294
3370
 
3295
3371
  result = s(:array, s(:kwarg, id, expr).line(line)).line line
3296
3372
  }
@@ -3300,6 +3376,7 @@ f_opt_paren_args: f_paren_args
3300
3376
  (label, line), = val
3301
3377
  id = label.to_sym
3302
3378
  self.env[id] = :lvar
3379
+ self.in_argdef = true
3303
3380
 
3304
3381
  result = s(:array, s(:kwarg, id).line(line)).line line
3305
3382
  }
@@ -3336,9 +3413,10 @@ f_opt_paren_args: f_paren_args
3336
3413
  }
3337
3414
  | kwrest_mark
3338
3415
  {
3416
+ (_, line), = val
3339
3417
  id = :"**"
3340
- self.env[id] = :lvar # TODO: needed?!?
3341
- result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
3418
+ self.env[id] = :lvar
3419
+ result = [id, line]
3342
3420
  }
3343
3421
 
3344
3422
  f_opt: f_arg_asgn
@@ -3350,10 +3428,10 @@ f_opt_paren_args: f_paren_args
3350
3428
  arg_value
3351
3429
  {
3352
3430
  lhs, _, rhs = val
3431
+ self.in_argdef = true
3353
3432
  result = self.assignable lhs, rhs
3354
3433
  # TODO: detect duplicate names
3355
3434
  # TODO? p->cur_arg = 0;
3356
- # TODO? p->ctxt.in_argdef = 1;
3357
3435
  }
3358
3436
 
3359
3437
  f_block_opt: f_arg_asgn
@@ -3365,9 +3443,9 @@ f_opt_paren_args: f_paren_args
3365
3443
  primary_value
3366
3444
  {
3367
3445
  lhs, _, rhs = val
3446
+ self.in_argdef = true
3368
3447
  result = self.assignable lhs, rhs
3369
3448
  # TODO? p->cur_arg = 0;
3370
- # TODO? p->ctxt.in_argdef = 1;
3371
3449
  }
3372
3450
 
3373
3451
  f_block_optarg: f_block_opt
@@ -3404,9 +3482,10 @@ f_opt_paren_args: f_paren_args
3404
3482
  }
3405
3483
  | restarg_mark
3406
3484
  {
3485
+ (_, line), = val
3407
3486
  name = :"*"
3408
3487
  self.env[name] = :lvar
3409
- result = [name, lexer.lineno] # FIX: tSTAR to include lineno
3488
+ result = [name, line]
3410
3489
  }
3411
3490
 
3412
3491
  blkarg_mark: tAMPER2 | tAMPER
@@ -3497,6 +3576,13 @@ f_opt_paren_args: f_paren_args
3497
3576
  line = arg.line
3498
3577
  result = s(:array, s(:kwsplat, arg).line(line)).line line
3499
3578
  }
3579
+ #if V >= 32
3580
+ | tDSTAR
3581
+ {
3582
+ (_, line), = val
3583
+ result = s(:array, s(:kwsplat).line(line)).line line
3584
+ }
3585
+ #endif
3500
3586
 
3501
3587
  operation: tIDENTIFIER | tCONSTANT | tFID
3502
3588
  operation2: tIDENTIFIER | tCONSTANT | tFID | op
@@ -3511,11 +3597,10 @@ f_opt_paren_args: f_paren_args
3511
3597
  opt_terms: | terms
3512
3598
  opt_nl: | tNL
3513
3599
  rparen: opt_nl tRPAREN
3514
- # TODO:
3515
- # {
3516
- # _, close = val
3517
- # result = [close, lexer.lineno]
3518
- # }
3600
+ {
3601
+ _, close = val # TODO: include lineno in close?
3602
+ result = [close, lexer.lineno]
3603
+ }
3519
3604
  rbracket: opt_nl tRBRACK
3520
3605
  {
3521
3606
  _, close = val