ruby-next-parser 3.0.1.0 → 3.1.0.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.
- checksums.yaml +4 -4
- data/lib/parser/ruby-next/AST_FORMAT.md +0 -50
- data/lib/parser/ruby-next/ast/processor.rb +0 -4
- data/lib/parser/ruby-next/builder.rb +0 -8
- data/lib/parser/ruby-next/lexer.rb +12253 -11327
- data/lib/parser/ruby-next/lexer.rl +35 -5
- data/lib/parser/ruby-next/meta.rb +1 -1
- data/lib/parser/ruby-next/version.rb +1 -1
- data/lib/parser/rubynext.rb +2692 -2699
- data/lib/parser/rubynext.y +72 -64
- metadata +5 -5
data/lib/parser/rubynext.y
CHANGED
@@ -17,7 +17,8 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
|
17
17
|
tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DBEG
|
18
18
|
tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
|
19
19
|
tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
|
20
|
-
tRATIONAL tIMAGINARY tLABEL_END tANDDOT
|
20
|
+
tRATIONAL tIMAGINARY tLABEL_END tANDDOT tBDOT2 tBDOT3
|
21
|
+
tMETHREF
|
21
22
|
|
22
23
|
prechigh
|
23
24
|
right tBANG tTILDE tUPLUS
|
@@ -371,7 +372,7 @@ rule
|
|
371
372
|
result = @lexer.in_kwarg
|
372
373
|
@lexer.in_kwarg = true
|
373
374
|
}
|
374
|
-
|
375
|
+
p_top_expr_body
|
375
376
|
{
|
376
377
|
@pattern_variables.pop
|
377
378
|
@lexer.in_kwarg = val[2]
|
@@ -386,7 +387,7 @@ rule
|
|
386
387
|
result = @lexer.in_kwarg
|
387
388
|
@lexer.in_kwarg = true
|
388
389
|
}
|
389
|
-
|
390
|
+
p_top_expr_body
|
390
391
|
{
|
391
392
|
@pattern_variables.pop
|
392
393
|
@lexer.in_kwarg = val[2]
|
@@ -2292,7 +2293,7 @@ opt_block_args_tail:
|
|
2292
2293
|
|
2293
2294
|
p_variable: tIDENTIFIER
|
2294
2295
|
{
|
2295
|
-
result = @builder.match_var(val[0])
|
2296
|
+
result = @builder.assignable(@builder.match_var(val[0]))
|
2296
2297
|
}
|
2297
2298
|
|
2298
2299
|
p_var_ref: tCARET tIDENTIFIER
|
@@ -2305,11 +2306,19 @@ opt_block_args_tail:
|
|
2305
2306
|
lvar = @builder.accessible(@builder.ident(val[1]))
|
2306
2307
|
result = @builder.pin(val[0], lvar)
|
2307
2308
|
}
|
2309
|
+
|
2310
|
+
| tCARET nonlocal_var
|
2311
|
+
{
|
2312
|
+
non_lvar = @builder.accessible(val[1])
|
2313
|
+
result = @builder.pin(val[0], non_lvar)
|
2314
|
+
}
|
2315
|
+
|
2308
2316
|
p_expr_ref: tCARET tLPAREN expr_value tRPAREN
|
2309
2317
|
{
|
2310
2318
|
expr = @builder.begin(val[1], val[2], val[3])
|
2311
2319
|
result = @builder.pin(val[0], expr)
|
2312
2320
|
}
|
2321
|
+
|
2313
2322
|
p_const: tCOLON3 cname
|
2314
2323
|
{
|
2315
2324
|
result = @builder.const_global(val[0], val[1])
|
@@ -2581,6 +2590,19 @@ regexp_contents: # nothing
|
|
2581
2590
|
result = @builder.complex(val[0])
|
2582
2591
|
}
|
2583
2592
|
|
2593
|
+
nonlocal_var: tIVAR
|
2594
|
+
{
|
2595
|
+
result = @builder.ivar(val[0])
|
2596
|
+
}
|
2597
|
+
| tGVAR
|
2598
|
+
{
|
2599
|
+
result = @builder.gvar(val[0])
|
2600
|
+
}
|
2601
|
+
| tCVAR
|
2602
|
+
{
|
2603
|
+
result = @builder.cvar(val[0])
|
2604
|
+
}
|
2605
|
+
|
2584
2606
|
user_variable: tIDENTIFIER
|
2585
2607
|
{
|
2586
2608
|
result = @builder.ident(val[0])
|
@@ -2633,46 +2655,6 @@ keyword_variable: kNIL
|
|
2633
2655
|
|
2634
2656
|
var_ref: user_variable
|
2635
2657
|
{
|
2636
|
-
if (node = val[0]) && node.type == :ident
|
2637
|
-
name = node.children[0]
|
2638
|
-
|
2639
|
-
if name =~ /\A_[1-9]\z/ && !static_env.declared?(name) && context.in_dynamic_block?
|
2640
|
-
# definitely an implicit param
|
2641
|
-
location = node.loc.expression
|
2642
|
-
|
2643
|
-
if max_numparam_stack.has_ordinary_params?
|
2644
|
-
diagnostic :error, :ordinary_param_defined, nil, [nil, location]
|
2645
|
-
end
|
2646
|
-
|
2647
|
-
raw_context = context.stack.dup
|
2648
|
-
raw_max_numparam_stack = max_numparam_stack.stack.dup
|
2649
|
-
|
2650
|
-
# ignore current block scope
|
2651
|
-
raw_context.pop
|
2652
|
-
raw_max_numparam_stack.pop
|
2653
|
-
|
2654
|
-
raw_context.reverse_each do |outer_scope|
|
2655
|
-
if outer_scope == :block || outer_scope == :lambda
|
2656
|
-
outer_scope_has_numparams = raw_max_numparam_stack.pop > 0
|
2657
|
-
|
2658
|
-
if outer_scope_has_numparams
|
2659
|
-
diagnostic :error, :numparam_used_in_outer_scope, nil, [nil, location]
|
2660
|
-
else
|
2661
|
-
# for now it's ok, but an outer scope can also be a block
|
2662
|
-
# with numparams, so we need to continue
|
2663
|
-
end
|
2664
|
-
else
|
2665
|
-
# found an outer scope that can't have numparams
|
2666
|
-
# like def/class/etc
|
2667
|
-
break
|
2668
|
-
end
|
2669
|
-
end
|
2670
|
-
|
2671
|
-
static_env.declare(name)
|
2672
|
-
max_numparam_stack.register(name[1].to_i)
|
2673
|
-
end
|
2674
|
-
end
|
2675
|
-
|
2676
2658
|
result = @builder.accessible(val[0])
|
2677
2659
|
}
|
2678
2660
|
| keyword_variable
|
@@ -3062,24 +3044,7 @@ f_opt_paren_args: f_paren_args
|
|
3062
3044
|
{
|
3063
3045
|
result = []
|
3064
3046
|
}
|
3065
|
-
|
|
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
|
-
}
|
3047
|
+
| assocs trailer
|
3083
3048
|
|
3084
3049
|
assocs: assoc
|
3085
3050
|
{
|
@@ -3100,8 +3065,7 @@ f_opt_paren_args: f_paren_args
|
|
3100
3065
|
}
|
3101
3066
|
| tLABEL
|
3102
3067
|
{
|
3103
|
-
|
3104
|
-
result = @builder.ipair_keyword(lvar)
|
3068
|
+
result = @builder.pair_label(val[0])
|
3105
3069
|
}
|
3106
3070
|
| tSTRING_BEG string_contents tLABEL_END arg_value
|
3107
3071
|
{
|
@@ -3177,3 +3141,47 @@ require 'parser/ruby-next/parser_ext'
|
|
3177
3141
|
diagnostic :error, :endless_setter, nil, name_t
|
3178
3142
|
end
|
3179
3143
|
end
|
3144
|
+
|
3145
|
+
def try_declare_numparam(node)
|
3146
|
+
name = node.children[0]
|
3147
|
+
|
3148
|
+
if name =~ /\A_[1-9]\z/ && !static_env.declared?(name) && context.in_dynamic_block?
|
3149
|
+
# definitely an implicit param
|
3150
|
+
location = node.loc.expression
|
3151
|
+
|
3152
|
+
if max_numparam_stack.has_ordinary_params?
|
3153
|
+
diagnostic :error, :ordinary_param_defined, nil, [nil, location]
|
3154
|
+
end
|
3155
|
+
|
3156
|
+
raw_context = context.stack.dup
|
3157
|
+
raw_max_numparam_stack = max_numparam_stack.stack.dup
|
3158
|
+
|
3159
|
+
# ignore current block scope
|
3160
|
+
raw_context.pop
|
3161
|
+
raw_max_numparam_stack.pop
|
3162
|
+
|
3163
|
+
raw_context.reverse_each do |outer_scope|
|
3164
|
+
if outer_scope == :block || outer_scope == :lambda
|
3165
|
+
outer_scope_has_numparams = raw_max_numparam_stack.pop > 0
|
3166
|
+
|
3167
|
+
if outer_scope_has_numparams
|
3168
|
+
diagnostic :error, :numparam_used_in_outer_scope, nil, [nil, location]
|
3169
|
+
else
|
3170
|
+
# for now it's ok, but an outer scope can also be a block
|
3171
|
+
# with numparams, so we need to continue
|
3172
|
+
end
|
3173
|
+
else
|
3174
|
+
# found an outer scope that can't have numparams
|
3175
|
+
# like def/class/etc
|
3176
|
+
break
|
3177
|
+
end
|
3178
|
+
end
|
3179
|
+
|
3180
|
+
static_env.declare(name)
|
3181
|
+
max_numparam_stack.register(name[1].to_i)
|
3182
|
+
|
3183
|
+
true
|
3184
|
+
else
|
3185
|
+
false
|
3186
|
+
end
|
3187
|
+
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.
|
4
|
+
version: 3.1.0.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: 2021-
|
11
|
+
date: 2021-11-28 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:
|
19
|
+
version: 3.0.3.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:
|
26
|
+
version: 3.0.3.0
|
27
27
|
description: "\n Parser extension to support edge and experimental Ruby syntax\n
|
28
28
|
\ "
|
29
29
|
email:
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
rubygems_version: 3.2.
|
66
|
+
rubygems_version: 3.2.22
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Parser extension to support edge and experimental Ruby syntax
|