parser 3.2.2.3 → 3.3.9.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/LICENSE.txt +2 -1
- data/lib/gauntlet_parser.rb +1 -1
- data/lib/parser/all.rb +15 -14
- data/lib/parser/ast/processor.rb +3 -1
- data/lib/parser/base.rb +3 -0
- data/lib/parser/builders/default.rb +59 -19
- data/lib/parser/context.rb +2 -0
- data/lib/parser/current.rb +37 -19
- data/lib/parser/lexer/literal.rb +16 -1
- data/lib/parser/lexer-F0.rb +360 -299
- data/lib/parser/lexer-F1.rb +634 -564
- data/lib/parser/lexer-strings.rb +89 -80
- data/lib/parser/macruby.rb +3 -3
- data/lib/parser/messages.rb +46 -41
- data/lib/parser/meta.rb +11 -3
- data/lib/parser/ruby18.rb +3 -3
- data/lib/parser/ruby19.rb +3 -3
- data/lib/parser/ruby20.rb +3 -3
- data/lib/parser/ruby21.rb +3 -3
- data/lib/parser/ruby22.rb +3 -3
- data/lib/parser/ruby23.rb +3 -3
- data/lib/parser/ruby24.rb +3 -3
- data/lib/parser/ruby25.rb +3 -3
- data/lib/parser/ruby26.rb +3 -3
- data/lib/parser/ruby27.rb +5 -4
- data/lib/parser/ruby30.rb +5 -4
- data/lib/parser/ruby31.rb +5 -4
- data/lib/parser/ruby32.rb +5 -4
- data/lib/parser/ruby33.rb +6764 -6878
- data/lib/parser/ruby34.rb +12597 -0
- data/lib/parser/rubymotion.rb +3 -3
- data/lib/parser/runner/ruby_parse.rb +3 -3
- data/lib/parser/runner/ruby_rewrite.rb +1 -1
- data/lib/parser/runner.rb +37 -31
- data/lib/parser/source/buffer.rb +6 -1
- data/lib/parser/source/comment/associator.rb +7 -7
- data/lib/parser/source/tree_rewriter/action.rb +5 -4
- data/lib/parser/static_environment.rb +56 -9
- data/lib/parser/unknown_encoding_in_magic_comment_error.rb +15 -0
- data/lib/parser/version.rb +1 -1
- data/lib/parser.rb +54 -53
- metadata +8 -10
- data/lib/parser/ruby28.rb +0 -8047
data/lib/parser/messages.rb
CHANGED
@@ -21,6 +21,7 @@ module Parser
|
|
21
21
|
:regexp_options => 'unknown regexp options: %{options}',
|
22
22
|
:cvar_name => "`%{name}' is not allowed as a class variable name",
|
23
23
|
:ivar_name => "`%{name}' is not allowed as an instance variable name",
|
24
|
+
:gvar_name => "`%{name}' is not allowed as a global variable name",
|
24
25
|
:trailing_in_number => "trailing `%{character}' in number",
|
25
26
|
:empty_numeric => 'numeric literal without digits',
|
26
27
|
:invalid_octal => 'invalid octal digit',
|
@@ -40,51 +41,55 @@ module Parser
|
|
40
41
|
:triple_dot_at_eol => '... at EOL, should be parenthesized',
|
41
42
|
|
42
43
|
# Parser errors
|
43
|
-
:nth_ref_alias
|
44
|
-
:begin_in_method
|
45
|
-
:backref_assignment
|
46
|
-
:invalid_assignment
|
47
|
-
:module_name_const
|
48
|
-
:unexpected_token
|
49
|
-
:argument_const
|
50
|
-
:argument_ivar
|
51
|
-
:argument_gvar
|
52
|
-
:argument_cvar
|
53
|
-
:duplicate_argument
|
54
|
-
:empty_symbol
|
55
|
-
:odd_hash
|
56
|
-
:singleton_literal
|
57
|
-
:dynamic_const
|
58
|
-
:const_reassignment
|
59
|
-
:module_in_def
|
60
|
-
:class_in_def
|
61
|
-
:unexpected_percent_str
|
62
|
-
:block_and_blockarg
|
63
|
-
:masgn_as_condition
|
64
|
-
:block_given_to_yield
|
65
|
-
:invalid_regexp
|
66
|
-
:invalid_return
|
67
|
-
:csend_in_lhs_of_masgn
|
68
|
-
:cant_assign_to_numparam
|
69
|
-
:reserved_for_numparam
|
70
|
-
:ordinary_param_defined
|
71
|
-
:numparam_used_in_outer_scope
|
72
|
-
:circular_argument_reference
|
73
|
-
:pm_interp_in_var_name
|
74
|
-
:lvar_name
|
75
|
-
:undefined_lvar
|
76
|
-
:duplicate_variable_name
|
77
|
-
:duplicate_pattern_key
|
78
|
-
:endless_setter
|
79
|
-
:invalid_id_to_get
|
80
|
-
:forward_arg_after_restarg
|
81
|
-
:no_anonymous_blockarg
|
82
|
-
:no_anonymous_restarg
|
83
|
-
:no_anonymous_kwrestarg
|
44
|
+
:nth_ref_alias => 'cannot define an alias for a back-reference variable',
|
45
|
+
:begin_in_method => 'BEGIN in method',
|
46
|
+
:backref_assignment => 'cannot assign to a back-reference variable',
|
47
|
+
:invalid_assignment => 'cannot assign to a keyword',
|
48
|
+
:module_name_const => 'class or module name must be a constant literal',
|
49
|
+
:unexpected_token => 'unexpected token %{token}',
|
50
|
+
:argument_const => 'formal argument cannot be a constant',
|
51
|
+
:argument_ivar => 'formal argument cannot be an instance variable',
|
52
|
+
:argument_gvar => 'formal argument cannot be a global variable',
|
53
|
+
:argument_cvar => 'formal argument cannot be a class variable',
|
54
|
+
:duplicate_argument => 'duplicate argument name',
|
55
|
+
:empty_symbol => 'empty symbol literal',
|
56
|
+
:odd_hash => 'odd number of entries for a hash',
|
57
|
+
:singleton_literal => 'cannot define a singleton method for a literal',
|
58
|
+
:dynamic_const => 'dynamic constant assignment',
|
59
|
+
:const_reassignment => 'constant re-assignment',
|
60
|
+
:module_in_def => 'module definition in method body',
|
61
|
+
:class_in_def => 'class definition in method body',
|
62
|
+
:unexpected_percent_str => '%{type}: unknown type of percent-literal',
|
63
|
+
:block_and_blockarg => 'both block argument and literal block are passed',
|
64
|
+
:masgn_as_condition => 'multiple assignment in conditional context',
|
65
|
+
:block_given_to_yield => 'block given to yield',
|
66
|
+
:invalid_regexp => '%{message}',
|
67
|
+
:invalid_return => 'Invalid return in class/module body',
|
68
|
+
:csend_in_lhs_of_masgn => '&. inside multiple assignment destination',
|
69
|
+
:cant_assign_to_numparam => 'cannot assign to numbered parameter %{name}',
|
70
|
+
:reserved_for_numparam => '%{name} is reserved for numbered parameter',
|
71
|
+
:ordinary_param_defined => 'ordinary parameter is defined',
|
72
|
+
:numparam_used_in_outer_scope => 'numbered parameter is already used in an outer scope',
|
73
|
+
:circular_argument_reference => 'circular argument reference %{var_name}',
|
74
|
+
:pm_interp_in_var_name => 'symbol literal with interpolation is not allowed',
|
75
|
+
:lvar_name => "`%{name}' is not allowed as a local variable name",
|
76
|
+
:undefined_lvar => "no such local variable: `%{name}'",
|
77
|
+
:duplicate_variable_name => 'duplicate variable name %{name}',
|
78
|
+
:duplicate_pattern_key => 'duplicate hash pattern key %{name}',
|
79
|
+
:endless_setter => 'setter method cannot be defined in an endless method definition',
|
80
|
+
:invalid_id_to_get => 'identifier %{identifier} is not valid to get',
|
81
|
+
:forward_arg_after_restarg => '... after rest argument',
|
82
|
+
:no_anonymous_blockarg => 'no anonymous block parameter',
|
83
|
+
:no_anonymous_restarg => 'no anonymous rest parameter',
|
84
|
+
:no_anonymous_kwrestarg => 'no anonymous keyword rest parameter',
|
85
|
+
:ambiguous_anonymous_restarg => 'anonymous rest parameter is also used within block',
|
86
|
+
:ambiguous_anonymous_kwrestarg => 'anonymous keyword rest parameter is also used within block',
|
87
|
+
:ambiguous_anonymous_blockarg => 'anonymous block parameter is also used within block',
|
84
88
|
|
85
89
|
# Parser warnings
|
86
90
|
:useless_else => 'else without rescue is useless',
|
87
91
|
:duplicate_hash_key => 'key is duplicated and overwritten',
|
92
|
+
:ambiguous_it_call => '`it` calls without arguments refers to the first block param',
|
88
93
|
|
89
94
|
# Parser errors that are not Ruby errors
|
90
95
|
:invalid_encoding => 'literal contains escape sequences incompatible with UTF-8',
|
data/lib/parser/meta.rb
CHANGED
@@ -4,9 +4,17 @@ module Parser
|
|
4
4
|
# Parser metadata
|
5
5
|
module Meta
|
6
6
|
|
7
|
+
# These are node types required by `Prism::Translation::Parser`,
|
8
|
+
# which has advanced syntax support ahead of the Parser gem.
|
9
|
+
PRISM_TRANSLATION_PARSER_NODE_TYPES = %i(
|
10
|
+
itarg itblock
|
11
|
+
).freeze
|
12
|
+
private_constant :PRISM_TRANSLATION_PARSER_NODE_TYPES
|
13
|
+
|
7
14
|
# All node types that parser can produce. Not all parser versions
|
8
15
|
# will be able to produce every possible node.
|
9
|
-
|
16
|
+
# Includes node types that are only emitted by the prism parser translator.
|
17
|
+
NODE_TYPES = (
|
10
18
|
%i(
|
11
19
|
true false nil int float str dstr
|
12
20
|
sym dsym xstr regopt regexp array splat
|
@@ -34,7 +42,7 @@ module Parser
|
|
34
42
|
empty_else find_pattern kwargs
|
35
43
|
match_pattern_p match_pattern
|
36
44
|
forwarded_restarg forwarded_kwrestarg
|
37
|
-
)
|
38
|
-
|
45
|
+
) + PRISM_TRANSLATION_PARSER_NODE_TYPES
|
46
|
+
).to_set.freeze
|
39
47
|
end # Meta
|
40
48
|
end # Parser
|
data/lib/parser/ruby18.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby18.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby18 < Parser::Base
|
data/lib/parser/ruby19.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby19.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby19 < Parser::Base
|
data/lib/parser/ruby20.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby20.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby20 < Parser::Base
|
data/lib/parser/ruby21.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby21.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby21 < Parser::Base
|
data/lib/parser/ruby22.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby22.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby22 < Parser::Base
|
data/lib/parser/ruby23.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby23.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby23 < Parser::Base
|
data/lib/parser/ruby24.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby24.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby24 < Parser::Base
|
data/lib/parser/ruby25.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby25.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby25 < Parser::Base
|
data/lib/parser/ruby26.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby26.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby26 < Parser::Base
|
data/lib/parser/ruby27.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby27.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby27 < Parser::Base
|
@@ -10871,11 +10871,12 @@ end
|
|
10871
10871
|
|
10872
10872
|
def _reduce_527(val, _values, result)
|
10873
10873
|
name = val[1][0]
|
10874
|
+
lvar = @builder.accessible(@builder.ident(val[1]))
|
10875
|
+
|
10874
10876
|
unless static_env.declared?(name)
|
10875
10877
|
diagnostic :error, :undefined_lvar, { :name => name }, val[1]
|
10876
10878
|
end
|
10877
10879
|
|
10878
|
-
lvar = @builder.accessible(@builder.ident(val[1]))
|
10879
10880
|
result = @builder.pin(val[0], lvar)
|
10880
10881
|
|
10881
10882
|
result
|
data/lib/parser/ruby30.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby30.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby30 < Parser::Base
|
@@ -11162,11 +11162,12 @@ end
|
|
11162
11162
|
|
11163
11163
|
def _reduce_538(val, _values, result)
|
11164
11164
|
name = val[1][0]
|
11165
|
+
lvar = @builder.accessible(@builder.ident(val[1]))
|
11166
|
+
|
11165
11167
|
unless static_env.declared?(name)
|
11166
11168
|
diagnostic :error, :undefined_lvar, { :name => name }, val[1]
|
11167
11169
|
end
|
11168
11170
|
|
11169
|
-
lvar = @builder.accessible(@builder.ident(val[1]))
|
11170
11171
|
result = @builder.pin(val[0], lvar)
|
11171
11172
|
|
11172
11173
|
result
|
data/lib/parser/ruby31.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby31.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby31 < Parser::Base
|
@@ -11589,11 +11589,12 @@ end
|
|
11589
11589
|
|
11590
11590
|
def _reduce_548(val, _values, result)
|
11591
11591
|
name = val[1][0]
|
11592
|
+
lvar = @builder.accessible(@builder.ident(val[1]))
|
11593
|
+
|
11592
11594
|
unless static_env.declared?(name)
|
11593
11595
|
diagnostic :error, :undefined_lvar, { :name => name }, val[1]
|
11594
11596
|
end
|
11595
11597
|
|
11596
|
-
lvar = @builder.accessible(@builder.ident(val[1]))
|
11597
11598
|
result = @builder.pin(val[0], lvar)
|
11598
11599
|
|
11599
11600
|
result
|
data/lib/parser/ruby32.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
# DO NOT MODIFY!!!!
|
4
|
-
# This file is automatically generated by Racc 1.
|
5
|
-
# from Racc grammar file "".
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
5
|
+
# from Racc grammar file "ruby32.y".
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'racc/parser.rb'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
require_relative '../parser'
|
12
12
|
|
13
13
|
module Parser
|
14
14
|
class Ruby32 < Parser::Base
|
@@ -11585,11 +11585,12 @@ end
|
|
11585
11585
|
|
11586
11586
|
def _reduce_548(val, _values, result)
|
11587
11587
|
name = val[1][0]
|
11588
|
+
lvar = @builder.accessible(@builder.ident(val[1]))
|
11589
|
+
|
11588
11590
|
unless static_env.declared?(name)
|
11589
11591
|
diagnostic :error, :undefined_lvar, { :name => name }, val[1]
|
11590
11592
|
end
|
11591
11593
|
|
11592
|
-
lvar = @builder.accessible(@builder.ident(val[1]))
|
11593
11594
|
result = @builder.pin(val[0], lvar)
|
11594
11595
|
|
11595
11596
|
result
|