ruby-next-parser 2.8.0.6 → 2.8.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parser/ruby-next/lexer.rb +814 -800
- data/lib/parser/ruby-next/lexer.rl +15 -1
- data/lib/parser/ruby-next/version.rb +1 -1
- data/lib/parser/rubynext.rb +3465 -3413
- data/lib/parser/rubynext.y +78 -61
- metadata +4 -4
data/lib/parser/rubynext.y
CHANGED
@@ -647,7 +647,7 @@ rule
|
|
647
647
|
|
648
648
|
fitem: fname
|
649
649
|
{
|
650
|
-
result = @builder.
|
650
|
+
result = @builder.symbol_internal(val[0])
|
651
651
|
}
|
652
652
|
| symbol
|
653
653
|
|
@@ -960,6 +960,14 @@ rule
|
|
960
960
|
{
|
961
961
|
result = val
|
962
962
|
}
|
963
|
+
| tLPAREN2 args tCOMMA args_forward rparen
|
964
|
+
{
|
965
|
+
unless @static_env.declared_forward_args?
|
966
|
+
diagnostic :error, :unexpected_token, { :token => 'tBDOT3' } , val[3]
|
967
|
+
end
|
968
|
+
|
969
|
+
result = [val[0], [*val[1], @builder.forwarded_args(val[3])], val[4]]
|
970
|
+
}
|
963
971
|
| tLPAREN2 args_forward rparen
|
964
972
|
{
|
965
973
|
unless @static_env.declared_forward_args?
|
@@ -1212,14 +1220,7 @@ rule
|
|
1212
1220
|
result = @builder.block(val[0],
|
1213
1221
|
begin_t, args, body, end_t)
|
1214
1222
|
}
|
1215
|
-
|
|
1216
|
-
{
|
1217
|
-
lambda_call = @builder.call_lambda(val[0])
|
1218
|
-
|
1219
|
-
args, (begin_t, body, end_t) = val[1]
|
1220
|
-
result = @builder.block(lambda_call,
|
1221
|
-
begin_t, args, body, end_t)
|
1222
|
-
}
|
1223
|
+
| lambda
|
1223
1224
|
| kIF expr_value then compstmt if_tail kEND
|
1224
1225
|
{
|
1225
1226
|
else_t, else_ = val[4]
|
@@ -1314,6 +1315,7 @@ rule
|
|
1314
1315
|
{
|
1315
1316
|
@static_env.extend_static
|
1316
1317
|
@lexer.cmdarg.push(false)
|
1318
|
+
@context.push(:module)
|
1317
1319
|
}
|
1318
1320
|
bodystmt kEND
|
1319
1321
|
{
|
@@ -1326,6 +1328,7 @@ rule
|
|
1326
1328
|
|
1327
1329
|
@lexer.cmdarg.pop
|
1328
1330
|
@static_env.unextend
|
1331
|
+
@context.pop
|
1329
1332
|
}
|
1330
1333
|
| defn_head f_arglist bodystmt kEND
|
1331
1334
|
{
|
@@ -1457,6 +1460,9 @@ rule
|
|
1457
1460
|
result = @builder.restarg(val[0])
|
1458
1461
|
}
|
1459
1462
|
|
1463
|
+
f_any_kwrest: f_kwrest
|
1464
|
+
| f_no_kwarg
|
1465
|
+
|
1460
1466
|
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
1461
1467
|
{
|
1462
1468
|
result = val[0].concat(val[2]).concat(val[3])
|
@@ -1465,11 +1471,7 @@ rule
|
|
1465
1471
|
{
|
1466
1472
|
result = val[0].concat(val[1])
|
1467
1473
|
}
|
1468
|
-
|
|
1469
|
-
{
|
1470
|
-
result = val[0].concat(val[1])
|
1471
|
-
}
|
1472
|
-
| f_no_kwarg opt_f_block_arg
|
1474
|
+
| f_any_kwrest opt_f_block_arg
|
1473
1475
|
{
|
1474
1476
|
result = val[0].concat(val[1])
|
1475
1477
|
}
|
@@ -1488,6 +1490,8 @@ opt_block_args_tail:
|
|
1488
1490
|
result = []
|
1489
1491
|
}
|
1490
1492
|
|
1493
|
+
excessed_comma: tCOMMA
|
1494
|
+
|
1491
1495
|
block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
|
1492
1496
|
{
|
1493
1497
|
result = val[0].
|
@@ -1522,7 +1526,7 @@ opt_block_args_tail:
|
|
1522
1526
|
concat(val[2]).
|
1523
1527
|
concat(val[3])
|
1524
1528
|
}
|
1525
|
-
| f_arg
|
1529
|
+
| f_arg excessed_comma
|
1526
1530
|
| f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1527
1531
|
{
|
1528
1532
|
result = val[0].
|
@@ -1622,7 +1626,8 @@ opt_block_args_tail:
|
|
1622
1626
|
}
|
1623
1627
|
| f_bad_arg
|
1624
1628
|
|
1625
|
-
lambda:
|
1629
|
+
lambda: tLAMBDA
|
1630
|
+
{
|
1626
1631
|
@static_env.extend_dynamic
|
1627
1632
|
@max_numparam_stack.push
|
1628
1633
|
@context.push(:lambda)
|
@@ -1634,12 +1639,16 @@ opt_block_args_tail:
|
|
1634
1639
|
}
|
1635
1640
|
lambda_body
|
1636
1641
|
{
|
1637
|
-
|
1638
|
-
|
1642
|
+
lambda_call = @builder.call_lambda(val[0])
|
1643
|
+
args = @max_numparam_stack.has_numparams? ? @builder.numargs(@max_numparam_stack.top) : val[2]
|
1644
|
+
begin_t, body, end_t = val[4]
|
1639
1645
|
|
1640
1646
|
@max_numparam_stack.pop
|
1641
1647
|
@static_env.unextend
|
1642
1648
|
@lexer.cmdarg.pop
|
1649
|
+
|
1650
|
+
result = @builder.block(lambda_call,
|
1651
|
+
begin_t, args, body, end_t)
|
1643
1652
|
}
|
1644
1653
|
|
1645
1654
|
f_larglist: tLPAREN2 f_args opt_bv_decl tRPAREN
|
@@ -1878,6 +1887,10 @@ opt_block_args_tail:
|
|
1878
1887
|
{
|
1879
1888
|
result = @builder.array_pattern(nil, [val[0]].concat(val[2]), nil)
|
1880
1889
|
}
|
1890
|
+
| p_find
|
1891
|
+
{
|
1892
|
+
result = @builder.find_pattern(nil, val[0], nil)
|
1893
|
+
}
|
1881
1894
|
| p_args_tail
|
1882
1895
|
{
|
1883
1896
|
result = @builder.array_pattern(nil, val[0], nil)
|
@@ -1920,6 +1933,12 @@ opt_block_args_tail:
|
|
1920
1933
|
pattern = @builder.array_pattern(nil, val[2], nil)
|
1921
1934
|
result = @builder.const_pattern(val[0], val[1], pattern, val[3])
|
1922
1935
|
}
|
1936
|
+
| p_const p_lparen p_find rparen
|
1937
|
+
{
|
1938
|
+
@pattern_hash_keys.pop
|
1939
|
+
pattern = @builder.find_pattern(nil, val[2], nil)
|
1940
|
+
result = @builder.const_pattern(val[0], val[1], pattern, val[3])
|
1941
|
+
}
|
1923
1942
|
| p_const p_lparen p_kwargs rparen
|
1924
1943
|
{
|
1925
1944
|
@pattern_hash_keys.pop
|
@@ -1937,6 +1956,12 @@ opt_block_args_tail:
|
|
1937
1956
|
pattern = @builder.array_pattern(nil, val[2], nil)
|
1938
1957
|
result = @builder.const_pattern(val[0], val[1], pattern, val[3])
|
1939
1958
|
}
|
1959
|
+
| p_const p_lbracket p_find rbracket
|
1960
|
+
{
|
1961
|
+
@pattern_hash_keys.pop
|
1962
|
+
pattern = @builder.find_pattern(nil, val[2], nil)
|
1963
|
+
result = @builder.const_pattern(val[0], val[1], pattern, val[3])
|
1964
|
+
}
|
1940
1965
|
| p_const p_lbracket p_kwargs rbracket
|
1941
1966
|
{
|
1942
1967
|
@pattern_hash_keys.pop
|
@@ -1948,14 +1973,13 @@ opt_block_args_tail:
|
|
1948
1973
|
pattern = @builder.array_pattern(val[1], nil, val[2])
|
1949
1974
|
result = @builder.const_pattern(val[0], val[1], pattern, val[2])
|
1950
1975
|
}
|
1951
|
-
| tLBRACK
|
1976
|
+
| tLBRACK p_args rbracket
|
1952
1977
|
{
|
1953
|
-
@
|
1978
|
+
result = @builder.array_pattern(val[0], val[1], val[2])
|
1954
1979
|
}
|
1955
|
-
|
1980
|
+
| tLBRACK p_find rbracket
|
1956
1981
|
{
|
1957
|
-
@
|
1958
|
-
result = @builder.array_pattern(val[0], val[2], val[3])
|
1982
|
+
result = @builder.find_pattern(val[0], val[1], val[2])
|
1959
1983
|
}
|
1960
1984
|
| tLBRACK rbracket
|
1961
1985
|
{
|
@@ -2036,25 +2060,27 @@ opt_block_args_tail:
|
|
2036
2060
|
result = [ *val[0], last_item ]
|
2037
2061
|
}
|
2038
2062
|
|
2039
|
-
p_args_tail:
|
2063
|
+
p_args_tail: p_rest
|
2040
2064
|
{
|
2041
|
-
|
2042
|
-
result = [ match_rest ]
|
2065
|
+
result = [ val[0] ]
|
2043
2066
|
}
|
2044
|
-
|
|
2067
|
+
| p_rest tCOMMA p_args_post
|
2045
2068
|
{
|
2046
|
-
|
2047
|
-
result = [ match_rest, *val[3] ]
|
2069
|
+
result = [ val[0], *val[2] ]
|
2048
2070
|
}
|
2049
|
-
|
2071
|
+
|
2072
|
+
p_find: p_rest tCOMMA p_args_post tCOMMA p_rest
|
2050
2073
|
{
|
2051
|
-
|
2052
|
-
result = [ match_rest ]
|
2074
|
+
result = [ val[0], *val[2], val[4] ]
|
2053
2075
|
}
|
2054
|
-
|
2076
|
+
|
2077
|
+
p_rest: tSTAR tIDENTIFIER
|
2055
2078
|
{
|
2056
|
-
|
2057
|
-
|
2079
|
+
result = @builder.match_rest(val[0], val[1])
|
2080
|
+
}
|
2081
|
+
| tSTAR
|
2082
|
+
{
|
2083
|
+
result = @builder.match_rest(val[0])
|
2058
2084
|
}
|
2059
2085
|
|
2060
2086
|
p_args_post: p_arg
|
@@ -2068,7 +2094,7 @@ opt_block_args_tail:
|
|
2068
2094
|
|
2069
2095
|
p_arg: p_expr
|
2070
2096
|
|
2071
|
-
p_kwargs: p_kwarg tCOMMA
|
2097
|
+
p_kwargs: p_kwarg tCOMMA p_any_kwrest
|
2072
2098
|
{
|
2073
2099
|
result = [ *val[0], *val[2] ]
|
2074
2100
|
}
|
@@ -2080,18 +2106,10 @@ opt_block_args_tail:
|
|
2080
2106
|
{
|
2081
2107
|
result = val[0]
|
2082
2108
|
}
|
2083
|
-
|
|
2109
|
+
| p_any_kwrest
|
2084
2110
|
{
|
2085
2111
|
result = val[0]
|
2086
2112
|
}
|
2087
|
-
| p_kwarg tCOMMA p_kwnorest
|
2088
|
-
{
|
2089
|
-
result = [ *val[0], *val[2] ]
|
2090
|
-
}
|
2091
|
-
| p_kwnorest
|
2092
|
-
{
|
2093
|
-
result = [ *val[0], *val[2] ]
|
2094
|
-
}
|
2095
2113
|
|
2096
2114
|
p_kwarg: p_kw
|
2097
2115
|
{
|
@@ -2135,6 +2153,9 @@ opt_block_args_tail:
|
|
2135
2153
|
result = [ @builder.match_nil_pattern(val[0], val[1]) ]
|
2136
2154
|
}
|
2137
2155
|
|
2156
|
+
p_any_kwrest: p_kwrest
|
2157
|
+
| p_kwnorest
|
2158
|
+
|
2138
2159
|
p_value: p_primitive
|
2139
2160
|
| p_primitive tDOT2 p_primitive
|
2140
2161
|
{
|
@@ -2176,14 +2197,7 @@ opt_block_args_tail:
|
|
2176
2197
|
{
|
2177
2198
|
result = @builder.accessible(val[0])
|
2178
2199
|
}
|
2179
|
-
|
|
2180
|
-
{
|
2181
|
-
lambda_call = @builder.call_lambda(val[0])
|
2182
|
-
|
2183
|
-
args, (begin_t, body, end_t) = val[1]
|
2184
|
-
result = @builder.block(lambda_call,
|
2185
|
-
begin_t, args, body, end_t)
|
2186
|
-
}
|
2200
|
+
| lambda
|
2187
2201
|
|
2188
2202
|
p_variable: tIDENTIFIER
|
2189
2203
|
{
|
@@ -2602,15 +2616,22 @@ keyword_variable: kNIL
|
|
2602
2616
|
result = nil
|
2603
2617
|
}
|
2604
2618
|
|
2605
|
-
|
2619
|
+
f_paren_args: tLPAREN2 f_args rparen
|
2606
2620
|
{
|
2607
2621
|
result = @builder.args(val[0], val[1], val[2])
|
2608
2622
|
|
2609
2623
|
@lexer.state = :expr_value
|
2610
2624
|
}
|
2625
|
+
| tLPAREN2 f_arg tCOMMA args_forward rparen
|
2626
|
+
{
|
2627
|
+
args = [ *val[1], @builder.forward_arg(val[3]) ]
|
2628
|
+
result = @builder.args(val[0], args, val[4])
|
2629
|
+
|
2630
|
+
@static_env.declare_forward_args
|
2631
|
+
}
|
2611
2632
|
| tLPAREN2 args_forward rparen
|
2612
2633
|
{
|
2613
|
-
result = @builder.
|
2634
|
+
result = @builder.forward_only_args(val[0], val[1], val[2])
|
2614
2635
|
@static_env.declare_forward_args
|
2615
2636
|
|
2616
2637
|
@lexer.state = :expr_value
|
@@ -2635,11 +2656,7 @@ keyword_variable: kNIL
|
|
2635
2656
|
{
|
2636
2657
|
result = val[0].concat(val[1])
|
2637
2658
|
}
|
2638
|
-
|
|
2639
|
-
{
|
2640
|
-
result = val[0].concat(val[1])
|
2641
|
-
}
|
2642
|
-
| f_no_kwarg opt_f_block_arg
|
2659
|
+
| f_any_kwrest opt_f_block_arg
|
2643
2660
|
{
|
2644
2661
|
result = val[0].concat(val[1])
|
2645
2662
|
}
|
@@ -3025,7 +3042,7 @@ require 'parser/ruby-next/parser_ext'
|
|
3025
3042
|
prepend Parser::NextExt
|
3026
3043
|
|
3027
3044
|
def version
|
3028
|
-
28
|
3045
|
+
28
|
3029
3046
|
end
|
3030
3047
|
|
3031
3048
|
def default_encoding
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-next-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.0.
|
4
|
+
version: 2.8.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.7.
|
19
|
+
version: 2.7.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.7.
|
26
|
+
version: 2.7.1.4
|
27
27
|
description: "\n Parser extension to support edge and experimental Ruby syntax\n
|
28
28
|
\ "
|
29
29
|
email:
|