ruby_parser 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +10 -0
- data/lib/ruby18_parser.rb +7 -2
- data/lib/ruby18_parser.y +7 -2
- data/lib/ruby19_parser.rb +6 -3
- data/lib/ruby19_parser.y +6 -3
- data/lib/ruby20_parser.rb +19 -8
- data/lib/ruby20_parser.y +18 -8
- data/lib/ruby_lexer.rb +5 -1
- data/lib/ruby_parser_extras.rb +6 -5
- data/test/test_ruby_lexer.rb +18 -8
- data/test/test_ruby_parser.rb +118 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 3.2.2 / 2013-07-11
|
2
|
+
|
3
|
+
* 5 bug fixes:
|
4
|
+
|
5
|
+
* 1.9/2.0: fixed assocs in return args. (presidentbeef)
|
6
|
+
* Fixed handling of parse error when class is nested in multiple defs. (whitequark)
|
7
|
+
* Fixed lexing of %w[] w/ funny whitespace separators. (whitequark)
|
8
|
+
* Fixed more call nodes that have trailing comma syntax. (presidentbeef)
|
9
|
+
* Fixed more call_args slippage.
|
10
|
+
|
1
11
|
=== 3.2.1 / 2013-07-03
|
2
12
|
|
3
13
|
* 1 bug fix:
|
data/lib/ruby18_parser.rb
CHANGED
@@ -4677,18 +4677,23 @@ def _reduce_317(val, _values, result)
|
|
4677
4677
|
end
|
4678
4678
|
|
4679
4679
|
def _reduce_318(val, _values, result)
|
4680
|
+
result = lexer.lineno, self.in_def
|
4681
|
+
|
4680
4682
|
self.comments.push self.lexer.comments
|
4681
4683
|
self.in_def = true
|
4682
4684
|
self.env.extend
|
4683
|
-
result = lexer.lineno, lexer.src.beginning_of_line?
|
4684
4685
|
|
4685
4686
|
result
|
4686
4687
|
end
|
4687
4688
|
|
4688
4689
|
def _reduce_319(val, _values, result)
|
4690
|
+
line, in_def = val[2]
|
4691
|
+
|
4689
4692
|
result = new_defn val
|
4693
|
+
result[2].line line
|
4694
|
+
|
4690
4695
|
self.env.unextend
|
4691
|
-
self.in_def =
|
4696
|
+
self.in_def = in_def
|
4692
4697
|
self.lexer.comments # we don't care about comments in the body
|
4693
4698
|
|
4694
4699
|
result
|
data/lib/ruby18_parser.y
CHANGED
@@ -1124,16 +1124,21 @@ rule
|
|
1124
1124
|
}
|
1125
1125
|
| kDEF fname
|
1126
1126
|
{
|
1127
|
+
result = lexer.lineno, self.in_def
|
1128
|
+
|
1127
1129
|
self.comments.push self.lexer.comments
|
1128
1130
|
self.in_def = true
|
1129
1131
|
self.env.extend
|
1130
|
-
result = lexer.lineno, lexer.src.beginning_of_line?
|
1131
1132
|
}
|
1132
1133
|
f_arglist bodystmt kEND
|
1133
1134
|
{
|
1135
|
+
line, in_def = val[2]
|
1136
|
+
|
1134
1137
|
result = new_defn val
|
1138
|
+
result[2].line line
|
1139
|
+
|
1135
1140
|
self.env.unextend
|
1136
|
-
self.in_def =
|
1141
|
+
self.in_def = in_def
|
1137
1142
|
self.lexer.comments # we don't care about comments in the body
|
1138
1143
|
}
|
1139
1144
|
| kDEF singleton dot_or_colon
|
data/lib/ruby19_parser.rb
CHANGED
@@ -4744,20 +4744,23 @@ def _reduce_321(val, _values, result)
|
|
4744
4744
|
end
|
4745
4745
|
|
4746
4746
|
def _reduce_322(val, _values, result)
|
4747
|
+
result = [lexer.lineno, self.in_def]
|
4748
|
+
|
4747
4749
|
self.comments.push self.lexer.comments
|
4748
4750
|
self.in_def = true
|
4749
4751
|
self.env.extend
|
4750
|
-
result = lexer.lineno
|
4751
4752
|
|
4752
4753
|
result
|
4753
4754
|
end
|
4754
4755
|
|
4755
4756
|
def _reduce_323(val, _values, result)
|
4757
|
+
line, in_def = val[2]
|
4758
|
+
|
4756
4759
|
result = new_defn val
|
4757
|
-
result[2].line
|
4760
|
+
result[2].line line
|
4758
4761
|
|
4759
4762
|
self.env.unextend
|
4760
|
-
self.in_def =
|
4763
|
+
self.in_def = in_def
|
4761
4764
|
self.lexer.comments # we don't care about comments in the body
|
4762
4765
|
|
4763
4766
|
result
|
data/lib/ruby19_parser.y
CHANGED
@@ -1103,18 +1103,21 @@ rule
|
|
1103
1103
|
}
|
1104
1104
|
| kDEF fname
|
1105
1105
|
{
|
1106
|
+
result = [lexer.lineno, self.in_def]
|
1107
|
+
|
1106
1108
|
self.comments.push self.lexer.comments
|
1107
1109
|
self.in_def = true
|
1108
1110
|
self.env.extend
|
1109
|
-
result = lexer.lineno
|
1110
1111
|
}
|
1111
1112
|
f_arglist bodystmt kEND
|
1112
1113
|
{
|
1114
|
+
line, in_def = val[2]
|
1115
|
+
|
1113
1116
|
result = new_defn val
|
1114
|
-
result[2].line
|
1117
|
+
result[2].line line
|
1115
1118
|
|
1116
1119
|
self.env.unextend
|
1117
|
-
self.in_def =
|
1120
|
+
self.in_def = in_def
|
1118
1121
|
self.lexer.comments # we don't care about comments in the body
|
1119
1122
|
}
|
1120
1123
|
| kDEF singleton dot_or_colon
|
data/lib/ruby20_parser.rb
CHANGED
@@ -2225,7 +2225,7 @@ racc_reduce_table = [
|
|
2225
2225
|
1, 146, :_reduce_none,
|
2226
2226
|
3, 146, :_reduce_6,
|
2227
2227
|
2, 146, :_reduce_none,
|
2228
|
-
1, 149, :
|
2228
|
+
1, 149, :_reduce_8,
|
2229
2229
|
0, 153, :_reduce_9,
|
2230
2230
|
5, 149, :_reduce_10,
|
2231
2231
|
4, 152, :_reduce_11,
|
@@ -3377,7 +3377,16 @@ end
|
|
3377
3377
|
|
3378
3378
|
# reduce 7 omitted
|
3379
3379
|
|
3380
|
-
|
3380
|
+
def _reduce_8(val, _values, result)
|
3381
|
+
result = val[0]
|
3382
|
+
|
3383
|
+
# TODO: remove once I have more confidence this is fixed
|
3384
|
+
# result.each_of_type :call_args do |s|
|
3385
|
+
# debug20 666, s, result
|
3386
|
+
# end
|
3387
|
+
|
3388
|
+
result
|
3389
|
+
end
|
3381
3390
|
|
3382
3391
|
def _reduce_9(val, _values, result)
|
3383
3392
|
if (self.in_def || self.in_single > 0) then
|
@@ -4504,7 +4513,7 @@ end
|
|
4504
4513
|
# reduce 243 omitted
|
4505
4514
|
|
4506
4515
|
def _reduce_244(val, _values, result)
|
4507
|
-
result = val[0]
|
4516
|
+
result = args [val[0]]
|
4508
4517
|
|
4509
4518
|
result
|
4510
4519
|
end
|
@@ -4517,7 +4526,6 @@ end
|
|
4517
4526
|
|
4518
4527
|
def _reduce_246(val, _values, result)
|
4519
4528
|
result = args [array_to_hash(val[0])]
|
4520
|
-
result[0] = :array # TODO: switch to args?
|
4521
4529
|
|
4522
4530
|
result
|
4523
4531
|
end
|
@@ -4750,6 +4758,7 @@ end
|
|
4750
4758
|
|
4751
4759
|
def _reduce_291(val, _values, result)
|
4752
4760
|
result = val[1] || s(:array)
|
4761
|
+
result[0] = :array # aref_args is :args
|
4753
4762
|
|
4754
4763
|
result
|
4755
4764
|
end
|
@@ -4916,7 +4925,6 @@ end
|
|
4916
4925
|
def _reduce_318(val, _values, result)
|
4917
4926
|
self.comments.push self.lexer.comments
|
4918
4927
|
if (self.in_def || self.in_single > 0) then
|
4919
|
-
debug20 15
|
4920
4928
|
yyerror "class definition in method body"
|
4921
4929
|
end
|
4922
4930
|
self.env.extend
|
@@ -4986,20 +4994,23 @@ def _reduce_326(val, _values, result)
|
|
4986
4994
|
end
|
4987
4995
|
|
4988
4996
|
def _reduce_327(val, _values, result)
|
4997
|
+
result = [lexer.lineno, self.in_def]
|
4998
|
+
|
4989
4999
|
self.comments.push self.lexer.comments
|
4990
5000
|
self.in_def = true
|
4991
5001
|
self.env.extend
|
4992
|
-
result = lexer.lineno
|
4993
5002
|
|
4994
5003
|
result
|
4995
5004
|
end
|
4996
5005
|
|
4997
5006
|
def _reduce_328(val, _values, result)
|
5007
|
+
line, in_def = val[2]
|
5008
|
+
|
4998
5009
|
result = new_defn val
|
4999
|
-
result[2].line
|
5010
|
+
result[2].line line
|
5000
5011
|
|
5001
5012
|
self.env.unextend
|
5002
|
-
self.in_def =
|
5013
|
+
self.in_def = in_def
|
5003
5014
|
self.lexer.comments # we don't care about comments in the body
|
5004
5015
|
|
5005
5016
|
result
|
data/lib/ruby20_parser.y
CHANGED
@@ -69,6 +69,14 @@ rule
|
|
69
69
|
| error top_stmt
|
70
70
|
|
71
71
|
top_stmt: stmt
|
72
|
+
{
|
73
|
+
result = val[0]
|
74
|
+
|
75
|
+
# TODO: remove once I have more confidence this is fixed
|
76
|
+
# result.each_of_type :call_args do |s|
|
77
|
+
# debug20 666, s, result
|
78
|
+
# end
|
79
|
+
}
|
72
80
|
| klBEGIN
|
73
81
|
{
|
74
82
|
if (self.in_def || self.in_single > 0) then
|
@@ -574,7 +582,7 @@ rule
|
|
574
582
|
| tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
|
575
583
|
| tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
|
576
584
|
| tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
|
577
|
-
| tUPLUS | tUMINUS | tUBANG | tAREF | tASET | tBACK_REF2
|
585
|
+
| tUPLUS | tUMINUS | tUBANG | tAREF | tASET | tBACK_REF2
|
578
586
|
|
579
587
|
reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
|
580
588
|
| kALIAS | kAND | kBEGIN | kBREAK | kCASE
|
@@ -682,7 +690,7 @@ rule
|
|
682
690
|
{
|
683
691
|
result = new_call(new_call(s(:lit, val[1]), :"**", argl(val[3])), :"-@")
|
684
692
|
debug20 12, val, result
|
685
|
-
}
|
693
|
+
}
|
686
694
|
| tUPLUS arg
|
687
695
|
{
|
688
696
|
result = new_call val[1], :"+@"
|
@@ -790,7 +798,7 @@ rule
|
|
790
798
|
aref_args: none
|
791
799
|
| args trailer
|
792
800
|
{
|
793
|
-
result = val[0]
|
801
|
+
result = args [val[0]]
|
794
802
|
}
|
795
803
|
| args tCOMMA assocs trailer
|
796
804
|
{
|
@@ -799,7 +807,6 @@ rule
|
|
799
807
|
| assocs trailer
|
800
808
|
{
|
801
809
|
result = args [array_to_hash(val[0])]
|
802
|
-
result[0] = :array # TODO: switch to args?
|
803
810
|
}
|
804
811
|
|
805
812
|
paren_args: tLPAREN2 opt_call_args rparen
|
@@ -964,6 +971,7 @@ rule
|
|
964
971
|
| tLBRACK aref_args tRBRACK
|
965
972
|
{
|
966
973
|
result = val[1] || s(:array)
|
974
|
+
result[0] = :array # aref_args is :args
|
967
975
|
}
|
968
976
|
| tLBRACE assoc_list tRCURLY
|
969
977
|
{
|
@@ -1077,7 +1085,6 @@ rule
|
|
1077
1085
|
{
|
1078
1086
|
self.comments.push self.lexer.comments
|
1079
1087
|
if (self.in_def || self.in_single > 0) then
|
1080
|
-
debug20 15
|
1081
1088
|
yyerror "class definition in method body"
|
1082
1089
|
end
|
1083
1090
|
self.env.extend
|
@@ -1129,18 +1136,21 @@ rule
|
|
1129
1136
|
}
|
1130
1137
|
| kDEF fname
|
1131
1138
|
{
|
1139
|
+
result = [lexer.lineno, self.in_def]
|
1140
|
+
|
1132
1141
|
self.comments.push self.lexer.comments
|
1133
1142
|
self.in_def = true
|
1134
1143
|
self.env.extend
|
1135
|
-
result = lexer.lineno
|
1136
1144
|
}
|
1137
1145
|
f_arglist bodystmt kEND
|
1138
1146
|
{
|
1147
|
+
line, in_def = val[2]
|
1148
|
+
|
1139
1149
|
result = new_defn val
|
1140
|
-
result[2].line
|
1150
|
+
result[2].line line
|
1141
1151
|
|
1142
1152
|
self.env.unextend
|
1143
|
-
self.in_def =
|
1153
|
+
self.in_def = in_def
|
1144
1154
|
self.lexer.comments # we don't care about comments in the body
|
1145
1155
|
}
|
1146
1156
|
| kDEF singleton dot_or_colon
|
data/lib/ruby_lexer.rb
CHANGED
@@ -616,7 +616,11 @@ class RubyLexer
|
|
616
616
|
t = Regexp.escape term
|
617
617
|
x = Regexp.escape(paren) if paren && paren != "\000"
|
618
618
|
re = if qwords then
|
619
|
-
|
619
|
+
if RUBY19 then
|
620
|
+
/[^#{t}#{x}\#\0\\\s]+|./ # |. to pick up whatever
|
621
|
+
else
|
622
|
+
/[^#{t}#{x}\#\0\\\s\v]+|./ # argh. 1.8's \s doesn't pick up \v
|
623
|
+
end
|
620
624
|
else
|
621
625
|
/[^#{t}#{x}\#\0\\]+|./
|
622
626
|
end
|
data/lib/ruby_parser_extras.rb
CHANGED
@@ -111,7 +111,7 @@ class RPStringScanner < StringScanner
|
|
111
111
|
end
|
112
112
|
|
113
113
|
module RubyParserStuff
|
114
|
-
VERSION = "3.2.
|
114
|
+
VERSION = "3.2.2" unless constants.include? "VERSION" # SIGH
|
115
115
|
|
116
116
|
attr_accessor :lexer, :in_def, :in_single, :file
|
117
117
|
attr_reader :env, :comments
|
@@ -596,7 +596,7 @@ module RubyParserStuff
|
|
596
596
|
# TODO: need a test with f(&b) { } to produce warning
|
597
597
|
|
598
598
|
args ||= s(:arglist)
|
599
|
-
args[0] = :arglist if [:array, :call_args].include? args.first
|
599
|
+
args[0] = :arglist if [:args, :array, :call_args].include? args.first
|
600
600
|
args = s(:arglist, args) unless args.first == :arglist
|
601
601
|
|
602
602
|
# HACK quick hack to make this work quickly... easy to clean up above
|
@@ -655,7 +655,7 @@ module RubyParserStuff
|
|
655
655
|
end
|
656
656
|
|
657
657
|
def new_defn val
|
658
|
-
(_, line), name, args, body
|
658
|
+
(_, line), name, _, args, body, * = val
|
659
659
|
body ||= s(:nil)
|
660
660
|
|
661
661
|
result = s(:defn, name.to_sym, args)
|
@@ -916,8 +916,7 @@ module RubyParserStuff
|
|
916
916
|
|
917
917
|
args ||= s(:arglist)
|
918
918
|
|
919
|
-
|
920
|
-
args[0] = :arglist if args.first == :array
|
919
|
+
args[0] = :arglist if [:call_args, :array].include?(args[0])
|
921
920
|
args = s(:arglist, args) unless args.first == :arglist
|
922
921
|
|
923
922
|
return s(:yield, *args[1..-1])
|
@@ -1075,7 +1074,9 @@ module RubyParserStuff
|
|
1075
1074
|
raise SyntaxError, "block argument should not be given" if
|
1076
1075
|
node[0] == :block_pass
|
1077
1076
|
|
1077
|
+
node[0] = :array if node[0] == :call_args
|
1078
1078
|
node = node.last if node[0] == :array && node.size == 2
|
1079
|
+
|
1079
1080
|
# HACK matz wraps ONE of the FOUR splats in a newline to
|
1080
1081
|
# distinguish. I use paren for now. ugh
|
1081
1082
|
node = s(:svalue, node) if node[0] == :splat and not node.paren
|
data/test/test_ruby_lexer.rb
CHANGED
@@ -2231,14 +2231,6 @@ class TestRubyLexer < Minitest::Test
|
|
2231
2231
|
:tSTRING_END, nil)
|
2232
2232
|
end
|
2233
2233
|
|
2234
|
-
def test_yylex_string_pct_w_tab
|
2235
|
-
util_lex_token("%w[abc\tdef]",
|
2236
|
-
:tQWORDS_BEG, "%w[",
|
2237
|
-
:tSTRING_CONTENT, "abc\tdef",
|
2238
|
-
:tSPACE, nil,
|
2239
|
-
:tSTRING_END, nil)
|
2240
|
-
end
|
2241
|
-
|
2242
2234
|
def test_yylex_string_single
|
2243
2235
|
util_lex_token("'string'",
|
2244
2236
|
:tSTRING, "string")
|
@@ -2375,6 +2367,24 @@ class TestRubyLexer < Minitest::Test
|
|
2375
2367
|
:tFLOAT, 0.0)
|
2376
2368
|
end
|
2377
2369
|
|
2370
|
+
def test_pct_w_backslashes
|
2371
|
+
["\t", "\n", "\r", "\v", "\f"].each do |char|
|
2372
|
+
next if !RubyLexer::RUBY19 and char == "\v"
|
2373
|
+
|
2374
|
+
assert_lex("%w[foo#{char}bar]",
|
2375
|
+
s(:array, s(:str, "foo"), s(:str, "bar")),
|
2376
|
+
|
2377
|
+
:tQWORDS_BEG, "%w[", :expr_beg, 0, 0,
|
2378
|
+
:tSTRING_CONTENT, "foo", :expr_beg, 0, 0,
|
2379
|
+
:tSPACE, nil, :expr_beg, 0, 0,
|
2380
|
+
:tSTRING_CONTENT, "bar", :expr_beg, 0, 0,
|
2381
|
+
:tSPACE, nil, :expr_beg, 0, 0,
|
2382
|
+
:tSTRING_END, nil, :expr_end, 0, 0)
|
2383
|
+
end
|
2384
|
+
|
2385
|
+
# flunk "Not yet"
|
2386
|
+
end
|
2387
|
+
|
2378
2388
|
############################################################
|
2379
2389
|
|
2380
2390
|
def util_bad_token s, *args
|
data/test/test_ruby_parser.rb
CHANGED
@@ -1236,6 +1236,15 @@ module TestRubyParserShared
|
|
1236
1236
|
assert_parse rb, pt
|
1237
1237
|
end
|
1238
1238
|
|
1239
|
+
def test_aref_args_lit_assocs
|
1240
|
+
skip if ruby18
|
1241
|
+
|
1242
|
+
rb = "[1, 2 => 3]"
|
1243
|
+
pt = s(:array, s(:lit, 1), s(:hash, s(:lit, 2), s(:lit, 3)))
|
1244
|
+
|
1245
|
+
assert_parse rb, pt
|
1246
|
+
end
|
1247
|
+
|
1239
1248
|
def test_BEGIN
|
1240
1249
|
rb = "BEGIN { 42 }"
|
1241
1250
|
pt = s(:iter, s(:preexe), s(:args), s(:lit, 42))
|
@@ -1429,6 +1438,13 @@ module TestRubyParserShared
|
|
1429
1438
|
|
1430
1439
|
assert_parse rb, pt
|
1431
1440
|
end
|
1441
|
+
|
1442
|
+
def test_fubar_nesting
|
1443
|
+
err = "class definition in method body"
|
1444
|
+
|
1445
|
+
assert_syntax_error "def a; class B; end; end", err
|
1446
|
+
assert_syntax_error "def a; def b; end; class B; end; end", err
|
1447
|
+
end
|
1432
1448
|
end
|
1433
1449
|
|
1434
1450
|
module TestRubyParserShared1920
|
@@ -1667,6 +1683,13 @@ module TestRubyParserShared1920
|
|
1667
1683
|
assert_parse rb, pt
|
1668
1684
|
end
|
1669
1685
|
|
1686
|
+
def test_method_call_trailing_comma
|
1687
|
+
rb = "a.f(1,)"
|
1688
|
+
pt = s(:call, s(:call, nil, :a), :f, s(:lit, 1))
|
1689
|
+
|
1690
|
+
assert_parse rb, pt
|
1691
|
+
end
|
1692
|
+
|
1670
1693
|
def test_call_assoc_trailing_comma
|
1671
1694
|
rb = "f(1=>2,)"
|
1672
1695
|
pt = s(:call, nil, :f, s(:hash, s(:lit, 1), s(:lit, 2)))
|
@@ -1674,6 +1697,13 @@ module TestRubyParserShared1920
|
|
1674
1697
|
assert_parse rb, pt
|
1675
1698
|
end
|
1676
1699
|
|
1700
|
+
def test_method_call_assoc_trailing_comma
|
1701
|
+
rb = "a.f(1=>2,)"
|
1702
|
+
pt = s(:call, s(:call, nil, :a), :f, s(:hash, s(:lit, 1), s(:lit, 2)))
|
1703
|
+
|
1704
|
+
assert_parse rb, pt
|
1705
|
+
end
|
1706
|
+
|
1677
1707
|
def test_call_args_assoc_trailing_comma
|
1678
1708
|
rb = "f(1, 2=>3,)"
|
1679
1709
|
pt = s(:call, nil, :f, s(:lit, 1), s(:hash, s(:lit, 2), s(:lit, 3)))
|
@@ -1695,6 +1725,80 @@ module TestRubyParserShared1920
|
|
1695
1725
|
assert_parse rb, pt
|
1696
1726
|
end
|
1697
1727
|
|
1728
|
+
def test_return_call_assocs
|
1729
|
+
rb = "return y(z:1)"
|
1730
|
+
pt = s(:return, s(:call, nil, :y, s(:hash, s(:lit, :z), s(:lit, 1))))
|
1731
|
+
|
1732
|
+
assert_parse rb, pt
|
1733
|
+
|
1734
|
+
rb = "return y z:1"
|
1735
|
+
pt = s(:return, s(:call, nil, :y, s(:hash, s(:lit, :z), s(:lit, 1))))
|
1736
|
+
|
1737
|
+
assert_parse rb, pt
|
1738
|
+
|
1739
|
+
rb = "return y(z=>1)"
|
1740
|
+
pt = s(:return, s(:call, nil, :y, s(:hash, s(:call, nil, :z), s(:lit, 1))))
|
1741
|
+
|
1742
|
+
assert_parse rb, pt
|
1743
|
+
|
1744
|
+
rb = "return y :z=>1"
|
1745
|
+
pt = s(:return, s(:call, nil, :y, s(:hash, s(:lit, :z), s(:lit, 1))))
|
1746
|
+
|
1747
|
+
assert_parse rb, pt
|
1748
|
+
|
1749
|
+
rb = "return 1, :z => 1"
|
1750
|
+
pt = s(:return,
|
1751
|
+
s(:array,
|
1752
|
+
s(:lit, 1),
|
1753
|
+
s(:hash, s(:lit, :z), s(:lit, 1))))
|
1754
|
+
|
1755
|
+
assert_parse rb, pt
|
1756
|
+
|
1757
|
+
rb = "return 1, :z => 1, :w => 2"
|
1758
|
+
pt = s(:return,
|
1759
|
+
s(:array,
|
1760
|
+
s(:lit, 1),
|
1761
|
+
s(:hash, s(:lit, :z), s(:lit, 1), s(:lit, :w), s(:lit, 2))))
|
1762
|
+
|
1763
|
+
assert_parse rb, pt
|
1764
|
+
end
|
1765
|
+
|
1766
|
+
def test_yield_call_assocs
|
1767
|
+
rb = "yield y(z:1)"
|
1768
|
+
pt = s(:yield, s(:call, nil, :y, s(:hash, s(:lit, :z), s(:lit, 1))))
|
1769
|
+
|
1770
|
+
assert_parse rb, pt
|
1771
|
+
|
1772
|
+
rb = "yield y z:1"
|
1773
|
+
pt = s(:yield, s(:call, nil, :y, s(:hash, s(:lit, :z), s(:lit, 1))))
|
1774
|
+
|
1775
|
+
assert_parse rb, pt
|
1776
|
+
|
1777
|
+
rb = "yield y(z=>1)"
|
1778
|
+
pt = s(:yield, s(:call, nil, :y, s(:hash, s(:call, nil, :z), s(:lit, 1))))
|
1779
|
+
|
1780
|
+
assert_parse rb, pt
|
1781
|
+
|
1782
|
+
rb = "yield y :z=>1"
|
1783
|
+
pt = s(:yield, s(:call, nil, :y, s(:hash, s(:lit, :z), s(:lit, 1))))
|
1784
|
+
|
1785
|
+
assert_parse rb, pt
|
1786
|
+
|
1787
|
+
rb = "yield 1, :z => 1"
|
1788
|
+
pt = s(:yield,
|
1789
|
+
s(:lit, 1),
|
1790
|
+
s(:hash, s(:lit, :z), s(:lit, 1)))
|
1791
|
+
|
1792
|
+
assert_parse rb, pt
|
1793
|
+
|
1794
|
+
rb = "yield 1, :z => 1, :w => 2"
|
1795
|
+
pt = s(:yield,
|
1796
|
+
s(:lit, 1),
|
1797
|
+
s(:hash, s(:lit, :z), s(:lit, 1), s(:lit, :w), s(:lit, 2)))
|
1798
|
+
|
1799
|
+
assert_parse rb, pt
|
1800
|
+
end
|
1801
|
+
|
1698
1802
|
def test_call_assoc_new
|
1699
1803
|
rb = "f(a:3)"
|
1700
1804
|
pt = s(:call, nil, :f, s(:hash, s(:lit, :a), s(:lit, 3)))
|
@@ -1821,6 +1925,13 @@ module TestRubyParserShared1920
|
|
1821
1925
|
|
1822
1926
|
assert_parse rb, pt
|
1823
1927
|
end
|
1928
|
+
|
1929
|
+
def test_call_array_lit_inline_hash
|
1930
|
+
rb = "a([:b, :c => 1])"
|
1931
|
+
pt = s(:call, nil, :a, s(:array, s(:lit, :b), s(:hash, s(:lit, :c), s(:lit, 1))))
|
1932
|
+
|
1933
|
+
assert_parse rb, pt
|
1934
|
+
end
|
1824
1935
|
end
|
1825
1936
|
|
1826
1937
|
class TestRubyParser < Minitest::Test
|
@@ -2244,6 +2355,13 @@ class TestRuby19Parser < RubyParserTestCase
|
|
2244
2355
|
assert_parse rb, pt
|
2245
2356
|
end
|
2246
2357
|
|
2358
|
+
def test_parse_opt_call_args_lit_comma
|
2359
|
+
rb = "1[2,]"
|
2360
|
+
pt = s(:call, s(:lit, 1), :[], s(:lit, 2))
|
2361
|
+
|
2362
|
+
assert_parse rb, pt
|
2363
|
+
end
|
2364
|
+
|
2247
2365
|
def test_bug_hash_args
|
2248
2366
|
rb = "foo(:bar, baz: nil)"
|
2249
2367
|
pt = s(:call, nil, :foo,
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 3.2.
|
9
|
+
- 2
|
10
|
+
version: 3.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2013-07-
|
39
|
+
date: 2013-07-12 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sexp_processor
|
metadata.gz.sig
CHANGED
Binary file
|