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/ruby32_parser.y CHANGED
@@ -96,9 +96,9 @@ rule
96
96
  result = iter
97
97
  }
98
98
 
99
- begin_block: tLCURLY { result = lexer.lineno } top_compstmt tRCURLY
99
+ begin_block: tLCURLY top_compstmt tRCURLY
100
100
  {
101
- _, line, stmt, _ = val
101
+ (_, line), stmt, _ = val
102
102
  result = new_iter s(:preexe).line(line), 0, stmt
103
103
  }
104
104
 
@@ -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
@@ -407,6 +408,7 @@ rule
407
408
  defs_head: k_def singleton dot_or_colon
408
409
  {
409
410
  lexer.lex_state = EXPR_FNAME
411
+ self.in_argdef = true
410
412
  }
411
413
  def_name
412
414
  {
@@ -620,7 +622,7 @@ rule
620
622
  }
621
623
  | tSTAR
622
624
  {
623
- l = lexer.lineno
625
+ (_, l), = val
624
626
  result = s(:masgn, s(:array, s(:splat).line(l)).line(l)).line l
625
627
  }
626
628
  | tSTAR tCOMMA mlhs_post
@@ -1130,8 +1132,10 @@ rule
1130
1132
 
1131
1133
  paren_args: tLPAREN2 opt_call_args rparen
1132
1134
  {
1133
- _, args, _ = val
1135
+ _, args, (_, line_max) = val
1136
+
1134
1137
  result = args
1138
+ result.line_max = line_max if args
1135
1139
  }
1136
1140
  | tLPAREN2 args tCOMMA args_forward rparen
1137
1141
  {
@@ -1248,7 +1252,7 @@ rule
1248
1252
  args: arg_value
1249
1253
  {
1250
1254
  arg, = val
1251
- lineno = arg.line || lexer.lineno # HACK
1255
+ lineno = arg.line
1252
1256
 
1253
1257
  result = s(:array, arg).line lineno
1254
1258
  }
@@ -1257,6 +1261,11 @@ rule
1257
1261
  _, arg = val
1258
1262
  result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
1259
1263
  }
1264
+ | tSTAR
1265
+ {
1266
+ (_, line), = val
1267
+ result = s(:array, s(:splat).line(line)).line line
1268
+ }
1260
1269
  | args tCOMMA arg_value
1261
1270
  {
1262
1271
  args, _, id = val
@@ -1264,11 +1273,14 @@ rule
1264
1273
  }
1265
1274
  | args tCOMMA tSTAR arg_value
1266
1275
  {
1267
- # TODO: the line number from tSTAR has been dropped
1268
- args, _, _, id = val
1269
- line = lexer.lineno
1276
+ args, _, (_, line), id = val
1270
1277
  result = self.list_append args, s(:splat, id).line(line)
1271
1278
  }
1279
+ | args tCOMMA tSTAR
1280
+ {
1281
+ args, _, (_, line) = val
1282
+ result = self.list_append args, s(:splat).line(line)
1283
+ }
1272
1284
 
1273
1285
  mrhs_arg: mrhs
1274
1286
  {
@@ -1285,7 +1297,6 @@ rule
1285
1297
  }
1286
1298
  | args tCOMMA tSTAR arg_value
1287
1299
  {
1288
- # TODO: make all tXXXX terminals include lexer.lineno
1289
1300
  arg, _, _, splat = val
1290
1301
  result = self.arg_concat arg, splat
1291
1302
  }
@@ -1314,7 +1325,6 @@ rule
1314
1325
  | k_begin
1315
1326
  {
1316
1327
  lexer.cmdarg.push false
1317
- result = self.lexer.lineno
1318
1328
  }
1319
1329
  bodystmt k_end
1320
1330
  {
@@ -1324,11 +1334,10 @@ rule
1324
1334
  | tLPAREN_ARG
1325
1335
  {
1326
1336
  lexer.lex_state = EXPR_ENDARG
1327
- result = lexer.lineno
1328
1337
  }
1329
1338
  rparen
1330
1339
  {
1331
- _, line, _ = val
1340
+ (_, line), _, _ = val
1332
1341
  result = s(:begin).line line
1333
1342
  }
1334
1343
  | tLPAREN_ARG
@@ -1344,9 +1353,8 @@ rule
1344
1353
  }
1345
1354
  | tLPAREN compstmt tRPAREN
1346
1355
  {
1347
- _, stmt, _ = val
1348
- result = stmt
1349
- result ||= s(:nil).line lexer.lineno
1356
+ (_, line), stmt, _ = val
1357
+ result = stmt || s(:nil).line(line)
1350
1358
  result.paren = true
1351
1359
  }
1352
1360
  | primary_value tCOLON2 tCONSTANT
@@ -1359,12 +1367,14 @@ rule
1359
1367
  {
1360
1368
  result = wrap :colon3, val[1]
1361
1369
  }
1362
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1370
+ | tLBRACK aref_args rbracket
1363
1371
  {
1364
- _, line, args, _ = val
1372
+ (_, line), args, (_, line_max) = val
1373
+
1365
1374
  result = args || s(:array)
1366
1375
  result.sexp_type = :array # aref_args is :args
1367
1376
  result.line line
1377
+ result.line_max = line_max
1368
1378
  }
1369
1379
  | tLBRACE
1370
1380
  {
@@ -1475,9 +1485,6 @@ rule
1475
1485
  result = new_for iter, var, body
1476
1486
  }
1477
1487
  | k_class
1478
- {
1479
- result = self.lexer.lineno
1480
- }
1481
1488
  cpath superclass
1482
1489
  {
1483
1490
  if (self.in_def || self.in_single > 0) then
@@ -1492,9 +1499,6 @@ rule
1492
1499
  self.lexer.ignore_body_comments
1493
1500
  }
1494
1501
  | k_class tLSHFT
1495
- {
1496
- result = self.lexer.lineno
1497
- }
1498
1502
  expr
1499
1503
  {
1500
1504
  result = self.in_def
@@ -1506,16 +1510,14 @@ rule
1506
1510
  self.in_single = 0
1507
1511
  self.env.extend
1508
1512
  }
1509
- bodystmt k_end
1513
+ bodystmt
1514
+ k_end
1510
1515
  {
1511
1516
  result = new_sclass val
1512
1517
  self.env.unextend
1513
1518
  self.lexer.ignore_body_comments
1514
1519
  }
1515
1520
  | k_module
1516
- {
1517
- result = self.lexer.lineno
1518
- }
1519
1521
  cpath
1520
1522
  {
1521
1523
  yyerror "module definition in method body" if
@@ -1618,6 +1620,7 @@ rule
1618
1620
  k_def: kDEF
1619
1621
  {
1620
1622
  self.comments.push self.lexer.comments
1623
+ self.in_argdef = true
1621
1624
  }
1622
1625
  k_do: kDO
1623
1626
  k_do_block: kDO_BLOCK
@@ -1657,20 +1660,33 @@ rule
1657
1660
  }
1658
1661
 
1659
1662
  f_marg: f_norm_arg
1663
+ {
1664
+ (sym, line), = val
1665
+
1666
+ result = s(:dummy, sym).line line
1667
+ }
1660
1668
  | tLPAREN f_margs rparen
1661
1669
  {
1662
- result = val[1]
1670
+ _, args, _ = val
1671
+ result = args
1663
1672
  }
1664
1673
 
1665
1674
  f_marg_list: f_marg
1666
1675
  {
1667
- sym, = val
1676
+ arg, = val
1677
+ line = arg.line
1668
1678
 
1669
- result = s(:array, sym).line lexer.lineno
1679
+ arg = arg.last if arg.sexp_type == :dummy
1680
+
1681
+ result = s(:array, arg).line line
1670
1682
  }
1671
1683
  | f_marg_list tCOMMA f_marg
1672
1684
  {
1673
- result = list_append val[0], val[2]
1685
+ args, _, arg = val
1686
+
1687
+ arg = arg.last if arg.sexp_type == :dummy
1688
+
1689
+ result = list_append args, arg
1674
1690
  }
1675
1691
 
1676
1692
  f_margs: f_marg_list
@@ -1713,14 +1729,14 @@ rule
1713
1729
  }
1714
1730
  | tSTAR
1715
1731
  {
1716
- result = args [:*]
1717
- result.line lexer.lineno # FIX: tSTAR -> line
1732
+ (_, line), = val
1733
+ result = args([:*]).line line
1718
1734
  }
1719
1735
 
1720
1736
  f_any_kwrest: f_kwrest
1721
1737
  | f_no_kwarg
1722
1738
 
1723
- f_eq: tEQL # TODO: self.in_argdef = false
1739
+ f_eq: { self.in_argdef = false } tEQL
1724
1740
 
1725
1741
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
1726
1742
  {
@@ -1824,15 +1840,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1824
1840
  {
1825
1841
  # TODO: current_arg = 0
1826
1842
  result = args val
1843
+ self.in_argdef = false
1827
1844
  }
1828
1845
  | tOROP
1829
1846
  {
1830
- result = s(:args).line lexer.lineno
1847
+ (_, line), = val
1848
+
1849
+ result = s(:args).line line
1831
1850
  }
1832
1851
  | tPIPE block_param opt_bv_decl tPIPE
1833
1852
  {
1834
1853
  # TODO: current_arg = 0
1835
1854
  result = args val
1855
+ self.in_argdef = false
1836
1856
  }
1837
1857
 
1838
1858
  opt_bv_decl: opt_nl
@@ -1859,7 +1879,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1859
1879
  lambda: tLAMBDA
1860
1880
  {
1861
1881
  self.env.extend :dynamic
1862
- result = [lexer.lineno, lexer.lpar_beg]
1882
+ result = lexer.lpar_beg
1863
1883
  lexer.paren_nest += 1
1864
1884
  lexer.lpar_beg = lexer.paren_nest
1865
1885
  }
@@ -1869,7 +1889,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1869
1889
  }
1870
1890
  lambda_body
1871
1891
  {
1872
- _, (line, lpar), args, _cmdarg, body = val
1892
+ (_, line), lpar, args, _cmdarg, body = val
1873
1893
  lexer.lpar_beg = lpar
1874
1894
 
1875
1895
  lexer.cmdarg.pop
@@ -1882,10 +1902,12 @@ opt_block_args_tail: tCOMMA block_args_tail
1882
1902
 
1883
1903
  f_larglist: tLPAREN2 f_args opt_bv_decl rparen
1884
1904
  {
1905
+ self.in_argdef = false
1885
1906
  result = args val
1886
1907
  }
1887
1908
  | f_args
1888
1909
  {
1910
+ self.in_argdef = false
1889
1911
  result = val[0]
1890
1912
  result = 0 if result == s(:args)
1891
1913
  }
@@ -1953,13 +1975,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1953
1975
  {
1954
1976
  call, args = val
1955
1977
 
1956
- result = call.concat args.sexp_body if args
1978
+ result = call
1979
+
1980
+ if args then
1981
+ call.concat args.sexp_body
1982
+ result.line_max = args.line_max
1983
+ end
1957
1984
  }
1958
1985
  | primary_value call_op operation2 opt_paren_args
1959
1986
  {
1960
- recv, call_op, (op, _line), args = val
1987
+ recv, call_op, (op, op_line), args = val
1961
1988
 
1962
1989
  result = new_call recv, op.to_sym, args, call_op
1990
+ result.line_max = op_line unless args
1963
1991
  }
1964
1992
  | primary_value tCOLON2 operation2 paren_args
1965
1993
  {
@@ -1987,7 +2015,8 @@ opt_block_args_tail: tCOMMA block_args_tail
1987
2015
  }
1988
2016
  | kSUPER
1989
2017
  {
1990
- result = s(:zsuper).line lexer.lineno
2018
+ (_, line), = val
2019
+ result = s(:zsuper).line line
1991
2020
  }
1992
2021
  | primary_value tLBRACK2 opt_call_args rbracket
1993
2022
  {
@@ -1997,11 +2026,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1997
2026
  brace_block: tLCURLY
1998
2027
  {
1999
2028
  self.env.extend :dynamic
2000
- result = self.lexer.lineno
2001
2029
  }
2002
- brace_body tRCURLY
2030
+ brace_body
2031
+ tRCURLY
2003
2032
  {
2004
- _, line, body, _ = val
2033
+ (_, line), _, body, _ = val
2005
2034
 
2006
2035
  result = body
2007
2036
  result.line line
@@ -2011,11 +2040,11 @@ opt_block_args_tail: tCOMMA block_args_tail
2011
2040
  | k_do
2012
2041
  {
2013
2042
  self.env.extend :dynamic
2014
- result = self.lexer.lineno
2015
2043
  }
2016
- do_body kEND
2044
+ do_body
2045
+ kEND
2017
2046
  {
2018
- _, line, body, _ = val
2047
+ (_, line), _, body, _ = val
2019
2048
 
2020
2049
  result = body
2021
2050
  result.line line
@@ -2073,14 +2102,13 @@ opt_block_args_tail: tCOMMA block_args_tail
2073
2102
  }
2074
2103
 
2075
2104
  case_body: k_when
2076
- {
2077
- result = self.lexer.lineno
2078
- }
2079
2105
  case_args then compstmt cases
2080
2106
  {
2081
- result = new_when(val[2], val[4])
2082
- result.line val[1]
2083
- result << val[5] if val[5]
2107
+ (_, line), case_args, _then, body, cases = val
2108
+
2109
+ result = new_when case_args, body
2110
+ result.line line
2111
+ result << cases if cases
2084
2112
  }
2085
2113
 
2086
2114
  cases: opt_else | case_body
@@ -2317,31 +2345,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2317
2345
  result = new_array_pattern_tail both, nil, nil, nil
2318
2346
  result.line head.line
2319
2347
  }
2320
- | p_args_head tSTAR tIDENTIFIER
2348
+ | p_args_head p_rest
2321
2349
  {
2322
- head, _, (id, _line) = val
2350
+ head, (rest, _) = val
2323
2351
 
2324
- result = new_array_pattern_tail head, true, id.to_sym, nil
2325
- result.line head.line
2326
- }
2327
- | p_args_head tSTAR tIDENTIFIER tCOMMA p_args_post
2328
- {
2329
- head, _, (id, _line), _, post = val
2330
-
2331
- result = new_array_pattern_tail head, true, id.to_sym, post
2332
- result.line head.line
2352
+ result = new_array_pattern_tail(head, true, rest, nil).line head.line
2333
2353
  }
2334
- | p_args_head tSTAR
2354
+ | p_args_head p_rest tCOMMA p_args_post
2335
2355
  {
2336
- expr, _ = val
2356
+ head, (rest, _), _, post = val
2337
2357
 
2338
- result = new_array_pattern_tail(expr, true, nil, nil).line expr.line
2339
- }
2340
- | p_args_head tSTAR tCOMMA p_args_post
2341
- {
2342
- head, _, _, post = val
2343
-
2344
- result = new_array_pattern_tail(head, true, nil, post).line head.line
2358
+ result = new_array_pattern_tail(head, true, rest, post).line head.line
2345
2359
  }
2346
2360
  | p_args_tail
2347
2361
 
@@ -2716,15 +2730,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2716
2730
 
2717
2731
  words: tWORDS_BEG tSPACE tSTRING_END
2718
2732
  {
2719
- (_, line), _, _ = val
2733
+ (_, line), _, (_, line_max) = val
2720
2734
 
2721
2735
  result = s(:array).line line
2736
+ result.line_max = line_max
2722
2737
  }
2723
2738
  | tWORDS_BEG word_list tSTRING_END
2724
2739
  {
2725
- (_, line), list, _ = val
2740
+ (_, line), list, (_, line_max) = val
2726
2741
 
2727
2742
  result = list.line line
2743
+ result.line_max = line_max
2728
2744
  }
2729
2745
 
2730
2746
  word_list: none
@@ -2744,15 +2760,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2744
2760
 
2745
2761
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2746
2762
  {
2747
- (_, line), _, _ = val
2763
+ (_, line), _, (_, line_max) = val
2748
2764
 
2749
2765
  result = s(:array).line line
2766
+ result.line_max = line_max
2750
2767
  }
2751
2768
  | tSYMBOLS_BEG symbol_list tSTRING_END
2752
2769
  {
2753
- (_, line), list, _, = val
2754
- list.line line
2755
- result = list
2770
+ (_, line), list, (_, line_max), = val
2771
+
2772
+ result = list.line line
2773
+ result.line_max = line_max
2756
2774
  }
2757
2775
 
2758
2776
  symbol_list: none
@@ -2767,28 +2785,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2767
2785
 
2768
2786
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2769
2787
  {
2770
- (_, line), _, _ = val
2788
+ (_, line), _, (_, line_max) = val
2771
2789
 
2772
2790
  result = s(:array).line line
2791
+ result.line_max = line_max
2773
2792
  }
2774
2793
  | tQWORDS_BEG qword_list tSTRING_END
2775
2794
  {
2776
- (_, line), list, _ = val
2795
+ (_, line), list, (_, line_max) = val
2777
2796
 
2778
2797
  result = list.line line
2798
+ result.line_max = line_max
2779
2799
  }
2780
2800
 
2781
2801
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2782
2802
  {
2783
- (_, line), _, _ = val
2803
+ (_, line), _, (_, line_max) = val
2784
2804
 
2785
2805
  result = s(:array).line line
2806
+ result.line_max = line_max
2786
2807
  }
2787
2808
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2788
2809
  {
2789
- (_, line), list, _ = val
2810
+ (_, line), list, (_, line_max) = val
2790
2811
 
2791
2812
  result = list.line line
2813
+ result.line_max = line_max
2792
2814
  }
2793
2815
 
2794
2816
  qword_list: none
@@ -2863,7 +2885,6 @@ regexp_contents: none
2863
2885
  lexer.brace_nest,
2864
2886
  lexer.string_nest, # TODO: remove
2865
2887
  lexer.lex_state,
2866
- lexer.lineno,
2867
2888
  ]
2868
2889
 
2869
2890
  lexer.cmdarg.push false
@@ -2878,9 +2899,9 @@ regexp_contents: none
2878
2899
  compstmt
2879
2900
  tSTRING_DEND
2880
2901
  {
2881
- _, memo, stmt, _ = val
2902
+ (_, line), memo, stmt, _ = val
2882
2903
 
2883
- lex_strterm, brace_nest, string_nest, oldlex_state, line = memo
2904
+ lex_strterm, brace_nest, string_nest, oldlex_state = memo
2884
2905
  # TODO: heredoc_indent
2885
2906
 
2886
2907
  lexer.lex_strterm = lex_strterm
@@ -2940,11 +2961,11 @@ regexp_contents: none
2940
2961
 
2941
2962
  dsym: tSYMBEG string_contents tSTRING_END
2942
2963
  {
2943
- _, result, _ = val
2964
+ (_, line), result, _ = val
2944
2965
 
2945
2966
  lexer.lex_state = EXPR_END
2946
2967
 
2947
- result ||= s(:str, "").line lexer.lineno
2968
+ result ||= s(:str, "").line line
2948
2969
 
2949
2970
  case result.sexp_type
2950
2971
  when :dstr then
@@ -2980,15 +3001,15 @@ regexp_contents: none
2980
3001
  | tCONSTANT
2981
3002
  | tCVAR
2982
3003
 
2983
- keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2984
- | kSELF { result = s(:self).line lexer.lineno }
2985
- | kTRUE { result = s(:true).line lexer.lineno }
2986
- | kFALSE { result = s(:false).line lexer.lineno }
2987
- | k__FILE__ { result = s(:str, self.file).line lexer.lineno }
2988
- | k__LINE__ { result = s(:lit, lexer.lineno).line lexer.lineno }
3004
+ keyword_variable: kNIL { (_, line), = val; result = s(:nil).line line }
3005
+ | kSELF { (_, line), = val; result = s(:self).line line }
3006
+ | kTRUE { (_, line), = val; result = s(:true).line line }
3007
+ | kFALSE { (_, line), = val; result = s(:false).line line }
3008
+ | k__FILE__ { (_, line), = val; result = s(:str, self.file).line line }
3009
+ | k__LINE__ { (_, line), = val; result = s(:lit, line).line line }
2989
3010
  | k__ENCODING__
2990
3011
  {
2991
- l = lexer.lineno
3012
+ (_, l), = val
2992
3013
  result =
2993
3014
  if defined? Encoding then
2994
3015
  s(:colon2, s(:const, :Encoding).line(l), :UTF_8).line l
@@ -3049,11 +3070,13 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
3049
3070
  f_opt_paren_args: f_paren_args
3050
3071
  | none
3051
3072
  {
3073
+ self.in_argdef = false
3052
3074
  result = end_args val
3053
3075
  }
3054
3076
 
3055
3077
  f_paren_args: tLPAREN2 f_args rparen
3056
3078
  {
3079
+ self.in_argdef = false
3057
3080
  result = end_args val
3058
3081
  }
3059
3082
 
@@ -3061,10 +3084,12 @@ f_opt_paren_args: f_paren_args
3061
3084
  | {
3062
3085
  result = self.in_kwarg
3063
3086
  self.in_kwarg = true
3087
+ self.in_argdef = true
3064
3088
  self.lexer.lex_state |= EXPR_LABEL
3065
3089
  }
3066
3090
  f_args term
3067
3091
  {
3092
+ self.in_argdef = false
3068
3093
  result = end_args val
3069
3094
  }
3070
3095
 
@@ -3151,12 +3176,12 @@ f_opt_paren_args: f_paren_args
3151
3176
  |
3152
3177
  {
3153
3178
  result = args val
3154
- # result.line lexer.lineno
3155
3179
  }
3156
3180
 
3157
3181
  args_forward: tBDOT3
3158
3182
  {
3159
- result = s(:forward_args).line lexer.lineno
3183
+ (_, line), = val
3184
+ result = s(:forward_args).line line
3160
3185
  }
3161
3186
 
3162
3187
  f_bad_arg: tCONSTANT
@@ -3210,10 +3235,25 @@ f_opt_paren_args: f_paren_args
3210
3235
  result = s(:args, list).line list.line
3211
3236
  end
3212
3237
 
3213
- result << (Sexp === item ? item : item.first)
3238
+ if Sexp === item then
3239
+ line_max = item.line_max
3240
+ else
3241
+ item, line_max = item
3242
+ end
3243
+
3244
+ result << item
3245
+ result.line_max = line_max
3214
3246
  }
3215
3247
 
3216
3248
  f_label: tLABEL
3249
+ {
3250
+ label, = val
3251
+ # arg_var(p, formal_argument(p, $1));
3252
+ # p->cur_arg = get_id($1);
3253
+ # p->max_numparam = ORDINAL_PARAM;
3254
+ self.in_argdef = false
3255
+ result = label
3256
+ }
3217
3257
 
3218
3258
  f_kw: f_label arg_value
3219
3259
  {
@@ -3222,6 +3262,7 @@ f_opt_paren_args: f_paren_args
3222
3262
 
3223
3263
  identifier = label.to_sym
3224
3264
  self.env[identifier] = :lvar
3265
+ self.in_argdef = true
3225
3266
 
3226
3267
  kwarg = s(:kwarg, identifier, arg).line line
3227
3268
  result = s(:array, kwarg).line line
@@ -3232,6 +3273,7 @@ f_opt_paren_args: f_paren_args
3232
3273
 
3233
3274
  id = label.to_sym
3234
3275
  self.env[id] = :lvar
3276
+ self.in_argdef = true
3235
3277
 
3236
3278
  result = s(:array, s(:kwarg, id).line(line)).line line
3237
3279
  }
@@ -3242,6 +3284,7 @@ f_opt_paren_args: f_paren_args
3242
3284
  (label, line), expr = val
3243
3285
  id = label.to_sym
3244
3286
  self.env[id] = :lvar
3287
+ self.in_argdef = true
3245
3288
 
3246
3289
  result = s(:array, s(:kwarg, id, expr).line(line)).line line
3247
3290
  }
@@ -3251,6 +3294,7 @@ f_opt_paren_args: f_paren_args
3251
3294
  (label, line), = val
3252
3295
  id = label.to_sym
3253
3296
  self.env[id] = :lvar
3297
+ self.in_argdef = true
3254
3298
 
3255
3299
  result = s(:array, s(:kwarg, id).line(line)).line line
3256
3300
  }
@@ -3287,9 +3331,10 @@ f_opt_paren_args: f_paren_args
3287
3331
  }
3288
3332
  | kwrest_mark
3289
3333
  {
3334
+ (_, line), = val
3290
3335
  id = :"**"
3291
- self.env[id] = :lvar # TODO: needed?!?
3292
- result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
3336
+ self.env[id] = :lvar
3337
+ result = [id, line]
3293
3338
  }
3294
3339
 
3295
3340
  f_opt: f_arg_asgn
@@ -3297,10 +3342,10 @@ f_opt_paren_args: f_paren_args
3297
3342
  arg_value
3298
3343
  {
3299
3344
  lhs, _, rhs = val
3345
+ self.in_argdef = true
3300
3346
  result = self.assignable lhs, rhs
3301
3347
  # TODO: detect duplicate names
3302
3348
  # TODO? p->cur_arg = 0;
3303
- # TODO? p->ctxt.in_argdef = 1;
3304
3349
  }
3305
3350
 
3306
3351
  f_block_opt: f_arg_asgn
@@ -3308,9 +3353,9 @@ f_opt_paren_args: f_paren_args
3308
3353
  primary_value
3309
3354
  {
3310
3355
  lhs, _, rhs = val
3356
+ self.in_argdef = true
3311
3357
  result = self.assignable lhs, rhs
3312
3358
  # TODO? p->cur_arg = 0;
3313
- # TODO? p->ctxt.in_argdef = 1;
3314
3359
  }
3315
3360
 
3316
3361
  f_block_optarg: f_block_opt
@@ -3347,9 +3392,10 @@ f_opt_paren_args: f_paren_args
3347
3392
  }
3348
3393
  | restarg_mark
3349
3394
  {
3395
+ (_, line), = val
3350
3396
  name = :"*"
3351
3397
  self.env[name] = :lvar
3352
- result = [name, lexer.lineno] # FIX: tSTAR to include lineno
3398
+ result = [name, line]
3353
3399
  }
3354
3400
 
3355
3401
  blkarg_mark: tAMPER2 | tAMPER
@@ -3440,6 +3486,11 @@ f_opt_paren_args: f_paren_args
3440
3486
  line = arg.line
3441
3487
  result = s(:array, s(:kwsplat, arg).line(line)).line line
3442
3488
  }
3489
+ | tDSTAR
3490
+ {
3491
+ (_, line), = val
3492
+ result = s(:array, s(:kwsplat).line(line)).line line
3493
+ }
3443
3494
 
3444
3495
  operation: tIDENTIFIER | tCONSTANT | tFID
3445
3496
  operation2: tIDENTIFIER | tCONSTANT | tFID | op
@@ -3454,11 +3505,10 @@ f_opt_paren_args: f_paren_args
3454
3505
  opt_terms: | terms
3455
3506
  opt_nl: | tNL
3456
3507
  rparen: opt_nl tRPAREN
3457
- # TODO:
3458
- # {
3459
- # _, close = val
3460
- # result = [close, lexer.lineno]
3461
- # }
3508
+ {
3509
+ _, close = val # TODO: include lineno in close?
3510
+ result = [close, lexer.lineno]
3511
+ }
3462
3512
  rbracket: opt_nl tRBRACK
3463
3513
  {
3464
3514
  _, close = val