ruby-next-parser 2.8.0.9 → 3.0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,7 +46,17 @@ preclow
46
46
 
47
47
  rule
48
48
 
49
- program: top_compstmt
49
+ program: {
50
+ @current_arg_stack.push(nil)
51
+ @max_numparam_stack.push
52
+ }
53
+ top_compstmt
54
+ {
55
+ result = val[1]
56
+
57
+ @current_arg_stack.pop
58
+ @max_numparam_stack.pop
59
+ }
50
60
 
51
61
  top_compstmt: top_stmts opt_terms
52
62
  {
@@ -206,25 +216,8 @@ rule
206
216
  {
207
217
  result = @builder.multi_assign(val[0], val[1], val[2])
208
218
  }
209
- | rassign
210
219
  | expr
211
220
 
212
- rassign: arg_value tASSOC lhs
213
- {
214
- result = @builder.rassign(val[0], val[1], val[2])
215
- }
216
- | arg_value tASSOC mlhs
217
- {
218
- result = @builder.multi_rassign(val[0], val[1], val[2])
219
- }
220
- | rassign tASSOC lhs
221
- {
222
- result = @builder.rassign(val[0], val[1], val[2])
223
- }
224
- | rassign tASSOC mlhs
225
- {
226
- result = @builder.multi_rassign(val[0], val[1], val[2])
227
- }
228
221
 
229
222
  command_asgn: lhs tEQL command_rhs
230
223
  {
@@ -268,6 +261,74 @@ rule
268
261
  val[0], val[1], val[2]),
269
262
  val[3], val[4])
270
263
  }
264
+ | defn_head f_opt_paren_args tEQL command
265
+ {
266
+ _def_t, name_t = val[0]
267
+ endless_method_name(name_t)
268
+
269
+ result = @builder.def_endless_method(*val[0],
270
+ val[1], val[2], val[3])
271
+
272
+ @lexer.cmdarg.pop
273
+ @lexer.cond.pop
274
+ @static_env.unextend
275
+ @context.pop
276
+ @current_arg_stack.pop
277
+ }
278
+ | defn_head f_opt_paren_args tEQL command kRESCUE_MOD arg
279
+ {
280
+ _def_t, name_t = val[0]
281
+ endless_method_name(name_t)
282
+
283
+ rescue_body = @builder.rescue_body(val[4],
284
+ nil, nil, nil,
285
+ nil, val[5])
286
+
287
+ method_body = @builder.begin_body(val[3], [ rescue_body ])
288
+
289
+ result = @builder.def_endless_method(*val[0],
290
+ val[1], val[2], method_body)
291
+
292
+ @lexer.cmdarg.pop
293
+ @lexer.cond.pop
294
+ @static_env.unextend
295
+ @context.pop
296
+ @current_arg_stack.pop
297
+ }
298
+ | defs_head f_opt_paren_args tEQL command
299
+ {
300
+ _def_t, _recv, _dot_t, name_t = val[0]
301
+ endless_method_name(name_t)
302
+
303
+ result = @builder.def_endless_singleton(*val[0],
304
+ val[1], val[2], val[3])
305
+
306
+ @lexer.cmdarg.pop
307
+ @lexer.cond.pop
308
+ @static_env.unextend
309
+ @context.pop
310
+ @current_arg_stack.pop
311
+ }
312
+ | defs_head f_opt_paren_args tEQL command kRESCUE_MOD arg
313
+ {
314
+ _def_t, _recv, _dot_t, name_t = val[0]
315
+ endless_method_name(name_t)
316
+
317
+ rescue_body = @builder.rescue_body(val[4],
318
+ nil, nil, nil,
319
+ nil, val[5])
320
+
321
+ method_body = @builder.begin_body(val[3], [ rescue_body ])
322
+
323
+ result = @builder.def_endless_singleton(*val[0],
324
+ val[1], val[2], method_body)
325
+
326
+ @lexer.cmdarg.pop
327
+ @lexer.cond.pop
328
+ @static_env.unextend
329
+ @context.pop
330
+ @current_arg_stack.pop
331
+ }
271
332
  | backref tOP_ASGN command_rhs
272
333
  {
273
334
  @builder.op_assign(val[0], val[1], val[2])
@@ -301,19 +362,35 @@ rule
301
362
  {
302
363
  result = @builder.not_op(val[0], nil, val[1], nil)
303
364
  }
365
+ | arg tASSOC
366
+ {
367
+ @lexer.state = :expr_beg
368
+ @lexer.command_start = false
369
+ @pattern_variables.push
370
+
371
+ result = @lexer.in_kwarg
372
+ @lexer.in_kwarg = true
373
+ }
374
+ p_expr
375
+ {
376
+ @pattern_variables.pop
377
+ @lexer.in_kwarg = val[2]
378
+ result = @builder.match_pattern(val[0], val[1], val[3])
379
+ }
304
380
  | arg kIN
305
381
  {
306
382
  @lexer.state = :expr_beg
307
383
  @lexer.command_start = false
308
- pattern_variables.push
384
+ @pattern_variables.push
309
385
 
310
386
  result = @lexer.in_kwarg
311
387
  @lexer.in_kwarg = true
312
388
  }
313
389
  p_expr
314
390
  {
391
+ @pattern_variables.pop
315
392
  @lexer.in_kwarg = val[2]
316
- result = @builder.in_match(val[0], val[1], val[3])
393
+ result = @builder.match_pattern_p(val[0], val[1], val[3])
317
394
  }
318
395
  | arg =tLBRACE_ARG
319
396
 
@@ -328,7 +405,7 @@ rule
328
405
  result = [ val[1], val[2] ]
329
406
  }
330
407
 
331
- def_name: fname
408
+ def_name: fname
332
409
  {
333
410
  @static_env.extend_static
334
411
  @lexer.cmdarg.push(false)
@@ -864,8 +941,11 @@ rule
864
941
  result = @builder.ternary(val[0], val[1],
865
942
  val[2], val[4], val[5])
866
943
  }
867
- | defn_head f_paren_args tEQL arg
944
+ | defn_head f_opt_paren_args tEQL arg
868
945
  {
946
+ _def_t, name_t = val[0]
947
+ endless_method_name(name_t)
948
+
869
949
  result = @builder.def_endless_method(*val[0],
870
950
  val[1], val[2], val[3])
871
951
 
@@ -875,8 +955,11 @@ rule
875
955
  @context.pop
876
956
  @current_arg_stack.pop
877
957
  }
878
- | defn_head f_paren_args tEQL arg kRESCUE_MOD arg
958
+ | defn_head f_opt_paren_args tEQL arg kRESCUE_MOD arg
879
959
  {
960
+ _def_t, name_t = val[0]
961
+ endless_method_name(name_t)
962
+
880
963
  rescue_body = @builder.rescue_body(val[4],
881
964
  nil, nil, nil,
882
965
  nil, val[5])
@@ -892,8 +975,11 @@ rule
892
975
  @context.pop
893
976
  @current_arg_stack.pop
894
977
  }
895
- | defs_head f_paren_args tEQL arg
978
+ | defs_head f_opt_paren_args tEQL arg
896
979
  {
980
+ _def_t, _recv, _dot_t, name_t = val[0]
981
+ endless_method_name(name_t)
982
+
897
983
  result = @builder.def_endless_singleton(*val[0],
898
984
  val[1], val[2], val[3])
899
985
 
@@ -903,8 +989,11 @@ rule
903
989
  @context.pop
904
990
  @current_arg_stack.pop
905
991
  }
906
- | defs_head f_paren_args tEQL arg kRESCUE_MOD arg
992
+ | defs_head f_opt_paren_args tEQL arg kRESCUE_MOD arg
907
993
  {
994
+ _def_t, _recv, _dot_t, name_t = val[0]
995
+ endless_method_name(name_t)
996
+
908
997
  rescue_body = @builder.rescue_body(val[4],
909
998
  nil, nil, nil,
910
999
  nil, val[5])
@@ -1847,6 +1936,8 @@ opt_block_args_tail:
1847
1936
  }
1848
1937
  p_top_expr then
1849
1938
  {
1939
+ @pattern_variables.pop
1940
+ @pattern_hash_keys.pop
1850
1941
  @lexer.in_kwarg = val[1]
1851
1942
  }
1852
1943
  compstmt p_cases
@@ -1927,6 +2018,7 @@ opt_block_args_tail:
1927
2018
  }
1928
2019
 
1929
2020
  p_expr_basic: p_value
2021
+ | p_variable
1930
2022
  | p_const p_lparen p_args rparen
1931
2023
  {
1932
2024
  @pattern_hash_keys.pop
@@ -2172,8 +2264,8 @@ opt_block_args_tail:
2172
2264
  {
2173
2265
  result = @builder.range_exclusive(val[0], val[1], nil)
2174
2266
  }
2175
- | p_variable
2176
2267
  | p_var_ref
2268
+ | p_expr_ref
2177
2269
  | p_const
2178
2270
  | tBDOT2 p_primitive
2179
2271
  {
@@ -2213,7 +2305,11 @@ opt_block_args_tail:
2213
2305
  lvar = @builder.accessible(@builder.ident(val[1]))
2214
2306
  result = @builder.pin(val[0], lvar)
2215
2307
  }
2216
-
2308
+ p_expr_ref: tCARET tLPAREN expr_value tRPAREN
2309
+ {
2310
+ expr = @builder.begin(val[1], val[2], val[3])
2311
+ result = @builder.pin(val[0], expr)
2312
+ }
2217
2313
  p_const: tCOLON3 cname
2218
2314
  {
2219
2315
  result = @builder.const_global(val[0], val[1])
@@ -2615,6 +2711,12 @@ keyword_variable: kNIL
2615
2711
  result = nil
2616
2712
  }
2617
2713
 
2714
+ f_opt_paren_args: f_paren_args
2715
+ | none
2716
+ {
2717
+ result = @builder.args(nil, [], nil)
2718
+ }
2719
+
2618
2720
  f_paren_args: tLPAREN2 f_args rparen
2619
2721
  {
2620
2722
  result = @builder.args(val[0], val[1], val[2])
@@ -2960,7 +3062,24 @@ keyword_variable: kNIL
2960
3062
  {
2961
3063
  result = []
2962
3064
  }
2963
- | assocs trailer
3065
+ | assoc_items trailer
3066
+
3067
+ assoc_items : assoc_item
3068
+ {
3069
+ result = [ val[0] ]
3070
+ }
3071
+ | assoc_items tCOMMA assoc_item
3072
+ {
3073
+ result = val[0] << val[2]
3074
+ }
3075
+
3076
+ assoc_item: assoc
3077
+ |
3078
+ tIDENTIFIER
3079
+ {
3080
+ lvar = @builder.accessible(@builder.ident(val[0]))
3081
+ result = @builder.ipair(lvar)
3082
+ }
2964
3083
 
2965
3084
  assocs: assoc
2966
3085
  {
@@ -2979,6 +3098,11 @@ keyword_variable: kNIL
2979
3098
  {
2980
3099
  result = @builder.pair_keyword(val[0], val[1])
2981
3100
  }
3101
+ | tLABEL
3102
+ {
3103
+ lvar = @builder.accessible(@builder.ident(val[0]))
3104
+ result = @builder.ipair_keyword(lvar)
3105
+ }
2982
3106
  | tSTRING_BEG string_contents tLABEL_END arg_value
2983
3107
  {
2984
3108
  result = @builder.pair_quoted(val[0], val[1], val[2], val[3])
@@ -3041,9 +3165,15 @@ require 'parser/ruby-next/parser_ext'
3041
3165
  prepend Parser::NextExt
3042
3166
 
3043
3167
  def version
3044
- 28
3168
+ 31
3045
3169
  end
3046
3170
 
3047
3171
  def default_encoding
3048
3172
  Encoding::UTF_8
3049
3173
  end
3174
+
3175
+ def endless_method_name(name_t)
3176
+ if !%w[=== == != <= >=].include?(name_t[0]) && name_t[0].end_with?('=')
3177
+ diagnostic :error, :endless_setter, nil, name_t
3178
+ end
3179
+ end
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.9
4
+ version: 3.0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-31 00:00:00.000000000 Z
11
+ date: 2021-06-04 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.1.4
19
+ version: 2.7.2.0
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.1.4
26
+ version: 2.7.2.0
27
27
  description: "\n Parser extension to support edge and experimental Ruby syntax\n
28
28
  \ "
29
29
  email:
@@ -46,9 +46,9 @@ homepage: http://github.com/ruby-next/parser
46
46
  licenses:
47
47
  - MIT
48
48
  metadata:
49
- homepage_uri: http://github.com/parser/ruby-next
50
- source_code_uri: http://github.com/parser/ruby-next
51
- post_install_message:
49
+ homepage_uri: http://github.com/ruby-next/parser
50
+ source_code_uri: http://github.com/ruby-next/parser
51
+ post_install_message:
52
52
  rdoc_options: []
53
53
  require_paths:
54
54
  - lib
@@ -63,8 +63,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubygems_version: 3.0.6
67
- signing_key:
66
+ rubygems_version: 3.2.15
67
+ signing_key:
68
68
  specification_version: 4
69
69
  summary: Parser extension to support edge and experimental Ruby syntax
70
70
  test_files: []