ruby_parser 3.20.0 → 3.20.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +12 -0
- data/compare/normalize.rb +1 -0
- data/lib/ruby20_parser.rb +4266 -4283
- data/lib/ruby20_parser.y +50 -26
- data/lib/ruby21_parser.rb +4240 -4239
- data/lib/ruby21_parser.y +50 -26
- data/lib/ruby22_parser.rb +4288 -4289
- data/lib/ruby22_parser.y +50 -26
- data/lib/ruby23_parser.rb +4273 -4242
- data/lib/ruby23_parser.y +50 -26
- data/lib/ruby24_parser.rb +4278 -4297
- data/lib/ruby24_parser.y +50 -26
- data/lib/ruby25_parser.rb +4269 -4288
- data/lib/ruby25_parser.y +50 -26
- data/lib/ruby26_parser.rb +4269 -4288
- data/lib/ruby26_parser.y +50 -26
- data/lib/ruby27_parser.rb +4172 -4205
- data/lib/ruby27_parser.y +50 -26
- data/lib/ruby30_parser.rb +6009 -5974
- data/lib/ruby30_parser.y +111 -84
- data/lib/ruby31_parser.rb +6130 -6227
- data/lib/ruby31_parser.y +111 -84
- data/lib/ruby32_parser.rb +6297 -6352
- data/lib/ruby32_parser.y +132 -104
- data/lib/ruby3_parser.yy +147 -84
- data/lib/ruby_lexer.rb +2 -0
- data/lib/ruby_lexer.rex.rb +1 -1
- data/lib/ruby_lexer_strings.rb +2 -2
- data/lib/ruby_parser.yy +50 -26
- data/lib/ruby_parser_extras.rb +23 -18
- data/test/test_ruby_parser.rb +187 -7
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
data/lib/ruby32_parser.y
CHANGED
@@ -96,9 +96,9 @@ rule
|
|
96
96
|
result = iter
|
97
97
|
}
|
98
98
|
|
99
|
-
begin_block: tLCURLY
|
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
|
@@ -620,7 +621,7 @@ rule
|
|
620
621
|
}
|
621
622
|
| tSTAR
|
622
623
|
{
|
623
|
-
l =
|
624
|
+
(_, l), = val
|
624
625
|
result = s(:masgn, s(:array, s(:splat).line(l)).line(l)).line l
|
625
626
|
}
|
626
627
|
| tSTAR tCOMMA mlhs_post
|
@@ -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
|
{
|
@@ -1248,7 +1251,7 @@ rule
|
|
1248
1251
|
args: arg_value
|
1249
1252
|
{
|
1250
1253
|
arg, = val
|
1251
|
-
lineno = arg.line
|
1254
|
+
lineno = arg.line
|
1252
1255
|
|
1253
1256
|
result = s(:array, arg).line lineno
|
1254
1257
|
}
|
@@ -1257,6 +1260,11 @@ rule
|
|
1257
1260
|
_, arg = val
|
1258
1261
|
result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
|
1259
1262
|
}
|
1263
|
+
| tSTAR
|
1264
|
+
{
|
1265
|
+
(_, line), = val
|
1266
|
+
result = s(:array, s(:splat).line(line)).line line
|
1267
|
+
}
|
1260
1268
|
| args tCOMMA arg_value
|
1261
1269
|
{
|
1262
1270
|
args, _, id = val
|
@@ -1264,11 +1272,14 @@ rule
|
|
1264
1272
|
}
|
1265
1273
|
| args tCOMMA tSTAR arg_value
|
1266
1274
|
{
|
1267
|
-
|
1268
|
-
args, _, _, id = val
|
1269
|
-
line = lexer.lineno
|
1275
|
+
args, _, (_, line), id = val
|
1270
1276
|
result = self.list_append args, s(:splat, id).line(line)
|
1271
1277
|
}
|
1278
|
+
| args tCOMMA tSTAR
|
1279
|
+
{
|
1280
|
+
args, _, (_, line) = val
|
1281
|
+
result = self.list_append args, s(:splat).line(line)
|
1282
|
+
}
|
1272
1283
|
|
1273
1284
|
mrhs_arg: mrhs
|
1274
1285
|
{
|
@@ -1285,7 +1296,6 @@ rule
|
|
1285
1296
|
}
|
1286
1297
|
| args tCOMMA tSTAR arg_value
|
1287
1298
|
{
|
1288
|
-
# TODO: make all tXXXX terminals include lexer.lineno
|
1289
1299
|
arg, _, _, splat = val
|
1290
1300
|
result = self.arg_concat arg, splat
|
1291
1301
|
}
|
@@ -1314,7 +1324,6 @@ rule
|
|
1314
1324
|
| k_begin
|
1315
1325
|
{
|
1316
1326
|
lexer.cmdarg.push false
|
1317
|
-
result = self.lexer.lineno
|
1318
1327
|
}
|
1319
1328
|
bodystmt k_end
|
1320
1329
|
{
|
@@ -1324,11 +1333,10 @@ rule
|
|
1324
1333
|
| tLPAREN_ARG
|
1325
1334
|
{
|
1326
1335
|
lexer.lex_state = EXPR_ENDARG
|
1327
|
-
result = lexer.lineno
|
1328
1336
|
}
|
1329
1337
|
rparen
|
1330
1338
|
{
|
1331
|
-
_, line, _ = val
|
1339
|
+
(_, line), _, _ = val
|
1332
1340
|
result = s(:begin).line line
|
1333
1341
|
}
|
1334
1342
|
| tLPAREN_ARG
|
@@ -1344,9 +1352,8 @@ rule
|
|
1344
1352
|
}
|
1345
1353
|
| tLPAREN compstmt tRPAREN
|
1346
1354
|
{
|
1347
|
-
_, stmt, _ = val
|
1348
|
-
result = stmt
|
1349
|
-
result ||= s(:nil).line lexer.lineno
|
1355
|
+
(_, line), stmt, _ = val
|
1356
|
+
result = stmt || s(:nil).line(line)
|
1350
1357
|
result.paren = true
|
1351
1358
|
}
|
1352
1359
|
| primary_value tCOLON2 tCONSTANT
|
@@ -1359,12 +1366,14 @@ rule
|
|
1359
1366
|
{
|
1360
1367
|
result = wrap :colon3, val[1]
|
1361
1368
|
}
|
1362
|
-
| tLBRACK
|
1369
|
+
| tLBRACK aref_args rbracket
|
1363
1370
|
{
|
1364
|
-
_, line, args, _ = val
|
1371
|
+
(_, line), args, (_, line_max) = val
|
1372
|
+
|
1365
1373
|
result = args || s(:array)
|
1366
1374
|
result.sexp_type = :array # aref_args is :args
|
1367
1375
|
result.line line
|
1376
|
+
result.line_max = line_max
|
1368
1377
|
}
|
1369
1378
|
| tLBRACE
|
1370
1379
|
{
|
@@ -1475,9 +1484,6 @@ rule
|
|
1475
1484
|
result = new_for iter, var, body
|
1476
1485
|
}
|
1477
1486
|
| k_class
|
1478
|
-
{
|
1479
|
-
result = self.lexer.lineno
|
1480
|
-
}
|
1481
1487
|
cpath superclass
|
1482
1488
|
{
|
1483
1489
|
if (self.in_def || self.in_single > 0) then
|
@@ -1492,9 +1498,6 @@ rule
|
|
1492
1498
|
self.lexer.ignore_body_comments
|
1493
1499
|
}
|
1494
1500
|
| k_class tLSHFT
|
1495
|
-
{
|
1496
|
-
result = self.lexer.lineno
|
1497
|
-
}
|
1498
1501
|
expr
|
1499
1502
|
{
|
1500
1503
|
result = self.in_def
|
@@ -1506,16 +1509,14 @@ rule
|
|
1506
1509
|
self.in_single = 0
|
1507
1510
|
self.env.extend
|
1508
1511
|
}
|
1509
|
-
bodystmt
|
1512
|
+
bodystmt
|
1513
|
+
k_end
|
1510
1514
|
{
|
1511
1515
|
result = new_sclass val
|
1512
1516
|
self.env.unextend
|
1513
1517
|
self.lexer.ignore_body_comments
|
1514
1518
|
}
|
1515
1519
|
| k_module
|
1516
|
-
{
|
1517
|
-
result = self.lexer.lineno
|
1518
|
-
}
|
1519
1520
|
cpath
|
1520
1521
|
{
|
1521
1522
|
yyerror "module definition in method body" if
|
@@ -1657,20 +1658,33 @@ rule
|
|
1657
1658
|
}
|
1658
1659
|
|
1659
1660
|
f_marg: f_norm_arg
|
1661
|
+
{
|
1662
|
+
(sym, line), = val
|
1663
|
+
|
1664
|
+
result = s(:dummy, sym).line line
|
1665
|
+
}
|
1660
1666
|
| tLPAREN f_margs rparen
|
1661
1667
|
{
|
1662
|
-
|
1668
|
+
_, args, _ = val
|
1669
|
+
result = args
|
1663
1670
|
}
|
1664
1671
|
|
1665
1672
|
f_marg_list: f_marg
|
1666
1673
|
{
|
1667
|
-
|
1674
|
+
arg, = val
|
1675
|
+
line = arg.line
|
1668
1676
|
|
1669
|
-
|
1677
|
+
arg = arg.last if arg.sexp_type == :dummy
|
1678
|
+
|
1679
|
+
result = s(:array, arg).line line
|
1670
1680
|
}
|
1671
1681
|
| f_marg_list tCOMMA f_marg
|
1672
1682
|
{
|
1673
|
-
|
1683
|
+
args, _, arg = val
|
1684
|
+
|
1685
|
+
arg = arg.last if arg.sexp_type == :dummy
|
1686
|
+
|
1687
|
+
result = list_append args, arg
|
1674
1688
|
}
|
1675
1689
|
|
1676
1690
|
f_margs: f_marg_list
|
@@ -1713,8 +1727,8 @@ rule
|
|
1713
1727
|
}
|
1714
1728
|
| tSTAR
|
1715
1729
|
{
|
1716
|
-
|
1717
|
-
result.line
|
1730
|
+
(_, line), = val
|
1731
|
+
result = args([:*]).line line
|
1718
1732
|
}
|
1719
1733
|
|
1720
1734
|
f_any_kwrest: f_kwrest
|
@@ -1827,7 +1841,9 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1827
1841
|
}
|
1828
1842
|
| tOROP
|
1829
1843
|
{
|
1830
|
-
|
1844
|
+
(_, line), = val
|
1845
|
+
|
1846
|
+
result = s(:args).line line
|
1831
1847
|
}
|
1832
1848
|
| tPIPE block_param opt_bv_decl tPIPE
|
1833
1849
|
{
|
@@ -1859,7 +1875,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1859
1875
|
lambda: tLAMBDA
|
1860
1876
|
{
|
1861
1877
|
self.env.extend :dynamic
|
1862
|
-
result =
|
1878
|
+
result = lexer.lpar_beg
|
1863
1879
|
lexer.paren_nest += 1
|
1864
1880
|
lexer.lpar_beg = lexer.paren_nest
|
1865
1881
|
}
|
@@ -1869,7 +1885,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1869
1885
|
}
|
1870
1886
|
lambda_body
|
1871
1887
|
{
|
1872
|
-
_,
|
1888
|
+
(_, line), lpar, args, _cmdarg, body = val
|
1873
1889
|
lexer.lpar_beg = lpar
|
1874
1890
|
|
1875
1891
|
lexer.cmdarg.pop
|
@@ -1953,13 +1969,19 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1953
1969
|
{
|
1954
1970
|
call, args = val
|
1955
1971
|
|
1956
|
-
result = call
|
1972
|
+
result = call
|
1973
|
+
|
1974
|
+
if args then
|
1975
|
+
call.concat args.sexp_body
|
1976
|
+
result.line_max = args.line_max
|
1977
|
+
end
|
1957
1978
|
}
|
1958
1979
|
| primary_value call_op operation2 opt_paren_args
|
1959
1980
|
{
|
1960
|
-
recv, call_op, (op,
|
1981
|
+
recv, call_op, (op, op_line), args = val
|
1961
1982
|
|
1962
1983
|
result = new_call recv, op.to_sym, args, call_op
|
1984
|
+
result.line_max = op_line unless args
|
1963
1985
|
}
|
1964
1986
|
| primary_value tCOLON2 operation2 paren_args
|
1965
1987
|
{
|
@@ -1987,7 +2009,8 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1987
2009
|
}
|
1988
2010
|
| kSUPER
|
1989
2011
|
{
|
1990
|
-
|
2012
|
+
(_, line), = val
|
2013
|
+
result = s(:zsuper).line line
|
1991
2014
|
}
|
1992
2015
|
| primary_value tLBRACK2 opt_call_args rbracket
|
1993
2016
|
{
|
@@ -1997,11 +2020,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1997
2020
|
brace_block: tLCURLY
|
1998
2021
|
{
|
1999
2022
|
self.env.extend :dynamic
|
2000
|
-
result = self.lexer.lineno
|
2001
2023
|
}
|
2002
|
-
brace_body
|
2024
|
+
brace_body
|
2025
|
+
tRCURLY
|
2003
2026
|
{
|
2004
|
-
_, line, body, _ = val
|
2027
|
+
(_, line), _, body, _ = val
|
2005
2028
|
|
2006
2029
|
result = body
|
2007
2030
|
result.line line
|
@@ -2011,11 +2034,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2011
2034
|
| k_do
|
2012
2035
|
{
|
2013
2036
|
self.env.extend :dynamic
|
2014
|
-
result = self.lexer.lineno
|
2015
2037
|
}
|
2016
|
-
do_body
|
2038
|
+
do_body
|
2039
|
+
kEND
|
2017
2040
|
{
|
2018
|
-
_, line, body, _ = val
|
2041
|
+
(_, line), _, body, _ = val
|
2019
2042
|
|
2020
2043
|
result = body
|
2021
2044
|
result.line line
|
@@ -2073,14 +2096,13 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2073
2096
|
}
|
2074
2097
|
|
2075
2098
|
case_body: k_when
|
2076
|
-
{
|
2077
|
-
result = self.lexer.lineno
|
2078
|
-
}
|
2079
2099
|
case_args then compstmt cases
|
2080
2100
|
{
|
2081
|
-
|
2082
|
-
|
2083
|
-
result
|
2101
|
+
(_, line), case_args, _then, body, cases = val
|
2102
|
+
|
2103
|
+
result = new_when case_args, body
|
2104
|
+
result.line line
|
2105
|
+
result << cases if cases
|
2084
2106
|
}
|
2085
2107
|
|
2086
2108
|
cases: opt_else | case_body
|
@@ -2317,31 +2339,17 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2317
2339
|
result = new_array_pattern_tail both, nil, nil, nil
|
2318
2340
|
result.line head.line
|
2319
2341
|
}
|
2320
|
-
| p_args_head
|
2321
|
-
{
|
2322
|
-
head, _, (id, _line) = val
|
2323
|
-
|
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
|
2342
|
+
| p_args_head p_rest
|
2328
2343
|
{
|
2329
|
-
head,
|
2344
|
+
head, (rest, _) = val
|
2330
2345
|
|
2331
|
-
result = new_array_pattern_tail
|
2332
|
-
result.line head.line
|
2346
|
+
result = new_array_pattern_tail(head, true, rest, nil).line head.line
|
2333
2347
|
}
|
2334
|
-
| p_args_head
|
2348
|
+
| p_args_head p_rest tCOMMA p_args_post
|
2335
2349
|
{
|
2336
|
-
|
2337
|
-
|
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
|
2350
|
+
head, (rest, _), _, post = val
|
2343
2351
|
|
2344
|
-
result = new_array_pattern_tail(head, true,
|
2352
|
+
result = new_array_pattern_tail(head, true, rest, post).line head.line
|
2345
2353
|
}
|
2346
2354
|
| p_args_tail
|
2347
2355
|
|
@@ -2716,15 +2724,17 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2716
2724
|
|
2717
2725
|
words: tWORDS_BEG tSPACE tSTRING_END
|
2718
2726
|
{
|
2719
|
-
(_, line), _, _ = val
|
2727
|
+
(_, line), _, (_, line_max) = val
|
2720
2728
|
|
2721
2729
|
result = s(:array).line line
|
2730
|
+
result.line_max = line_max
|
2722
2731
|
}
|
2723
2732
|
| tWORDS_BEG word_list tSTRING_END
|
2724
2733
|
{
|
2725
|
-
(_, line), list, _ = val
|
2734
|
+
(_, line), list, (_, line_max) = val
|
2726
2735
|
|
2727
2736
|
result = list.line line
|
2737
|
+
result.line_max = line_max
|
2728
2738
|
}
|
2729
2739
|
|
2730
2740
|
word_list: none
|
@@ -2744,15 +2754,17 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2744
2754
|
|
2745
2755
|
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
2746
2756
|
{
|
2747
|
-
(_, line), _, _ = val
|
2757
|
+
(_, line), _, (_, line_max) = val
|
2748
2758
|
|
2749
2759
|
result = s(:array).line line
|
2760
|
+
result.line_max = line_max
|
2750
2761
|
}
|
2751
2762
|
| tSYMBOLS_BEG symbol_list tSTRING_END
|
2752
2763
|
{
|
2753
|
-
(_, line), list, _, = val
|
2754
|
-
|
2755
|
-
result = list
|
2764
|
+
(_, line), list, (_, line_max), = val
|
2765
|
+
|
2766
|
+
result = list.line line
|
2767
|
+
result.line_max = line_max
|
2756
2768
|
}
|
2757
2769
|
|
2758
2770
|
symbol_list: none
|
@@ -2767,28 +2779,32 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2767
2779
|
|
2768
2780
|
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
2769
2781
|
{
|
2770
|
-
(_, line), _, _ = val
|
2782
|
+
(_, line), _, (_, line_max) = val
|
2771
2783
|
|
2772
2784
|
result = s(:array).line line
|
2785
|
+
result.line_max = line_max
|
2773
2786
|
}
|
2774
2787
|
| tQWORDS_BEG qword_list tSTRING_END
|
2775
2788
|
{
|
2776
|
-
(_, line), list, _ = val
|
2789
|
+
(_, line), list, (_, line_max) = val
|
2777
2790
|
|
2778
2791
|
result = list.line line
|
2792
|
+
result.line_max = line_max
|
2779
2793
|
}
|
2780
2794
|
|
2781
2795
|
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
2782
2796
|
{
|
2783
|
-
(_, line), _, _ = val
|
2797
|
+
(_, line), _, (_, line_max) = val
|
2784
2798
|
|
2785
2799
|
result = s(:array).line line
|
2800
|
+
result.line_max = line_max
|
2786
2801
|
}
|
2787
2802
|
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
2788
2803
|
{
|
2789
|
-
(_, line), list, _ = val
|
2804
|
+
(_, line), list, (_, line_max) = val
|
2790
2805
|
|
2791
2806
|
result = list.line line
|
2807
|
+
result.line_max = line_max
|
2792
2808
|
}
|
2793
2809
|
|
2794
2810
|
qword_list: none
|
@@ -2863,7 +2879,6 @@ regexp_contents: none
|
|
2863
2879
|
lexer.brace_nest,
|
2864
2880
|
lexer.string_nest, # TODO: remove
|
2865
2881
|
lexer.lex_state,
|
2866
|
-
lexer.lineno,
|
2867
2882
|
]
|
2868
2883
|
|
2869
2884
|
lexer.cmdarg.push false
|
@@ -2878,9 +2893,9 @@ regexp_contents: none
|
|
2878
2893
|
compstmt
|
2879
2894
|
tSTRING_DEND
|
2880
2895
|
{
|
2881
|
-
_, memo, stmt, _ = val
|
2896
|
+
(_, line), memo, stmt, _ = val
|
2882
2897
|
|
2883
|
-
lex_strterm, brace_nest, string_nest, oldlex_state
|
2898
|
+
lex_strterm, brace_nest, string_nest, oldlex_state = memo
|
2884
2899
|
# TODO: heredoc_indent
|
2885
2900
|
|
2886
2901
|
lexer.lex_strterm = lex_strterm
|
@@ -2940,11 +2955,11 @@ regexp_contents: none
|
|
2940
2955
|
|
2941
2956
|
dsym: tSYMBEG string_contents tSTRING_END
|
2942
2957
|
{
|
2943
|
-
_, result, _ = val
|
2958
|
+
(_, line), result, _ = val
|
2944
2959
|
|
2945
2960
|
lexer.lex_state = EXPR_END
|
2946
2961
|
|
2947
|
-
result ||= s(:str, "").line
|
2962
|
+
result ||= s(:str, "").line line
|
2948
2963
|
|
2949
2964
|
case result.sexp_type
|
2950
2965
|
when :dstr then
|
@@ -2980,15 +2995,15 @@ regexp_contents: none
|
|
2980
2995
|
| tCONSTANT
|
2981
2996
|
| tCVAR
|
2982
2997
|
|
2983
|
-
keyword_variable: kNIL { result = s(:nil).line
|
2984
|
-
| kSELF { result = s(:self).line
|
2985
|
-
| kTRUE { result = s(:true).line
|
2986
|
-
| kFALSE { result = s(:false).line
|
2987
|
-
| k__FILE__ { result = s(:str, self.file).line
|
2988
|
-
| k__LINE__ { result = s(:lit,
|
2998
|
+
keyword_variable: kNIL { (_, line), = val; result = s(:nil).line line }
|
2999
|
+
| kSELF { (_, line), = val; result = s(:self).line line }
|
3000
|
+
| kTRUE { (_, line), = val; result = s(:true).line line }
|
3001
|
+
| kFALSE { (_, line), = val; result = s(:false).line line }
|
3002
|
+
| k__FILE__ { (_, line), = val; result = s(:str, self.file).line line }
|
3003
|
+
| k__LINE__ { (_, line), = val; result = s(:lit, line).line line }
|
2989
3004
|
| k__ENCODING__
|
2990
3005
|
{
|
2991
|
-
l =
|
3006
|
+
(_, l), = val
|
2992
3007
|
result =
|
2993
3008
|
if defined? Encoding then
|
2994
3009
|
s(:colon2, s(:const, :Encoding).line(l), :UTF_8).line l
|
@@ -3151,12 +3166,12 @@ f_opt_paren_args: f_paren_args
|
|
3151
3166
|
|
|
3152
3167
|
{
|
3153
3168
|
result = args val
|
3154
|
-
# result.line lexer.lineno
|
3155
3169
|
}
|
3156
3170
|
|
3157
3171
|
args_forward: tBDOT3
|
3158
3172
|
{
|
3159
|
-
|
3173
|
+
(_, line), = val
|
3174
|
+
result = s(:forward_args).line line
|
3160
3175
|
}
|
3161
3176
|
|
3162
3177
|
f_bad_arg: tCONSTANT
|
@@ -3210,7 +3225,14 @@ f_opt_paren_args: f_paren_args
|
|
3210
3225
|
result = s(:args, list).line list.line
|
3211
3226
|
end
|
3212
3227
|
|
3213
|
-
|
3228
|
+
if Sexp === item then
|
3229
|
+
line_max = item.line_max
|
3230
|
+
else
|
3231
|
+
item, line_max = item
|
3232
|
+
end
|
3233
|
+
|
3234
|
+
result << item
|
3235
|
+
result.line_max = line_max
|
3214
3236
|
}
|
3215
3237
|
|
3216
3238
|
f_label: tLABEL
|
@@ -3287,9 +3309,10 @@ f_opt_paren_args: f_paren_args
|
|
3287
3309
|
}
|
3288
3310
|
| kwrest_mark
|
3289
3311
|
{
|
3312
|
+
(_, line), = val
|
3290
3313
|
id = :"**"
|
3291
|
-
self.env[id] = :lvar
|
3292
|
-
result = [id,
|
3314
|
+
self.env[id] = :lvar
|
3315
|
+
result = [id, line]
|
3293
3316
|
}
|
3294
3317
|
|
3295
3318
|
f_opt: f_arg_asgn
|
@@ -3347,9 +3370,10 @@ f_opt_paren_args: f_paren_args
|
|
3347
3370
|
}
|
3348
3371
|
| restarg_mark
|
3349
3372
|
{
|
3373
|
+
(_, line), = val
|
3350
3374
|
name = :"*"
|
3351
3375
|
self.env[name] = :lvar
|
3352
|
-
result = [name,
|
3376
|
+
result = [name, line]
|
3353
3377
|
}
|
3354
3378
|
|
3355
3379
|
blkarg_mark: tAMPER2 | tAMPER
|
@@ -3440,6 +3464,11 @@ f_opt_paren_args: f_paren_args
|
|
3440
3464
|
line = arg.line
|
3441
3465
|
result = s(:array, s(:kwsplat, arg).line(line)).line line
|
3442
3466
|
}
|
3467
|
+
| tDSTAR
|
3468
|
+
{
|
3469
|
+
(_, line), = val
|
3470
|
+
result = s(:array, s(:kwsplat).line(line)).line line
|
3471
|
+
}
|
3443
3472
|
|
3444
3473
|
operation: tIDENTIFIER | tCONSTANT | tFID
|
3445
3474
|
operation2: tIDENTIFIER | tCONSTANT | tFID | op
|
@@ -3454,11 +3483,10 @@ f_opt_paren_args: f_paren_args
|
|
3454
3483
|
opt_terms: | terms
|
3455
3484
|
opt_nl: | tNL
|
3456
3485
|
rparen: opt_nl tRPAREN
|
3457
|
-
|
3458
|
-
|
3459
|
-
|
3460
|
-
|
3461
|
-
# }
|
3486
|
+
{
|
3487
|
+
_, close = val # TODO: include lineno in close?
|
3488
|
+
result = [close, lexer.lineno]
|
3489
|
+
}
|
3462
3490
|
rbracket: opt_nl tRBRACK
|
3463
3491
|
{
|
3464
3492
|
_, close = val
|