ruby_parser 3.20.0 → 3.20.2
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
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +12 -0
- data/compare/normalize.rb +1 -0
- data/lib/ruby20_parser.rb +4266 -4283
- data/lib/ruby20_parser.y +50 -26
- data/lib/ruby21_parser.rb +4240 -4239
- data/lib/ruby21_parser.y +50 -26
- data/lib/ruby22_parser.rb +4288 -4289
- data/lib/ruby22_parser.y +50 -26
- data/lib/ruby23_parser.rb +4273 -4242
- data/lib/ruby23_parser.y +50 -26
- data/lib/ruby24_parser.rb +4278 -4297
- data/lib/ruby24_parser.y +50 -26
- data/lib/ruby25_parser.rb +4269 -4288
- data/lib/ruby25_parser.y +50 -26
- data/lib/ruby26_parser.rb +4269 -4288
- data/lib/ruby26_parser.y +50 -26
- data/lib/ruby27_parser.rb +4172 -4205
- data/lib/ruby27_parser.y +50 -26
- data/lib/ruby30_parser.rb +6009 -5974
- data/lib/ruby30_parser.y +111 -84
- data/lib/ruby31_parser.rb +6130 -6227
- data/lib/ruby31_parser.y +111 -84
- data/lib/ruby32_parser.rb +6297 -6352
- data/lib/ruby32_parser.y +132 -104
- data/lib/ruby3_parser.yy +147 -84
- data/lib/ruby_lexer.rb +2 -0
- data/lib/ruby_lexer.rex.rb +1 -1
- data/lib/ruby_lexer_strings.rb +2 -2
- data/lib/ruby_parser.yy +50 -26
- data/lib/ruby_parser_extras.rb +23 -18
- data/test/test_ruby_parser.rb +187 -7
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
data/lib/ruby_parser.yy
CHANGED
|
@@ -253,6 +253,7 @@ rule
|
|
|
253
253
|
| lhs tEQL mrhs
|
|
254
254
|
{
|
|
255
255
|
lhs, _, rhs = val
|
|
256
|
+
|
|
256
257
|
result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
|
|
257
258
|
}
|
|
258
259
|
#if V == 20
|
|
@@ -1107,8 +1108,10 @@ rule
|
|
|
1107
1108
|
|
|
1108
1109
|
paren_args: tLPAREN2 opt_call_args rparen
|
|
1109
1110
|
{
|
|
1110
|
-
_, args, _ = val
|
|
1111
|
+
_, args, (_, line_max) = val
|
|
1112
|
+
|
|
1111
1113
|
result = args
|
|
1114
|
+
result.line_max = line_max if args
|
|
1112
1115
|
}
|
|
1113
1116
|
#if V >= 27
|
|
1114
1117
|
| tLPAREN2 args tCOMMA args_forward rparen
|
|
@@ -1290,7 +1293,6 @@ rule
|
|
|
1290
1293
|
| k_begin
|
|
1291
1294
|
{
|
|
1292
1295
|
lexer.cmdarg.push false
|
|
1293
|
-
result = self.lexer.lineno
|
|
1294
1296
|
}
|
|
1295
1297
|
bodystmt k_end
|
|
1296
1298
|
{
|
|
@@ -1335,12 +1337,14 @@ rule
|
|
|
1335
1337
|
{
|
|
1336
1338
|
result = wrap :colon3, val[1]
|
|
1337
1339
|
}
|
|
1338
|
-
| tLBRACK { result = lexer.lineno } aref_args
|
|
1340
|
+
| tLBRACK { result = lexer.lineno } aref_args rbracket
|
|
1339
1341
|
{
|
|
1340
|
-
_, line, args, _ = val
|
|
1342
|
+
_, line, args, (_, line_max) = val
|
|
1343
|
+
|
|
1341
1344
|
result = args || s(:array)
|
|
1342
1345
|
result.sexp_type = :array # aref_args is :args
|
|
1343
1346
|
result.line line
|
|
1347
|
+
result.line_max = line_max
|
|
1344
1348
|
}
|
|
1345
1349
|
| tLBRACE
|
|
1346
1350
|
{
|
|
@@ -1453,9 +1457,6 @@ rule
|
|
|
1453
1457
|
result = new_for iter, var, body
|
|
1454
1458
|
}
|
|
1455
1459
|
| k_class
|
|
1456
|
-
{
|
|
1457
|
-
result = self.lexer.lineno
|
|
1458
|
-
}
|
|
1459
1460
|
cpath superclass
|
|
1460
1461
|
{
|
|
1461
1462
|
if (self.in_def || self.in_single > 0) then
|
|
@@ -1470,9 +1471,6 @@ rule
|
|
|
1470
1471
|
self.lexer.ignore_body_comments
|
|
1471
1472
|
}
|
|
1472
1473
|
| k_class tLSHFT
|
|
1473
|
-
{
|
|
1474
|
-
result = self.lexer.lineno
|
|
1475
|
-
}
|
|
1476
1474
|
expr
|
|
1477
1475
|
{
|
|
1478
1476
|
result = self.in_def
|
|
@@ -1491,9 +1489,6 @@ rule
|
|
|
1491
1489
|
self.lexer.ignore_body_comments
|
|
1492
1490
|
}
|
|
1493
1491
|
| k_module
|
|
1494
|
-
{
|
|
1495
|
-
result = self.lexer.lineno
|
|
1496
|
-
}
|
|
1497
1492
|
cpath
|
|
1498
1493
|
{
|
|
1499
1494
|
yyerror "module definition in method body" if
|
|
@@ -1942,13 +1937,19 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
1942
1937
|
{
|
|
1943
1938
|
call, args = val
|
|
1944
1939
|
|
|
1945
|
-
result = call
|
|
1940
|
+
result = call
|
|
1941
|
+
|
|
1942
|
+
if args then
|
|
1943
|
+
call.concat args.sexp_body
|
|
1944
|
+
result.line_max = args.line_max
|
|
1945
|
+
end
|
|
1946
1946
|
}
|
|
1947
1947
|
| primary_value call_op operation2 opt_paren_args
|
|
1948
1948
|
{
|
|
1949
|
-
recv, call_op, (op,
|
|
1949
|
+
recv, call_op, (op, op_line), args = val
|
|
1950
1950
|
|
|
1951
1951
|
result = new_call recv, op.to_sym, args, call_op
|
|
1952
|
+
result.line_max = op_line unless args
|
|
1952
1953
|
}
|
|
1953
1954
|
| primary_value tCOLON2 operation2 paren_args
|
|
1954
1955
|
{
|
|
@@ -2674,15 +2675,17 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2674
2675
|
|
|
2675
2676
|
words: tWORDS_BEG tSPACE tSTRING_END
|
|
2676
2677
|
{
|
|
2677
|
-
(_, line), _, _ = val
|
|
2678
|
+
(_, line), _, (_, line_max) = val
|
|
2678
2679
|
|
|
2679
2680
|
result = s(:array).line line
|
|
2681
|
+
result.line_max = line_max
|
|
2680
2682
|
}
|
|
2681
2683
|
| tWORDS_BEG word_list tSTRING_END
|
|
2682
2684
|
{
|
|
2683
|
-
(_, line), list, _ = val
|
|
2685
|
+
(_, line), list, (_, line_max) = val
|
|
2684
2686
|
|
|
2685
2687
|
result = list.line line
|
|
2688
|
+
result.line_max = line_max
|
|
2686
2689
|
}
|
|
2687
2690
|
|
|
2688
2691
|
word_list: none
|
|
@@ -2702,15 +2705,17 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2702
2705
|
|
|
2703
2706
|
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
|
2704
2707
|
{
|
|
2705
|
-
(_, line), _, _ = val
|
|
2708
|
+
(_, line), _, (_, line_max) = val
|
|
2706
2709
|
|
|
2707
2710
|
result = s(:array).line line
|
|
2711
|
+
result.line_max = line_max
|
|
2708
2712
|
}
|
|
2709
2713
|
| tSYMBOLS_BEG symbol_list tSTRING_END
|
|
2710
2714
|
{
|
|
2711
|
-
(_, line), list, _, = val
|
|
2712
|
-
|
|
2713
|
-
result = list
|
|
2715
|
+
(_, line), list, (_, line_max), = val
|
|
2716
|
+
|
|
2717
|
+
result = list.line line
|
|
2718
|
+
result.line_max = line_max
|
|
2714
2719
|
}
|
|
2715
2720
|
|
|
2716
2721
|
symbol_list: none
|
|
@@ -2725,28 +2730,32 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
|
2725
2730
|
|
|
2726
2731
|
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
|
2727
2732
|
{
|
|
2728
|
-
(_, line), _, _ = val
|
|
2733
|
+
(_, line), _, (_, line_max) = val
|
|
2729
2734
|
|
|
2730
2735
|
result = s(:array).line line
|
|
2736
|
+
result.line_max = line_max
|
|
2731
2737
|
}
|
|
2732
2738
|
| tQWORDS_BEG qword_list tSTRING_END
|
|
2733
2739
|
{
|
|
2734
|
-
(_, line), list, _ = val
|
|
2740
|
+
(_, line), list, (_, line_max) = val
|
|
2735
2741
|
|
|
2736
2742
|
result = list.line line
|
|
2743
|
+
result.line_max = line_max
|
|
2737
2744
|
}
|
|
2738
2745
|
|
|
2739
2746
|
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
|
2740
2747
|
{
|
|
2741
|
-
(_, line), _, _ = val
|
|
2748
|
+
(_, line), _, (_, line_max) = val
|
|
2742
2749
|
|
|
2743
2750
|
result = s(:array).line line
|
|
2751
|
+
result.line_max = line_max
|
|
2744
2752
|
}
|
|
2745
2753
|
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
|
2746
2754
|
{
|
|
2747
|
-
(_, line), list, _ = val
|
|
2755
|
+
(_, line), list, (_, line_max) = val
|
|
2748
2756
|
|
|
2749
2757
|
result = list.line line
|
|
2758
|
+
result.line_max = line_max
|
|
2750
2759
|
}
|
|
2751
2760
|
|
|
2752
2761
|
qword_list: none
|
|
@@ -3197,7 +3206,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
|
3197
3206
|
result = s(:args, list).line list.line
|
|
3198
3207
|
end
|
|
3199
3208
|
|
|
3200
|
-
|
|
3209
|
+
if Sexp === item then
|
|
3210
|
+
line_max = item.line_max
|
|
3211
|
+
else
|
|
3212
|
+
item, line_max = item
|
|
3213
|
+
end
|
|
3214
|
+
|
|
3215
|
+
result << item
|
|
3216
|
+
result.line_max = line_max
|
|
3201
3217
|
}
|
|
3202
3218
|
|
|
3203
3219
|
#if V == 20
|
|
@@ -3449,7 +3465,15 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
|
3449
3465
|
opt_terms: | terms
|
|
3450
3466
|
opt_nl: | tNL
|
|
3451
3467
|
rparen: opt_nl tRPAREN
|
|
3468
|
+
{
|
|
3469
|
+
_, close = val
|
|
3470
|
+
result = [close, lexer.lineno]
|
|
3471
|
+
}
|
|
3452
3472
|
rbracket: opt_nl tRBRACK
|
|
3473
|
+
{
|
|
3474
|
+
_, close = val
|
|
3475
|
+
result = [close, lexer.lineno]
|
|
3476
|
+
}
|
|
3453
3477
|
#if V >= 27
|
|
3454
3478
|
rbrace: opt_nl tRCURLY
|
|
3455
3479
|
#endif
|
data/lib/ruby_parser_extras.rb
CHANGED
|
@@ -18,7 +18,7 @@ class Sexp
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
##
|
|
21
|
-
# Returns the
|
|
21
|
+
# Returns the minimum line number of the children of self.
|
|
22
22
|
|
|
23
23
|
def line_min
|
|
24
24
|
@line_min ||= [self.deep_each.map(&:line).min, self.line].compact.min
|
|
@@ -30,7 +30,7 @@ class Sexp
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
module RubyParserStuff
|
|
33
|
-
VERSION = "3.20.
|
|
33
|
+
VERSION = "3.20.2"
|
|
34
34
|
|
|
35
35
|
attr_accessor :lexer, :in_def, :in_single, :file
|
|
36
36
|
attr_accessor :in_kwarg
|
|
@@ -153,6 +153,7 @@ module RubyParserStuff
|
|
|
153
153
|
result.line lexer.lineno
|
|
154
154
|
else
|
|
155
155
|
result.line ss.first.line
|
|
156
|
+
result.line_max = ss.first.line_max
|
|
156
157
|
end
|
|
157
158
|
|
|
158
159
|
args.each do |arg|
|
|
@@ -330,9 +331,8 @@ module RubyParserStuff
|
|
|
330
331
|
end
|
|
331
332
|
|
|
332
333
|
args.each do |arg|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
end
|
|
334
|
+
# ruby 3.0+ TODO: next if arg in [String, Integer] # eg ["(", 1]
|
|
335
|
+
next if arg.class == Array && arg.map(&:class) == [String, Integer]
|
|
336
336
|
|
|
337
337
|
case arg
|
|
338
338
|
when Sexp then
|
|
@@ -794,6 +794,7 @@ module RubyParserStuff
|
|
|
794
794
|
case lhs.sexp_type
|
|
795
795
|
when :lasgn, :iasgn, :cdecl, :cvdecl, :gasgn, :cvasgn, :attrasgn, :safe_attrasgn then
|
|
796
796
|
lhs << rhs
|
|
797
|
+
lhs.line_max = rhs.line_max
|
|
797
798
|
when :const then
|
|
798
799
|
lhs.sexp_type = :cdecl
|
|
799
800
|
lhs << rhs
|
|
@@ -823,10 +824,10 @@ module RubyParserStuff
|
|
|
823
824
|
end
|
|
824
825
|
|
|
825
826
|
def new_begin val
|
|
826
|
-
_,
|
|
827
|
+
(_, line), _, body, _ = val
|
|
827
828
|
|
|
828
829
|
result = body ? s(:begin, body) : s(:nil)
|
|
829
|
-
result.line
|
|
830
|
+
result.line line
|
|
830
831
|
|
|
831
832
|
result
|
|
832
833
|
end
|
|
@@ -885,12 +886,13 @@ module RubyParserStuff
|
|
|
885
886
|
# TODO: need a test with f(&b) to produce block_pass
|
|
886
887
|
# TODO: need a test with f(&b) { } to produce warning
|
|
887
888
|
|
|
888
|
-
if args
|
|
889
|
+
if args then
|
|
889
890
|
if ARG_TYPES[args.sexp_type] then
|
|
890
891
|
result.concat args.sexp_body
|
|
891
892
|
else
|
|
892
893
|
result << args
|
|
893
894
|
end
|
|
895
|
+
result.line_max = args.line_max
|
|
894
896
|
end
|
|
895
897
|
|
|
896
898
|
# line = result.grep(Sexp).map(&:line).compact.min
|
|
@@ -926,8 +928,7 @@ module RubyParserStuff
|
|
|
926
928
|
end
|
|
927
929
|
|
|
928
930
|
def new_class val
|
|
929
|
-
|
|
930
|
-
line, path, superclass, body = val[1], val[2], val[3], val[5]
|
|
931
|
+
(_, line), path, superclass, _, body, (_, line_max) = val
|
|
931
932
|
|
|
932
933
|
path = path.first if path.instance_of? Array
|
|
933
934
|
|
|
@@ -942,6 +943,7 @@ module RubyParserStuff
|
|
|
942
943
|
end
|
|
943
944
|
|
|
944
945
|
result.line = line
|
|
946
|
+
result.line_max = line_max
|
|
945
947
|
result.comments = self.comments.pop
|
|
946
948
|
result
|
|
947
949
|
end
|
|
@@ -970,13 +972,14 @@ module RubyParserStuff
|
|
|
970
972
|
end
|
|
971
973
|
|
|
972
974
|
def new_defn val
|
|
973
|
-
_, (name, line), in_def, args, body, _ = val
|
|
975
|
+
_, (name, line), in_def, args, body, (_, line_max) = val
|
|
974
976
|
|
|
975
977
|
body ||= s(:nil).line line
|
|
976
978
|
|
|
977
979
|
args.line line
|
|
978
980
|
|
|
979
981
|
result = s(:defn, name.to_sym, args).line line
|
|
982
|
+
result.line_max = line_max
|
|
980
983
|
|
|
981
984
|
if body.sexp_type == :block then
|
|
982
985
|
result.push(*body.sexp_body)
|
|
@@ -1033,13 +1036,14 @@ module RubyParserStuff
|
|
|
1033
1036
|
end
|
|
1034
1037
|
|
|
1035
1038
|
def new_defs val
|
|
1036
|
-
_, recv, (name, line), in_def, args, body, _ = val
|
|
1039
|
+
_, recv, (name, line), in_def, args, body, (_, line_max) = val
|
|
1037
1040
|
|
|
1038
1041
|
body ||= s(:nil).line line
|
|
1039
1042
|
|
|
1040
1043
|
args.line line
|
|
1041
1044
|
|
|
1042
1045
|
result = s(:defs, recv, name.to_sym, args).line line
|
|
1046
|
+
result.line_max = line_max
|
|
1043
1047
|
|
|
1044
1048
|
# TODO: remove_begin
|
|
1045
1049
|
# TODO: reduce_nodes
|
|
@@ -1204,12 +1208,12 @@ module RubyParserStuff
|
|
|
1204
1208
|
end
|
|
1205
1209
|
|
|
1206
1210
|
def new_module val
|
|
1207
|
-
|
|
1208
|
-
line, path, body = val[1], val[2], val[4]
|
|
1211
|
+
(_, line_min), path, _, body, (_, line_max) = val
|
|
1209
1212
|
|
|
1210
1213
|
path = path.first if path.instance_of? Array
|
|
1211
1214
|
|
|
1212
|
-
result = s(:module, path).line
|
|
1215
|
+
result = s(:module, path).line line_min
|
|
1216
|
+
result.line_max = line_max
|
|
1213
1217
|
|
|
1214
1218
|
if body then # REFACTOR?
|
|
1215
1219
|
if body.sexp_type == :block then
|
|
@@ -1291,9 +1295,10 @@ module RubyParserStuff
|
|
|
1291
1295
|
end
|
|
1292
1296
|
|
|
1293
1297
|
def new_regexp val
|
|
1294
|
-
(_, line), node, (options,
|
|
1298
|
+
(_, line), node, (options, line_max) = val
|
|
1295
1299
|
|
|
1296
1300
|
node ||= s(:str, "").line line
|
|
1301
|
+
node.line_max = line_max
|
|
1297
1302
|
|
|
1298
1303
|
o, k = 0, nil
|
|
1299
1304
|
options.split(//).uniq.each do |c| # FIX: this has a better home
|
|
@@ -1361,7 +1366,7 @@ module RubyParserStuff
|
|
|
1361
1366
|
end
|
|
1362
1367
|
|
|
1363
1368
|
def new_sclass val
|
|
1364
|
-
|
|
1369
|
+
(_, line), _, recv, in_def, _, in_single, body, _ = val
|
|
1365
1370
|
|
|
1366
1371
|
result = s(:sclass, recv)
|
|
1367
1372
|
|
|
@@ -1373,7 +1378,7 @@ module RubyParserStuff
|
|
|
1373
1378
|
end
|
|
1374
1379
|
end
|
|
1375
1380
|
|
|
1376
|
-
result.line =
|
|
1381
|
+
result.line = line
|
|
1377
1382
|
self.in_def = in_def
|
|
1378
1383
|
self.in_single = in_single
|
|
1379
1384
|
result
|
data/test/test_ruby_parser.rb
CHANGED
|
@@ -15,11 +15,26 @@ class Sexp
|
|
|
15
15
|
def == other # :nodoc:
|
|
16
16
|
if other.class == self.class then
|
|
17
17
|
super and
|
|
18
|
-
(line.nil?
|
|
18
|
+
(line.nil? or other.line.nil? or line == other.line) and
|
|
19
|
+
(!defined?(@line_max) or @line_max.nil? or line_max == other.line_max)
|
|
20
|
+
# (line_max.nil? or other.line_max.nil? or line_max == other.line_max)
|
|
19
21
|
else
|
|
20
22
|
false
|
|
21
23
|
end
|
|
22
24
|
end
|
|
25
|
+
|
|
26
|
+
# convenience function just for testing
|
|
27
|
+
alias dead line_max
|
|
28
|
+
def line_max n = UNASSIGNED
|
|
29
|
+
if n != UNASSIGNED then
|
|
30
|
+
raise ArgumentError, "setting %p.line_max %p" % [self, n] unless Integer === n
|
|
31
|
+
@line_max = n
|
|
32
|
+
self
|
|
33
|
+
else
|
|
34
|
+
# raise "Accessing before @line_max defined" unless defined?(@line_max)
|
|
35
|
+
@line_max ||= self.deep_each.map(&:line).compact.max
|
|
36
|
+
end
|
|
37
|
+
end
|
|
23
38
|
end
|
|
24
39
|
|
|
25
40
|
module TestRubyParserShared
|
|
@@ -117,11 +132,13 @@ module TestRubyParserShared
|
|
|
117
132
|
# for the array. Luckily, the arary elements all seemt to get the correct
|
|
118
133
|
# line number.
|
|
119
134
|
rb = "[\n'a',\n'b']\n1"
|
|
135
|
+
|
|
120
136
|
pt = s(:block,
|
|
121
137
|
s(:array,
|
|
122
138
|
s(:str, "a").line(2),
|
|
123
|
-
s(:str, "b").line(3)),
|
|
139
|
+
s(:str, "b").line(3)).line(1),
|
|
124
140
|
s(:lit, 1).line(4)).line 1
|
|
141
|
+
|
|
125
142
|
assert_parse rb, pt
|
|
126
143
|
end
|
|
127
144
|
|
|
@@ -965,7 +982,12 @@ module TestRubyParserShared
|
|
|
965
982
|
end
|
|
966
983
|
|
|
967
984
|
def test_heredoc_with_extra_carriage_horrible_mix?
|
|
968
|
-
rb =
|
|
985
|
+
rb = <<~RUBY
|
|
986
|
+
<<'eot'\r
|
|
987
|
+
body\r
|
|
988
|
+
eot
|
|
989
|
+
RUBY
|
|
990
|
+
|
|
969
991
|
pt = s(:str, "body\r\n")
|
|
970
992
|
|
|
971
993
|
assert_parse rb, pt
|
|
@@ -1051,9 +1073,9 @@ module TestRubyParserShared
|
|
|
1051
1073
|
end
|
|
1052
1074
|
|
|
1053
1075
|
def test_i_fucking_hate_line_numbers2
|
|
1054
|
-
rb =
|
|
1076
|
+
rb = <<~EOM
|
|
1055
1077
|
if true then
|
|
1056
|
-
p(
|
|
1078
|
+
p("a")
|
|
1057
1079
|
b = 1
|
|
1058
1080
|
p b
|
|
1059
1081
|
c =1
|
|
@@ -1074,6 +1096,138 @@ module TestRubyParserShared
|
|
|
1074
1096
|
assert_parse rb, pt
|
|
1075
1097
|
end
|
|
1076
1098
|
|
|
1099
|
+
line_max_array = s(:array,
|
|
1100
|
+
s(:lit, :line2).line(2),
|
|
1101
|
+
s(:lit, :line3).line(3)).line(1).line_max(4)
|
|
1102
|
+
line_max_array_empty = s(:array).line(1).line_max(4)
|
|
1103
|
+
[
|
|
1104
|
+
[:plain_array,
|
|
1105
|
+
"[\n:line2,\n:line3\n]",
|
|
1106
|
+
line_max_array,
|
|
1107
|
+
],
|
|
1108
|
+
[:pct_i,
|
|
1109
|
+
"%i[\nline2\nline3\n]",
|
|
1110
|
+
line_max_array,
|
|
1111
|
+
],
|
|
1112
|
+
[:pct_i_empty,
|
|
1113
|
+
"%i[\n\n\n]",
|
|
1114
|
+
line_max_array_empty,
|
|
1115
|
+
],
|
|
1116
|
+
[:pct_I,
|
|
1117
|
+
"%I[\nline2\nline3\n]",
|
|
1118
|
+
line_max_array,
|
|
1119
|
+
],
|
|
1120
|
+
[:pct_I_empty,
|
|
1121
|
+
"%I[\n\n\n]",
|
|
1122
|
+
line_max_array_empty,
|
|
1123
|
+
],
|
|
1124
|
+
[:call_parens,
|
|
1125
|
+
"x(\n:line2,\n:line3\n)",
|
|
1126
|
+
s(:call, nil, :x, *line_max_array.sexp_body).line(1).line_max(4),
|
|
1127
|
+
],
|
|
1128
|
+
[:pct_w,
|
|
1129
|
+
"%w[\nline2\nline3\n]",
|
|
1130
|
+
s(:array,
|
|
1131
|
+
s(:str, "line2").line(2),
|
|
1132
|
+
s(:str, "line3").line(3)).line(1).line_max(4),
|
|
1133
|
+
],
|
|
1134
|
+
[:pct_w_empty,
|
|
1135
|
+
"%w[\n\n\n]",
|
|
1136
|
+
line_max_array_empty,
|
|
1137
|
+
],
|
|
1138
|
+
[:pct_W,
|
|
1139
|
+
"%W[\nline2\nline3\n]",
|
|
1140
|
+
s(:array,
|
|
1141
|
+
s(:str, "line2").line(2),
|
|
1142
|
+
s(:str, "line3").line(3)).line(1).line_max(4),
|
|
1143
|
+
],
|
|
1144
|
+
[:pct_W_empty,
|
|
1145
|
+
"%W[\n\n\n]",
|
|
1146
|
+
line_max_array_empty,
|
|
1147
|
+
],
|
|
1148
|
+
[:regexp,
|
|
1149
|
+
"%r[\n\n\n]", # double-quotes to have the \n counted as lines on input
|
|
1150
|
+
s(:lit, %r[#{"\n\n\n"}]).line(1).line_max(4),
|
|
1151
|
+
],
|
|
1152
|
+
[:module,
|
|
1153
|
+
<<~"RUBY",
|
|
1154
|
+
module X # line 1
|
|
1155
|
+
module Y # line 2
|
|
1156
|
+
Z = 42 # line 3
|
|
1157
|
+
end # line 4
|
|
1158
|
+
end # line 5
|
|
1159
|
+
RUBY
|
|
1160
|
+
s(:module, :X,
|
|
1161
|
+
s(:module, :Y,
|
|
1162
|
+
s(:cdecl, :Z, s(:lit, 42).line(3)).line(3).line_max(3)
|
|
1163
|
+
).line(2).line_max(4)
|
|
1164
|
+
).line(1).line_max(5)],
|
|
1165
|
+
[:class,
|
|
1166
|
+
<<~"RUBY",
|
|
1167
|
+
class X # line 1
|
|
1168
|
+
class Y # line 2
|
|
1169
|
+
Z = 42 # line 3
|
|
1170
|
+
end # line 4
|
|
1171
|
+
end # line 5
|
|
1172
|
+
RUBY
|
|
1173
|
+
s(:class, :X, nil,
|
|
1174
|
+
s(:class, :Y, nil,
|
|
1175
|
+
s(:cdecl, :Z, s(:lit, 42).line(3)).line(3).line_max(3)
|
|
1176
|
+
).line(2).line_max(4)
|
|
1177
|
+
).line(1).line_max(5)],
|
|
1178
|
+
[:cdecl,
|
|
1179
|
+
<<~"RUBY",
|
|
1180
|
+
module X
|
|
1181
|
+
X = [
|
|
1182
|
+
:line3,
|
|
1183
|
+
:line4,
|
|
1184
|
+
]
|
|
1185
|
+
end
|
|
1186
|
+
RUBY
|
|
1187
|
+
s(:module, :X,
|
|
1188
|
+
s(:cdecl, :X,
|
|
1189
|
+
s(:array,
|
|
1190
|
+
s(:lit, :line3).line(3),
|
|
1191
|
+
s(:lit, :line4).line(4)).line(2).line_max(5),
|
|
1192
|
+
).line(2).line_max(5),
|
|
1193
|
+
).line(1).line_max(6)
|
|
1194
|
+
],
|
|
1195
|
+
[:defn,
|
|
1196
|
+
<<~"RUBY",
|
|
1197
|
+
class X # line 1
|
|
1198
|
+
def y(a, # line 2
|
|
1199
|
+
b) # line 3
|
|
1200
|
+
a + b # line 4
|
|
1201
|
+
end # line 5
|
|
1202
|
+
end # line 6
|
|
1203
|
+
RUBY
|
|
1204
|
+
s(:class, :X, nil,
|
|
1205
|
+
s(:defn, :y, s(:args, :a, :b).line(2).line_max(3),
|
|
1206
|
+
s(:call, s(:lvar, :a).line(4), :+, s(:lvar, :b).line(4)).line(4)
|
|
1207
|
+
).line(2).line_max(5),
|
|
1208
|
+
).line(1).line_max(6),
|
|
1209
|
+
],
|
|
1210
|
+
[:defs,
|
|
1211
|
+
<<~"RUBY",
|
|
1212
|
+
class X # line 1
|
|
1213
|
+
def self.y(a, # line 2
|
|
1214
|
+
b) # line 3
|
|
1215
|
+
a + b # line 4
|
|
1216
|
+
end # line 5
|
|
1217
|
+
end # line 6
|
|
1218
|
+
RUBY
|
|
1219
|
+
s(:class, :X, nil,
|
|
1220
|
+
s(:defs, s(:self).line(2), :y, s(:args, :a, :b).line(2).line_max(3),
|
|
1221
|
+
s(:call, s(:lvar, :a).line(4), :+, s(:lvar, :b).line(4)).line(4)
|
|
1222
|
+
).line(2).line_max(5),
|
|
1223
|
+
).line(1).line_max(6),
|
|
1224
|
+
],
|
|
1225
|
+
].each do |(name, rb, pt)|
|
|
1226
|
+
define_method "test_line_numbers__max_line__#{name}" do
|
|
1227
|
+
assert_parse rb, pt
|
|
1228
|
+
end
|
|
1229
|
+
end
|
|
1230
|
+
|
|
1077
1231
|
def test_if_elsif
|
|
1078
1232
|
rb = "if 1; elsif 2; end"
|
|
1079
1233
|
pt = s(:if, s(:lit, 1), nil, s(:if, s(:lit, 2), nil, nil))
|
|
@@ -5480,6 +5634,34 @@ end
|
|
|
5480
5634
|
|
|
5481
5635
|
module TestRubyParserShared32Plus
|
|
5482
5636
|
include TestRubyParserShared31Plus
|
|
5637
|
+
|
|
5638
|
+
def test_args_star__anon_solo
|
|
5639
|
+
rb = "f(*)"
|
|
5640
|
+
pt = s(:call, nil, :f, s(:splat))
|
|
5641
|
+
|
|
5642
|
+
assert_parse rb, pt
|
|
5643
|
+
end
|
|
5644
|
+
|
|
5645
|
+
def test_args_star__anon_trailing
|
|
5646
|
+
rb = "f(x, *)"
|
|
5647
|
+
pt = s(:call, nil, :f, s(:call, nil, :x), s(:splat))
|
|
5648
|
+
|
|
5649
|
+
assert_parse rb, pt
|
|
5650
|
+
end
|
|
5651
|
+
|
|
5652
|
+
def test_args_dstar__anon_solo
|
|
5653
|
+
rb = "f(**)"
|
|
5654
|
+
pt = s(:call, nil, :f, s(:hash, s(:kwsplat))) # TODO double check this
|
|
5655
|
+
|
|
5656
|
+
assert_parse rb, pt
|
|
5657
|
+
end
|
|
5658
|
+
|
|
5659
|
+
def test_args_dstar__anon_trailing
|
|
5660
|
+
rb = "f(x, **)"
|
|
5661
|
+
pt = s(:call, nil, :f, s(:call, nil, :x), s(:hash, s(:kwsplat))) # TODO double check this
|
|
5662
|
+
|
|
5663
|
+
assert_parse rb, pt
|
|
5664
|
+
end
|
|
5483
5665
|
end
|
|
5484
5666
|
|
|
5485
5667
|
class Minitest::Test
|
|
@@ -5782,8 +5964,6 @@ class TestRubyParserV26 < RubyParserTestCase
|
|
|
5782
5964
|
end
|
|
5783
5965
|
|
|
5784
5966
|
class TestRubyParserV27 < RubyParserTestCase
|
|
5785
|
-
make_my_diffs_pretty!
|
|
5786
|
-
|
|
5787
5967
|
include TestRubyParserShared27Plus
|
|
5788
5968
|
|
|
5789
5969
|
def setup
|
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.2
|
|
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-06-06 00:00:00.000000000 Z
|
|
33
33
|
dependencies:
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: sexp_processor
|
|
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
245
245
|
- !ruby/object:Gem::Version
|
|
246
246
|
version: '0'
|
|
247
247
|
requirements: []
|
|
248
|
-
rubygems_version: 3.4.
|
|
248
|
+
rubygems_version: 3.4.10
|
|
249
249
|
signing_key:
|
|
250
250
|
specification_version: 4
|
|
251
251
|
summary: ruby_parser (RP) is a ruby parser written in pure ruby (utilizing racc--which
|
metadata.gz.sig
CHANGED
|
Binary file
|