ruby-next-parser 3.1.1.3 → 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
  {
@@ -2345,7 +2365,7 @@ opt_block_args_tail:
2345
2365
  result = @builder.pin(val[0], non_lvar)
2346
2366
  }
2347
2367
 
2348
- p_expr_ref: tCARET tLPAREN expr_value tRPAREN
2368
+ p_expr_ref: tCARET tLPAREN expr_value rparen
2349
2369
  {
2350
2370
  expr = @builder.begin(val[1], val[2], val[3])
2351
2371
  result = @builder.pin(val[0], expr)
@@ -2639,22 +2659,11 @@ regexp_contents: # nothing
2639
2659
  {
2640
2660
  result = @builder.ident(val[0])
2641
2661
  }
2642
- | tIVAR
2643
- {
2644
- result = @builder.ivar(val[0])
2645
- }
2646
- | tGVAR
2647
- {
2648
- result = @builder.gvar(val[0])
2649
- }
2650
2662
  | tCONSTANT
2651
2663
  {
2652
2664
  result = @builder.const(val[0])
2653
2665
  }
2654
- | tCVAR
2655
- {
2656
- result = @builder.cvar(val[0])
2657
- }
2666
+ | nonlocal_var
2658
2667
 
2659
2668
  keyword_variable: kNIL
2660
2669
  {
@@ -3002,6 +3011,8 @@ f_opt_paren_args: f_paren_args
3002
3011
  }
3003
3012
  | kwrest_mark
3004
3013
  {
3014
+ @static_env.declare_anonymous_kwrestarg
3015
+
3005
3016
  result = [ @builder.kwrestarg(val[0]) ]
3006
3017
  }
3007
3018
 
@@ -3047,6 +3058,8 @@ f_opt_paren_args: f_paren_args
3047
3058
  }
3048
3059
  | restarg_mark
3049
3060
  {
3061
+ @static_env.declare_anonymous_restarg
3062
+
3050
3063
  result = [ @builder.restarg(val[0]) ]
3051
3064
  }
3052
3065
 
@@ -3115,6 +3128,14 @@ f_opt_paren_args: f_paren_args
3115
3128
  {
3116
3129
  result = @builder.kwsplat(val[0], val[1])
3117
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
+ }
3118
3139
 
3119
3140
  operation: tIDENTIFIER | tCONSTANT | tFID
3120
3141
  operation2: operation | op
@@ -3142,7 +3163,7 @@ f_opt_paren_args: f_paren_args
3142
3163
  {
3143
3164
  result = val[1]
3144
3165
  }
3145
- trailer: | tNL | tCOMMA
3166
+ trailer: opt_nl | tCOMMA
3146
3167
 
3147
3168
  term: tSEMI
3148
3169
  {
@@ -3169,7 +3190,7 @@ require 'parser/ruby-next/parser_ext'
3169
3190
  prepend Parser::NextExt
3170
3191
 
3171
3192
  def version
3172
- 32
3193
+ 33
3173
3194
  end
3174
3195
 
3175
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.3
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-04-05 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.3.7
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