ruby-next-parser 3.0.0.1 → 3.0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  {
@@ -301,19 +294,35 @@ rule
301
294
  {
302
295
  result = @builder.not_op(val[0], nil, val[1], nil)
303
296
  }
297
+ | arg tASSOC
298
+ {
299
+ @lexer.state = :expr_beg
300
+ @lexer.command_start = false
301
+ @pattern_variables.push
302
+
303
+ result = @lexer.in_kwarg
304
+ @lexer.in_kwarg = true
305
+ }
306
+ p_expr
307
+ {
308
+ @pattern_variables.pop
309
+ @lexer.in_kwarg = val[2]
310
+ result = @builder.match_pattern(val[0], val[1], val[3])
311
+ }
304
312
  | arg kIN
305
313
  {
306
314
  @lexer.state = :expr_beg
307
315
  @lexer.command_start = false
308
- pattern_variables.push
316
+ @pattern_variables.push
309
317
 
310
318
  result = @lexer.in_kwarg
311
319
  @lexer.in_kwarg = true
312
320
  }
313
321
  p_expr
314
322
  {
323
+ @pattern_variables.pop
315
324
  @lexer.in_kwarg = val[2]
316
- result = @builder.in_match(val[0], val[1], val[3])
325
+ result = @builder.match_pattern_p(val[0], val[1], val[3])
317
326
  }
318
327
  | arg =tLBRACE_ARG
319
328
 
@@ -328,7 +337,7 @@ rule
328
337
  result = [ val[1], val[2] ]
329
338
  }
330
339
 
331
- def_name: fname
340
+ def_name: fname
332
341
  {
333
342
  @static_env.extend_static
334
343
  @lexer.cmdarg.push(false)
@@ -864,13 +873,10 @@ rule
864
873
  result = @builder.ternary(val[0], val[1],
865
874
  val[2], val[4], val[5])
866
875
  }
867
- | defn_head f_paren_args tEQL arg
876
+ | defn_head f_opt_paren_args tEQL arg
868
877
  {
869
878
  _def_t, name_t = val[0]
870
-
871
- if name_t[0].end_with?('=')
872
- diagnostic :error, :endless_setter, nil, name_t
873
- end
879
+ endless_method_name(name_t)
874
880
 
875
881
  result = @builder.def_endless_method(*val[0],
876
882
  val[1], val[2], val[3])
@@ -881,8 +887,11 @@ rule
881
887
  @context.pop
882
888
  @current_arg_stack.pop
883
889
  }
884
- | defn_head f_paren_args tEQL arg kRESCUE_MOD arg
890
+ | defn_head f_opt_paren_args tEQL arg kRESCUE_MOD arg
885
891
  {
892
+ _def_t, name_t = val[0]
893
+ endless_method_name(name_t)
894
+
886
895
  rescue_body = @builder.rescue_body(val[4],
887
896
  nil, nil, nil,
888
897
  nil, val[5])
@@ -898,8 +907,11 @@ rule
898
907
  @context.pop
899
908
  @current_arg_stack.pop
900
909
  }
901
- | defs_head f_paren_args tEQL arg
910
+ | defs_head f_opt_paren_args tEQL arg
902
911
  {
912
+ _def_t, _recv, _dot_t, name_t = val[0]
913
+ endless_method_name(name_t)
914
+
903
915
  result = @builder.def_endless_singleton(*val[0],
904
916
  val[1], val[2], val[3])
905
917
 
@@ -909,8 +921,11 @@ rule
909
921
  @context.pop
910
922
  @current_arg_stack.pop
911
923
  }
912
- | defs_head f_paren_args tEQL arg kRESCUE_MOD arg
924
+ | defs_head f_opt_paren_args tEQL arg kRESCUE_MOD arg
913
925
  {
926
+ _def_t, _recv, _dot_t, name_t = val[0]
927
+ endless_method_name(name_t)
928
+
914
929
  rescue_body = @builder.rescue_body(val[4],
915
930
  nil, nil, nil,
916
931
  nil, val[5])
@@ -1853,6 +1868,8 @@ opt_block_args_tail:
1853
1868
  }
1854
1869
  p_top_expr then
1855
1870
  {
1871
+ @pattern_variables.pop
1872
+ @pattern_hash_keys.pop
1856
1873
  @lexer.in_kwarg = val[1]
1857
1874
  }
1858
1875
  compstmt p_cases
@@ -2621,6 +2638,12 @@ keyword_variable: kNIL
2621
2638
  result = nil
2622
2639
  }
2623
2640
 
2641
+ f_opt_paren_args: f_paren_args
2642
+ | none
2643
+ {
2644
+ result = @builder.args(nil, [], nil)
2645
+ }
2646
+
2624
2647
  f_paren_args: tLPAREN2 f_args rparen
2625
2648
  {
2626
2649
  result = @builder.args(val[0], val[1], val[2])
@@ -3070,3 +3093,9 @@ require 'parser/ruby-next/parser_ext'
3070
3093
  def default_encoding
3071
3094
  Encoding::UTF_8
3072
3095
  end
3096
+
3097
+ def endless_method_name(name_t)
3098
+ if name_t[0].end_with?('=')
3099
+ diagnostic :error, :endless_setter, nil, name_t
3100
+ end
3101
+ 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: 3.0.0.1
4
+ version: 3.0.0.2
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-09-28 00:00:00.000000000 Z
11
+ date: 2020-12-23 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.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.0.5
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: