ruby-next-parser 3.1.1.2 → 3.2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -360,6 +360,7 @@ rule
360
360
  @lexer.state = :expr_beg
361
361
  @lexer.command_start = false
362
362
  @pattern_variables.push
363
+ @pattern_hash_keys.push
363
364
 
364
365
  result = @context.in_kwarg
365
366
  @context.in_kwarg = true
@@ -367,6 +368,7 @@ rule
367
368
  p_top_expr_body
368
369
  {
369
370
  @pattern_variables.pop
371
+ @pattern_hash_keys.pop
370
372
  @context.in_kwarg = val[2]
371
373
  result = @builder.match_pattern(val[0], val[1], val[3])
372
374
  }
@@ -375,6 +377,7 @@ rule
375
377
  @lexer.state = :expr_beg
376
378
  @lexer.command_start = false
377
379
  @pattern_variables.push
380
+ @pattern_hash_keys.push
378
381
 
379
382
  result = @context.in_kwarg
380
383
  @context.in_kwarg = true
@@ -382,6 +385,7 @@ rule
382
385
  p_top_expr_body
383
386
  {
384
387
  @pattern_variables.pop
388
+ @pattern_hash_keys.pop
385
389
  @context.in_kwarg = val[2]
386
390
  result = @builder.match_pattern_p(val[0], val[1], val[3])
387
391
  }
@@ -1172,6 +1176,14 @@ rule
1172
1176
  {
1173
1177
  result = [ @builder.splat(val[0], val[1]) ]
1174
1178
  }
1179
+ | tSTAR
1180
+ {
1181
+ if !@static_env.declared_anonymous_restarg?
1182
+ diagnostic :error, :no_anonymous_restarg, nil, val[0]
1183
+ end
1184
+
1185
+ result = [ @builder.forwarded_restarg(val[0]) ]
1186
+ }
1175
1187
  | args tCOMMA arg_value
1176
1188
  {
1177
1189
  result = val[0] << val[2]
@@ -1180,6 +1192,14 @@ rule
1180
1192
  {
1181
1193
  result = val[0] << @builder.splat(val[2], val[3])
1182
1194
  }
1195
+ | args tCOMMA tSTAR
1196
+ {
1197
+ if !@static_env.declared_anonymous_restarg?
1198
+ diagnostic :error, :no_anonymous_restarg, nil, val[2]
1199
+ end
1200
+
1201
+ result = val[0] << @builder.forwarded_restarg(val[2])
1202
+ }
1183
1203
 
1184
1204
  mrhs_arg: mrhs
1185
1205
  {
@@ -2266,11 +2286,14 @@ opt_block_args_tail:
2266
2286
 
2267
2287
  p_kwnorest: kwrest_mark kNIL
2268
2288
  {
2269
- result = [ @builder.match_nil_pattern(val[0], val[1]) ]
2289
+ result = val
2270
2290
  }
2271
2291
 
2272
2292
  p_any_kwrest: p_kwrest
2273
2293
  | p_kwnorest
2294
+ {
2295
+ result = [ @builder.match_nil_pattern(val[0][0], val[0][1]) ]
2296
+ }
2274
2297
 
2275
2298
  p_value: p_primitive
2276
2299
  | p_primitive tDOT2 p_primitive
@@ -2342,7 +2365,7 @@ opt_block_args_tail:
2342
2365
  result = @builder.pin(val[0], non_lvar)
2343
2366
  }
2344
2367
 
2345
- p_expr_ref: tCARET tLPAREN expr_value tRPAREN
2368
+ p_expr_ref: tCARET tLPAREN expr_value rparen
2346
2369
  {
2347
2370
  expr = @builder.begin(val[1], val[2], val[3])
2348
2371
  result = @builder.pin(val[0], expr)
@@ -2636,22 +2659,11 @@ regexp_contents: # nothing
2636
2659
  {
2637
2660
  result = @builder.ident(val[0])
2638
2661
  }
2639
- | tIVAR
2640
- {
2641
- result = @builder.ivar(val[0])
2642
- }
2643
- | tGVAR
2644
- {
2645
- result = @builder.gvar(val[0])
2646
- }
2647
2662
  | tCONSTANT
2648
2663
  {
2649
2664
  result = @builder.const(val[0])
2650
2665
  }
2651
- | tCVAR
2652
- {
2653
- result = @builder.cvar(val[0])
2654
- }
2666
+ | nonlocal_var
2655
2667
 
2656
2668
  keyword_variable: kNIL
2657
2669
  {
@@ -2986,9 +2998,9 @@ f_opt_paren_args: f_paren_args
2986
2998
 
2987
2999
  kwrest_mark: tPOW | tDSTAR
2988
3000
 
2989
- f_no_kwarg: kwrest_mark kNIL
3001
+ f_no_kwarg: p_kwnorest
2990
3002
  {
2991
- result = [ @builder.kwnilarg(val[0], val[1]) ]
3003
+ result = [ @builder.kwnilarg(val[0][0], val[0][1]) ]
2992
3004
  }
2993
3005
 
2994
3006
  f_kwrest: kwrest_mark tIDENTIFIER
@@ -2999,6 +3011,8 @@ f_opt_paren_args: f_paren_args
2999
3011
  }
3000
3012
  | kwrest_mark
3001
3013
  {
3014
+ @static_env.declare_anonymous_kwrestarg
3015
+
3002
3016
  result = [ @builder.kwrestarg(val[0]) ]
3003
3017
  }
3004
3018
 
@@ -3044,6 +3058,8 @@ f_opt_paren_args: f_paren_args
3044
3058
  }
3045
3059
  | restarg_mark
3046
3060
  {
3061
+ @static_env.declare_anonymous_restarg
3062
+
3047
3063
  result = [ @builder.restarg(val[0]) ]
3048
3064
  }
3049
3065
 
@@ -3112,9 +3128,17 @@ f_opt_paren_args: f_paren_args
3112
3128
  {
3113
3129
  result = @builder.kwsplat(val[0], val[1])
3114
3130
  }
3131
+ | tDSTAR
3132
+ {
3133
+ if !@static_env.declared_anonymous_kwrestarg?
3134
+ diagnostic :error, :no_anonymous_kwrestarg, nil, val[0]
3135
+ end
3136
+
3137
+ result = @builder.forwarded_kwrestarg(val[0])
3138
+ }
3115
3139
 
3116
3140
  operation: tIDENTIFIER | tCONSTANT | tFID
3117
- operation2: tIDENTIFIER | tCONSTANT | tFID | op
3141
+ operation2: operation | op
3118
3142
  operation3: tIDENTIFIER | tFID | op
3119
3143
  dot_or_colon: call_op | tCOLON2
3120
3144
  call_op: tDOT
@@ -3139,7 +3163,7 @@ f_opt_paren_args: f_paren_args
3139
3163
  {
3140
3164
  result = val[1]
3141
3165
  }
3142
- trailer: | tNL | tCOMMA
3166
+ trailer: opt_nl | tCOMMA
3143
3167
 
3144
3168
  term: tSEMI
3145
3169
  {
@@ -3166,7 +3190,7 @@ require 'parser/ruby-next/parser_ext'
3166
3190
  prepend Parser::NextExt
3167
3191
 
3168
3192
  def version
3169
- 32
3193
+ 33
3170
3194
  end
3171
3195
 
3172
3196
  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: 3.1.1.2
4
+ version: 3.2.2.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: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2023-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -35,7 +35,8 @@ files:
35
35
  - lib/parser/ruby-next/AST_FORMAT.md
36
36
  - lib/parser/ruby-next/ast/processor.rb
37
37
  - lib/parser/ruby-next/builder.rb
38
- - lib/parser/ruby-next/lexer.rb
38
+ - lib/parser/ruby-next/lexer-F0.rb
39
+ - lib/parser/ruby-next/lexer-F1.rb
39
40
  - lib/parser/ruby-next/lexer.rl
40
41
  - lib/parser/ruby-next/meta.rb
41
42
  - lib/parser/ruby-next/parser_ext.rb
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  - !ruby/object:Gem::Version
64
65
  version: '0'
65
66
  requirements: []
66
- rubygems_version: 3.2.22
67
+ rubygems_version: 3.4.20
67
68
  signing_key:
68
69
  specification_version: 4
69
70
  summary: Parser extension to support edge and experimental Ruby syntax