ruby_parser 3.13.0 → 3.15.0
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.tar.gz.sig +0 -0
- data/.autotest +18 -29
- data/History.rdoc +123 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +3 -3
- data/Rakefile +41 -24
- data/bin/ruby_parse +3 -1
- data/bin/ruby_parse_extract_error +18 -35
- data/compare/normalize.rb +43 -3
- data/debugging.md +39 -0
- data/lib/rp_extensions.rb +1 -1
- data/lib/ruby20_parser.rb +3654 -3466
- data/lib/ruby20_parser.y +504 -327
- data/lib/ruby21_parser.rb +3643 -3455
- data/lib/ruby21_parser.y +512 -334
- data/lib/ruby22_parser.rb +3669 -3492
- data/lib/ruby22_parser.y +513 -335
- data/lib/ruby23_parser.rb +3692 -3499
- data/lib/ruby23_parser.y +513 -335
- data/lib/ruby24_parser.rb +3685 -3463
- data/lib/ruby24_parser.y +517 -331
- data/lib/ruby25_parser.rb +3685 -3462
- data/lib/ruby25_parser.y +517 -331
- data/lib/ruby26_parser.rb +3696 -3471
- data/lib/ruby26_parser.y +523 -335
- data/lib/ruby27_parser.rb +7224 -0
- data/lib/ruby27_parser.y +2657 -0
- data/lib/ruby_lexer.rb +611 -495
- data/lib/ruby_lexer.rex +27 -28
- data/lib/ruby_lexer.rex.rb +71 -31
- data/lib/ruby_parser.rb +31 -27
- data/lib/ruby_parser.yy +529 -336
- data/lib/ruby_parser_extras.rb +720 -449
- data/test/test_ruby_lexer.rb +1560 -1412
- data/test/test_ruby_parser.rb +2611 -1912
- data/test/test_ruby_parser_extras.rb +39 -4
- data/tools/munge.rb +12 -6
- data/tools/ripper.rb +19 -3
- metadata +25 -18
- metadata.gz.sig +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1172d3be0aa30a6d959bd6ab265a6e05b391923196ec30236705637f8b05cc0
|
4
|
+
data.tar.gz: bedbe7c23eb256413a34d9b5dc67d975c70a8757edea6b22cebfcb82fb42d412
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e3174ada892182f6f60497feaa74668517e71bcffd44b10590f9c2fc153ba1744dbb8afd35493d1f7cb96598795e30505c922c2e53e441cbb1a7a646e9005ef
|
7
|
+
data.tar.gz: 2cab3beeefb45cba366c482e862bb2594169560f8920d39b28a7a86ad5c6c6582393fe91e082cd6387314f36ae5e660d8e18c2de8a4ddcefce9d40600593f795
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.autotest
CHANGED
@@ -7,20 +7,20 @@ require 'autotest/rcov' if ENV['RCOV']
|
|
7
7
|
Autotest.add_hook :initialize do |at|
|
8
8
|
at.extra_files << "../../sexp_processor/dev/lib/pt_testcase.rb"
|
9
9
|
at.libs << ":../../sexp_processor/dev/lib"
|
10
|
-
at.add_exception "unit"
|
11
|
-
at.add_exception "coverage"
|
12
|
-
at.add_exception "coverage.info"
|
13
10
|
at.add_exception ".diff"
|
11
|
+
at.add_exception ".rdoc"
|
12
|
+
at.add_exception ".yml"
|
13
|
+
at.add_exception ".txt"
|
14
14
|
at.add_exception ".output"
|
15
|
-
at.add_exception "
|
16
|
-
at.add_exception "
|
17
|
-
at.add_exception "
|
18
|
-
at.add_exception "
|
19
|
-
at.add_exception "
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
at.add_exception "bin"
|
16
|
+
at.add_exception "compare"
|
17
|
+
at.add_exception "coverage"
|
18
|
+
at.add_exception "coverage.info"
|
19
|
+
at.add_exception "misc"
|
20
|
+
|
21
|
+
Dir["lib/ruby??_parser.{rb,y}"].each do |f|
|
22
|
+
at.add_exception f
|
23
|
+
end
|
24
24
|
|
25
25
|
Dir["gauntlet*"].each do |f|
|
26
26
|
at.add_exception f
|
@@ -30,12 +30,12 @@ Autotest.add_hook :initialize do |at|
|
|
30
30
|
at.testlib = "minitest/autorun"
|
31
31
|
|
32
32
|
at.add_mapping(/^lib\/.*\.y$/) do |f, _|
|
33
|
-
g = File.basename(f, ".y").gsub("_", "_?").gsub(/
|
33
|
+
g = File.basename(f, ".y").gsub("_", "_?").gsub(/2\d/, '')
|
34
34
|
at.files_matching %r%^test/.*#{g}.rb$%
|
35
35
|
end
|
36
36
|
|
37
37
|
at.add_mapping(/^lib\/.*\.yy$/) do |f, _|
|
38
|
-
g = File.basename(f, ".yy").gsub("_", "_?")
|
38
|
+
g = File.basename(f, ".yy").gsub("_", "_?")
|
39
39
|
at.files_matching %r%^test/.*#{g}.rb$%
|
40
40
|
end
|
41
41
|
|
@@ -52,27 +52,16 @@ Autotest.add_hook :initialize do |at|
|
|
52
52
|
at.files_matching(/test_.*rb$/)
|
53
53
|
end
|
54
54
|
|
55
|
-
%w(TestEnvironment TestStackState).each do |klass|
|
55
|
+
%w(TestEnvironment TestStackState TestValueExpr).each do |klass|
|
56
56
|
at.extra_class_map[klass] = "test/test_ruby_parser_extras.rb"
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
|
-
|
59
|
+
Dir["lib/ruby??_parser.rb"].each do |s|
|
60
|
+
n = s[/\d+/]
|
61
|
+
at.extra_class_map["TestRubyParserV#{n}"] = "test/test_ruby_parser.rb"
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
64
65
|
Autotest.add_hook :run_command do |at, _|
|
65
66
|
system "rake parser lexer DEBUG=1"
|
66
67
|
end
|
67
|
-
|
68
|
-
class Autotest
|
69
|
-
def ruby
|
70
|
-
File.expand_path "~/.multiruby/install/1.9.3-p194/bin/ruby"
|
71
|
-
end
|
72
|
-
end if ENV["R19"]
|
73
|
-
|
74
|
-
class Autotest
|
75
|
-
def ruby
|
76
|
-
File.expand_path "~/.multiruby/install/2.0.0-p195/bin/ruby"
|
77
|
-
end
|
78
|
-
end if ENV["R20"]
|
data/History.rdoc
CHANGED
@@ -1,3 +1,126 @@
|
|
1
|
+
=== 3.15.0 / 2020-08-31
|
2
|
+
|
3
|
+
* 1 major enhancement:
|
4
|
+
|
5
|
+
* Added tentative 2.7 support.
|
6
|
+
|
7
|
+
* 1 minor enhancement:
|
8
|
+
|
9
|
+
* Improved ruby_parse_extract_error's handling of moving slow files out.
|
10
|
+
|
11
|
+
* 22 bug fixes:
|
12
|
+
|
13
|
+
* Bumped ruby version to include 3.0 (trunk).
|
14
|
+
* Fix an error related to empty ensure bodies. (presidentbeef)
|
15
|
+
* Fix handling of bad magic encoding comment.
|
16
|
+
* Fixed SystemStackError when parsing a huoooge hash, caused by a splat arg.
|
17
|
+
* Fixed a number of errors parsing do blocks in strange edge cases.
|
18
|
+
* Fixed a string backslash lexing bug when the string is an invalid encoding. (nijikon, gmcgibbon)
|
19
|
+
* Fixed bug assigning line number to some arg nodes.
|
20
|
+
* Fixed bug concatinating string literals with differing encodings.
|
21
|
+
* Fixed bug lexing heredoc w/ nasty mix of \r\n and \n.
|
22
|
+
* Fixed bug lexing multiple codepoints in \u{0000 1111 2222} forms.
|
23
|
+
* Fixed bug setting line numbers in empty xstrings in some contexts.
|
24
|
+
* Fixed edge case on call w/ begin + do block as an arg.
|
25
|
+
* Fixed handling of UTF BOM.
|
26
|
+
* Fixed handling of lexer state across string interpolation braces.
|
27
|
+
* Fixed infinite loop when lexing backslash+cr+newline (aka dos-files)
|
28
|
+
* Fixed lambda + do block edge case.
|
29
|
+
* Fixed lexing of some ?\M... and ?\C... edge cases.
|
30
|
+
* Fixed more do/brace block edge case failures.
|
31
|
+
* Fixed parsing bug where splat was used in the middle of a list.
|
32
|
+
* Fixed parsing of interpolation in heredoc-like strings. (presidentbeef)
|
33
|
+
* Fixed parsing some esoteric edge cases in op_asgn.
|
34
|
+
* Fixed unicode processing in ident chars so now they better mix.
|
35
|
+
|
36
|
+
=== 3.14.2 / 2020-02-06
|
37
|
+
|
38
|
+
* 1 minor enhancement:
|
39
|
+
|
40
|
+
* Cleaned up call_args and removed arg_blk_pass from ruby_parser_extras.rb! Yay!
|
41
|
+
|
42
|
+
=== 3.14.1 / 2019-10-29
|
43
|
+
|
44
|
+
* 1 minor enhancement:
|
45
|
+
|
46
|
+
* Declared that ruby_parser supports ruby 2.2 and up.
|
47
|
+
|
48
|
+
* 3 bug fixes:
|
49
|
+
|
50
|
+
* Fixed a problem with %W with a null-byte terminator. (wtf?) (spohlenz)
|
51
|
+
* Fixed line numbering for command (eg methods without parentheses) arguments. (mvz)
|
52
|
+
* Fixed lineno on new dxstrs. (presidentbeef)
|
53
|
+
|
54
|
+
=== 3.14.0 / 2019-09-24
|
55
|
+
|
56
|
+
* 8 minor enhancements:
|
57
|
+
|
58
|
+
* Added Sexp#line_min & new line number debugging feature.
|
59
|
+
* Allow bin/ruby_parse to use RP_TIMEOUT to tweak default timeout for large files & slow debugging modes.
|
60
|
+
* Did you know that custom inspect can't be > 65 chars? 65! Me neither. Fixed.
|
61
|
+
* For now, value_expr == remove_begin.
|
62
|
+
* Improved error messages for unterminated regexps.
|
63
|
+
* Moved all STR_* consts into State::Values and made them State instances.
|
64
|
+
* Overhauled RubyLexer::State + Values to allow for completely separate groups of States.
|
65
|
+
* RubyParserExtras#remove_begin removes nested begins and patches line numbers.
|
66
|
+
|
67
|
+
* 22 bug fixes:
|
68
|
+
|
69
|
+
* Changed EOF signaling to return [false, false] per doco.
|
70
|
+
* Changed RubyParserStuff#remove_begin to keep inner line number, if any. (mvz)
|
71
|
+
* Differentiated between lambda call and stabby proc. Added :lambda sexp. (whitequark)
|
72
|
+
* Extended State#== to check equal? first as an optimization.
|
73
|
+
* Fixed a bug in tab indent width.
|
74
|
+
* Fixed a line numbering bug for assignables.
|
75
|
+
* Fixed a line numbering bug for defns w/ nil bodies.
|
76
|
+
* Fixed another missing line number, driven out by ruby_to_ruby bootstrap.
|
77
|
+
* Fixed dedenting squiggle heredocs if interpolation is in the mix. (mvz)
|
78
|
+
* Fixed differentiation of `{ |a| ... }` vs `{ |a,| ... }`. Fixes #236 (whitequark).
|
79
|
+
* Fixed lex_state for symbols.
|
80
|
+
* Fixed lex_state for tSTRING_END and tREGEXP_END.
|
81
|
+
* Fixed line numbers for BEGIN block. (mvz)
|
82
|
+
* Fixed op_asgn1 w/ command_call having array instead of arglist. (mvz)
|
83
|
+
* Fixed parsing of () in a command-call (eg p).
|
84
|
+
* Fixed remaining missing line numbers by forcing extra checks during test and blowing up. They may still be wrong (esp after heredocs, ugh), but they're there! Special thank you to mvz for pushing on this and providing tests and PRs.
|
85
|
+
* Fixed some lex_state versioning issues with closing braces/bracket on ruby<25.
|
86
|
+
* Keep carriage return escapes in heredocs. (mvz)
|
87
|
+
* Massive overhaul of line number code.
|
88
|
+
* More line number fixes and extra tests from mvz. Thank you!
|
89
|
+
* Parsing BEGIN block when not at top level should raise an error. (mvz)
|
90
|
+
* Removed irb task from Rakefile as it has been pushed up to Hoe and doubles up here.
|
91
|
+
|
92
|
+
=== 3.13.1 / 2019-03-25
|
93
|
+
|
94
|
+
* 1 major enhancement:
|
95
|
+
|
96
|
+
* Overhauled RubyLexer#lex_state to allow for multi-state value.
|
97
|
+
|
98
|
+
* 5 minor enhancements:
|
99
|
+
|
100
|
+
* Added RubyParser#current so scripts can poke around inside.
|
101
|
+
* Cleaned up and modernized bin/ruby_parse_extract_error.
|
102
|
+
* Removed RubyLexer#in_lex_state? in favor of State#=~ and #==.
|
103
|
+
* Renamed RubyLexer#in_arg_state? to is_after_operator?.
|
104
|
+
* Replaced all use of :expr_<*> symbols w/ bitfields.
|
105
|
+
|
106
|
+
* 15 bug fixes:
|
107
|
+
|
108
|
+
* Added tests to show #233 already fixed.
|
109
|
+
* Fixed a lexer state bug dealing with complex edge case in hash key w/ interpolated symbol and an array value. Not a great fix. (presidentbeef)
|
110
|
+
* Fixed a number of lex_state check problems.
|
111
|
+
* Fixed alias and undef keyword data.
|
112
|
+
* Fixed bug normalizing to utf-8 on tail of dstr (post-interpolation). (mvz)
|
113
|
+
* Fixed handling of hex chars for bare unicode escape. (mvz)
|
114
|
+
* Fixed handling of invalid string octals more gracefully. Needs generalization.
|
115
|
+
* Fixed lexing of regexps w/ backslashed unicode. I hope.
|
116
|
+
* Fixed parse_percent for EXPR_FITEM edge cases. Fixed bug #125.
|
117
|
+
* Fixed parsing of op_asgn on constants (eg ::X ||= 1).
|
118
|
+
* Fixed precedence of rescue modifier on assignments. (mvz/whitequark)
|
119
|
+
* Fixed some EXPR_FNAME edge cases.
|
120
|
+
* Fixed using unicode in gvars. Fixed bug 202. (331299)
|
121
|
+
* Handle invalid string literals more gracefully.
|
122
|
+
* Minor fix lexing %s[]
|
123
|
+
|
1
124
|
=== 3.13.0 / 2019-03-12
|
2
125
|
|
3
126
|
* 3 major enhancements:
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -7,9 +7,9 @@ rdoc :: http://docs.seattlerb.org/ruby_parser
|
|
7
7
|
== DESCRIPTION:
|
8
8
|
|
9
9
|
ruby_parser (RP) is a ruby parser written in pure ruby (utilizing
|
10
|
-
racc--which does by default use a C extension).
|
11
|
-
|
12
|
-
|
10
|
+
racc--which does by default use a C extension). It outputs
|
11
|
+
s-expressions which can be manipulated and converted back to ruby via
|
12
|
+
the ruby2ruby gem.
|
13
13
|
|
14
14
|
As an example:
|
15
15
|
|
data/Rakefile
CHANGED
@@ -8,12 +8,13 @@ Hoe.plugin :racc
|
|
8
8
|
Hoe.plugin :isolate
|
9
9
|
Hoe.plugin :rdoc
|
10
10
|
|
11
|
-
Hoe.add_include_dirs
|
11
|
+
Hoe.add_include_dirs "lib"
|
12
12
|
Hoe.add_include_dirs "../../sexp_processor/dev/lib"
|
13
13
|
Hoe.add_include_dirs "../../minitest/dev/lib"
|
14
14
|
Hoe.add_include_dirs "../../oedipus_lex/dev/lib"
|
15
15
|
|
16
|
-
V2 = %w[20 21 22 23 24 25 26]
|
16
|
+
V2 = %w[20 21 22 23 24 25 26 27]
|
17
|
+
V2.replace [V2.last] if ENV["FAST"] # HACK
|
17
18
|
|
18
19
|
Hoe.spec "ruby_parser" do
|
19
20
|
developer "Ryan Davis", "ryand-ruby@zenspider.com"
|
@@ -24,6 +25,8 @@ Hoe.spec "ruby_parser" do
|
|
24
25
|
dependency "rake", "< 11", :developer
|
25
26
|
dependency "oedipus_lex", "~> 2.5", :developer
|
26
27
|
|
28
|
+
require_ruby_version [">= 2.1", "< 3.1"]
|
29
|
+
|
27
30
|
if plugin? :perforce then # generated files
|
28
31
|
V2.each do |n|
|
29
32
|
self.perforce_ignore << "lib/ruby#{n}_parser.rb"
|
@@ -54,6 +57,8 @@ end
|
|
54
57
|
|
55
58
|
file "lib/ruby_lexer.rex.rb" => "lib/ruby_lexer.rex"
|
56
59
|
|
60
|
+
task :generate => [:lexer, :parser]
|
61
|
+
|
57
62
|
task :clean do
|
58
63
|
rm_rf(Dir["**/*~"] +
|
59
64
|
Dir["diff.diff"] + # not all diffs. bit me too many times
|
@@ -73,10 +78,6 @@ task :huh? do
|
|
73
78
|
puts "ruby #{Hoe::RUBY_FLAGS} bin/ruby_parse -q -g ..."
|
74
79
|
end
|
75
80
|
|
76
|
-
task :irb => [:isolate] do
|
77
|
-
sh "GEM_HOME=#{Gem.path.first} irb -rubygems -Ilib -rruby_parser;"
|
78
|
-
end
|
79
|
-
|
80
81
|
def (task(:phony)).timestamp
|
81
82
|
Time.at 0
|
82
83
|
end
|
@@ -107,7 +108,7 @@ def ruby_parse version
|
|
107
108
|
ruby_dir = "ruby-#{version}"
|
108
109
|
diff = "diff#{v}.diff"
|
109
110
|
rp_out = "lib/ruby#{v}_parser.output"
|
110
|
-
|
111
|
+
_rp_y = "lib/ruby#{v}_parser.y"
|
111
112
|
rp_y_rb = "lib/ruby#{v}_parser.rb"
|
112
113
|
|
113
114
|
c_diff = "compare/#{diff}"
|
@@ -125,13 +126,22 @@ def ruby_parse version
|
|
125
126
|
|
126
127
|
file c_parse_y => c_tarball do
|
127
128
|
in_compare do
|
128
|
-
|
129
|
+
extract_glob = case version
|
130
|
+
when /2\.7/
|
131
|
+
"{id.h,parse.y,tool/{id2token.rb,lib/vpath.rb}}"
|
132
|
+
else
|
133
|
+
"{id.h,parse.y,tool/{id2token.rb,vpath.rb}}"
|
134
|
+
end
|
135
|
+
system "tar yxf #{tarball} #{ruby_dir}/#{extract_glob}"
|
136
|
+
|
129
137
|
Dir.chdir ruby_dir do
|
130
138
|
if File.exist? "tool/id2token.rb" then
|
131
139
|
sh "ruby tool/id2token.rb --path-separator=.:./ id.h parse.y | expand > ../#{parse_y}"
|
132
140
|
else
|
133
141
|
sh "expand parse.y > ../#{parse_y}"
|
134
142
|
end
|
143
|
+
|
144
|
+
ruby "-pi", "-e", 'gsub(/^%define\s+api\.pure/, "%pure-parser")', "../#{parse_y}"
|
135
145
|
end
|
136
146
|
sh "rm -rf #{ruby_dir}"
|
137
147
|
end
|
@@ -180,22 +190,21 @@ def ruby_parse version
|
|
180
190
|
end
|
181
191
|
end
|
182
192
|
|
183
|
-
# ruby_parse "1.8.7-p374"
|
184
|
-
# ruby_parse "1.9.3-p551"
|
185
193
|
ruby_parse "2.0.0-p648"
|
186
194
|
ruby_parse "2.1.9"
|
187
195
|
ruby_parse "2.2.9"
|
188
196
|
ruby_parse "2.3.8"
|
189
|
-
ruby_parse "2.4.
|
190
|
-
ruby_parse "2.5.
|
191
|
-
ruby_parse "2.6.
|
197
|
+
ruby_parse "2.4.9"
|
198
|
+
ruby_parse "2.5.8"
|
199
|
+
ruby_parse "2.6.6"
|
200
|
+
ruby_parse "2.7.1"
|
192
201
|
|
193
202
|
task :debug => :isolate do
|
194
203
|
ENV["V"] ||= V2.last
|
195
204
|
Rake.application[:parser].invoke # this way we can have DEBUG set
|
196
205
|
Rake.application[:lexer].invoke # this way we can have DEBUG set
|
197
206
|
|
198
|
-
|
207
|
+
$:.unshift "lib"
|
199
208
|
require "ruby_parser"
|
200
209
|
require "pp"
|
201
210
|
|
@@ -206,19 +215,21 @@ task :debug => :isolate do
|
|
206
215
|
time = (ENV["RP_TIMEOUT"] || 10).to_i
|
207
216
|
|
208
217
|
n = ENV["BUG"]
|
209
|
-
file = (n && "bug#{n}.rb") || ENV["F"] || ENV["FILE"]
|
218
|
+
file = (n && "bug#{n}.rb") || ENV["F"] || ENV["FILE"] || "bug.rb"
|
219
|
+
ruby = ENV["R"] || ENV["RUBY"]
|
220
|
+
|
221
|
+
if ruby then
|
222
|
+
file = "env"
|
223
|
+
else
|
224
|
+
ruby = File.read file
|
225
|
+
end
|
210
226
|
|
211
|
-
ruby = if file then
|
212
|
-
File.read(file)
|
213
|
-
else
|
214
|
-
file = "env"
|
215
|
-
ENV["R"] || ENV["RUBY"]
|
216
|
-
end
|
217
227
|
|
218
228
|
begin
|
219
229
|
pp parser.process(ruby, file, time)
|
220
|
-
rescue Racc::ParseError => e
|
230
|
+
rescue ArgumentError, Racc::ParseError => e
|
221
231
|
p e
|
232
|
+
puts e.backtrace.join "\n "
|
222
233
|
ss = parser.lexer.ss
|
223
234
|
src = ss.string
|
224
235
|
lines = src[0..ss.pos].split(/\n/)
|
@@ -227,7 +238,7 @@ task :debug => :isolate do
|
|
227
238
|
end
|
228
239
|
|
229
240
|
task :debug3 do
|
230
|
-
file = ENV["F"]
|
241
|
+
file = ENV["F"] || "bug.rb"
|
231
242
|
verbose = ENV["V"] ? "-v" : ""
|
232
243
|
munge = "./tools/munge.rb #{verbose}"
|
233
244
|
|
@@ -235,9 +246,15 @@ task :debug3 do
|
|
235
246
|
|
236
247
|
ENV.delete "V"
|
237
248
|
|
249
|
+
sh "ruby -v"
|
238
250
|
sh "ruby -y #{file} 2>&1 | #{munge} > tmp/ruby"
|
239
251
|
sh "./tools/ripper.rb -d #{file} | #{munge} > tmp/rip"
|
240
|
-
sh "rake debug F=#{file} DEBUG=1
|
252
|
+
sh "rake debug F=#{file} DEBUG=1 2>&1 | #{munge} > tmp/rp"
|
253
|
+
sh "diff -U 999 -d tmp/{rip,rp}"
|
254
|
+
end
|
255
|
+
|
256
|
+
task :cmp do
|
257
|
+
sh %(emacsclient --eval '(ediff-files "tmp/ruby" "tmp/rp")')
|
241
258
|
end
|
242
259
|
|
243
260
|
task :cmp3 do
|
data/bin/ruby_parse
CHANGED
@@ -26,6 +26,8 @@ class File
|
|
26
26
|
end
|
27
27
|
|
28
28
|
begin
|
29
|
+
time = (ENV["RP_TIMEOUT"] || 10).to_i
|
30
|
+
|
29
31
|
ARGV.each do |file|
|
30
32
|
rp = RubyParser.new
|
31
33
|
loc = `wc -l #{file}`.strip.to_i
|
@@ -45,7 +47,7 @@ begin
|
|
45
47
|
begin
|
46
48
|
begin
|
47
49
|
rp.reset
|
48
|
-
r = rp.
|
50
|
+
r = rp.process(File.binread(file), file, time)
|
49
51
|
pp r unless $q
|
50
52
|
good += 1
|
51
53
|
rescue SyntaxError => e
|
@@ -1,44 +1,20 @@
|
|
1
1
|
#!/usr/bin/ruby -ws
|
2
2
|
|
3
|
-
$d ||= false
|
4
|
-
$
|
5
|
-
$
|
6
|
-
$
|
7
|
-
$
|
8
|
-
$m ||= ENV["MOVE_TIMEOUT"]
|
9
|
-
$q ||= false
|
10
|
-
$q ||= ENV["QUIET"]
|
11
|
-
$v ||= ENV["V"] || "20"
|
12
|
-
$s ||= ENV["SPEED"] || false
|
3
|
+
$d ||= ENV["DELETE"] || false
|
4
|
+
$t ||= ENV["DELETE_TIMEOUT"] || false
|
5
|
+
$m ||= ENV["MOVE_TIMEOUT"] || false
|
6
|
+
$q ||= ENV["QUIET"] || false
|
7
|
+
$s ||= ENV["SPEED"] || false
|
13
8
|
|
14
9
|
require 'rubygems'
|
15
10
|
require 'ruby_parser'
|
16
11
|
require 'fileutils'
|
17
12
|
|
18
|
-
$parser_class = case $v
|
19
|
-
when "18" then
|
20
|
-
Ruby18Parser
|
21
|
-
when "19" then
|
22
|
-
Ruby19Parser
|
23
|
-
when "20" then
|
24
|
-
Ruby20Parser
|
25
|
-
else
|
26
|
-
abort "Unknown version #{$v.inspect}. Needs to be 18, 19, or 20"
|
27
|
-
end
|
28
|
-
|
29
|
-
class IO
|
30
|
-
RUBY19 = "<3".respond_to? :encoding
|
31
|
-
|
32
|
-
class << self
|
33
|
-
alias :binread :read unless RUBY19
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
13
|
ARGV.push "-" if ARGV.empty?
|
38
14
|
|
39
|
-
class
|
15
|
+
class RubyParser
|
40
16
|
def extract_defs
|
41
|
-
ss = lexer.ss
|
17
|
+
ss = current.lexer.ss
|
42
18
|
|
43
19
|
raise "can't access source. possible encoding issue" unless ss
|
44
20
|
|
@@ -106,6 +82,7 @@ def process_error parser
|
|
106
82
|
end
|
107
83
|
rescue RuntimeError, Racc::ParseError => e
|
108
84
|
warn "# process error: #{e.message.strip}"
|
85
|
+
warn "# #{e.backtrace.first}"
|
109
86
|
end
|
110
87
|
|
111
88
|
def process file
|
@@ -113,7 +90,7 @@ def process file
|
|
113
90
|
time = (ENV["RP_TIMEOUT"] || 10).to_i
|
114
91
|
|
115
92
|
$stderr.print "# Validating #{file}: "
|
116
|
-
parser =
|
93
|
+
parser = RubyParser.new
|
117
94
|
t0 = Time.now if $s
|
118
95
|
parser.process(ruby, file, time)
|
119
96
|
if $s then
|
@@ -127,9 +104,14 @@ rescue Timeout::Error
|
|
127
104
|
warn "TIMEOUT parsing #{file}. Skipping."
|
128
105
|
|
129
106
|
if $m then
|
130
|
-
|
131
|
-
|
132
|
-
|
107
|
+
base_dir, *rest = file.split("/")
|
108
|
+
base_dir.sub!(/\.slow\.?.*/, "")
|
109
|
+
base_dir += ".slow.#{time}"
|
110
|
+
|
111
|
+
new_file = File.join(base_dir, *rest)
|
112
|
+
|
113
|
+
FileUtils.mkdir_p File.dirname(new_file)
|
114
|
+
FileUtils.move file, new_file, verbose:true
|
133
115
|
elsif $t then
|
134
116
|
File.unlink file
|
135
117
|
end
|
@@ -137,6 +119,7 @@ rescue StandardError, SyntaxError, Racc::ParseError => e
|
|
137
119
|
$exit = 1
|
138
120
|
warn ""
|
139
121
|
warn "# error: #{e.message.strip}" unless $q
|
122
|
+
warn "# #{e.backtrace.first}"
|
140
123
|
warn ""
|
141
124
|
return if $q
|
142
125
|
|