parser 3.3.0.5 → 3.3.7.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 -15
- data/lib/parser/ast/processor.rb +3 -1
- data/lib/parser/builders/default.rb +1 -1
- data/lib/parser/context.rb +2 -0
- data/lib/parser/current.rb +18 -18
- data/lib/parser/macruby.rb +2 -2
- data/lib/parser/ruby18.rb +2 -2
- data/lib/parser/ruby19.rb +2 -2
- data/lib/parser/ruby20.rb +2 -2
- data/lib/parser/ruby21.rb +2 -2
- data/lib/parser/ruby22.rb +2 -2
- data/lib/parser/ruby23.rb +2 -2
- data/lib/parser/ruby24.rb +2 -2
- data/lib/parser/ruby25.rb +2 -2
- data/lib/parser/ruby26.rb +2 -2
- data/lib/parser/ruby27.rb +2 -2
- data/lib/parser/ruby30.rb +2 -2
- data/lib/parser/ruby31.rb +2 -2
- data/lib/parser/ruby32.rb +2 -2
- data/lib/parser/ruby33.rb +6 -6
- data/lib/parser/ruby34.rb +13 -6
- data/lib/parser/rubymotion.rb +2 -2
- data/lib/parser/runner/ruby_parse.rb +3 -3
- data/lib/parser/runner/ruby_rewrite.rb +1 -1
- data/lib/parser/runner.rb +33 -32
- data/lib/parser/source/buffer.rb +6 -1
- data/lib/parser/source/tree_rewriter/action.rb +5 -4
- data/lib/parser/static_environment.rb +47 -12
- 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 +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd5e6ca52bfa9161331505e6cd3de1ef64c5c8ce74a6c1b35b714368b08e5788
|
|
4
|
+
data.tar.gz: e3a21e476c70f8a8c3404269ecfa9b04c8e30d1736ab6d6228dad931281d3cd4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b99fd52bd95c339076da89cef07325e18ebff96edaa644a21d4974f98cf668520fc69ca27df6d4498579ee99dd3dd784fb27f9eb0a68759d44df1c462bcfb965
|
|
7
|
+
data.tar.gz: a64068bf553c5f784c657481052c27fb5525fadeb914e791408b43eb55d01ef0ab39b01106e04a7f83234c07fa996d219c3f902204ecbb9f0723f36e43c98bd5
|
data/LICENSE.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
Copyright (c) 2013-
|
|
1
|
+
Copyright (c) 2013-2024 parser project contributors
|
|
2
|
+
Copyright (c) 2013-2016 Catherine <whitequark@whitequark.org>
|
|
2
3
|
|
|
3
4
|
Parts of the source are derived from ruby_parser:
|
|
4
5
|
Copyright (c) Ryan Davis, seattle.rb
|
data/lib/gauntlet_parser.rb
CHANGED
data/lib/parser/all.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
require_relative 'ruby18'
|
|
4
|
+
require_relative 'ruby19'
|
|
5
|
+
require_relative 'ruby20'
|
|
6
|
+
require_relative 'ruby21'
|
|
7
|
+
require_relative 'ruby22'
|
|
8
|
+
require_relative 'ruby23'
|
|
9
|
+
require_relative 'ruby24'
|
|
10
|
+
require_relative 'ruby25'
|
|
11
|
+
require_relative 'ruby26'
|
|
12
|
+
require_relative 'ruby27'
|
|
13
|
+
require_relative 'ruby30'
|
|
14
|
+
require_relative 'ruby31'
|
|
15
|
+
require_relative 'ruby32'
|
|
16
|
+
require_relative 'ruby33'
|
|
17
|
+
require_relative 'ruby34'
|
data/lib/parser/ast/processor.rb
CHANGED
|
@@ -426,7 +426,7 @@ module Parser
|
|
|
426
426
|
def regexp_compose(begin_t, parts, end_t, options)
|
|
427
427
|
begin
|
|
428
428
|
static_regexp(parts, options)
|
|
429
|
-
rescue RegexpError => e
|
|
429
|
+
rescue RegexpError, Encoding::UndefinedConversionError => e
|
|
430
430
|
diagnostic :error, :invalid_regexp, { :message => e.message },
|
|
431
431
|
loc(begin_t).join(loc(end_t))
|
|
432
432
|
end
|
data/lib/parser/context.rb
CHANGED
|
@@ -24,6 +24,7 @@ module Parser
|
|
|
24
24
|
in_class
|
|
25
25
|
in_block
|
|
26
26
|
in_lambda
|
|
27
|
+
cant_return
|
|
27
28
|
]
|
|
28
29
|
|
|
29
30
|
def initialize
|
|
@@ -38,6 +39,7 @@ module Parser
|
|
|
38
39
|
@in_class = false
|
|
39
40
|
@in_block = false
|
|
40
41
|
@in_lambda = false
|
|
42
|
+
@cant_return = false
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
attr_accessor(*FLAGS)
|
data/lib/parser/current.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Parser
|
|
|
17
17
|
warn_syntax_deviation 'parser/ruby20', current_version
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
require_relative 'ruby20'
|
|
21
21
|
CurrentRuby = Ruby20
|
|
22
22
|
|
|
23
23
|
when /^2\.1\./
|
|
@@ -26,7 +26,7 @@ module Parser
|
|
|
26
26
|
warn_syntax_deviation 'parser/ruby21', current_version
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
require_relative 'ruby21'
|
|
30
30
|
CurrentRuby = Ruby21
|
|
31
31
|
|
|
32
32
|
when /^2\.2\./
|
|
@@ -35,7 +35,7 @@ module Parser
|
|
|
35
35
|
warn_syntax_deviation 'parser/ruby22', current_version
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
require_relative 'ruby22'
|
|
39
39
|
CurrentRuby = Ruby22
|
|
40
40
|
|
|
41
41
|
when /^2\.3\./
|
|
@@ -44,7 +44,7 @@ module Parser
|
|
|
44
44
|
warn_syntax_deviation 'parser/ruby23', current_version
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
require_relative 'ruby23'
|
|
48
48
|
CurrentRuby = Ruby23
|
|
49
49
|
|
|
50
50
|
when /^2\.4\./
|
|
@@ -53,7 +53,7 @@ module Parser
|
|
|
53
53
|
warn_syntax_deviation 'parser/ruby24', current_version
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
require_relative 'ruby24'
|
|
57
57
|
CurrentRuby = Ruby24
|
|
58
58
|
|
|
59
59
|
when /^2\.5\./
|
|
@@ -62,7 +62,7 @@ module Parser
|
|
|
62
62
|
warn_syntax_deviation 'parser/ruby25', current_version
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
require_relative 'ruby25'
|
|
66
66
|
CurrentRuby = Ruby25
|
|
67
67
|
|
|
68
68
|
when /^2\.6\./
|
|
@@ -71,7 +71,7 @@ module Parser
|
|
|
71
71
|
warn_syntax_deviation 'parser/ruby26', current_version
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
require_relative 'ruby26'
|
|
75
75
|
CurrentRuby = Ruby26
|
|
76
76
|
|
|
77
77
|
when /^2\.7\./
|
|
@@ -80,43 +80,43 @@ module Parser
|
|
|
80
80
|
warn_syntax_deviation 'parser/ruby27', current_version
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
require_relative 'ruby27'
|
|
84
84
|
CurrentRuby = Ruby27
|
|
85
85
|
|
|
86
86
|
when /^3\.0\./
|
|
87
|
-
current_version = '3.0.
|
|
87
|
+
current_version = '3.0.7'
|
|
88
88
|
if RUBY_VERSION != current_version
|
|
89
89
|
warn_syntax_deviation 'parser/ruby30', current_version
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
require_relative 'ruby30'
|
|
93
93
|
CurrentRuby = Ruby30
|
|
94
94
|
|
|
95
95
|
when /^3\.1\./
|
|
96
|
-
current_version = '3.1.
|
|
96
|
+
current_version = '3.1.6'
|
|
97
97
|
if RUBY_VERSION != current_version
|
|
98
98
|
warn_syntax_deviation 'parser/ruby31', current_version
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
require_relative 'ruby31'
|
|
102
102
|
CurrentRuby = Ruby31
|
|
103
103
|
|
|
104
104
|
when /^3\.2\./
|
|
105
|
-
current_version = '3.2.
|
|
105
|
+
current_version = '3.2.6'
|
|
106
106
|
if RUBY_VERSION != current_version
|
|
107
107
|
warn_syntax_deviation 'parser/ruby32', current_version
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
require_relative 'ruby32'
|
|
111
111
|
CurrentRuby = Ruby32
|
|
112
112
|
|
|
113
113
|
when /^3\.3\./
|
|
114
|
-
current_version = '3.3.
|
|
114
|
+
current_version = '3.3.7'
|
|
115
115
|
if RUBY_VERSION != current_version
|
|
116
116
|
warn_syntax_deviation 'parser/ruby33', current_version
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
require_relative 'ruby33'
|
|
120
120
|
CurrentRuby = Ruby33
|
|
121
121
|
|
|
122
122
|
when /^3\.4\./
|
|
@@ -125,13 +125,13 @@ module Parser
|
|
|
125
125
|
warn_syntax_deviation 'parser/ruby34', current_version
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
require_relative 'ruby34'
|
|
129
129
|
CurrentRuby = Ruby34
|
|
130
130
|
|
|
131
131
|
else # :nocov:
|
|
132
132
|
# Keep this in sync with released Ruby.
|
|
133
133
|
warn_syntax_deviation 'parser/ruby33', '3.3.x'
|
|
134
|
-
|
|
134
|
+
require_relative 'ruby33'
|
|
135
135
|
CurrentRuby = Ruby33
|
|
136
136
|
end
|
|
137
137
|
end
|
data/lib/parser/macruby.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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
5
|
# from Racc grammar file "macruby.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 MacRuby < Parser::Base
|
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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
|
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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
|
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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
|
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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
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
|
data/lib/parser/ruby33.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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
5
|
# from Racc grammar file "ruby33.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 Ruby33 < Parser::Base
|
|
@@ -9905,7 +9905,7 @@ def _reduce_291(val, _values, result)
|
|
|
9905
9905
|
end
|
|
9906
9906
|
|
|
9907
9907
|
if @context.in_dynamic_block? && context.in_def &&
|
|
9908
|
-
@static_env.
|
|
9908
|
+
@static_env.declared_anonymous_blockarg_in_current_scpe? && @static_env.parent_has_anonymous_blockarg?
|
|
9909
9909
|
diagnostic :error, :ambiguous_anonymous_blockarg, nil, val[0]
|
|
9910
9910
|
end
|
|
9911
9911
|
|
|
@@ -9958,7 +9958,7 @@ def _reduce_299(val, _values, result)
|
|
|
9958
9958
|
end
|
|
9959
9959
|
|
|
9960
9960
|
if @context.in_dynamic_block? && context.in_def &&
|
|
9961
|
-
@static_env.
|
|
9961
|
+
@static_env.declared_anonymous_restarg_in_current_scope? && @static_env.parent_has_anonymous_restarg?
|
|
9962
9962
|
diagnostic :error, :ambiguous_anonymous_restarg, nil, val[0]
|
|
9963
9963
|
end
|
|
9964
9964
|
|
|
@@ -10977,7 +10977,7 @@ end
|
|
|
10977
10977
|
|
|
10978
10978
|
def _reduce_457(val, _values, result)
|
|
10979
10979
|
result = @context.in_kwarg
|
|
10980
|
-
|
|
10980
|
+
|
|
10981
10981
|
@lexer.state = :expr_beg
|
|
10982
10982
|
@lexer.command_start = false
|
|
10983
10983
|
@context.in_kwarg = true
|
|
@@ -12492,7 +12492,7 @@ def _reduce_715(val, _values, result)
|
|
|
12492
12492
|
end
|
|
12493
12493
|
|
|
12494
12494
|
if @context.in_dynamic_block? && context.in_def &&
|
|
12495
|
-
@static_env.
|
|
12495
|
+
@static_env.declared_anonymous_kwrestarg_in_current_scope? && @static_env.parent_has_anonymous_kwrestarg?
|
|
12496
12496
|
diagnostic :error, :ambiguous_anonymous_kwrestarg, nil, val[0]
|
|
12497
12497
|
end
|
|
12498
12498
|
|
data/lib/parser/ruby34.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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
5
|
# from Racc grammar file "ruby34.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 Ruby34 < Parser::Base
|
|
@@ -8788,6 +8788,7 @@ def _reduce_64(val, _values, result)
|
|
|
8788
8788
|
|
|
8789
8789
|
result = [ val[0], @context.dup ]
|
|
8790
8790
|
@context.in_def = true
|
|
8791
|
+
@context.cant_return = false
|
|
8791
8792
|
|
|
8792
8793
|
result
|
|
8793
8794
|
end
|
|
@@ -9905,7 +9906,7 @@ def _reduce_291(val, _values, result)
|
|
|
9905
9906
|
end
|
|
9906
9907
|
|
|
9907
9908
|
if @context.in_dynamic_block? && context.in_def &&
|
|
9908
|
-
@static_env.
|
|
9909
|
+
@static_env.declared_anonymous_blockarg_in_current_scpe? && @static_env.parent_has_anonymous_blockarg?
|
|
9909
9910
|
diagnostic :error, :ambiguous_anonymous_blockarg, nil, val[0]
|
|
9910
9911
|
end
|
|
9911
9912
|
|
|
@@ -9958,7 +9959,7 @@ def _reduce_299(val, _values, result)
|
|
|
9958
9959
|
end
|
|
9959
9960
|
|
|
9960
9961
|
if @context.in_dynamic_block? && context.in_def &&
|
|
9961
|
-
@static_env.
|
|
9962
|
+
@static_env.declared_anonymous_restarg_in_current_scope? && @static_env.parent_has_anonymous_restarg?
|
|
9962
9963
|
diagnostic :error, :ambiguous_anonymous_restarg, nil, val[0]
|
|
9963
9964
|
end
|
|
9964
9965
|
|
|
@@ -10209,6 +10210,7 @@ end
|
|
|
10209
10210
|
|
|
10210
10211
|
def _reduce_344(val, _values, result)
|
|
10211
10212
|
@context.in_class = true
|
|
10213
|
+
@context.cant_return = true
|
|
10212
10214
|
local_push
|
|
10213
10215
|
|
|
10214
10216
|
result
|
|
@@ -10226,6 +10228,7 @@ def _reduce_345(val, _values, result)
|
|
|
10226
10228
|
|
|
10227
10229
|
local_pop
|
|
10228
10230
|
@context.in_class = ctx.in_class
|
|
10231
|
+
@context.cant_return = ctx.cant_return
|
|
10229
10232
|
|
|
10230
10233
|
result
|
|
10231
10234
|
end
|
|
@@ -10233,6 +10236,7 @@ end
|
|
|
10233
10236
|
def _reduce_346(val, _values, result)
|
|
10234
10237
|
@context.in_def = false
|
|
10235
10238
|
@context.in_class = false
|
|
10239
|
+
@context.cant_return = true
|
|
10236
10240
|
local_push
|
|
10237
10241
|
|
|
10238
10242
|
result
|
|
@@ -10246,12 +10250,14 @@ def _reduce_347(val, _values, result)
|
|
|
10246
10250
|
local_pop
|
|
10247
10251
|
@context.in_def = ctx.in_def
|
|
10248
10252
|
@context.in_class = ctx.in_class
|
|
10253
|
+
@context.cant_return = ctx.cant_return
|
|
10249
10254
|
|
|
10250
10255
|
result
|
|
10251
10256
|
end
|
|
10252
10257
|
|
|
10253
10258
|
def _reduce_348(val, _values, result)
|
|
10254
10259
|
@context.in_class = true
|
|
10260
|
+
@context.cant_return = true
|
|
10255
10261
|
local_push
|
|
10256
10262
|
|
|
10257
10263
|
result
|
|
@@ -10267,6 +10273,7 @@ def _reduce_349(val, _values, result)
|
|
|
10267
10273
|
|
|
10268
10274
|
local_pop
|
|
10269
10275
|
@context.in_class = ctx.in_class
|
|
10276
|
+
@context.cant_return = ctx.cant_return
|
|
10270
10277
|
|
|
10271
10278
|
result
|
|
10272
10279
|
end
|
|
@@ -10341,7 +10348,7 @@ def _reduce_359(val, _values, result)
|
|
|
10341
10348
|
end
|
|
10342
10349
|
|
|
10343
10350
|
def _reduce_360(val, _values, result)
|
|
10344
|
-
if @context.
|
|
10351
|
+
if @context.cant_return && !(context.in_block || context.in_lambda)
|
|
10345
10352
|
diagnostic :error, :invalid_return, nil, val[0]
|
|
10346
10353
|
end
|
|
10347
10354
|
|
|
@@ -12492,7 +12499,7 @@ def _reduce_715(val, _values, result)
|
|
|
12492
12499
|
end
|
|
12493
12500
|
|
|
12494
12501
|
if @context.in_dynamic_block? && context.in_def &&
|
|
12495
|
-
@static_env.
|
|
12502
|
+
@static_env.declared_anonymous_kwrestarg_in_current_scope? && @static_env.parent_has_anonymous_kwrestarg?
|
|
12496
12503
|
diagnostic :error, :ambiguous_anonymous_kwrestarg, nil, val[0]
|
|
12497
12504
|
end
|
|
12498
12505
|
|
data/lib/parser/rubymotion.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.
|
|
4
|
+
# This file is automatically generated by Racc 1.8.1
|
|
5
5
|
# from Racc grammar file "rubymotion.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 RubyMotion < Parser::Base
|
data/lib/parser/runner.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'benchmark'
|
|
4
3
|
require 'find'
|
|
5
4
|
require 'optparse'
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
require_relative '../parser'
|
|
8
7
|
|
|
9
8
|
module Parser
|
|
10
9
|
|
|
@@ -64,87 +63,87 @@ module Parser
|
|
|
64
63
|
end
|
|
65
64
|
|
|
66
65
|
opts.on '--18', 'Parse as Ruby 1.8.7 would' do
|
|
67
|
-
|
|
66
|
+
require_relative 'ruby18'
|
|
68
67
|
@parser_class = Parser::Ruby18
|
|
69
68
|
end
|
|
70
69
|
|
|
71
70
|
opts.on '--19', 'Parse as Ruby 1.9.3 would' do
|
|
72
|
-
|
|
71
|
+
require_relative 'ruby19'
|
|
73
72
|
@parser_class = Parser::Ruby19
|
|
74
73
|
end
|
|
75
74
|
|
|
76
75
|
opts.on '--20', 'Parse as Ruby 2.0 would' do
|
|
77
|
-
|
|
76
|
+
require_relative 'ruby20'
|
|
78
77
|
@parser_class = Parser::Ruby20
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
opts.on '--21', 'Parse as Ruby 2.1 would' do
|
|
82
|
-
|
|
81
|
+
require_relative 'ruby21'
|
|
83
82
|
@parser_class = Parser::Ruby21
|
|
84
83
|
end
|
|
85
84
|
|
|
86
85
|
opts.on '--22', 'Parse as Ruby 2.2 would' do
|
|
87
|
-
|
|
86
|
+
require_relative 'ruby22'
|
|
88
87
|
@parser_class = Parser::Ruby22
|
|
89
88
|
end
|
|
90
89
|
|
|
91
90
|
opts.on '--23', 'Parse as Ruby 2.3 would' do
|
|
92
|
-
|
|
91
|
+
require_relative 'ruby23'
|
|
93
92
|
@parser_class = Parser::Ruby23
|
|
94
93
|
end
|
|
95
94
|
|
|
96
95
|
opts.on '--24', 'Parse as Ruby 2.4 would' do
|
|
97
|
-
|
|
96
|
+
require_relative 'ruby24'
|
|
98
97
|
@parser_class = Parser::Ruby24
|
|
99
98
|
end
|
|
100
99
|
|
|
101
100
|
opts.on '--25', 'Parse as Ruby 2.5 would' do
|
|
102
|
-
|
|
101
|
+
require_relative 'ruby25'
|
|
103
102
|
@parser_class = Parser::Ruby25
|
|
104
103
|
end
|
|
105
104
|
|
|
106
105
|
opts.on '--26', 'Parse as Ruby 2.6 would' do
|
|
107
|
-
|
|
106
|
+
require_relative 'ruby26'
|
|
108
107
|
@parser_class = Parser::Ruby26
|
|
109
108
|
end
|
|
110
109
|
|
|
111
110
|
opts.on '--27', 'Parse as Ruby 2.7 would' do
|
|
112
|
-
|
|
111
|
+
require_relative 'ruby27'
|
|
113
112
|
@parser_class = Parser::Ruby27
|
|
114
113
|
end
|
|
115
114
|
|
|
116
115
|
opts.on '--30', 'Parse as Ruby 3.0 would' do
|
|
117
|
-
|
|
116
|
+
require_relative 'ruby30'
|
|
118
117
|
@parser_class = Parser::Ruby30
|
|
119
118
|
end
|
|
120
119
|
|
|
121
120
|
opts.on '--31', 'Parse as Ruby 3.1 would' do
|
|
122
|
-
|
|
121
|
+
require_relative 'ruby31'
|
|
123
122
|
@parser_class = Parser::Ruby31
|
|
124
123
|
end
|
|
125
124
|
|
|
126
125
|
opts.on '--32', 'Parse as Ruby 3.2 would' do
|
|
127
|
-
|
|
126
|
+
require_relative 'ruby32'
|
|
128
127
|
@parser_class = Parser::Ruby32
|
|
129
128
|
end
|
|
130
129
|
|
|
131
130
|
opts.on '--33', 'Parse as Ruby 3.3 would' do
|
|
132
|
-
|
|
131
|
+
require_relative 'ruby33'
|
|
133
132
|
@parser_class = Parser::Ruby33
|
|
134
133
|
end
|
|
135
134
|
|
|
136
135
|
opts.on '--34', 'Parse as Ruby 3.4 would' do
|
|
137
|
-
|
|
136
|
+
require_relative 'ruby34'
|
|
138
137
|
@parser_class = Parser::Ruby34
|
|
139
138
|
end
|
|
140
139
|
|
|
141
140
|
opts.on '--mac', 'Parse as MacRuby 0.12 would' do
|
|
142
|
-
|
|
141
|
+
require_relative 'macruby'
|
|
143
142
|
@parser_class = Parser::MacRuby
|
|
144
143
|
end
|
|
145
144
|
|
|
146
145
|
opts.on '--ios', 'Parse as mid-2015 RubyMotion would' do
|
|
147
|
-
|
|
146
|
+
require_relative 'rubymotion'
|
|
148
147
|
@parser_class = Parser::RubyMotion
|
|
149
148
|
end
|
|
150
149
|
|
|
@@ -193,7 +192,7 @@ module Parser
|
|
|
193
192
|
end
|
|
194
193
|
|
|
195
194
|
if @parser_class.nil?
|
|
196
|
-
|
|
195
|
+
require_relative 'current'
|
|
197
196
|
@parser_class = Parser::CurrentRuby
|
|
198
197
|
end
|
|
199
198
|
end
|
|
@@ -220,14 +219,13 @@ module Parser
|
|
|
220
219
|
end
|
|
221
220
|
|
|
222
221
|
def process_all_input
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
end
|
|
222
|
+
time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
223
|
+
process_fragments
|
|
224
|
+
process_files
|
|
225
|
+
time_elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start
|
|
228
226
|
|
|
229
227
|
if @benchmark
|
|
230
|
-
report_with_time(
|
|
228
|
+
report_with_time(time_elapsed)
|
|
231
229
|
end
|
|
232
230
|
end
|
|
233
231
|
|
|
@@ -244,7 +242,12 @@ module Parser
|
|
|
244
242
|
|
|
245
243
|
def process_files
|
|
246
244
|
@files.each do |filename|
|
|
247
|
-
source =
|
|
245
|
+
source = begin
|
|
246
|
+
File.read(filename).force_encoding(@parser.default_encoding)
|
|
247
|
+
rescue Errno::EISDIR
|
|
248
|
+
# Will happen for a folder called `foo.rb`. Just catch this here, it's cheaper than checking every file.
|
|
249
|
+
next
|
|
250
|
+
end
|
|
248
251
|
|
|
249
252
|
buffer = Parser::Source::Buffer.new(filename)
|
|
250
253
|
|
|
@@ -278,12 +281,10 @@ module Parser
|
|
|
278
281
|
raise NotImplementedError, "implement #{self.class}##{__callee__}"
|
|
279
282
|
end
|
|
280
283
|
|
|
281
|
-
def report_with_time(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
speed = '%.3f' % (@source_size / cpu_time / 1000)
|
|
284
|
+
def report_with_time(time_elapsed)
|
|
285
|
+
speed = '%.3f' % (@source_size / time_elapsed / 1000)
|
|
285
286
|
puts "Parsed #{@source_count} files (#{@source_size} characters)" \
|
|
286
|
-
" in #{'%.2f' %
|
|
287
|
+
" in #{'%.2f' % time_elapsed} seconds (#{speed} kchars/s)."
|
|
287
288
|
|
|
288
289
|
if defined?(RUBY_ENGINE)
|
|
289
290
|
engine = RUBY_ENGINE
|
data/lib/parser/source/buffer.rb
CHANGED
|
@@ -46,6 +46,7 @@ module Parser
|
|
|
46
46
|
# magic encoding comment or UTF-8 BOM. `string` can be in any encoding.
|
|
47
47
|
#
|
|
48
48
|
# @param [String] string
|
|
49
|
+
# @raise [Parser::UnknownEncodingInMagicComment] if the encoding is not recognized
|
|
49
50
|
# @return [String, nil] encoding name, if recognized
|
|
50
51
|
#
|
|
51
52
|
def self.recognize_encoding(string)
|
|
@@ -66,7 +67,11 @@ module Parser
|
|
|
66
67
|
return nil if encoding_line.nil? || encoding_line[0] != '#'
|
|
67
68
|
|
|
68
69
|
if (result = ENCODING_RE.match(encoding_line))
|
|
69
|
-
|
|
70
|
+
begin
|
|
71
|
+
Encoding.find(result[3] || result[4] || result[6])
|
|
72
|
+
rescue ArgumentError => e
|
|
73
|
+
raise Parser::UnknownEncodingInMagicComment, e.message
|
|
74
|
+
end
|
|
70
75
|
else
|
|
71
76
|
nil
|
|
72
77
|
end
|
|
@@ -6,9 +6,10 @@ module Parser
|
|
|
6
6
|
# @api private
|
|
7
7
|
#
|
|
8
8
|
# Actions are arranged in a tree and get combined so that:
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
9
|
+
#
|
|
10
|
+
# * Children are strictly contained by their parent
|
|
11
|
+
# * Siblings are all disjointed from one another and ordered
|
|
12
|
+
# * Only actions with `replacement == nil` may have children
|
|
12
13
|
#
|
|
13
14
|
class TreeRewriter::Action
|
|
14
15
|
attr_reader :range, :replacement, :insert_before, :insert_after
|
|
@@ -60,7 +61,7 @@ module Parser
|
|
|
60
61
|
|
|
61
62
|
##
|
|
62
63
|
# A root action has its range set to the whole source range, even
|
|
63
|
-
# though it typically
|
|
64
|
+
# though it typically does not act on that range.
|
|
64
65
|
# This method returns the action as if it was a child action with
|
|
65
66
|
# its range contracted.
|
|
66
67
|
# @return [Action]
|
|
@@ -4,9 +4,15 @@ module Parser
|
|
|
4
4
|
|
|
5
5
|
class StaticEnvironment
|
|
6
6
|
FORWARD_ARGS = :FORWARD_ARGS
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
ANONYMOUS_RESTARG_IN_CURRENT_SCOPE = :ANONYMOUS_RESTARG_IN_CURRENT_SCOPE
|
|
9
|
+
ANONYMOUS_RESTARG_INHERITED = :ANONYMOUS_RESTARG_INHERITED
|
|
10
|
+
|
|
11
|
+
ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE = :ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE
|
|
12
|
+
ANONYMOUS_KWRESTARG_INHERITED = :ANONYMOUS_KWRESTARG_INHERITED
|
|
13
|
+
|
|
14
|
+
ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE = :ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE
|
|
15
|
+
ANONYMOUS_BLOCKARG_INHERITED = :ANONYMOUS_BLOCKARG_INHERITED
|
|
10
16
|
|
|
11
17
|
def initialize
|
|
12
18
|
reset
|
|
@@ -27,6 +33,15 @@ module Parser
|
|
|
27
33
|
def extend_dynamic
|
|
28
34
|
@stack.push(@variables)
|
|
29
35
|
@variables = @variables.dup
|
|
36
|
+
if @variables.delete(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE)
|
|
37
|
+
@variables.add(ANONYMOUS_BLOCKARG_INHERITED)
|
|
38
|
+
end
|
|
39
|
+
if @variables.delete(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE)
|
|
40
|
+
@variables.add(ANONYMOUS_RESTARG_INHERITED)
|
|
41
|
+
end
|
|
42
|
+
if @variables.delete(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE)
|
|
43
|
+
@variables.add(ANONYMOUS_KWRESTARG_INHERITED)
|
|
44
|
+
end
|
|
30
45
|
|
|
31
46
|
self
|
|
32
47
|
end
|
|
@@ -47,6 +62,8 @@ module Parser
|
|
|
47
62
|
@variables.include?(name.to_sym)
|
|
48
63
|
end
|
|
49
64
|
|
|
65
|
+
# Forward args
|
|
66
|
+
|
|
50
67
|
def declare_forward_args
|
|
51
68
|
declare(FORWARD_ARGS)
|
|
52
69
|
end
|
|
@@ -55,40 +72,58 @@ module Parser
|
|
|
55
72
|
declared?(FORWARD_ARGS)
|
|
56
73
|
end
|
|
57
74
|
|
|
75
|
+
# Anonymous blockarg
|
|
76
|
+
|
|
58
77
|
def declare_anonymous_blockarg
|
|
59
|
-
declare(
|
|
78
|
+
declare(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE)
|
|
60
79
|
end
|
|
61
80
|
|
|
62
81
|
def declared_anonymous_blockarg?
|
|
63
|
-
declared?(
|
|
82
|
+
declared?(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE) || declared?(ANONYMOUS_BLOCKARG_INHERITED)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def declared_anonymous_blockarg_in_current_scpe?
|
|
86
|
+
declared?(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE)
|
|
64
87
|
end
|
|
65
88
|
|
|
66
89
|
def parent_has_anonymous_blockarg?
|
|
67
|
-
@stack.any? { |variables| variables.include?(
|
|
90
|
+
@stack.any? { |variables| variables.include?(ANONYMOUS_BLOCKARG_IN_CURRENT_SCOPE) }
|
|
68
91
|
end
|
|
69
92
|
|
|
93
|
+
# Anonymous restarg
|
|
94
|
+
|
|
70
95
|
def declare_anonymous_restarg
|
|
71
|
-
declare(
|
|
96
|
+
declare(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE)
|
|
72
97
|
end
|
|
73
98
|
|
|
74
99
|
def declared_anonymous_restarg?
|
|
75
|
-
declared?(
|
|
100
|
+
declared?(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE) || declared?(ANONYMOUS_RESTARG_INHERITED)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def declared_anonymous_restarg_in_current_scope?
|
|
104
|
+
declared?(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE)
|
|
76
105
|
end
|
|
77
106
|
|
|
78
107
|
def parent_has_anonymous_restarg?
|
|
79
|
-
@stack.any? { |variables| variables.include?(
|
|
108
|
+
@stack.any? { |variables| variables.include?(ANONYMOUS_RESTARG_IN_CURRENT_SCOPE) }
|
|
80
109
|
end
|
|
81
110
|
|
|
111
|
+
# Anonymous kwresarg
|
|
112
|
+
|
|
82
113
|
def declare_anonymous_kwrestarg
|
|
83
|
-
declare(
|
|
114
|
+
declare(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE)
|
|
84
115
|
end
|
|
85
116
|
|
|
86
117
|
def declared_anonymous_kwrestarg?
|
|
87
|
-
declared?(
|
|
118
|
+
declared?(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE) || declared?(ANONYMOUS_KWRESTARG_INHERITED)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def declared_anonymous_kwrestarg_in_current_scope?
|
|
122
|
+
declared?(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE)
|
|
88
123
|
end
|
|
89
124
|
|
|
90
125
|
def parent_has_anonymous_kwrestarg?
|
|
91
|
-
@stack.any? { |variables| variables.include?(
|
|
126
|
+
@stack.any? { |variables| variables.include?(ANONYMOUS_KWRESTARG_IN_CURRENT_SCOPE) }
|
|
92
127
|
end
|
|
93
128
|
|
|
94
129
|
def empty?
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Parser
|
|
4
|
+
##
|
|
5
|
+
# {Parser::UnknownEncodingInMagicComment} is raised when a magic encoding
|
|
6
|
+
# comment is encountered that the currently running Ruby version doesn't
|
|
7
|
+
# recognize. It inherits from {ArgumentError} since that is the exception
|
|
8
|
+
# Ruby itself raises when trying to execute a file with an unknown encoding.
|
|
9
|
+
# As such, it is also not a {Parser::SyntaxError}.
|
|
10
|
+
#
|
|
11
|
+
# @api public
|
|
12
|
+
#
|
|
13
|
+
class UnknownEncodingInMagicComment < ArgumentError
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/parser/version.rb
CHANGED
data/lib/parser.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
if RUBY_VERSION =~ /^1\.[89]\./
|
|
4
|
-
|
|
4
|
+
require_relative 'parser/version'
|
|
5
5
|
raise LoadError, <<-UNSUPPORTED_VERSION_MSG
|
|
6
6
|
parser v#{Parser::VERSION} cannot run on Ruby #{RUBY_VERSION}.
|
|
7
7
|
Please upgrade to Ruby 2.0.0 or higher, or use an older version of the parser gem.
|
|
@@ -17,74 +17,75 @@ require 'ast'
|
|
|
17
17
|
# @api public
|
|
18
18
|
#
|
|
19
19
|
module Parser
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
require_relative 'parser/version'
|
|
21
|
+
require_relative 'parser/messages'
|
|
22
|
+
require_relative 'parser/deprecation'
|
|
23
23
|
|
|
24
24
|
module AST
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
require_relative 'parser/ast/node'
|
|
26
|
+
require_relative 'parser/ast/processor'
|
|
27
|
+
require_relative 'parser/meta'
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
module Source
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
31
|
+
require_relative 'parser/source/buffer'
|
|
32
|
+
require_relative 'parser/source/range'
|
|
33
|
+
|
|
34
|
+
require_relative 'parser/source/comment'
|
|
35
|
+
require_relative 'parser/source/comment/associator'
|
|
36
|
+
|
|
37
|
+
require_relative 'parser/source/rewriter'
|
|
38
|
+
require_relative 'parser/source/rewriter/action'
|
|
39
|
+
require_relative 'parser/source/tree_rewriter'
|
|
40
|
+
require_relative 'parser/source/tree_rewriter/action'
|
|
41
|
+
|
|
42
|
+
require_relative 'parser/source/map'
|
|
43
|
+
require_relative 'parser/source/map/operator'
|
|
44
|
+
require_relative 'parser/source/map/collection'
|
|
45
|
+
require_relative 'parser/source/map/constant'
|
|
46
|
+
require_relative 'parser/source/map/variable'
|
|
47
|
+
require_relative 'parser/source/map/keyword'
|
|
48
|
+
require_relative 'parser/source/map/definition'
|
|
49
|
+
require_relative 'parser/source/map/method_definition'
|
|
50
|
+
require_relative 'parser/source/map/send'
|
|
51
|
+
require_relative 'parser/source/map/index'
|
|
52
|
+
require_relative 'parser/source/map/condition'
|
|
53
|
+
require_relative 'parser/source/map/ternary'
|
|
54
|
+
require_relative 'parser/source/map/for'
|
|
55
|
+
require_relative 'parser/source/map/rescue_body'
|
|
56
|
+
require_relative 'parser/source/map/heredoc'
|
|
57
|
+
require_relative 'parser/source/map/objc_kwarg'
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
require_relative 'parser/syntax_error'
|
|
61
|
+
require_relative 'parser/clobbering_error'
|
|
62
|
+
require_relative 'parser/unknown_encoding_in_magic_comment_error'
|
|
63
|
+
require_relative 'parser/diagnostic'
|
|
64
|
+
require_relative 'parser/diagnostic/engine'
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
require_relative 'parser/static_environment'
|
|
66
67
|
|
|
67
68
|
if RUBY_ENGINE == 'truffleruby'
|
|
68
|
-
|
|
69
|
+
require_relative 'parser/lexer-F0'
|
|
69
70
|
else
|
|
70
|
-
|
|
71
|
+
require_relative 'parser/lexer-F1'
|
|
71
72
|
end
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
require_relative 'parser/lexer-strings'
|
|
74
|
+
require_relative 'parser/lexer/literal'
|
|
75
|
+
require_relative 'parser/lexer/stack_state'
|
|
76
|
+
require_relative 'parser/lexer/dedenter'
|
|
76
77
|
|
|
77
78
|
module Builders
|
|
78
|
-
|
|
79
|
+
require_relative 'parser/builders/default'
|
|
79
80
|
end
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
require_relative 'parser/context'
|
|
83
|
+
require_relative 'parser/max_numparam_stack'
|
|
84
|
+
require_relative 'parser/current_arg_stack'
|
|
85
|
+
require_relative 'parser/variables_stack'
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
require_relative 'parser/base'
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
require_relative 'parser/rewriter'
|
|
90
|
+
require_relative 'parser/tree_rewriter'
|
|
90
91
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: parser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.3.0
|
|
4
|
+
version: 3.3.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- whitequark
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-01-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ast
|
|
@@ -242,6 +242,7 @@ files:
|
|
|
242
242
|
- lib/parser/static_environment.rb
|
|
243
243
|
- lib/parser/syntax_error.rb
|
|
244
244
|
- lib/parser/tree_rewriter.rb
|
|
245
|
+
- lib/parser/unknown_encoding_in_magic_comment_error.rb
|
|
245
246
|
- lib/parser/variables_stack.rb
|
|
246
247
|
- lib/parser/version.rb
|
|
247
248
|
- parser.gemspec
|
|
@@ -250,9 +251,9 @@ licenses:
|
|
|
250
251
|
- MIT
|
|
251
252
|
metadata:
|
|
252
253
|
bug_tracker_uri: https://github.com/whitequark/parser/issues
|
|
253
|
-
changelog_uri: https://github.com/whitequark/parser/blob/v3.3.0
|
|
254
|
-
documentation_uri: https://www.rubydoc.info/gems/parser/3.3.0
|
|
255
|
-
source_code_uri: https://github.com/whitequark/parser/tree/v3.3.0
|
|
254
|
+
changelog_uri: https://github.com/whitequark/parser/blob/v3.3.7.0/CHANGELOG.md
|
|
255
|
+
documentation_uri: https://www.rubydoc.info/gems/parser/3.3.7.0
|
|
256
|
+
source_code_uri: https://github.com/whitequark/parser/tree/v3.3.7.0
|
|
256
257
|
post_install_message:
|
|
257
258
|
rdoc_options: []
|
|
258
259
|
require_paths:
|