ruby-next-parser 2.8.0.5 → 3.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -647,7 +647,7 @@ rule
647
647
 
648
648
  fitem: fname
649
649
  {
650
- result = @builder.symbol(val[0])
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
- | tLAMBDA lambda
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
- | f_kwrest opt_f_block_arg
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 tCOMMA
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
- args = @max_numparam_stack.has_numparams? ? @builder.numargs(@max_numparam_stack.top) : val[1]
1638
- result = [ args, val[3] ]
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
- @pattern_hash_keys.push
1978
+ result = @builder.array_pattern(val[0], val[1], val[2])
1954
1979
  }
1955
- p_args rbracket
1980
+ | tLBRACK p_find rbracket
1956
1981
  {
1957
- @pattern_hash_keys.pop
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: tSTAR tIDENTIFIER
2063
+ p_args_tail: p_rest
2064
+ {
2065
+ result = [ val[0] ]
2066
+ }
2067
+ | p_rest tCOMMA p_args_post
2040
2068
  {
2041
- match_rest = @builder.match_rest(val[0], val[1])
2042
- result = [ match_rest ]
2069
+ result = [ val[0], *val[2] ]
2043
2070
  }
2044
- | tSTAR tIDENTIFIER tCOMMA p_args_post
2071
+
2072
+ p_find: p_rest tCOMMA p_args_post tCOMMA p_rest
2045
2073
  {
2046
- match_rest = @builder.match_rest(val[0], val[1])
2047
- result = [ match_rest, *val[3] ]
2074
+ result = [ val[0], *val[2], val[4] ]
2048
2075
  }
2049
- | tSTAR
2076
+
2077
+ p_rest: tSTAR tIDENTIFIER
2050
2078
  {
2051
- match_rest = @builder.match_rest(val[0])
2052
- result = [ match_rest ]
2079
+ result = @builder.match_rest(val[0], val[1])
2053
2080
  }
2054
- | tSTAR tCOMMA p_args_post
2081
+ | tSTAR
2055
2082
  {
2056
- match_rest = @builder.match_rest(val[0])
2057
- result = [ match_rest, *val[2] ]
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 p_kwrest
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
- | p_kwrest
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
  {
@@ -2113,7 +2131,6 @@ opt_block_args_tail:
2113
2131
 
2114
2132
  p_kw_label: tLABEL
2115
2133
  {
2116
- check_kwarg_name(val[0])
2117
2134
  result = [:label, val[0]]
2118
2135
  }
2119
2136
  | tSTRING_BEG string_contents tLABEL_END
@@ -2135,6 +2152,9 @@ opt_block_args_tail:
2135
2152
  result = [ @builder.match_nil_pattern(val[0], val[1]) ]
2136
2153
  }
2137
2154
 
2155
+ p_any_kwrest: p_kwrest
2156
+ | p_kwnorest
2157
+
2138
2158
  p_value: p_primitive
2139
2159
  | p_primitive tDOT2 p_primitive
2140
2160
  {
@@ -2176,14 +2196,7 @@ opt_block_args_tail:
2176
2196
  {
2177
2197
  result = @builder.accessible(val[0])
2178
2198
  }
2179
- | tLAMBDA lambda
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
- }
2199
+ | lambda
2187
2200
 
2188
2201
  p_variable: tIDENTIFIER
2189
2202
  {
@@ -2602,15 +2615,22 @@ keyword_variable: kNIL
2602
2615
  result = nil
2603
2616
  }
2604
2617
 
2605
- f_paren_args: tLPAREN2 f_args rparen
2618
+ f_paren_args: tLPAREN2 f_args rparen
2606
2619
  {
2607
2620
  result = @builder.args(val[0], val[1], val[2])
2608
2621
 
2609
2622
  @lexer.state = :expr_value
2610
2623
  }
2624
+ | tLPAREN2 f_arg tCOMMA args_forward rparen
2625
+ {
2626
+ args = [ *val[1], @builder.forward_arg(val[3]) ]
2627
+ result = @builder.args(val[0], args, val[4])
2628
+
2629
+ @static_env.declare_forward_args
2630
+ }
2611
2631
  | tLPAREN2 args_forward rparen
2612
2632
  {
2613
- result = @builder.forward_args(val[0], val[1], val[2])
2633
+ result = @builder.forward_only_args(val[0], val[1], val[2])
2614
2634
  @static_env.declare_forward_args
2615
2635
 
2616
2636
  @lexer.state = :expr_value
@@ -2635,11 +2655,7 @@ keyword_variable: kNIL
2635
2655
  {
2636
2656
  result = val[0].concat(val[1])
2637
2657
  }
2638
- | f_kwrest opt_f_block_arg
2639
- {
2640
- result = val[0].concat(val[1])
2641
- }
2642
- | f_no_kwarg opt_f_block_arg
2658
+ | f_any_kwrest opt_f_block_arg
2643
2659
  {
2644
2660
  result = val[0].concat(val[1])
2645
2661
  }
@@ -2944,7 +2960,24 @@ keyword_variable: kNIL
2944
2960
  {
2945
2961
  result = []
2946
2962
  }
2947
- | assocs trailer
2963
+ | assoc_items trailer
2964
+
2965
+ assoc_items : assoc_item
2966
+ {
2967
+ result = [ val[0] ]
2968
+ }
2969
+ | assoc_items tCOMMA assoc_item
2970
+ {
2971
+ result = val[0] << val[2]
2972
+ }
2973
+
2974
+ assoc_item: assoc
2975
+ |
2976
+ tIDENTIFIER
2977
+ {
2978
+ lvar = @builder.accessible(@builder.ident(val[0]))
2979
+ result = @builder.ipair(lvar)
2980
+ }
2948
2981
 
2949
2982
  assocs: assoc
2950
2983
  {
@@ -3025,7 +3058,7 @@ require 'parser/ruby-next/parser_ext'
3025
3058
  prepend Parser::NextExt
3026
3059
 
3027
3060
  def version
3028
- 28 # the master Ruby version
3061
+ 30
3029
3062
  end
3030
3063
 
3031
3064
  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.5
4
+ version: 3.0.0.0
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-02 00:00:00.000000000 Z
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -39,7 +39,6 @@ files:
39
39
  - lib/parser/ruby-next/lexer.rl
40
40
  - lib/parser/ruby-next/meta.rb
41
41
  - lib/parser/ruby-next/parser_ext.rb
42
- - lib/parser/ruby-next/source/map/endless_definition.rb
43
42
  - lib/parser/ruby-next/version.rb
44
43
  - lib/parser/rubynext.rb
45
44
  - lib/parser/rubynext.y
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Parser
4
- module Source
5
-
6
- class Map::EndlessDefinition < Map
7
- attr_reader :keyword
8
- attr_reader :operator
9
- attr_reader :name
10
- attr_reader :assignment
11
-
12
- def initialize(keyword_l, operator_l, name_l, assignment_l, body_l)
13
- @keyword = keyword_l
14
- @operator = operator_l
15
- @name = name_l
16
- @assignment = assignment_l
17
-
18
- super(@keyword.join(body_l))
19
- end
20
- end
21
-
22
- end
23
- end