ruby_parser 3.20.1 → 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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +18 -0
- data/compare/normalize.rb +1 -0
- data/lib/ruby20_parser.rb +4220 -4273
- data/lib/ruby20_parser.y +0 -10
- data/lib/ruby21_parser.rb +4203 -4238
- data/lib/ruby21_parser.y +0 -10
- data/lib/ruby22_parser.rb +4239 -4276
- data/lib/ruby22_parser.y +0 -10
- data/lib/ruby23_parser.rb +4235 -4240
- data/lib/ruby23_parser.y +0 -10
- data/lib/ruby24_parser.rb +4229 -4284
- data/lib/ruby24_parser.y +0 -10
- data/lib/ruby25_parser.rb +4220 -4275
- data/lib/ruby25_parser.y +0 -10
- data/lib/ruby26_parser.rb +4221 -4276
- data/lib/ruby26_parser.y +0 -10
- data/lib/ruby27_parser.rb +4138 -4207
- data/lib/ruby27_parser.y +0 -10
- data/lib/ruby30_parser.rb +5989 -5957
- data/lib/ruby30_parser.y +95 -72
- data/lib/ruby31_parser.rb +6157 -6172
- data/lib/ruby31_parser.y +96 -73
- data/lib/ruby32_parser.rb +6251 -6314
- data/lib/ruby32_parser.y +117 -93
- data/lib/ruby3_parser.yy +132 -73
- data/lib/ruby_lexer.rb +15 -7
- data/lib/ruby_lexer.rex.rb +1 -1
- data/lib/ruby_lexer_strings.rb +2 -2
- data/lib/ruby_parser.yy +0 -10
- data/lib/ruby_parser_extras.rb +9 -9
- data/test/test_ruby_parser.rb +39 -1
- data/tools/munge.rb +8 -2
- data/tools/ripper.rb +14 -12
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
data/lib/ruby3_parser.yy
CHANGED
@@ -104,9 +104,9 @@ rule
|
|
104
104
|
result = iter
|
105
105
|
}
|
106
106
|
|
107
|
-
begin_block: tLCURLY
|
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
|
|
@@ -426,6 +426,7 @@ rule
|
|
426
426
|
defs_head: k_def singleton dot_or_colon
|
427
427
|
{
|
428
428
|
lexer.lex_state = EXPR_FNAME
|
429
|
+
self.in_argdef = true
|
429
430
|
}
|
430
431
|
def_name
|
431
432
|
{
|
@@ -639,7 +640,7 @@ rule
|
|
639
640
|
}
|
640
641
|
| tSTAR
|
641
642
|
{
|
642
|
-
l =
|
643
|
+
(_, l), = val
|
643
644
|
result = s(:masgn, s(:array, s(:splat).line(l)).line(l)).line l
|
644
645
|
}
|
645
646
|
| tSTAR tCOMMA mlhs_post
|
@@ -1271,7 +1272,7 @@ rule
|
|
1271
1272
|
args: arg_value
|
1272
1273
|
{
|
1273
1274
|
arg, = val
|
1274
|
-
lineno = arg.line
|
1275
|
+
lineno = arg.line
|
1275
1276
|
|
1276
1277
|
result = s(:array, arg).line lineno
|
1277
1278
|
}
|
@@ -1280,6 +1281,13 @@ rule
|
|
1280
1281
|
_, arg = val
|
1281
1282
|
result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
|
1282
1283
|
}
|
1284
|
+
#if V >= 32
|
1285
|
+
| tSTAR
|
1286
|
+
{
|
1287
|
+
(_, line), = val
|
1288
|
+
result = s(:array, s(:splat).line(line)).line line
|
1289
|
+
}
|
1290
|
+
#endif
|
1283
1291
|
| args tCOMMA arg_value
|
1284
1292
|
{
|
1285
1293
|
args, _, id = val
|
@@ -1287,11 +1295,16 @@ rule
|
|
1287
1295
|
}
|
1288
1296
|
| args tCOMMA tSTAR arg_value
|
1289
1297
|
{
|
1290
|
-
|
1291
|
-
args, _, _, id = val
|
1292
|
-
line = lexer.lineno
|
1298
|
+
args, _, (_, line), id = val
|
1293
1299
|
result = self.list_append args, s(:splat, id).line(line)
|
1294
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
|
1295
1308
|
|
1296
1309
|
mrhs_arg: mrhs
|
1297
1310
|
{
|
@@ -1308,7 +1321,6 @@ rule
|
|
1308
1321
|
}
|
1309
1322
|
| args tCOMMA tSTAR arg_value
|
1310
1323
|
{
|
1311
|
-
# TODO: make all tXXXX terminals include lexer.lineno
|
1312
1324
|
arg, _, _, splat = val
|
1313
1325
|
result = self.arg_concat arg, splat
|
1314
1326
|
}
|
@@ -1337,7 +1349,6 @@ rule
|
|
1337
1349
|
| k_begin
|
1338
1350
|
{
|
1339
1351
|
lexer.cmdarg.push false
|
1340
|
-
result = self.lexer.lineno
|
1341
1352
|
}
|
1342
1353
|
bodystmt k_end
|
1343
1354
|
{
|
@@ -1347,11 +1358,10 @@ rule
|
|
1347
1358
|
| tLPAREN_ARG
|
1348
1359
|
{
|
1349
1360
|
lexer.lex_state = EXPR_ENDARG
|
1350
|
-
result = lexer.lineno
|
1351
1361
|
}
|
1352
1362
|
rparen
|
1353
1363
|
{
|
1354
|
-
_, line, _ = val
|
1364
|
+
(_, line), _, _ = val
|
1355
1365
|
result = s(:begin).line line
|
1356
1366
|
}
|
1357
1367
|
| tLPAREN_ARG
|
@@ -1367,9 +1377,8 @@ rule
|
|
1367
1377
|
}
|
1368
1378
|
| tLPAREN compstmt tRPAREN
|
1369
1379
|
{
|
1370
|
-
_, stmt, _ = val
|
1371
|
-
result = stmt
|
1372
|
-
result ||= s(:nil).line lexer.lineno
|
1380
|
+
(_, line), stmt, _ = val
|
1381
|
+
result = stmt || s(:nil).line(line)
|
1373
1382
|
result.paren = true
|
1374
1383
|
}
|
1375
1384
|
| primary_value tCOLON2 tCONSTANT
|
@@ -1382,9 +1391,9 @@ rule
|
|
1382
1391
|
{
|
1383
1392
|
result = wrap :colon3, val[1]
|
1384
1393
|
}
|
1385
|
-
| tLBRACK
|
1394
|
+
| tLBRACK aref_args rbracket
|
1386
1395
|
{
|
1387
|
-
_, line, args, (_, line_max) = val
|
1396
|
+
(_, line), args, (_, line_max) = val
|
1388
1397
|
|
1389
1398
|
result = args || s(:array)
|
1390
1399
|
result.sexp_type = :array # aref_args is :args
|
@@ -1500,9 +1509,6 @@ rule
|
|
1500
1509
|
result = new_for iter, var, body
|
1501
1510
|
}
|
1502
1511
|
| k_class
|
1503
|
-
{
|
1504
|
-
result = self.lexer.lineno
|
1505
|
-
}
|
1506
1512
|
cpath superclass
|
1507
1513
|
{
|
1508
1514
|
if (self.in_def || self.in_single > 0) then
|
@@ -1517,9 +1523,6 @@ rule
|
|
1517
1523
|
self.lexer.ignore_body_comments
|
1518
1524
|
}
|
1519
1525
|
| k_class tLSHFT
|
1520
|
-
{
|
1521
|
-
result = self.lexer.lineno
|
1522
|
-
}
|
1523
1526
|
expr
|
1524
1527
|
{
|
1525
1528
|
result = self.in_def
|
@@ -1531,16 +1534,14 @@ rule
|
|
1531
1534
|
self.in_single = 0
|
1532
1535
|
self.env.extend
|
1533
1536
|
}
|
1534
|
-
bodystmt
|
1537
|
+
bodystmt
|
1538
|
+
k_end
|
1535
1539
|
{
|
1536
1540
|
result = new_sclass val
|
1537
1541
|
self.env.unextend
|
1538
1542
|
self.lexer.ignore_body_comments
|
1539
1543
|
}
|
1540
1544
|
| k_module
|
1541
|
-
{
|
1542
|
-
result = self.lexer.lineno
|
1543
|
-
}
|
1544
1545
|
cpath
|
1545
1546
|
{
|
1546
1547
|
yyerror "module definition in method body" if
|
@@ -1643,6 +1644,7 @@ rule
|
|
1643
1644
|
k_def: kDEF
|
1644
1645
|
{
|
1645
1646
|
self.comments.push self.lexer.comments
|
1647
|
+
self.in_argdef = true
|
1646
1648
|
}
|
1647
1649
|
k_do: kDO
|
1648
1650
|
k_do_block: kDO_BLOCK
|
@@ -1682,20 +1684,33 @@ rule
|
|
1682
1684
|
}
|
1683
1685
|
|
1684
1686
|
f_marg: f_norm_arg
|
1687
|
+
{
|
1688
|
+
(sym, line), = val
|
1689
|
+
|
1690
|
+
result = s(:dummy, sym).line line
|
1691
|
+
}
|
1685
1692
|
| tLPAREN f_margs rparen
|
1686
1693
|
{
|
1687
|
-
|
1694
|
+
_, args, _ = val
|
1695
|
+
result = args
|
1688
1696
|
}
|
1689
1697
|
|
1690
1698
|
f_marg_list: f_marg
|
1691
1699
|
{
|
1692
|
-
|
1700
|
+
arg, = val
|
1701
|
+
line = arg.line
|
1693
1702
|
|
1694
|
-
|
1703
|
+
arg = arg.last if arg.sexp_type == :dummy
|
1704
|
+
|
1705
|
+
result = s(:array, arg).line line
|
1695
1706
|
}
|
1696
1707
|
| f_marg_list tCOMMA f_marg
|
1697
1708
|
{
|
1698
|
-
|
1709
|
+
args, _, arg = val
|
1710
|
+
|
1711
|
+
arg = arg.last if arg.sexp_type == :dummy
|
1712
|
+
|
1713
|
+
result = list_append args, arg
|
1699
1714
|
}
|
1700
1715
|
|
1701
1716
|
f_margs: f_marg_list
|
@@ -1738,15 +1753,15 @@ rule
|
|
1738
1753
|
}
|
1739
1754
|
| tSTAR
|
1740
1755
|
{
|
1741
|
-
|
1742
|
-
result.line
|
1756
|
+
(_, line), = val
|
1757
|
+
result = args([:*]).line line
|
1743
1758
|
}
|
1744
1759
|
|
1745
1760
|
f_any_kwrest: f_kwrest
|
1746
1761
|
| f_no_kwarg
|
1747
1762
|
|
1748
1763
|
#if V > 30
|
1749
|
-
f_eq:
|
1764
|
+
f_eq: { self.in_argdef = false } tEQL
|
1750
1765
|
#endif
|
1751
1766
|
|
1752
1767
|
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -1851,15 +1866,19 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1851
1866
|
{
|
1852
1867
|
# TODO: current_arg = 0
|
1853
1868
|
result = args val
|
1869
|
+
self.in_argdef = false
|
1854
1870
|
}
|
1855
1871
|
| tOROP
|
1856
1872
|
{
|
1857
|
-
|
1873
|
+
(_, line), = val
|
1874
|
+
|
1875
|
+
result = s(:args).line line
|
1858
1876
|
}
|
1859
1877
|
| tPIPE block_param opt_bv_decl tPIPE
|
1860
1878
|
{
|
1861
1879
|
# TODO: current_arg = 0
|
1862
1880
|
result = args val
|
1881
|
+
self.in_argdef = false
|
1863
1882
|
}
|
1864
1883
|
|
1865
1884
|
opt_bv_decl: opt_nl
|
@@ -1886,7 +1905,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1886
1905
|
lambda: tLAMBDA
|
1887
1906
|
{
|
1888
1907
|
self.env.extend :dynamic
|
1889
|
-
result =
|
1908
|
+
result = lexer.lpar_beg
|
1890
1909
|
lexer.paren_nest += 1
|
1891
1910
|
lexer.lpar_beg = lexer.paren_nest
|
1892
1911
|
}
|
@@ -1896,7 +1915,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1896
1915
|
}
|
1897
1916
|
lambda_body
|
1898
1917
|
{
|
1899
|
-
_,
|
1918
|
+
(_, line), lpar, args, _cmdarg, body = val
|
1900
1919
|
lexer.lpar_beg = lpar
|
1901
1920
|
|
1902
1921
|
lexer.cmdarg.pop
|
@@ -1909,10 +1928,12 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1909
1928
|
|
1910
1929
|
f_larglist: tLPAREN2 f_args opt_bv_decl rparen
|
1911
1930
|
{
|
1931
|
+
self.in_argdef = false
|
1912
1932
|
result = args val
|
1913
1933
|
}
|
1914
1934
|
| f_args
|
1915
1935
|
{
|
1936
|
+
self.in_argdef = false
|
1916
1937
|
result = val[0]
|
1917
1938
|
result = 0 if result == s(:args)
|
1918
1939
|
}
|
@@ -2020,7 +2041,8 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2020
2041
|
}
|
2021
2042
|
| kSUPER
|
2022
2043
|
{
|
2023
|
-
|
2044
|
+
(_, line), = val
|
2045
|
+
result = s(:zsuper).line line
|
2024
2046
|
}
|
2025
2047
|
| primary_value tLBRACK2 opt_call_args rbracket
|
2026
2048
|
{
|
@@ -2030,11 +2052,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2030
2052
|
brace_block: tLCURLY
|
2031
2053
|
{
|
2032
2054
|
self.env.extend :dynamic
|
2033
|
-
result = self.lexer.lineno
|
2034
2055
|
}
|
2035
|
-
brace_body
|
2056
|
+
brace_body
|
2057
|
+
tRCURLY
|
2036
2058
|
{
|
2037
|
-
_, line, body, _ = val
|
2059
|
+
(_, line), _, body, _ = val
|
2038
2060
|
|
2039
2061
|
result = body
|
2040
2062
|
result.line line
|
@@ -2044,11 +2066,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2044
2066
|
| k_do
|
2045
2067
|
{
|
2046
2068
|
self.env.extend :dynamic
|
2047
|
-
result = self.lexer.lineno
|
2048
2069
|
}
|
2049
|
-
do_body
|
2070
|
+
do_body
|
2071
|
+
kEND
|
2050
2072
|
{
|
2051
|
-
_, line, body, _ = val
|
2073
|
+
(_, line), _, body, _ = val
|
2052
2074
|
|
2053
2075
|
result = body
|
2054
2076
|
result.line line
|
@@ -2106,14 +2128,13 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2106
2128
|
}
|
2107
2129
|
|
2108
2130
|
case_body: k_when
|
2109
|
-
{
|
2110
|
-
result = self.lexer.lineno
|
2111
|
-
}
|
2112
2131
|
case_args then compstmt cases
|
2113
2132
|
{
|
2114
|
-
|
2115
|
-
|
2116
|
-
result
|
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
|
2117
2138
|
}
|
2118
2139
|
|
2119
2140
|
cases: opt_else | case_body
|
@@ -2352,6 +2373,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2352
2373
|
result = new_array_pattern_tail both, nil, nil, nil
|
2353
2374
|
result.line head.line
|
2354
2375
|
}
|
2376
|
+
#if V < 32
|
2355
2377
|
| p_args_head tSTAR tIDENTIFIER
|
2356
2378
|
{
|
2357
2379
|
head, _, (id, _line) = val
|
@@ -2378,6 +2400,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2378
2400
|
|
2379
2401
|
result = new_array_pattern_tail(head, true, nil, post).line head.line
|
2380
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
|
2381
2417
|
| p_args_tail
|
2382
2418
|
|
2383
2419
|
p_args_head: p_arg tCOMMA
|
@@ -2917,7 +2953,6 @@ regexp_contents: none
|
|
2917
2953
|
lexer.brace_nest,
|
2918
2954
|
lexer.string_nest, # TODO: remove
|
2919
2955
|
lexer.lex_state,
|
2920
|
-
lexer.lineno,
|
2921
2956
|
]
|
2922
2957
|
|
2923
2958
|
lexer.cmdarg.push false
|
@@ -2932,9 +2967,9 @@ regexp_contents: none
|
|
2932
2967
|
compstmt
|
2933
2968
|
tSTRING_DEND
|
2934
2969
|
{
|
2935
|
-
_, memo, stmt, _ = val
|
2970
|
+
(_, line), memo, stmt, _ = val
|
2936
2971
|
|
2937
|
-
lex_strterm, brace_nest, string_nest, oldlex_state
|
2972
|
+
lex_strterm, brace_nest, string_nest, oldlex_state = memo
|
2938
2973
|
# TODO: heredoc_indent
|
2939
2974
|
|
2940
2975
|
lexer.lex_strterm = lex_strterm
|
@@ -2994,11 +3029,11 @@ regexp_contents: none
|
|
2994
3029
|
|
2995
3030
|
dsym: tSYMBEG string_contents tSTRING_END
|
2996
3031
|
{
|
2997
|
-
_, result, _ = val
|
3032
|
+
(_, line), result, _ = val
|
2998
3033
|
|
2999
3034
|
lexer.lex_state = EXPR_END
|
3000
3035
|
|
3001
|
-
result ||= s(:str, "").line
|
3036
|
+
result ||= s(:str, "").line line
|
3002
3037
|
|
3003
3038
|
case result.sexp_type
|
3004
3039
|
when :dstr then
|
@@ -3036,15 +3071,15 @@ regexp_contents: none
|
|
3036
3071
|
| tCONSTANT
|
3037
3072
|
| tCVAR
|
3038
3073
|
|
3039
|
-
keyword_variable: kNIL { result = s(:nil).line
|
3040
|
-
| kSELF { result = s(:self).line
|
3041
|
-
| kTRUE { result = s(:true).line
|
3042
|
-
| kFALSE { result = s(:false).line
|
3043
|
-
| k__FILE__ { result = s(:str, self.file).line
|
3044
|
-
| k__LINE__ { result = s(:lit,
|
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 }
|
3045
3080
|
| k__ENCODING__
|
3046
3081
|
{
|
3047
|
-
l =
|
3082
|
+
(_, l), = val
|
3048
3083
|
result =
|
3049
3084
|
if defined? Encoding then
|
3050
3085
|
s(:colon2, s(:const, :Encoding).line(l), :UTF_8).line l
|
@@ -3105,11 +3140,13 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
3105
3140
|
f_opt_paren_args: f_paren_args
|
3106
3141
|
| none
|
3107
3142
|
{
|
3143
|
+
self.in_argdef = false
|
3108
3144
|
result = end_args val
|
3109
3145
|
}
|
3110
3146
|
|
3111
3147
|
f_paren_args: tLPAREN2 f_args rparen
|
3112
3148
|
{
|
3149
|
+
self.in_argdef = false
|
3113
3150
|
result = end_args val
|
3114
3151
|
}
|
3115
3152
|
#if V == 30
|
@@ -3127,10 +3164,12 @@ f_opt_paren_args: f_paren_args
|
|
3127
3164
|
| {
|
3128
3165
|
result = self.in_kwarg
|
3129
3166
|
self.in_kwarg = true
|
3167
|
+
self.in_argdef = true
|
3130
3168
|
self.lexer.lex_state |= EXPR_LABEL
|
3131
3169
|
}
|
3132
3170
|
f_args term
|
3133
3171
|
{
|
3172
|
+
self.in_argdef = false
|
3134
3173
|
result = end_args val
|
3135
3174
|
}
|
3136
3175
|
|
@@ -3219,12 +3258,12 @@ f_opt_paren_args: f_paren_args
|
|
3219
3258
|
|
|
3220
3259
|
{
|
3221
3260
|
result = args val
|
3222
|
-
# result.line lexer.lineno
|
3223
3261
|
}
|
3224
3262
|
|
3225
3263
|
args_forward: tBDOT3
|
3226
3264
|
{
|
3227
|
-
|
3265
|
+
(_, line), = val
|
3266
|
+
result = s(:forward_args).line line
|
3228
3267
|
}
|
3229
3268
|
|
3230
3269
|
f_bad_arg: tCONSTANT
|
@@ -3289,6 +3328,14 @@ f_opt_paren_args: f_paren_args
|
|
3289
3328
|
}
|
3290
3329
|
|
3291
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
|
+
}
|
3292
3339
|
|
3293
3340
|
f_kw: f_label arg_value
|
3294
3341
|
{
|
@@ -3297,6 +3344,7 @@ f_opt_paren_args: f_paren_args
|
|
3297
3344
|
|
3298
3345
|
identifier = label.to_sym
|
3299
3346
|
self.env[identifier] = :lvar
|
3347
|
+
self.in_argdef = true
|
3300
3348
|
|
3301
3349
|
kwarg = s(:kwarg, identifier, arg).line line
|
3302
3350
|
result = s(:array, kwarg).line line
|
@@ -3307,6 +3355,7 @@ f_opt_paren_args: f_paren_args
|
|
3307
3355
|
|
3308
3356
|
id = label.to_sym
|
3309
3357
|
self.env[id] = :lvar
|
3358
|
+
self.in_argdef = true
|
3310
3359
|
|
3311
3360
|
result = s(:array, s(:kwarg, id).line(line)).line line
|
3312
3361
|
}
|
@@ -3317,6 +3366,7 @@ f_opt_paren_args: f_paren_args
|
|
3317
3366
|
(label, line), expr = val
|
3318
3367
|
id = label.to_sym
|
3319
3368
|
self.env[id] = :lvar
|
3369
|
+
self.in_argdef = true
|
3320
3370
|
|
3321
3371
|
result = s(:array, s(:kwarg, id, expr).line(line)).line line
|
3322
3372
|
}
|
@@ -3326,6 +3376,7 @@ f_opt_paren_args: f_paren_args
|
|
3326
3376
|
(label, line), = val
|
3327
3377
|
id = label.to_sym
|
3328
3378
|
self.env[id] = :lvar
|
3379
|
+
self.in_argdef = true
|
3329
3380
|
|
3330
3381
|
result = s(:array, s(:kwarg, id).line(line)).line line
|
3331
3382
|
}
|
@@ -3362,9 +3413,10 @@ f_opt_paren_args: f_paren_args
|
|
3362
3413
|
}
|
3363
3414
|
| kwrest_mark
|
3364
3415
|
{
|
3416
|
+
(_, line), = val
|
3365
3417
|
id = :"**"
|
3366
|
-
self.env[id] = :lvar
|
3367
|
-
result = [id,
|
3418
|
+
self.env[id] = :lvar
|
3419
|
+
result = [id, line]
|
3368
3420
|
}
|
3369
3421
|
|
3370
3422
|
f_opt: f_arg_asgn
|
@@ -3376,10 +3428,10 @@ f_opt_paren_args: f_paren_args
|
|
3376
3428
|
arg_value
|
3377
3429
|
{
|
3378
3430
|
lhs, _, rhs = val
|
3431
|
+
self.in_argdef = true
|
3379
3432
|
result = self.assignable lhs, rhs
|
3380
3433
|
# TODO: detect duplicate names
|
3381
3434
|
# TODO? p->cur_arg = 0;
|
3382
|
-
# TODO? p->ctxt.in_argdef = 1;
|
3383
3435
|
}
|
3384
3436
|
|
3385
3437
|
f_block_opt: f_arg_asgn
|
@@ -3391,9 +3443,9 @@ f_opt_paren_args: f_paren_args
|
|
3391
3443
|
primary_value
|
3392
3444
|
{
|
3393
3445
|
lhs, _, rhs = val
|
3446
|
+
self.in_argdef = true
|
3394
3447
|
result = self.assignable lhs, rhs
|
3395
3448
|
# TODO? p->cur_arg = 0;
|
3396
|
-
# TODO? p->ctxt.in_argdef = 1;
|
3397
3449
|
}
|
3398
3450
|
|
3399
3451
|
f_block_optarg: f_block_opt
|
@@ -3430,9 +3482,10 @@ f_opt_paren_args: f_paren_args
|
|
3430
3482
|
}
|
3431
3483
|
| restarg_mark
|
3432
3484
|
{
|
3485
|
+
(_, line), = val
|
3433
3486
|
name = :"*"
|
3434
3487
|
self.env[name] = :lvar
|
3435
|
-
result = [name,
|
3488
|
+
result = [name, line]
|
3436
3489
|
}
|
3437
3490
|
|
3438
3491
|
blkarg_mark: tAMPER2 | tAMPER
|
@@ -3523,6 +3576,13 @@ f_opt_paren_args: f_paren_args
|
|
3523
3576
|
line = arg.line
|
3524
3577
|
result = s(:array, s(:kwsplat, arg).line(line)).line line
|
3525
3578
|
}
|
3579
|
+
#if V >= 32
|
3580
|
+
| tDSTAR
|
3581
|
+
{
|
3582
|
+
(_, line), = val
|
3583
|
+
result = s(:array, s(:kwsplat).line(line)).line line
|
3584
|
+
}
|
3585
|
+
#endif
|
3526
3586
|
|
3527
3587
|
operation: tIDENTIFIER | tCONSTANT | tFID
|
3528
3588
|
operation2: tIDENTIFIER | tCONSTANT | tFID | op
|
@@ -3537,11 +3597,10 @@ f_opt_paren_args: f_paren_args
|
|
3537
3597
|
opt_terms: | terms
|
3538
3598
|
opt_nl: | tNL
|
3539
3599
|
rparen: opt_nl tRPAREN
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3543
|
-
|
3544
|
-
# }
|
3600
|
+
{
|
3601
|
+
_, close = val # TODO: include lineno in close?
|
3602
|
+
result = [close, lexer.lineno]
|
3603
|
+
}
|
3545
3604
|
rbracket: opt_nl tRBRACK
|
3546
3605
|
{
|
3547
3606
|
_, close = val
|
data/lib/ruby_lexer.rb
CHANGED
@@ -117,7 +117,7 @@ class RubyLexer
|
|
117
117
|
|
118
118
|
def initialize _ = nil
|
119
119
|
@lex_state = nil # remove one warning under $DEBUG
|
120
|
-
|
120
|
+
@lex_state = EXPR_NONE
|
121
121
|
|
122
122
|
self.cond = RubyParserStuff::StackState.new(:cond, $DEBUG)
|
123
123
|
self.cmdarg = RubyParserStuff::StackState.new(:cmdarg, $DEBUG)
|
@@ -271,6 +271,8 @@ class RubyLexer
|
|
271
271
|
nil # TODO
|
272
272
|
end
|
273
273
|
|
274
|
+
# TODO: make all tXXXX terminals include lexer.lineno ... enforce it somehow?
|
275
|
+
|
274
276
|
def process_brace_close text
|
275
277
|
case matched
|
276
278
|
when "}" then
|
@@ -353,8 +355,14 @@ class RubyLexer
|
|
353
355
|
end
|
354
356
|
end
|
355
357
|
|
356
|
-
def process_dots text
|
357
|
-
|
358
|
+
def process_dots text # parse32.y:10216
|
359
|
+
is_beg = self.is_beg?
|
360
|
+
self.lex_state = EXPR_BEG
|
361
|
+
|
362
|
+
return result EXPR_ENDARG, :tBDOT3, text if
|
363
|
+
parser.in_argdef && text == "..." # TODO: version check?
|
364
|
+
|
365
|
+
tokens = ruby27plus? && is_beg ? BTOKENS : TOKENS
|
358
366
|
|
359
367
|
result EXPR_BEG, tokens[text], text
|
360
368
|
end
|
@@ -687,7 +695,7 @@ class RubyLexer
|
|
687
695
|
return process_token_keyword keyword if keyword
|
688
696
|
end
|
689
697
|
|
690
|
-
# matching: compare/
|
698
|
+
# matching: compare/parse32.y:9031
|
691
699
|
state = if lex_state =~ EXPR_BEG_ANY|EXPR_ARG_ANY|EXPR_DOT then
|
692
700
|
cmd_state ? EXPR_CMDARG : EXPR_ARG
|
693
701
|
elsif lex_state =~ EXPR_FNAME then
|
@@ -709,7 +717,7 @@ class RubyLexer
|
|
709
717
|
end
|
710
718
|
|
711
719
|
def process_token_keyword keyword
|
712
|
-
# matching MIDDLE of parse_ident in compare/
|
720
|
+
# matching MIDDLE of parse_ident in compare/parse32.y:9695
|
713
721
|
state = lex_state
|
714
722
|
|
715
723
|
return result(EXPR_ENDFN, keyword.id0, token) if lex_state =~ EXPR_FNAME
|
@@ -718,7 +726,7 @@ class RubyLexer
|
|
718
726
|
self.command_start = true if lex_state =~ EXPR_BEG
|
719
727
|
|
720
728
|
case
|
721
|
-
when keyword.id0 == :kDO then #
|
729
|
+
when keyword.id0 == :kDO then # parse32.y line 9712
|
722
730
|
case
|
723
731
|
when lambda_beginning? then
|
724
732
|
self.lpar_beg = nil # lambda_beginning? == FALSE in the body of "-> do ... end"
|
@@ -890,7 +898,7 @@ class RubyLexer
|
|
890
898
|
end
|
891
899
|
|
892
900
|
def inspect
|
893
|
-
return "
|
901
|
+
return "EXPR_NONE" if n.zero? # HACK?
|
894
902
|
|
895
903
|
names.map { |v, k| k if self =~ v }.
|
896
904
|
compact.
|
data/lib/ruby_lexer.rex.rb
CHANGED
data/lib/ruby_lexer_strings.rb
CHANGED
@@ -56,7 +56,7 @@ class RubyLexer
|
|
56
56
|
return :tSTRING_DVAR, matched
|
57
57
|
when scan(/#[{]/) then
|
58
58
|
self.command_start = true
|
59
|
-
return :tSTRING_DBEG, matched
|
59
|
+
return :tSTRING_DBEG, [matched, lineno]
|
60
60
|
when scan(/#/) then
|
61
61
|
string_buffer << "#"
|
62
62
|
end
|
@@ -415,7 +415,7 @@ class RubyLexer
|
|
415
415
|
return :tSTRING_DVAR, matched
|
416
416
|
when scan(/#[{]/) then
|
417
417
|
self.command_start = true
|
418
|
-
return :tSTRING_DBEG, matched
|
418
|
+
return :tSTRING_DBEG, [matched, lineno]
|
419
419
|
when scan(/#/) then
|
420
420
|
# do nothing but swallow
|
421
421
|
end
|