ruby_parser 3.0.1 → 3.0.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.
Potentially problematic release.
This version of ruby_parser might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/History.txt +21 -0
- data/Rakefile +8 -1
- data/bin/ruby_parse_extract_error +5 -4
- data/lib/ruby19_parser.rb +7 -3
- data/lib/ruby19_parser.y +7 -3
- data/lib/ruby_lexer.rb +10 -9
- data/lib/ruby_parser_extras.rb +12 -8
- data/test/test_ruby_parser.rb +112 -34
- metadata +10 -10
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
=== 3.0.2 / 2012-11-21
|
2
|
+
|
3
|
+
52 down makes 99.9767% or 3.7σ. 130 files failed to parse out of 558k.
|
4
|
+
|
5
|
+
* 4 minor enhancements:
|
6
|
+
|
7
|
+
* Added RP_TIMEOUT env var to override default timeout of 10 seconds.
|
8
|
+
* Minor optimization to RubyLexer#parse_number
|
9
|
+
* Only output parseerror output to stderr if $DEBUG.
|
10
|
+
* ruby_parse_extract_error modified to include 'it' blocks in its search.
|
11
|
+
|
12
|
+
* 7 bug fixes:
|
13
|
+
|
14
|
+
* 1.9: Fixed args in dot-call forms (eg f.(...)).
|
15
|
+
* 1.9: Fixed lexing stabby lambda w/ do/end
|
16
|
+
* Deal better with DOS files. Ugh.
|
17
|
+
* Fix line number of production after heredoc.
|
18
|
+
* Fixed RubyParser#process to reuse parser instances across calls.
|
19
|
+
* Fixed line numbers for several productions.
|
20
|
+
* new_call sets line number to smallest line number of members.
|
21
|
+
|
1
22
|
=== 3.0.1 / 2012-11-02
|
2
23
|
|
3
24
|
* 2 bug fixes -- both based on MRI bugs... Yay?:
|
data/Rakefile
CHANGED
@@ -144,6 +144,7 @@ task :debug => :isolate do
|
|
144
144
|
|
145
145
|
$: << "lib"
|
146
146
|
require 'ruby_parser'
|
147
|
+
require 'pp'
|
147
148
|
|
148
149
|
parser = if ENV["V"] == "18" then
|
149
150
|
Ruby18Parser.new
|
@@ -151,6 +152,8 @@ task :debug => :isolate do
|
|
151
152
|
Ruby19Parser.new
|
152
153
|
end
|
153
154
|
|
155
|
+
time = (ENV["RP_TIMEOUT"] || 10).to_i
|
156
|
+
|
154
157
|
file = ENV["F"] || ENV["FILE"]
|
155
158
|
|
156
159
|
ruby = if file then
|
@@ -161,7 +164,7 @@ task :debug => :isolate do
|
|
161
164
|
end
|
162
165
|
|
163
166
|
begin
|
164
|
-
|
167
|
+
pp parser.process(ruby, file, time)
|
165
168
|
rescue Racc::ParseError => e
|
166
169
|
p e
|
167
170
|
ss = parser.lexer.src
|
@@ -185,4 +188,8 @@ task :extract => :isolate do
|
|
185
188
|
ruby "-Ilib", "bin/ruby_parse_extract_error", file
|
186
189
|
end
|
187
190
|
|
191
|
+
task :bugs do
|
192
|
+
sh "for f in bug*.rb ; do rake debug F=$f && rm $f ; done"
|
193
|
+
end
|
194
|
+
|
188
195
|
# vim: syntax=Ruby
|
@@ -21,7 +21,7 @@ class Racc::Parser
|
|
21
21
|
src = ss.string
|
22
22
|
pre_error = src[0...ss.pos]
|
23
23
|
|
24
|
-
defs = pre_error.grep(/^ *def/)
|
24
|
+
defs = pre_error.grep(/^ *(?:def|it)/)
|
25
25
|
|
26
26
|
raise "can't figure out where the bad code starts" unless defs.last
|
27
27
|
|
@@ -34,7 +34,7 @@ class Racc::Parser
|
|
34
34
|
|
35
35
|
src = pre_error + post_error[0..idx+$&.length]
|
36
36
|
|
37
|
-
src.scan(/^(( *)def .*?^\2end)/m)
|
37
|
+
src.scan(/^(( *)(?:def|it) .*?^\2end)/m)
|
38
38
|
end
|
39
39
|
|
40
40
|
def retest_for_errors defs
|
@@ -56,7 +56,7 @@ def expand path
|
|
56
56
|
files << f if File.file? f
|
57
57
|
end
|
58
58
|
|
59
|
-
files
|
59
|
+
files.sort
|
60
60
|
else
|
61
61
|
Dir.glob path
|
62
62
|
end
|
@@ -86,10 +86,11 @@ end
|
|
86
86
|
|
87
87
|
def process file
|
88
88
|
ruby = file == "-" ? $stdin.read : File.read(file)
|
89
|
+
time = (ENV["RP_TIMEOUT"] || 10).to_i
|
89
90
|
|
90
91
|
$stderr.print "# Validating #{file}: "
|
91
92
|
parser = Ruby19Parser.new
|
92
|
-
parser.process(ruby, file)
|
93
|
+
parser.process(ruby, file, time)
|
93
94
|
warn "good"
|
94
95
|
File.unlink file if $d
|
95
96
|
rescue Timeout::Error
|
data/lib/ruby19_parser.rb
CHANGED
@@ -4740,13 +4740,15 @@ def _reduce_322(val, _values, result)
|
|
4740
4740
|
self.comments.push self.lexer.comments
|
4741
4741
|
self.in_def = true
|
4742
4742
|
self.env.extend
|
4743
|
-
result = lexer.lineno
|
4743
|
+
result = lexer.lineno
|
4744
4744
|
|
4745
4745
|
result
|
4746
4746
|
end
|
4747
4747
|
|
4748
4748
|
def _reduce_323(val, _values, result)
|
4749
4749
|
result = new_defn val
|
4750
|
+
result[2].line val[2]
|
4751
|
+
|
4750
4752
|
self.env.unextend
|
4751
4753
|
self.in_def = false
|
4752
4754
|
|
@@ -4764,12 +4766,14 @@ def _reduce_325(val, _values, result)
|
|
4764
4766
|
self.in_single += 1
|
4765
4767
|
self.env.extend
|
4766
4768
|
lexer.lex_state = :expr_end # force for args
|
4769
|
+
result = lexer.lineno
|
4767
4770
|
|
4768
4771
|
result
|
4769
4772
|
end
|
4770
4773
|
|
4771
4774
|
def _reduce_326(val, _values, result)
|
4772
4775
|
result = new_defs val
|
4776
|
+
result[3].line val[5]
|
4773
4777
|
|
4774
4778
|
self.env.unextend
|
4775
4779
|
self.in_single -= 1
|
@@ -5209,13 +5213,13 @@ def _reduce_408(val, _values, result)
|
|
5209
5213
|
end
|
5210
5214
|
|
5211
5215
|
def _reduce_409(val, _values, result)
|
5212
|
-
result = new_call val[0], :call
|
5216
|
+
result = new_call val[0], :call, val[2]
|
5213
5217
|
|
5214
5218
|
result
|
5215
5219
|
end
|
5216
5220
|
|
5217
5221
|
def _reduce_410(val, _values, result)
|
5218
|
-
result = new_call val[0], :call
|
5222
|
+
result = new_call val[0], :call, val[2]
|
5219
5223
|
|
5220
5224
|
result
|
5221
5225
|
end
|
data/lib/ruby19_parser.y
CHANGED
@@ -1109,11 +1109,13 @@ rule
|
|
1109
1109
|
self.comments.push self.lexer.comments
|
1110
1110
|
self.in_def = true
|
1111
1111
|
self.env.extend
|
1112
|
-
result = lexer.lineno
|
1112
|
+
result = lexer.lineno
|
1113
1113
|
}
|
1114
1114
|
f_arglist bodystmt kEND
|
1115
1115
|
{
|
1116
1116
|
result = new_defn val
|
1117
|
+
result[2].line val[2]
|
1118
|
+
|
1117
1119
|
self.env.unextend
|
1118
1120
|
self.in_def = false
|
1119
1121
|
}
|
@@ -1127,10 +1129,12 @@ rule
|
|
1127
1129
|
self.in_single += 1
|
1128
1130
|
self.env.extend
|
1129
1131
|
lexer.lex_state = :expr_end # force for args
|
1132
|
+
result = lexer.lineno
|
1130
1133
|
}
|
1131
1134
|
f_arglist bodystmt kEND
|
1132
1135
|
{
|
1133
1136
|
result = new_defs val
|
1137
|
+
result[3].line val[5]
|
1134
1138
|
|
1135
1139
|
self.env.unextend
|
1136
1140
|
self.in_single -= 1
|
@@ -1452,11 +1456,11 @@ rule
|
|
1452
1456
|
}
|
1453
1457
|
| primary_value tDOT paren_args
|
1454
1458
|
{
|
1455
|
-
result = new_call val[0], :call
|
1459
|
+
result = new_call val[0], :call, val[2]
|
1456
1460
|
}
|
1457
1461
|
| primary_value tCOLON2 paren_args
|
1458
1462
|
{
|
1459
|
-
result = new_call val[0], :call
|
1463
|
+
result = new_call val[0], :call, val[2]
|
1460
1464
|
}
|
1461
1465
|
| kSUPER paren_args
|
1462
1466
|
{
|
data/lib/ruby_lexer.rb
CHANGED
@@ -279,12 +279,12 @@ class RubyLexer
|
|
279
279
|
case
|
280
280
|
when src.scan(/[+-]?0[xXbBdD]\b/) then
|
281
281
|
rb_compile_error "Invalid numeric format"
|
282
|
+
when src.scan(/[+-]?(?:(?:[1-9][\d_]*|0)(?!\.\d)\b|0[Dd][0-9_]+)/) then
|
283
|
+
int_with_base(10)
|
282
284
|
when src.scan(/[+-]?0x[a-f0-9_]+/i) then
|
283
285
|
int_with_base(16)
|
284
286
|
when src.scan(/[+-]?0[Bb][01_]+/) then
|
285
287
|
int_with_base(2)
|
286
|
-
when src.scan(/[+-]?0[Dd][0-9_]+/) then
|
287
|
-
int_with_base(10)
|
288
288
|
when src.scan(/[+-]?0[Oo]?[0-7_]*[89]/) then
|
289
289
|
rb_compile_error "Illegal octal digit."
|
290
290
|
when src.scan(/[+-]?0[Oo]?[0-7_]+|0[Oo]/) then
|
@@ -298,9 +298,7 @@ class RubyLexer
|
|
298
298
|
end
|
299
299
|
self.yacc_value = number.to_f
|
300
300
|
:tFLOAT
|
301
|
-
when src.scan(/[+-]?0
|
302
|
-
int_with_base(10)
|
303
|
-
when src.scan(/[+-]?[\d_]+\b/) then
|
301
|
+
when src.scan(/[+-]?[0-9_]+(?![e])/) then
|
304
302
|
int_with_base(10)
|
305
303
|
else
|
306
304
|
rb_compile_error "Bad number format"
|
@@ -1233,7 +1231,7 @@ class RubyLexer
|
|
1233
1231
|
return process_token(command_state)
|
1234
1232
|
end
|
1235
1233
|
elsif src.check(/\_/) then
|
1236
|
-
if src.beginning_of_line? && src.scan(/\__END__(\n|\Z)/) then
|
1234
|
+
if src.beginning_of_line? && src.scan(/\__END__(\r?\n|\Z)/) then
|
1237
1235
|
self.lineno = nil
|
1238
1236
|
return RubyLexer::EOF
|
1239
1237
|
elsif src.scan(/\_\w*/) then
|
@@ -1380,13 +1378,16 @@ class RubyLexer
|
|
1380
1378
|
|
1381
1379
|
if keyword.id0 == :kDO then
|
1382
1380
|
self.command_start = true
|
1383
|
-
|
1384
|
-
return :kDO_BLOCK if cmdarg.is_in_state && state != :expr_cmdarg
|
1385
|
-
return :kDO_BLOCK if state == :expr_endarg
|
1381
|
+
|
1386
1382
|
if defined?(@hack_expects_lambda) && @hack_expects_lambda
|
1387
1383
|
@hack_expects_lambda = false
|
1388
1384
|
return :kDO_LAMBDA
|
1389
1385
|
end
|
1386
|
+
|
1387
|
+
return :kDO_COND if cond.is_in_state
|
1388
|
+
return :kDO_BLOCK if cmdarg.is_in_state && state != :expr_cmdarg
|
1389
|
+
return :kDO_BLOCK if state == :expr_endarg
|
1390
|
+
|
1390
1391
|
return :kDO
|
1391
1392
|
end
|
1392
1393
|
|
data/lib/ruby_parser_extras.rb
CHANGED
@@ -78,7 +78,7 @@ class RPStringScanner < StringScanner
|
|
78
78
|
|
79
79
|
def unread_many str # TODO: remove this entirely - we should not need it
|
80
80
|
warn({:unread_many => caller[0]}.inspect) if ENV['TALLY']
|
81
|
-
self.extra_lines_added += str.count("\n")
|
81
|
+
self.extra_lines_added += str.count("\n") - 1
|
82
82
|
begin
|
83
83
|
string[charpos, 0] = str
|
84
84
|
rescue IndexError
|
@@ -108,7 +108,7 @@ class RPStringScanner < StringScanner
|
|
108
108
|
end
|
109
109
|
|
110
110
|
module RubyParserStuff
|
111
|
-
VERSION = '3.0.
|
111
|
+
VERSION = '3.0.2' unless constants.include? "VERSION" # SIGH
|
112
112
|
|
113
113
|
attr_accessor :lexer, :in_def, :in_single, :file
|
114
114
|
attr_reader :env, :comments
|
@@ -355,6 +355,8 @@ module RubyParserStuff
|
|
355
355
|
end
|
356
356
|
end
|
357
357
|
|
358
|
+
result.line(result.line - 1) if result.line and lexer.src.bol?
|
359
|
+
|
358
360
|
raise "identifier #{id.inspect} is not valid" unless result
|
359
361
|
|
360
362
|
result
|
@@ -517,7 +519,6 @@ module RubyParserStuff
|
|
517
519
|
|
518
520
|
def new_call recv, meth, args = nil
|
519
521
|
result = s(:call, recv, meth)
|
520
|
-
result.line = recv.line if recv
|
521
522
|
|
522
523
|
# TODO: need a test with f(&b) to produce block_pass
|
523
524
|
# TODO: need a test with f(&b) { } to produce warning
|
@@ -529,6 +530,9 @@ module RubyParserStuff
|
|
529
530
|
# HACK quick hack to make this work quickly... easy to clean up above
|
530
531
|
result.concat args[1..-1]
|
531
532
|
|
533
|
+
line = result.grep(Sexp).map(&:line).compact.min
|
534
|
+
result.line = line if line
|
535
|
+
|
532
536
|
result
|
533
537
|
end
|
534
538
|
|
@@ -1046,7 +1050,7 @@ module RubyParserStuff
|
|
1046
1050
|
end
|
1047
1051
|
|
1048
1052
|
def yyerror msg
|
1049
|
-
warn msg
|
1053
|
+
warn msg if $DEBUG
|
1050
1054
|
super()
|
1051
1055
|
end
|
1052
1056
|
|
@@ -1054,8 +1058,8 @@ module RubyParserStuff
|
|
1054
1058
|
super
|
1055
1059
|
rescue Racc::ParseError => e
|
1056
1060
|
# I don't like how the exception obscures the error message
|
1057
|
-
|
1058
|
-
warn
|
1061
|
+
e.message.replace "%s:%p :: %s" % [self.file, lexer.lineno, e.message.strip]
|
1062
|
+
warn e.message if $DEBUG
|
1059
1063
|
raise
|
1060
1064
|
end
|
1061
1065
|
|
@@ -1286,9 +1290,9 @@ class RubyParser
|
|
1286
1290
|
end
|
1287
1291
|
|
1288
1292
|
def process(s, f = "(string)") # parens for emacs *sigh*
|
1289
|
-
|
1293
|
+
@p19.process s, f
|
1290
1294
|
rescue Racc::ParseError
|
1291
|
-
|
1295
|
+
@p18.process s, f
|
1292
1296
|
end
|
1293
1297
|
|
1294
1298
|
alias :parse :process
|
data/test/test_ruby_parser.rb
CHANGED
@@ -12,6 +12,18 @@ $: << File.expand_path('~/Work/p4/zss/src/sexp_processor/dev/lib')
|
|
12
12
|
|
13
13
|
require 'pt_testcase'
|
14
14
|
|
15
|
+
class Sexp
|
16
|
+
alias oldeq2 ==
|
17
|
+
def ==(obj) # :nodoc:
|
18
|
+
if obj.class == self.class then
|
19
|
+
super and
|
20
|
+
(self.line.nil? or obj.line.nil? or self.line == obj.line)
|
21
|
+
else
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
class RubyParserTestCase < ParseTreeTestCase
|
16
28
|
attr_accessor :result, :processor
|
17
29
|
|
@@ -41,21 +53,18 @@ class RubyParserTestCase < ParseTreeTestCase
|
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
44
|
-
assert_equal emsg, e.message
|
56
|
+
assert_equal emsg, e.message
|
45
57
|
end
|
46
58
|
|
47
59
|
def assert_parse_error rb, emsg
|
48
60
|
e = nil
|
49
|
-
|
61
|
+
assert_silent do
|
50
62
|
e = assert_raises Racc::ParseError do
|
51
63
|
processor.parse rb
|
52
64
|
end
|
53
65
|
end
|
54
66
|
|
55
|
-
assert_equal
|
56
|
-
assert_match(/parse error on value/, err)
|
57
|
-
|
58
|
-
assert_equal emsg, e.message.strip # TODO: why strip?
|
67
|
+
assert_equal emsg, e.message
|
59
68
|
end
|
60
69
|
|
61
70
|
def assert_parse_line rb, pt, line
|
@@ -545,21 +554,8 @@ module TestRubyParserShared
|
|
545
554
|
end
|
546
555
|
|
547
556
|
STARTING_LINE = {
|
548
|
-
"
|
549
|
-
"case_no_expr" => 2,
|
550
|
-
"case_splat" => 2,
|
551
|
-
"dstr_heredoc_expand" => 1,
|
552
|
-
"dstr_heredoc_windoze_sucks" => 1,
|
553
|
-
"dstr_heredoc_yet_again" => 1,
|
554
|
-
"str_heredoc" => 1,
|
555
|
-
"str_heredoc_call" => 1,
|
556
|
-
"str_heredoc_empty" => 1,
|
557
|
-
"str_heredoc_indent" => 1,
|
557
|
+
"case_no_expr" => 2, # TODO this should be 1
|
558
558
|
"structure_unused_literal_wwtt" => 3, # yes, 3... odd test
|
559
|
-
"undef_block_1" => 2,
|
560
|
-
"undef_block_2" => 2,
|
561
|
-
"undef_block_3" => 2,
|
562
|
-
"undef_block_wtf" => 2,
|
563
559
|
}
|
564
560
|
|
565
561
|
def after_process_hook klass, node, data, input_name, output_name
|
@@ -663,9 +659,12 @@ module TestRubyParserShared
|
|
663
659
|
puts string
|
664
660
|
CODE
|
665
661
|
|
666
|
-
|
667
|
-
|
668
|
-
|
662
|
+
pt = s(:block,
|
663
|
+
s(:lasgn, :string,
|
664
|
+
s(:str, " very long string\n").line(1)).line(1),
|
665
|
+
s(:call, nil, :puts, s(:lvar, :string).line(4)).line(4)).line(1)
|
666
|
+
|
667
|
+
assert_parse rb, pt
|
669
668
|
end
|
670
669
|
|
671
670
|
def test_parse_line_newlines
|
@@ -879,6 +878,68 @@ module TestRubyParserShared
|
|
879
878
|
|
880
879
|
assert_parse rb, pt
|
881
880
|
end
|
881
|
+
|
882
|
+
def test_i_fucking_hate_line_numbers
|
883
|
+
rb = <<-EOM.gsub(/^ {6}/, '')
|
884
|
+
def a
|
885
|
+
p 1
|
886
|
+
a.b 2
|
887
|
+
c.d 3, 4
|
888
|
+
e.f 5
|
889
|
+
g.h 6, 7
|
890
|
+
p(1)
|
891
|
+
a.b(2)
|
892
|
+
c.d(3, 4)
|
893
|
+
e.f(5)
|
894
|
+
g.h(6, 7)
|
895
|
+
end
|
896
|
+
EOM
|
897
|
+
|
898
|
+
pt = s(:defn, :a, s(:args).line(2),
|
899
|
+
s(:call, nil, :p, s(:lit, 1).line(2)).line(2),
|
900
|
+
s(:call, s(:call, nil, :a).line(3), :b,
|
901
|
+
s(:lit, 2).line(3)).line(3),
|
902
|
+
s(:call, s(:call, nil, :c).line(4), :d,
|
903
|
+
s(:lit, 3).line(4), s(:lit, 4).line(4)).line(4),
|
904
|
+
s(:call, s(:call, nil, :e).line(5), :f,
|
905
|
+
s(:lit, 5).line(5)).line(5),
|
906
|
+
s(:call, s(:call, nil, :g).line(6), :h,
|
907
|
+
s(:lit, 6).line(6), s(:lit, 7).line(6)).line(6),
|
908
|
+
s(:call, nil, :p, s(:lit, 1).line(7)).line(7),
|
909
|
+
s(:call, s(:call, nil, :a).line(8), :b,
|
910
|
+
s(:lit, 2).line(8)).line(8),
|
911
|
+
s(:call, s(:call, nil, :c).line(9), :d,
|
912
|
+
s(:lit, 3).line(9), s(:lit, 4).line(9)).line(9),
|
913
|
+
s(:call, s(:call, nil, :e).line(10), :f,
|
914
|
+
s(:lit, 5).line(10)).line(10),
|
915
|
+
s(:call, s(:call, nil, :g).line(11), :h,
|
916
|
+
s(:lit, 6).line(11), s(:lit, 7).line(11)).line(11)
|
917
|
+
).line(1)
|
918
|
+
|
919
|
+
assert_parse rb, pt
|
920
|
+
end
|
921
|
+
|
922
|
+
def test_i_fucking_hate_line_numbers2
|
923
|
+
rb = <<-EOM.gsub(/^ {6}/, '')
|
924
|
+
def a
|
925
|
+
p('a')
|
926
|
+
b = 1
|
927
|
+
p b
|
928
|
+
c =1
|
929
|
+
end
|
930
|
+
a
|
931
|
+
EOM
|
932
|
+
|
933
|
+
pt = s(:block,
|
934
|
+
s(:defn, :a, s(:args).line(2),
|
935
|
+
s(:call, nil, :p, s(:str, "a").line(2)).line(2),
|
936
|
+
s(:lasgn, :b, s(:lit, 1).line(3)).line(3),
|
937
|
+
s(:call, nil, :p, s(:lvar, :b).line(4)).line(4),
|
938
|
+
s(:lasgn, :c, s(:lit, 1).line(5)).line(5)).line(1),
|
939
|
+
s(:call, nil, :a).line(7)).line(1)
|
940
|
+
|
941
|
+
assert_parse rb, pt
|
942
|
+
end
|
882
943
|
end
|
883
944
|
|
884
945
|
class TestRubyParser < MiniTest::Unit::TestCase
|
@@ -889,13 +950,10 @@ class TestRubyParser < MiniTest::Unit::TestCase
|
|
889
950
|
rb = "while false : 42 end"
|
890
951
|
pt = s(:while, s(:false), s(:lit, 42), true)
|
891
952
|
|
892
|
-
|
953
|
+
assert_silent do
|
893
954
|
assert_equal pt, processor.parse(rb)
|
894
955
|
end
|
895
956
|
|
896
|
-
assert_empty out
|
897
|
-
assert_match(/parse error on value .:/, err)
|
898
|
-
|
899
957
|
# 1.9 only syntax
|
900
958
|
rb = "a.()"
|
901
959
|
pt = s(:call, s(:call, nil, :a), :call)
|
@@ -909,7 +967,7 @@ class TestRubyParser < MiniTest::Unit::TestCase
|
|
909
967
|
end
|
910
968
|
end
|
911
969
|
|
912
|
-
msg = "parse error on value \"(\" (tLPAREN2)"
|
970
|
+
msg = "(string):1 :: parse error on value \"(\" (tLPAREN2)"
|
913
971
|
assert_equal msg, e.message.strip
|
914
972
|
end
|
915
973
|
end
|
@@ -1186,13 +1244,13 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1186
1244
|
def test_do_colon_19
|
1187
1245
|
rb = "while false : 42 end"
|
1188
1246
|
|
1189
|
-
assert_parse_error rb, "parse error on value \":\" (tCOLON)"
|
1247
|
+
assert_parse_error rb, "(string):1 :: parse error on value \":\" (tCOLON)"
|
1190
1248
|
end
|
1191
1249
|
|
1192
1250
|
def test_assoc_list_19
|
1193
1251
|
rb = "{1, 2, 3, 4}"
|
1194
1252
|
|
1195
|
-
assert_parse_error rb, "parse error on value \",\" (tCOMMA)"
|
1253
|
+
assert_parse_error rb, "(string):1 :: parse error on value \",\" (tCOMMA)"
|
1196
1254
|
end
|
1197
1255
|
|
1198
1256
|
def test_case_then_colon_19
|
@@ -1203,19 +1261,19 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1203
1261
|
end
|
1204
1262
|
EOM
|
1205
1263
|
|
1206
|
-
assert_parse_error rb, "parse error on value \":\" (tCOLON)"
|
1264
|
+
assert_parse_error rb, "(string):2 :: parse error on value \":\" (tCOLON)"
|
1207
1265
|
end
|
1208
1266
|
|
1209
1267
|
def test_parse_def_xxx1
|
1210
1268
|
rb = 'def f(a, *b, c = nil) end'
|
1211
1269
|
|
1212
|
-
assert_parse_error rb, 'parse error on value "=" (tEQL)'
|
1270
|
+
assert_parse_error rb, '(string):1 :: parse error on value "=" (tEQL)'
|
1213
1271
|
end
|
1214
1272
|
|
1215
1273
|
def test_parse_def_xxx2
|
1216
1274
|
rb = 'def f(a = nil, *b, c = nil) end'
|
1217
1275
|
|
1218
|
-
assert_parse_error rb, 'parse error on value "=" (tEQL)'
|
1276
|
+
assert_parse_error rb, '(string):1 :: parse error on value "=" (tEQL)'
|
1219
1277
|
end
|
1220
1278
|
|
1221
1279
|
def test_parse_until_not_canonical
|
@@ -1411,7 +1469,7 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1411
1469
|
def test_motherfuckin_leading_dots2
|
1412
1470
|
rb = "a\n..b"
|
1413
1471
|
|
1414
|
-
assert_parse_error rb, 'parse error on value ".." (tDOT2)'
|
1472
|
+
assert_parse_error rb, '(string):2 :: parse error on value ".." (tDOT2)'
|
1415
1473
|
end
|
1416
1474
|
|
1417
1475
|
def test_kill_me
|
@@ -1656,4 +1714,24 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1656
1714
|
|
1657
1715
|
assert_parse rb, pt
|
1658
1716
|
end
|
1717
|
+
|
1718
|
+
def test_lambda_do_vs_brace
|
1719
|
+
pt = s(:call, nil, :f, s(:iter, s(:call, nil, :lambda), 0))
|
1720
|
+
|
1721
|
+
rb = "f ->() {}"
|
1722
|
+
assert_parse rb, pt
|
1723
|
+
|
1724
|
+
rb = "f ->() do end"
|
1725
|
+
assert_parse rb, pt
|
1726
|
+
end
|
1727
|
+
|
1728
|
+
def test_thingy
|
1729
|
+
pt = s(:call, s(:call, nil, :f), :call, s(:lit, 42))
|
1730
|
+
|
1731
|
+
rb = "f.(42)"
|
1732
|
+
assert_parse rb, pt
|
1733
|
+
|
1734
|
+
rb = "f::(42)"
|
1735
|
+
assert_parse rb, pt
|
1736
|
+
end
|
1659
1737
|
end
|
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: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 3.0.
|
9
|
+
- 2
|
10
|
+
version: 3.0.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: 2012-11-
|
39
|
+
date: 2012-11-21 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sexp_processor
|
@@ -61,11 +61,11 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
64
|
+
hash: 31
|
65
65
|
segments:
|
66
66
|
- 4
|
67
|
-
-
|
68
|
-
version: "4.
|
67
|
+
- 2
|
68
|
+
version: "4.2"
|
69
69
|
type: :development
|
70
70
|
version_requirements: *id002
|
71
71
|
- !ruby/object:Gem::Dependency
|
@@ -107,11 +107,11 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
hash:
|
110
|
+
hash: 1
|
111
111
|
segments:
|
112
112
|
- 3
|
113
|
-
-
|
114
|
-
version: "3.
|
113
|
+
- 3
|
114
|
+
version: "3.3"
|
115
115
|
type: :development
|
116
116
|
version_requirements: *id005
|
117
117
|
description: |-
|
metadata.gz.sig
CHANGED
Binary file
|