ruby-next-parser 2.8.0.4 → 2.8.0.9

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
 
@@ -869,6 +869,23 @@ rule
869
869
  result = @builder.def_endless_method(*val[0],
870
870
  val[1], val[2], val[3])
871
871
 
872
+ @lexer.cmdarg.pop
873
+ @lexer.cond.pop
874
+ @static_env.unextend
875
+ @context.pop
876
+ @current_arg_stack.pop
877
+ }
878
+ | defn_head f_paren_args tEQL arg kRESCUE_MOD arg
879
+ {
880
+ rescue_body = @builder.rescue_body(val[4],
881
+ nil, nil, nil,
882
+ nil, val[5])
883
+
884
+ method_body = @builder.begin_body(val[3], [ rescue_body ])
885
+
886
+ result = @builder.def_endless_method(*val[0],
887
+ val[1], val[2], method_body)
888
+
872
889
  @lexer.cmdarg.pop
873
890
  @lexer.cond.pop
874
891
  @static_env.unextend
@@ -880,6 +897,23 @@ rule
880
897
  result = @builder.def_endless_singleton(*val[0],
881
898
  val[1], val[2], val[3])
882
899
 
900
+ @lexer.cmdarg.pop
901
+ @lexer.cond.pop
902
+ @static_env.unextend
903
+ @context.pop
904
+ @current_arg_stack.pop
905
+ }
906
+ | defs_head f_paren_args tEQL arg kRESCUE_MOD arg
907
+ {
908
+ rescue_body = @builder.rescue_body(val[4],
909
+ nil, nil, nil,
910
+ nil, val[5])
911
+
912
+ method_body = @builder.begin_body(val[3], [ rescue_body ])
913
+
914
+ result = @builder.def_endless_singleton(*val[0],
915
+ val[1], val[2], method_body)
916
+
883
917
  @lexer.cmdarg.pop
884
918
  @lexer.cond.pop
885
919
  @static_env.unextend
@@ -926,6 +960,14 @@ rule
926
960
  {
927
961
  result = val
928
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
+ }
929
971
  | tLPAREN2 args_forward rparen
930
972
  {
931
973
  unless @static_env.declared_forward_args?
@@ -1178,14 +1220,7 @@ rule
1178
1220
  result = @builder.block(val[0],
1179
1221
  begin_t, args, body, end_t)
1180
1222
  }
1181
- | tLAMBDA lambda
1182
- {
1183
- lambda_call = @builder.call_lambda(val[0])
1184
-
1185
- args, (begin_t, body, end_t) = val[1]
1186
- result = @builder.block(lambda_call,
1187
- begin_t, args, body, end_t)
1188
- }
1223
+ | lambda
1189
1224
  | kIF expr_value then compstmt if_tail kEND
1190
1225
  {
1191
1226
  else_t, else_ = val[4]
@@ -1280,6 +1315,7 @@ rule
1280
1315
  {
1281
1316
  @static_env.extend_static
1282
1317
  @lexer.cmdarg.push(false)
1318
+ @context.push(:module)
1283
1319
  }
1284
1320
  bodystmt kEND
1285
1321
  {
@@ -1292,6 +1328,7 @@ rule
1292
1328
 
1293
1329
  @lexer.cmdarg.pop
1294
1330
  @static_env.unextend
1331
+ @context.pop
1295
1332
  }
1296
1333
  | defn_head f_arglist bodystmt kEND
1297
1334
  {
@@ -1423,6 +1460,9 @@ rule
1423
1460
  result = @builder.restarg(val[0])
1424
1461
  }
1425
1462
 
1463
+ f_any_kwrest: f_kwrest
1464
+ | f_no_kwarg
1465
+
1426
1466
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
1427
1467
  {
1428
1468
  result = val[0].concat(val[2]).concat(val[3])
@@ -1431,11 +1471,7 @@ rule
1431
1471
  {
1432
1472
  result = val[0].concat(val[1])
1433
1473
  }
1434
- | f_kwrest opt_f_block_arg
1435
- {
1436
- result = val[0].concat(val[1])
1437
- }
1438
- | f_no_kwarg opt_f_block_arg
1474
+ | f_any_kwrest opt_f_block_arg
1439
1475
  {
1440
1476
  result = val[0].concat(val[1])
1441
1477
  }
@@ -1454,6 +1490,8 @@ opt_block_args_tail:
1454
1490
  result = []
1455
1491
  }
1456
1492
 
1493
+ excessed_comma: tCOMMA
1494
+
1457
1495
  block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
1458
1496
  {
1459
1497
  result = val[0].
@@ -1488,7 +1526,7 @@ opt_block_args_tail:
1488
1526
  concat(val[2]).
1489
1527
  concat(val[3])
1490
1528
  }
1491
- | f_arg tCOMMA
1529
+ | f_arg excessed_comma
1492
1530
  | f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
1493
1531
  {
1494
1532
  result = val[0].
@@ -1588,7 +1626,8 @@ opt_block_args_tail:
1588
1626
  }
1589
1627
  | f_bad_arg
1590
1628
 
1591
- lambda: {
1629
+ lambda: tLAMBDA
1630
+ {
1592
1631
  @static_env.extend_dynamic
1593
1632
  @max_numparam_stack.push
1594
1633
  @context.push(:lambda)
@@ -1600,12 +1639,16 @@ opt_block_args_tail:
1600
1639
  }
1601
1640
  lambda_body
1602
1641
  {
1603
- args = @max_numparam_stack.has_numparams? ? @builder.numargs(@max_numparam_stack.top) : val[1]
1604
- 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]
1605
1645
 
1606
1646
  @max_numparam_stack.pop
1607
1647
  @static_env.unextend
1608
1648
  @lexer.cmdarg.pop
1649
+
1650
+ result = @builder.block(lambda_call,
1651
+ begin_t, args, body, end_t)
1609
1652
  }
1610
1653
 
1611
1654
  f_larglist: tLPAREN2 f_args opt_bv_decl tRPAREN
@@ -1844,6 +1887,10 @@ opt_block_args_tail:
1844
1887
  {
1845
1888
  result = @builder.array_pattern(nil, [val[0]].concat(val[2]), nil)
1846
1889
  }
1890
+ | p_find
1891
+ {
1892
+ result = @builder.find_pattern(nil, val[0], nil)
1893
+ }
1847
1894
  | p_args_tail
1848
1895
  {
1849
1896
  result = @builder.array_pattern(nil, val[0], nil)
@@ -1886,6 +1933,12 @@ opt_block_args_tail:
1886
1933
  pattern = @builder.array_pattern(nil, val[2], nil)
1887
1934
  result = @builder.const_pattern(val[0], val[1], pattern, val[3])
1888
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
+ }
1889
1942
  | p_const p_lparen p_kwargs rparen
1890
1943
  {
1891
1944
  @pattern_hash_keys.pop
@@ -1903,6 +1956,12 @@ opt_block_args_tail:
1903
1956
  pattern = @builder.array_pattern(nil, val[2], nil)
1904
1957
  result = @builder.const_pattern(val[0], val[1], pattern, val[3])
1905
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
+ }
1906
1965
  | p_const p_lbracket p_kwargs rbracket
1907
1966
  {
1908
1967
  @pattern_hash_keys.pop
@@ -1914,14 +1973,13 @@ opt_block_args_tail:
1914
1973
  pattern = @builder.array_pattern(val[1], nil, val[2])
1915
1974
  result = @builder.const_pattern(val[0], val[1], pattern, val[2])
1916
1975
  }
1917
- | tLBRACK
1976
+ | tLBRACK p_args rbracket
1918
1977
  {
1919
- @pattern_hash_keys.push
1978
+ result = @builder.array_pattern(val[0], val[1], val[2])
1920
1979
  }
1921
- p_args rbracket
1980
+ | tLBRACK p_find rbracket
1922
1981
  {
1923
- @pattern_hash_keys.pop
1924
- result = @builder.array_pattern(val[0], val[2], val[3])
1982
+ result = @builder.find_pattern(val[0], val[1], val[2])
1925
1983
  }
1926
1984
  | tLBRACK rbracket
1927
1985
  {
@@ -2002,25 +2060,27 @@ opt_block_args_tail:
2002
2060
  result = [ *val[0], last_item ]
2003
2061
  }
2004
2062
 
2005
- p_args_tail: tSTAR tIDENTIFIER
2063
+ p_args_tail: p_rest
2006
2064
  {
2007
- match_rest = @builder.match_rest(val[0], val[1])
2008
- result = [ match_rest ]
2065
+ result = [ val[0] ]
2009
2066
  }
2010
- | tSTAR tIDENTIFIER tCOMMA p_args_post
2067
+ | p_rest tCOMMA p_args_post
2011
2068
  {
2012
- match_rest = @builder.match_rest(val[0], val[1])
2013
- result = [ match_rest, *val[3] ]
2069
+ result = [ val[0], *val[2] ]
2014
2070
  }
2015
- | tSTAR
2071
+
2072
+ p_find: p_rest tCOMMA p_args_post tCOMMA p_rest
2073
+ {
2074
+ result = [ val[0], *val[2], val[4] ]
2075
+ }
2076
+
2077
+ p_rest: tSTAR tIDENTIFIER
2016
2078
  {
2017
- match_rest = @builder.match_rest(val[0])
2018
- result = [ match_rest ]
2079
+ result = @builder.match_rest(val[0], val[1])
2019
2080
  }
2020
- | tSTAR tCOMMA p_args_post
2081
+ | tSTAR
2021
2082
  {
2022
- match_rest = @builder.match_rest(val[0])
2023
- result = [ match_rest, *val[2] ]
2083
+ result = @builder.match_rest(val[0])
2024
2084
  }
2025
2085
 
2026
2086
  p_args_post: p_arg
@@ -2034,7 +2094,7 @@ opt_block_args_tail:
2034
2094
 
2035
2095
  p_arg: p_expr
2036
2096
 
2037
- p_kwargs: p_kwarg tCOMMA p_kwrest
2097
+ p_kwargs: p_kwarg tCOMMA p_any_kwrest
2038
2098
  {
2039
2099
  result = [ *val[0], *val[2] ]
2040
2100
  }
@@ -2046,18 +2106,10 @@ opt_block_args_tail:
2046
2106
  {
2047
2107
  result = val[0]
2048
2108
  }
2049
- | p_kwrest
2109
+ | p_any_kwrest
2050
2110
  {
2051
2111
  result = val[0]
2052
2112
  }
2053
- | p_kwarg tCOMMA p_kwnorest
2054
- {
2055
- result = [ *val[0], *val[2] ]
2056
- }
2057
- | p_kwnorest
2058
- {
2059
- result = [ *val[0], *val[2] ]
2060
- }
2061
2113
 
2062
2114
  p_kwarg: p_kw
2063
2115
  {
@@ -2079,7 +2131,6 @@ opt_block_args_tail:
2079
2131
 
2080
2132
  p_kw_label: tLABEL
2081
2133
  {
2082
- check_kwarg_name(val[0])
2083
2134
  result = [:label, val[0]]
2084
2135
  }
2085
2136
  | tSTRING_BEG string_contents tLABEL_END
@@ -2101,6 +2152,9 @@ opt_block_args_tail:
2101
2152
  result = [ @builder.match_nil_pattern(val[0], val[1]) ]
2102
2153
  }
2103
2154
 
2155
+ p_any_kwrest: p_kwrest
2156
+ | p_kwnorest
2157
+
2104
2158
  p_value: p_primitive
2105
2159
  | p_primitive tDOT2 p_primitive
2106
2160
  {
@@ -2142,14 +2196,7 @@ opt_block_args_tail:
2142
2196
  {
2143
2197
  result = @builder.accessible(val[0])
2144
2198
  }
2145
- | tLAMBDA lambda
2146
- {
2147
- lambda_call = @builder.call_lambda(val[0])
2148
-
2149
- args, (begin_t, body, end_t) = val[1]
2150
- result = @builder.block(lambda_call,
2151
- begin_t, args, body, end_t)
2152
- }
2199
+ | lambda
2153
2200
 
2154
2201
  p_variable: tIDENTIFIER
2155
2202
  {
@@ -2568,15 +2615,22 @@ keyword_variable: kNIL
2568
2615
  result = nil
2569
2616
  }
2570
2617
 
2571
- f_paren_args: tLPAREN2 f_args rparen
2618
+ f_paren_args: tLPAREN2 f_args rparen
2572
2619
  {
2573
2620
  result = @builder.args(val[0], val[1], val[2])
2574
2621
 
2575
2622
  @lexer.state = :expr_value
2576
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
+ }
2577
2631
  | tLPAREN2 args_forward rparen
2578
2632
  {
2579
- result = @builder.forward_args(val[0], val[1], val[2])
2633
+ result = @builder.forward_only_args(val[0], val[1], val[2])
2580
2634
  @static_env.declare_forward_args
2581
2635
 
2582
2636
  @lexer.state = :expr_value
@@ -2601,11 +2655,7 @@ keyword_variable: kNIL
2601
2655
  {
2602
2656
  result = val[0].concat(val[1])
2603
2657
  }
2604
- | f_kwrest opt_f_block_arg
2605
- {
2606
- result = val[0].concat(val[1])
2607
- }
2608
- | f_no_kwarg opt_f_block_arg
2658
+ | f_any_kwrest opt_f_block_arg
2609
2659
  {
2610
2660
  result = val[0].concat(val[1])
2611
2661
  }
@@ -2991,7 +3041,7 @@ require 'parser/ruby-next/parser_ext'
2991
3041
  prepend Parser::NextExt
2992
3042
 
2993
3043
  def version
2994
- 28 # the master Ruby version
3044
+ 28
2995
3045
  end
2996
3046
 
2997
3047
  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
4
+ version: 2.8.0.9
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-05-01 00:00:00.000000000 Z
11
+ date: 2020-07-31 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.0.5
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.0.5
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:
@@ -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
@@ -57,7 +56,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
56
  requirements:
58
57
  - - ">="
59
58
  - !ruby/object:Gem::Version
60
- version: 2.4.0
59
+ version: 2.0.0
61
60
  required_rubygems_version: !ruby/object:Gem::Requirement
62
61
  requirements:
63
62
  - - ">="
@@ -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