ruby_parser 3.20.1 → 3.20.2
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 +6 -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 +5966 -5957
- data/lib/ruby30_parser.y +71 -70
- data/lib/ruby31_parser.rb +6090 -6213
- data/lib/ruby31_parser.y +71 -70
- data/lib/ruby32_parser.rb +6258 -6339
- data/lib/ruby32_parser.y +92 -90
- data/lib/ruby3_parser.yy +107 -70
- 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 +0 -10
- data/lib/ruby_parser_extras.rb +7 -8
- data/test/test_ruby_parser.rb +31 -1
- 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
|
|
@@ -639,7 +639,7 @@ rule
|
|
639
639
|
}
|
640
640
|
| tSTAR
|
641
641
|
{
|
642
|
-
l =
|
642
|
+
(_, l), = val
|
643
643
|
result = s(:masgn, s(:array, s(:splat).line(l)).line(l)).line l
|
644
644
|
}
|
645
645
|
| tSTAR tCOMMA mlhs_post
|
@@ -1271,7 +1271,7 @@ rule
|
|
1271
1271
|
args: arg_value
|
1272
1272
|
{
|
1273
1273
|
arg, = val
|
1274
|
-
lineno = arg.line
|
1274
|
+
lineno = arg.line
|
1275
1275
|
|
1276
1276
|
result = s(:array, arg).line lineno
|
1277
1277
|
}
|
@@ -1280,6 +1280,13 @@ rule
|
|
1280
1280
|
_, arg = val
|
1281
1281
|
result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
|
1282
1282
|
}
|
1283
|
+
#if V >= 32
|
1284
|
+
| tSTAR
|
1285
|
+
{
|
1286
|
+
(_, line), = val
|
1287
|
+
result = s(:array, s(:splat).line(line)).line line
|
1288
|
+
}
|
1289
|
+
#endif
|
1283
1290
|
| args tCOMMA arg_value
|
1284
1291
|
{
|
1285
1292
|
args, _, id = val
|
@@ -1287,11 +1294,16 @@ rule
|
|
1287
1294
|
}
|
1288
1295
|
| args tCOMMA tSTAR arg_value
|
1289
1296
|
{
|
1290
|
-
|
1291
|
-
args, _, _, id = val
|
1292
|
-
line = lexer.lineno
|
1297
|
+
args, _, (_, line), id = val
|
1293
1298
|
result = self.list_append args, s(:splat, id).line(line)
|
1294
1299
|
}
|
1300
|
+
#if V >= 32
|
1301
|
+
| args tCOMMA tSTAR
|
1302
|
+
{
|
1303
|
+
args, _, (_, line) = val
|
1304
|
+
result = self.list_append args, s(:splat).line(line)
|
1305
|
+
}
|
1306
|
+
#endif
|
1295
1307
|
|
1296
1308
|
mrhs_arg: mrhs
|
1297
1309
|
{
|
@@ -1308,7 +1320,6 @@ rule
|
|
1308
1320
|
}
|
1309
1321
|
| args tCOMMA tSTAR arg_value
|
1310
1322
|
{
|
1311
|
-
# TODO: make all tXXXX terminals include lexer.lineno
|
1312
1323
|
arg, _, _, splat = val
|
1313
1324
|
result = self.arg_concat arg, splat
|
1314
1325
|
}
|
@@ -1337,7 +1348,6 @@ rule
|
|
1337
1348
|
| k_begin
|
1338
1349
|
{
|
1339
1350
|
lexer.cmdarg.push false
|
1340
|
-
result = self.lexer.lineno
|
1341
1351
|
}
|
1342
1352
|
bodystmt k_end
|
1343
1353
|
{
|
@@ -1347,11 +1357,10 @@ rule
|
|
1347
1357
|
| tLPAREN_ARG
|
1348
1358
|
{
|
1349
1359
|
lexer.lex_state = EXPR_ENDARG
|
1350
|
-
result = lexer.lineno
|
1351
1360
|
}
|
1352
1361
|
rparen
|
1353
1362
|
{
|
1354
|
-
_, line, _ = val
|
1363
|
+
(_, line), _, _ = val
|
1355
1364
|
result = s(:begin).line line
|
1356
1365
|
}
|
1357
1366
|
| tLPAREN_ARG
|
@@ -1367,9 +1376,8 @@ rule
|
|
1367
1376
|
}
|
1368
1377
|
| tLPAREN compstmt tRPAREN
|
1369
1378
|
{
|
1370
|
-
_, stmt, _ = val
|
1371
|
-
result = stmt
|
1372
|
-
result ||= s(:nil).line lexer.lineno
|
1379
|
+
(_, line), stmt, _ = val
|
1380
|
+
result = stmt || s(:nil).line(line)
|
1373
1381
|
result.paren = true
|
1374
1382
|
}
|
1375
1383
|
| primary_value tCOLON2 tCONSTANT
|
@@ -1382,9 +1390,9 @@ rule
|
|
1382
1390
|
{
|
1383
1391
|
result = wrap :colon3, val[1]
|
1384
1392
|
}
|
1385
|
-
| tLBRACK
|
1393
|
+
| tLBRACK aref_args rbracket
|
1386
1394
|
{
|
1387
|
-
_, line, args, (_, line_max) = val
|
1395
|
+
(_, line), args, (_, line_max) = val
|
1388
1396
|
|
1389
1397
|
result = args || s(:array)
|
1390
1398
|
result.sexp_type = :array # aref_args is :args
|
@@ -1500,9 +1508,6 @@ rule
|
|
1500
1508
|
result = new_for iter, var, body
|
1501
1509
|
}
|
1502
1510
|
| k_class
|
1503
|
-
{
|
1504
|
-
result = self.lexer.lineno
|
1505
|
-
}
|
1506
1511
|
cpath superclass
|
1507
1512
|
{
|
1508
1513
|
if (self.in_def || self.in_single > 0) then
|
@@ -1517,9 +1522,6 @@ rule
|
|
1517
1522
|
self.lexer.ignore_body_comments
|
1518
1523
|
}
|
1519
1524
|
| k_class tLSHFT
|
1520
|
-
{
|
1521
|
-
result = self.lexer.lineno
|
1522
|
-
}
|
1523
1525
|
expr
|
1524
1526
|
{
|
1525
1527
|
result = self.in_def
|
@@ -1531,16 +1533,14 @@ rule
|
|
1531
1533
|
self.in_single = 0
|
1532
1534
|
self.env.extend
|
1533
1535
|
}
|
1534
|
-
bodystmt
|
1536
|
+
bodystmt
|
1537
|
+
k_end
|
1535
1538
|
{
|
1536
1539
|
result = new_sclass val
|
1537
1540
|
self.env.unextend
|
1538
1541
|
self.lexer.ignore_body_comments
|
1539
1542
|
}
|
1540
1543
|
| k_module
|
1541
|
-
{
|
1542
|
-
result = self.lexer.lineno
|
1543
|
-
}
|
1544
1544
|
cpath
|
1545
1545
|
{
|
1546
1546
|
yyerror "module definition in method body" if
|
@@ -1682,20 +1682,33 @@ rule
|
|
1682
1682
|
}
|
1683
1683
|
|
1684
1684
|
f_marg: f_norm_arg
|
1685
|
+
{
|
1686
|
+
(sym, line), = val
|
1687
|
+
|
1688
|
+
result = s(:dummy, sym).line line
|
1689
|
+
}
|
1685
1690
|
| tLPAREN f_margs rparen
|
1686
1691
|
{
|
1687
|
-
|
1692
|
+
_, args, _ = val
|
1693
|
+
result = args
|
1688
1694
|
}
|
1689
1695
|
|
1690
1696
|
f_marg_list: f_marg
|
1691
1697
|
{
|
1692
|
-
|
1698
|
+
arg, = val
|
1699
|
+
line = arg.line
|
1700
|
+
|
1701
|
+
arg = arg.last if arg.sexp_type == :dummy
|
1693
1702
|
|
1694
|
-
result = s(:array,
|
1703
|
+
result = s(:array, arg).line line
|
1695
1704
|
}
|
1696
1705
|
| f_marg_list tCOMMA f_marg
|
1697
1706
|
{
|
1698
|
-
|
1707
|
+
args, _, arg = val
|
1708
|
+
|
1709
|
+
arg = arg.last if arg.sexp_type == :dummy
|
1710
|
+
|
1711
|
+
result = list_append args, arg
|
1699
1712
|
}
|
1700
1713
|
|
1701
1714
|
f_margs: f_marg_list
|
@@ -1738,8 +1751,8 @@ rule
|
|
1738
1751
|
}
|
1739
1752
|
| tSTAR
|
1740
1753
|
{
|
1741
|
-
|
1742
|
-
result.line
|
1754
|
+
(_, line), = val
|
1755
|
+
result = args([:*]).line line
|
1743
1756
|
}
|
1744
1757
|
|
1745
1758
|
f_any_kwrest: f_kwrest
|
@@ -1854,7 +1867,9 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1854
1867
|
}
|
1855
1868
|
| tOROP
|
1856
1869
|
{
|
1857
|
-
|
1870
|
+
(_, line), = val
|
1871
|
+
|
1872
|
+
result = s(:args).line line
|
1858
1873
|
}
|
1859
1874
|
| tPIPE block_param opt_bv_decl tPIPE
|
1860
1875
|
{
|
@@ -1886,7 +1901,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1886
1901
|
lambda: tLAMBDA
|
1887
1902
|
{
|
1888
1903
|
self.env.extend :dynamic
|
1889
|
-
result =
|
1904
|
+
result = lexer.lpar_beg
|
1890
1905
|
lexer.paren_nest += 1
|
1891
1906
|
lexer.lpar_beg = lexer.paren_nest
|
1892
1907
|
}
|
@@ -1896,7 +1911,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1896
1911
|
}
|
1897
1912
|
lambda_body
|
1898
1913
|
{
|
1899
|
-
_,
|
1914
|
+
(_, line), lpar, args, _cmdarg, body = val
|
1900
1915
|
lexer.lpar_beg = lpar
|
1901
1916
|
|
1902
1917
|
lexer.cmdarg.pop
|
@@ -2020,7 +2035,8 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2020
2035
|
}
|
2021
2036
|
| kSUPER
|
2022
2037
|
{
|
2023
|
-
|
2038
|
+
(_, line), = val
|
2039
|
+
result = s(:zsuper).line line
|
2024
2040
|
}
|
2025
2041
|
| primary_value tLBRACK2 opt_call_args rbracket
|
2026
2042
|
{
|
@@ -2030,11 +2046,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2030
2046
|
brace_block: tLCURLY
|
2031
2047
|
{
|
2032
2048
|
self.env.extend :dynamic
|
2033
|
-
result = self.lexer.lineno
|
2034
2049
|
}
|
2035
|
-
brace_body
|
2050
|
+
brace_body
|
2051
|
+
tRCURLY
|
2036
2052
|
{
|
2037
|
-
_, line, body, _ = val
|
2053
|
+
(_, line), _, body, _ = val
|
2038
2054
|
|
2039
2055
|
result = body
|
2040
2056
|
result.line line
|
@@ -2044,11 +2060,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2044
2060
|
| k_do
|
2045
2061
|
{
|
2046
2062
|
self.env.extend :dynamic
|
2047
|
-
result = self.lexer.lineno
|
2048
2063
|
}
|
2049
|
-
do_body
|
2064
|
+
do_body
|
2065
|
+
kEND
|
2050
2066
|
{
|
2051
|
-
_, line, body, _ = val
|
2067
|
+
(_, line), _, body, _ = val
|
2052
2068
|
|
2053
2069
|
result = body
|
2054
2070
|
result.line line
|
@@ -2106,14 +2122,13 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2106
2122
|
}
|
2107
2123
|
|
2108
2124
|
case_body: k_when
|
2109
|
-
{
|
2110
|
-
result = self.lexer.lineno
|
2111
|
-
}
|
2112
2125
|
case_args then compstmt cases
|
2113
2126
|
{
|
2114
|
-
|
2115
|
-
|
2116
|
-
result
|
2127
|
+
(_, line), case_args, _then, body, cases = val
|
2128
|
+
|
2129
|
+
result = new_when case_args, body
|
2130
|
+
result.line line
|
2131
|
+
result << cases if cases
|
2117
2132
|
}
|
2118
2133
|
|
2119
2134
|
cases: opt_else | case_body
|
@@ -2352,6 +2367,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2352
2367
|
result = new_array_pattern_tail both, nil, nil, nil
|
2353
2368
|
result.line head.line
|
2354
2369
|
}
|
2370
|
+
#if V < 32
|
2355
2371
|
| p_args_head tSTAR tIDENTIFIER
|
2356
2372
|
{
|
2357
2373
|
head, _, (id, _line) = val
|
@@ -2378,6 +2394,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2378
2394
|
|
2379
2395
|
result = new_array_pattern_tail(head, true, nil, post).line head.line
|
2380
2396
|
}
|
2397
|
+
#else
|
2398
|
+
| p_args_head p_rest
|
2399
|
+
{
|
2400
|
+
head, (rest, _) = val
|
2401
|
+
|
2402
|
+
result = new_array_pattern_tail(head, true, rest, nil).line head.line
|
2403
|
+
}
|
2404
|
+
| p_args_head p_rest tCOMMA p_args_post
|
2405
|
+
{
|
2406
|
+
head, (rest, _), _, post = val
|
2407
|
+
|
2408
|
+
result = new_array_pattern_tail(head, true, rest, post).line head.line
|
2409
|
+
}
|
2410
|
+
#endif
|
2381
2411
|
| p_args_tail
|
2382
2412
|
|
2383
2413
|
p_args_head: p_arg tCOMMA
|
@@ -2917,7 +2947,6 @@ regexp_contents: none
|
|
2917
2947
|
lexer.brace_nest,
|
2918
2948
|
lexer.string_nest, # TODO: remove
|
2919
2949
|
lexer.lex_state,
|
2920
|
-
lexer.lineno,
|
2921
2950
|
]
|
2922
2951
|
|
2923
2952
|
lexer.cmdarg.push false
|
@@ -2932,9 +2961,9 @@ regexp_contents: none
|
|
2932
2961
|
compstmt
|
2933
2962
|
tSTRING_DEND
|
2934
2963
|
{
|
2935
|
-
_, memo, stmt, _ = val
|
2964
|
+
(_, line), memo, stmt, _ = val
|
2936
2965
|
|
2937
|
-
lex_strterm, brace_nest, string_nest, oldlex_state
|
2966
|
+
lex_strterm, brace_nest, string_nest, oldlex_state = memo
|
2938
2967
|
# TODO: heredoc_indent
|
2939
2968
|
|
2940
2969
|
lexer.lex_strterm = lex_strterm
|
@@ -2994,11 +3023,11 @@ regexp_contents: none
|
|
2994
3023
|
|
2995
3024
|
dsym: tSYMBEG string_contents tSTRING_END
|
2996
3025
|
{
|
2997
|
-
_, result, _ = val
|
3026
|
+
(_, line), result, _ = val
|
2998
3027
|
|
2999
3028
|
lexer.lex_state = EXPR_END
|
3000
3029
|
|
3001
|
-
result ||= s(:str, "").line
|
3030
|
+
result ||= s(:str, "").line line
|
3002
3031
|
|
3003
3032
|
case result.sexp_type
|
3004
3033
|
when :dstr then
|
@@ -3036,15 +3065,15 @@ regexp_contents: none
|
|
3036
3065
|
| tCONSTANT
|
3037
3066
|
| tCVAR
|
3038
3067
|
|
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,
|
3068
|
+
keyword_variable: kNIL { (_, line), = val; result = s(:nil).line line }
|
3069
|
+
| kSELF { (_, line), = val; result = s(:self).line line }
|
3070
|
+
| kTRUE { (_, line), = val; result = s(:true).line line }
|
3071
|
+
| kFALSE { (_, line), = val; result = s(:false).line line }
|
3072
|
+
| k__FILE__ { (_, line), = val; result = s(:str, self.file).line line }
|
3073
|
+
| k__LINE__ { (_, line), = val; result = s(:lit, line).line line }
|
3045
3074
|
| k__ENCODING__
|
3046
3075
|
{
|
3047
|
-
l =
|
3076
|
+
(_, l), = val
|
3048
3077
|
result =
|
3049
3078
|
if defined? Encoding then
|
3050
3079
|
s(:colon2, s(:const, :Encoding).line(l), :UTF_8).line l
|
@@ -3219,12 +3248,12 @@ f_opt_paren_args: f_paren_args
|
|
3219
3248
|
|
|
3220
3249
|
{
|
3221
3250
|
result = args val
|
3222
|
-
# result.line lexer.lineno
|
3223
3251
|
}
|
3224
3252
|
|
3225
3253
|
args_forward: tBDOT3
|
3226
3254
|
{
|
3227
|
-
|
3255
|
+
(_, line), = val
|
3256
|
+
result = s(:forward_args).line line
|
3228
3257
|
}
|
3229
3258
|
|
3230
3259
|
f_bad_arg: tCONSTANT
|
@@ -3362,9 +3391,10 @@ f_opt_paren_args: f_paren_args
|
|
3362
3391
|
}
|
3363
3392
|
| kwrest_mark
|
3364
3393
|
{
|
3394
|
+
(_, line), = val
|
3365
3395
|
id = :"**"
|
3366
|
-
self.env[id] = :lvar
|
3367
|
-
result = [id,
|
3396
|
+
self.env[id] = :lvar
|
3397
|
+
result = [id, line]
|
3368
3398
|
}
|
3369
3399
|
|
3370
3400
|
f_opt: f_arg_asgn
|
@@ -3430,9 +3460,10 @@ f_opt_paren_args: f_paren_args
|
|
3430
3460
|
}
|
3431
3461
|
| restarg_mark
|
3432
3462
|
{
|
3463
|
+
(_, line), = val
|
3433
3464
|
name = :"*"
|
3434
3465
|
self.env[name] = :lvar
|
3435
|
-
result = [name,
|
3466
|
+
result = [name, line]
|
3436
3467
|
}
|
3437
3468
|
|
3438
3469
|
blkarg_mark: tAMPER2 | tAMPER
|
@@ -3523,6 +3554,13 @@ f_opt_paren_args: f_paren_args
|
|
3523
3554
|
line = arg.line
|
3524
3555
|
result = s(:array, s(:kwsplat, arg).line(line)).line line
|
3525
3556
|
}
|
3557
|
+
#if V >= 32
|
3558
|
+
| tDSTAR
|
3559
|
+
{
|
3560
|
+
(_, line), = val
|
3561
|
+
result = s(:array, s(:kwsplat).line(line)).line line
|
3562
|
+
}
|
3563
|
+
#endif
|
3526
3564
|
|
3527
3565
|
operation: tIDENTIFIER | tCONSTANT | tFID
|
3528
3566
|
operation2: tIDENTIFIER | tCONSTANT | tFID | op
|
@@ -3537,11 +3575,10 @@ f_opt_paren_args: f_paren_args
|
|
3537
3575
|
opt_terms: | terms
|
3538
3576
|
opt_nl: | tNL
|
3539
3577
|
rparen: opt_nl tRPAREN
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3543
|
-
|
3544
|
-
# }
|
3578
|
+
{
|
3579
|
+
_, close = val # TODO: include lineno in close?
|
3580
|
+
result = [close, lexer.lineno]
|
3581
|
+
}
|
3545
3582
|
rbracket: opt_nl tRBRACK
|
3546
3583
|
{
|
3547
3584
|
_, close = val
|
data/lib/ruby_lexer.rb
CHANGED
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
|
data/lib/ruby_parser.yy
CHANGED
@@ -1293,7 +1293,6 @@ rule
|
|
1293
1293
|
| k_begin
|
1294
1294
|
{
|
1295
1295
|
lexer.cmdarg.push false
|
1296
|
-
result = self.lexer.lineno
|
1297
1296
|
}
|
1298
1297
|
bodystmt k_end
|
1299
1298
|
{
|
@@ -1458,9 +1457,6 @@ rule
|
|
1458
1457
|
result = new_for iter, var, body
|
1459
1458
|
}
|
1460
1459
|
| k_class
|
1461
|
-
{
|
1462
|
-
result = self.lexer.lineno
|
1463
|
-
}
|
1464
1460
|
cpath superclass
|
1465
1461
|
{
|
1466
1462
|
if (self.in_def || self.in_single > 0) then
|
@@ -1475,9 +1471,6 @@ rule
|
|
1475
1471
|
self.lexer.ignore_body_comments
|
1476
1472
|
}
|
1477
1473
|
| k_class tLSHFT
|
1478
|
-
{
|
1479
|
-
result = self.lexer.lineno
|
1480
|
-
}
|
1481
1474
|
expr
|
1482
1475
|
{
|
1483
1476
|
result = self.in_def
|
@@ -1496,9 +1489,6 @@ rule
|
|
1496
1489
|
self.lexer.ignore_body_comments
|
1497
1490
|
}
|
1498
1491
|
| k_module
|
1499
|
-
{
|
1500
|
-
result = self.lexer.lineno
|
1501
|
-
}
|
1502
1492
|
cpath
|
1503
1493
|
{
|
1504
1494
|
yyerror "module definition in method body" if
|
data/lib/ruby_parser_extras.rb
CHANGED
@@ -30,7 +30,7 @@ class Sexp
|
|
30
30
|
end
|
31
31
|
|
32
32
|
module RubyParserStuff
|
33
|
-
VERSION = "3.20.
|
33
|
+
VERSION = "3.20.2"
|
34
34
|
|
35
35
|
attr_accessor :lexer, :in_def, :in_single, :file
|
36
36
|
attr_accessor :in_kwarg
|
@@ -824,10 +824,10 @@ module RubyParserStuff
|
|
824
824
|
end
|
825
825
|
|
826
826
|
def new_begin val
|
827
|
-
_,
|
827
|
+
(_, line), _, body, _ = val
|
828
828
|
|
829
829
|
result = body ? s(:begin, body) : s(:nil)
|
830
|
-
result.line
|
830
|
+
result.line line
|
831
831
|
|
832
832
|
result
|
833
833
|
end
|
@@ -928,8 +928,7 @@ module RubyParserStuff
|
|
928
928
|
end
|
929
929
|
|
930
930
|
def new_class val
|
931
|
-
|
932
|
-
_, line, path, superclass, _, body, (_, line_max) = val
|
931
|
+
(_, line), path, superclass, _, body, (_, line_max) = val
|
933
932
|
|
934
933
|
path = path.first if path.instance_of? Array
|
935
934
|
|
@@ -1209,7 +1208,7 @@ module RubyParserStuff
|
|
1209
1208
|
end
|
1210
1209
|
|
1211
1210
|
def new_module val
|
1212
|
-
(_, line_min),
|
1211
|
+
(_, line_min), path, _, body, (_, line_max) = val
|
1213
1212
|
|
1214
1213
|
path = path.first if path.instance_of? Array
|
1215
1214
|
|
@@ -1367,7 +1366,7 @@ module RubyParserStuff
|
|
1367
1366
|
end
|
1368
1367
|
|
1369
1368
|
def new_sclass val
|
1370
|
-
|
1369
|
+
(_, line), _, recv, in_def, _, in_single, body, _ = val
|
1371
1370
|
|
1372
1371
|
result = s(:sclass, recv)
|
1373
1372
|
|
@@ -1379,7 +1378,7 @@ module RubyParserStuff
|
|
1379
1378
|
end
|
1380
1379
|
end
|
1381
1380
|
|
1382
|
-
result.line =
|
1381
|
+
result.line = line
|
1383
1382
|
self.in_def = in_def
|
1384
1383
|
self.in_single = in_single
|
1385
1384
|
result
|
data/test/test_ruby_parser.rb
CHANGED
@@ -132,11 +132,13 @@ module TestRubyParserShared
|
|
132
132
|
# for the array. Luckily, the arary elements all seemt to get the correct
|
133
133
|
# line number.
|
134
134
|
rb = "[\n'a',\n'b']\n1"
|
135
|
+
|
135
136
|
pt = s(:block,
|
136
137
|
s(:array,
|
137
138
|
s(:str, "a").line(2),
|
138
|
-
s(:str, "b").line(3)),
|
139
|
+
s(:str, "b").line(3)).line(1),
|
139
140
|
s(:lit, 1).line(4)).line 1
|
141
|
+
|
140
142
|
assert_parse rb, pt
|
141
143
|
end
|
142
144
|
|
@@ -5632,6 +5634,34 @@ end
|
|
5632
5634
|
|
5633
5635
|
module TestRubyParserShared32Plus
|
5634
5636
|
include TestRubyParserShared31Plus
|
5637
|
+
|
5638
|
+
def test_args_star__anon_solo
|
5639
|
+
rb = "f(*)"
|
5640
|
+
pt = s(:call, nil, :f, s(:splat))
|
5641
|
+
|
5642
|
+
assert_parse rb, pt
|
5643
|
+
end
|
5644
|
+
|
5645
|
+
def test_args_star__anon_trailing
|
5646
|
+
rb = "f(x, *)"
|
5647
|
+
pt = s(:call, nil, :f, s(:call, nil, :x), s(:splat))
|
5648
|
+
|
5649
|
+
assert_parse rb, pt
|
5650
|
+
end
|
5651
|
+
|
5652
|
+
def test_args_dstar__anon_solo
|
5653
|
+
rb = "f(**)"
|
5654
|
+
pt = s(:call, nil, :f, s(:hash, s(:kwsplat))) # TODO double check this
|
5655
|
+
|
5656
|
+
assert_parse rb, pt
|
5657
|
+
end
|
5658
|
+
|
5659
|
+
def test_args_dstar__anon_trailing
|
5660
|
+
rb = "f(x, **)"
|
5661
|
+
pt = s(:call, nil, :f, s(:call, nil, :x), s(:hash, s(:kwsplat))) # TODO double check this
|
5662
|
+
|
5663
|
+
assert_parse rb, pt
|
5664
|
+
end
|
5635
5665
|
end
|
5636
5666
|
|
5637
5667
|
class Minitest::Test
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.20.
|
4
|
+
version: 3.20.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
ROfWo9Uyp8ba/j9eVG14KkYRaLydAY1MNQk2yd3R5CGfeOpD1kttxjoypoUJ2dOG
|
30
30
|
nsNBRuQJ1UfiCG97a6DNm+Fr
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2023-
|
32
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: sexp_processor
|
metadata.gz.sig
CHANGED
Binary file
|