ruby_parser 3.20.1 → 3.20.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +18 -0
- data/compare/normalize.rb +1 -0
- data/lib/ruby20_parser.rb +4220 -4273
- data/lib/ruby20_parser.y +0 -10
- data/lib/ruby21_parser.rb +4203 -4238
- data/lib/ruby21_parser.y +0 -10
- data/lib/ruby22_parser.rb +4239 -4276
- data/lib/ruby22_parser.y +0 -10
- data/lib/ruby23_parser.rb +4235 -4240
- data/lib/ruby23_parser.y +0 -10
- data/lib/ruby24_parser.rb +4229 -4284
- data/lib/ruby24_parser.y +0 -10
- data/lib/ruby25_parser.rb +4220 -4275
- data/lib/ruby25_parser.y +0 -10
- data/lib/ruby26_parser.rb +4221 -4276
- data/lib/ruby26_parser.y +0 -10
- data/lib/ruby27_parser.rb +4138 -4207
- data/lib/ruby27_parser.y +0 -10
- data/lib/ruby30_parser.rb +5989 -5957
- data/lib/ruby30_parser.y +95 -72
- data/lib/ruby31_parser.rb +6157 -6172
- data/lib/ruby31_parser.y +96 -73
- data/lib/ruby32_parser.rb +6251 -6314
- data/lib/ruby32_parser.y +117 -93
- data/lib/ruby3_parser.yy +132 -73
- data/lib/ruby_lexer.rb +15 -7
- data/lib/ruby_lexer.rex.rb +1 -1
- data/lib/ruby_lexer_strings.rb +2 -2
- data/lib/ruby_parser.yy +0 -10
- data/lib/ruby_parser_extras.rb +9 -9
- data/test/test_ruby_parser.rb +39 -1
- data/tools/munge.rb +8 -2
- data/tools/ripper.rb +14 -12
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
data/lib/ruby_parser.yy
CHANGED
@@ -1293,7 +1293,6 @@ rule
|
|
1293
1293
|
| k_begin
|
1294
1294
|
{
|
1295
1295
|
lexer.cmdarg.push false
|
1296
|
-
result = self.lexer.lineno
|
1297
1296
|
}
|
1298
1297
|
bodystmt k_end
|
1299
1298
|
{
|
@@ -1458,9 +1457,6 @@ rule
|
|
1458
1457
|
result = new_for iter, var, body
|
1459
1458
|
}
|
1460
1459
|
| k_class
|
1461
|
-
{
|
1462
|
-
result = self.lexer.lineno
|
1463
|
-
}
|
1464
1460
|
cpath superclass
|
1465
1461
|
{
|
1466
1462
|
if (self.in_def || self.in_single > 0) then
|
@@ -1475,9 +1471,6 @@ rule
|
|
1475
1471
|
self.lexer.ignore_body_comments
|
1476
1472
|
}
|
1477
1473
|
| k_class tLSHFT
|
1478
|
-
{
|
1479
|
-
result = self.lexer.lineno
|
1480
|
-
}
|
1481
1474
|
expr
|
1482
1475
|
{
|
1483
1476
|
result = self.in_def
|
@@ -1496,9 +1489,6 @@ rule
|
|
1496
1489
|
self.lexer.ignore_body_comments
|
1497
1490
|
}
|
1498
1491
|
| k_module
|
1499
|
-
{
|
1500
|
-
result = self.lexer.lineno
|
1501
|
-
}
|
1502
1492
|
cpath
|
1503
1493
|
{
|
1504
1494
|
yyerror "module definition in method body" if
|
data/lib/ruby_parser_extras.rb
CHANGED
@@ -30,9 +30,9 @@ class Sexp
|
|
30
30
|
end
|
31
31
|
|
32
32
|
module RubyParserStuff
|
33
|
-
VERSION = "3.20.
|
33
|
+
VERSION = "3.20.3"
|
34
34
|
|
35
|
-
attr_accessor :lexer, :in_def, :in_single, :file
|
35
|
+
attr_accessor :lexer, :in_def, :in_single, :file, :in_argdef
|
36
36
|
attr_accessor :in_kwarg
|
37
37
|
attr_reader :env, :comments
|
38
38
|
|
@@ -122,6 +122,7 @@ module RubyParserStuff
|
|
122
122
|
self.lexer = RubyLexer.new v && v.to_i
|
123
123
|
self.lexer.parser = self
|
124
124
|
self.in_kwarg = false
|
125
|
+
self.in_argdef = false
|
125
126
|
|
126
127
|
@env = RubyParserStuff::Environment.new
|
127
128
|
@comments = []
|
@@ -824,10 +825,10 @@ module RubyParserStuff
|
|
824
825
|
end
|
825
826
|
|
826
827
|
def new_begin val
|
827
|
-
_,
|
828
|
+
(_, line), _, body, _ = val
|
828
829
|
|
829
830
|
result = body ? s(:begin, body) : s(:nil)
|
830
|
-
result.line
|
831
|
+
result.line line
|
831
832
|
|
832
833
|
result
|
833
834
|
end
|
@@ -928,8 +929,7 @@ module RubyParserStuff
|
|
928
929
|
end
|
929
930
|
|
930
931
|
def new_class val
|
931
|
-
|
932
|
-
_, line, path, superclass, _, body, (_, line_max) = val
|
932
|
+
(_, line), path, superclass, _, body, (_, line_max) = val
|
933
933
|
|
934
934
|
path = path.first if path.instance_of? Array
|
935
935
|
|
@@ -1209,7 +1209,7 @@ module RubyParserStuff
|
|
1209
1209
|
end
|
1210
1210
|
|
1211
1211
|
def new_module val
|
1212
|
-
(_, line_min),
|
1212
|
+
(_, line_min), path, _, body, (_, line_max) = val
|
1213
1213
|
|
1214
1214
|
path = path.first if path.instance_of? Array
|
1215
1215
|
|
@@ -1367,7 +1367,7 @@ module RubyParserStuff
|
|
1367
1367
|
end
|
1368
1368
|
|
1369
1369
|
def new_sclass val
|
1370
|
-
|
1370
|
+
(_, line), _, recv, in_def, _, in_single, body, _ = val
|
1371
1371
|
|
1372
1372
|
result = s(:sclass, recv)
|
1373
1373
|
|
@@ -1379,7 +1379,7 @@ module RubyParserStuff
|
|
1379
1379
|
end
|
1380
1380
|
end
|
1381
1381
|
|
1382
|
-
result.line =
|
1382
|
+
result.line = line
|
1383
1383
|
self.in_def = in_def
|
1384
1384
|
self.in_single = in_single
|
1385
1385
|
result
|
data/test/test_ruby_parser.rb
CHANGED
@@ -132,11 +132,13 @@ module TestRubyParserShared
|
|
132
132
|
# for the array. Luckily, the arary elements all seemt to get the correct
|
133
133
|
# line number.
|
134
134
|
rb = "[\n'a',\n'b']\n1"
|
135
|
+
|
135
136
|
pt = s(:block,
|
136
137
|
s(:array,
|
137
138
|
s(:str, "a").line(2),
|
138
|
-
s(:str, "b").line(3)),
|
139
|
+
s(:str, "b").line(3)).line(1),
|
139
140
|
s(:lit, 1).line(4)).line 1
|
141
|
+
|
140
142
|
assert_parse rb, pt
|
141
143
|
end
|
142
144
|
|
@@ -5554,6 +5556,14 @@ module TestRubyParserShared31Plus
|
|
5554
5556
|
assert_case_in rb, pt
|
5555
5557
|
end
|
5556
5558
|
|
5559
|
+
def test_defn_forward_args__no_parens
|
5560
|
+
rb = "def f ...\n m(...)\nend"
|
5561
|
+
pt = s(:defn, :f, s(:args, s(:forward_args)),
|
5562
|
+
s(:call, nil, :m, s(:forward_args).line(2)).line(2))
|
5563
|
+
|
5564
|
+
assert_parse rb, pt
|
5565
|
+
end
|
5566
|
+
|
5557
5567
|
def test_case_in_carat_nonlocal_vars
|
5558
5568
|
processor.env[:a] = :lvar
|
5559
5569
|
|
@@ -5632,6 +5642,34 @@ end
|
|
5632
5642
|
|
5633
5643
|
module TestRubyParserShared32Plus
|
5634
5644
|
include TestRubyParserShared31Plus
|
5645
|
+
|
5646
|
+
def test_args_star__anon_solo
|
5647
|
+
rb = "f(*)"
|
5648
|
+
pt = s(:call, nil, :f, s(:splat))
|
5649
|
+
|
5650
|
+
assert_parse rb, pt
|
5651
|
+
end
|
5652
|
+
|
5653
|
+
def test_args_star__anon_trailing
|
5654
|
+
rb = "f(x, *)"
|
5655
|
+
pt = s(:call, nil, :f, s(:call, nil, :x), s(:splat))
|
5656
|
+
|
5657
|
+
assert_parse rb, pt
|
5658
|
+
end
|
5659
|
+
|
5660
|
+
def test_args_dstar__anon_solo
|
5661
|
+
rb = "f(**)"
|
5662
|
+
pt = s(:call, nil, :f, s(:hash, s(:kwsplat))) # TODO double check this
|
5663
|
+
|
5664
|
+
assert_parse rb, pt
|
5665
|
+
end
|
5666
|
+
|
5667
|
+
def test_args_dstar__anon_trailing
|
5668
|
+
rb = "f(x, **)"
|
5669
|
+
pt = s(:call, nil, :f, s(:call, nil, :x), s(:hash, s(:kwsplat))) # TODO double check this
|
5670
|
+
|
5671
|
+
assert_parse rb, pt
|
5672
|
+
end
|
5635
5673
|
end
|
5636
5674
|
|
5637
5675
|
class Minitest::Test
|
data/tools/munge.rb
CHANGED
@@ -174,6 +174,10 @@ ARGF.each_line do |line|
|
|
174
174
|
last_token = token
|
175
175
|
when /^Reading a token: / then
|
176
176
|
next # skip
|
177
|
+
when /^Reading a token$/ then # wtf?
|
178
|
+
next # skip
|
179
|
+
when /^(?:add_delayed_token|parser_dispatch)/ then # dunno what this is yet
|
180
|
+
next # skip
|
177
181
|
when /^read\s+:(\w+)/ then # read :tNL(tNL) nil
|
178
182
|
token = munge $1
|
179
183
|
next if last_token == token
|
@@ -212,7 +216,9 @@ ARGF.each_line do |line|
|
|
212
216
|
reduce_line = nil
|
213
217
|
stack.clear
|
214
218
|
when /^reduce/ then # ruby_parser side
|
215
|
-
|
219
|
+
s = munge line.chomp
|
220
|
+
next if s =~ /reduce\s+(\w+) --> \1/
|
221
|
+
puts s
|
216
222
|
puts
|
217
223
|
when /^(\w+_stack)\.(\w+)/ then
|
218
224
|
# TODO: make pretty, but still informative w/ line numbers etc
|
@@ -223,7 +229,7 @@ ARGF.each_line do |line|
|
|
223
229
|
# puts line
|
224
230
|
# TODO: make pretty, but still informative w/ line numbers etc
|
225
231
|
puts line.gsub("true", "1").gsub("false", "0")
|
226
|
-
when /^lex_state: :?([\w|]+) -> :?([\w|]+)(?: (?:at|from) (.*))?/ then
|
232
|
+
when /^lex_state: :?([\w|()]+) -> :?([\w|]+)(?: (?:at|from) (.*))?/ then
|
227
233
|
a, b, c = $1.upcase, $2.upcase, $3
|
228
234
|
a.gsub!(/EXPR_/, "")
|
229
235
|
b.gsub!(/EXPR_/, "")
|
data/tools/ripper.rb
CHANGED
@@ -21,18 +21,20 @@ end
|
|
21
21
|
ARGV.each do |path|
|
22
22
|
src = path == "-" ? $stdin.read : File.read(path)
|
23
23
|
|
24
|
-
sexp =
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
sexp = nil
|
25
|
+
|
26
|
+
if $b then
|
27
|
+
sexp = Ripper.sexp src
|
28
|
+
else
|
29
|
+
rip = MySexpBuilder.new src
|
30
|
+
rip.yydebug = $d
|
31
|
+
sexp = rip.parse
|
32
|
+
|
33
|
+
if rip.error? then
|
34
|
+
warn "skipping"
|
35
|
+
next
|
36
|
+
end
|
37
|
+
end
|
36
38
|
|
37
39
|
puts "accept"
|
38
40
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.20.
|
4
|
+
version: 3.20.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
ROfWo9Uyp8ba/j9eVG14KkYRaLydAY1MNQk2yd3R5CGfeOpD1kttxjoypoUJ2dOG
|
30
30
|
nsNBRuQJ1UfiCG97a6DNm+Fr
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2023-
|
32
|
+
date: 2023-07-12 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: sexp_processor
|
metadata.gz.sig
CHANGED
Binary file
|