ruby_parser 3.12.0 → 3.18.1
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/.autotest +18 -29
- data/History.rdoc +283 -0
- data/Manifest.txt +12 -4
- data/README.rdoc +4 -3
- data/Rakefile +189 -51
- data/bin/ruby_parse +3 -1
- data/bin/ruby_parse_extract_error +19 -36
- data/compare/normalize.rb +76 -4
- data/debugging.md +190 -0
- data/gauntlet.md +106 -0
- data/lib/rp_extensions.rb +14 -42
- data/lib/rp_stringscanner.rb +20 -51
- data/lib/ruby20_parser.rb +4659 -4218
- data/lib/ruby20_parser.y +953 -602
- data/lib/ruby21_parser.rb +4723 -4308
- data/lib/ruby21_parser.y +956 -605
- data/lib/ruby22_parser.rb +4762 -4337
- data/lib/ruby22_parser.y +960 -612
- data/lib/ruby23_parser.rb +4761 -4342
- data/lib/ruby23_parser.y +961 -613
- data/lib/ruby24_parser.rb +4791 -4341
- data/lib/ruby24_parser.y +968 -612
- data/lib/ruby25_parser.rb +4791 -4341
- data/lib/ruby25_parser.y +968 -612
- data/lib/ruby26_parser.rb +7287 -0
- data/lib/ruby26_parser.y +2749 -0
- data/lib/ruby27_parser.rb +8517 -0
- data/lib/ruby27_parser.y +3346 -0
- data/lib/ruby30_parser.rb +8751 -0
- data/lib/ruby30_parser.y +3472 -0
- data/lib/ruby3_parser.yy +3476 -0
- data/lib/ruby_lexer.rb +611 -826
- data/lib/ruby_lexer.rex +48 -40
- data/lib/ruby_lexer.rex.rb +122 -46
- data/lib/ruby_lexer_strings.rb +638 -0
- data/lib/ruby_parser.rb +38 -34
- data/lib/ruby_parser.yy +1710 -704
- data/lib/ruby_parser_extras.rb +987 -553
- data/test/test_ruby_lexer.rb +1718 -1539
- data/test/test_ruby_parser.rb +3957 -2164
- data/test/test_ruby_parser_extras.rb +39 -4
- data/tools/munge.rb +250 -0
- data/tools/ripper.rb +44 -0
- data.tar.gz.sig +0 -0
- metadata +68 -47
- metadata.gz.sig +0 -0
- data/lib/ruby18_parser.rb +0 -5793
- data/lib/ruby18_parser.y +0 -1908
- data/lib/ruby19_parser.rb +0 -6185
- data/lib/ruby19_parser.y +0 -2116
data/lib/ruby_parser.rb
CHANGED
@@ -9,32 +9,33 @@ class RubyParser
|
|
9
9
|
|
10
10
|
VERSIONS = []
|
11
11
|
|
12
|
-
|
13
|
-
include RubyParserStuff
|
12
|
+
attr_accessor :current
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
def self.for_current_ruby
|
15
|
+
name = "V#{RUBY_VERSION[/^\d+\.\d+/].delete "."}"
|
16
|
+
klass = if const_defined? name then
|
17
|
+
const_get name
|
18
|
+
else
|
19
|
+
latest = VERSIONS.first
|
20
|
+
warn "NOTE: RubyParser::#{name} undefined, using #{latest}."
|
21
|
+
latest
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
@version ||= Parser > self && self.name[/(?:V|Ruby)(\d+)/, 1].to_i
|
25
|
-
end
|
24
|
+
klass.new
|
26
25
|
end
|
27
26
|
|
28
|
-
|
27
|
+
def self.latest
|
28
|
+
VERSIONS.first.new
|
29
|
+
end
|
29
30
|
|
30
31
|
def process s, f = "(string)", t = 10
|
31
32
|
e = nil
|
32
33
|
VERSIONS.each do |klass|
|
33
|
-
parser = klass.new
|
34
|
+
self.current = parser = klass.new
|
34
35
|
begin
|
35
36
|
return parser.process s, f, t
|
36
37
|
rescue Racc::ParseError, RubyParser::SyntaxError => exc
|
37
|
-
e
|
38
|
+
e ||= exc
|
38
39
|
end
|
39
40
|
end
|
40
41
|
raise e
|
@@ -46,47 +47,50 @@ class RubyParser
|
|
46
47
|
# do nothing
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
end
|
50
|
+
class Parser < Racc::Parser
|
51
|
+
include RubyParserStuff
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
const_get name
|
57
|
-
else
|
58
|
-
latest = VERSIONS.first
|
59
|
-
warn "NOTE: RubyParser::#{name} undefined, using #{latest}."
|
60
|
-
latest
|
61
|
-
end
|
53
|
+
def self.inherited x
|
54
|
+
RubyParser::VERSIONS << x
|
55
|
+
end
|
62
56
|
|
63
|
-
|
57
|
+
def self.version= v
|
58
|
+
@version = v
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.version
|
62
|
+
@version ||= Parser > self && self.name[/(?:V|Ruby)(\d+)/, 1].to_i
|
63
|
+
end
|
64
64
|
end
|
65
|
+
|
66
|
+
class SyntaxError < RuntimeError; end
|
65
67
|
end
|
66
68
|
|
67
69
|
##
|
68
70
|
# Unfortunately a problem with racc is that it won't let me namespace
|
69
|
-
# properly, so instead of RubyParser::
|
70
|
-
# the old
|
71
|
+
# properly, so instead of RubyParser::V25, I still have to generate
|
72
|
+
# the old Ruby25Parser and shove it in as V25.
|
71
73
|
|
72
|
-
require "ruby18_parser"
|
73
|
-
require "ruby19_parser"
|
74
74
|
require "ruby20_parser"
|
75
75
|
require "ruby21_parser"
|
76
76
|
require "ruby22_parser"
|
77
77
|
require "ruby23_parser"
|
78
78
|
require "ruby24_parser"
|
79
79
|
require "ruby25_parser"
|
80
|
+
require "ruby26_parser"
|
81
|
+
require "ruby27_parser"
|
82
|
+
require "ruby30_parser"
|
80
83
|
|
81
84
|
class RubyParser # HACK
|
82
85
|
VERSIONS.clear # also a HACK caused by racc namespace issues
|
83
86
|
|
87
|
+
class V30 < ::Ruby30Parser; end
|
88
|
+
class V27 < ::Ruby27Parser; end
|
89
|
+
class V26 < ::Ruby26Parser; end
|
84
90
|
class V25 < ::Ruby25Parser; end
|
85
91
|
class V24 < ::Ruby24Parser; end
|
86
92
|
class V23 < ::Ruby23Parser; end
|
87
93
|
class V22 < ::Ruby22Parser; end
|
88
94
|
class V21 < ::Ruby21Parser; end
|
89
95
|
class V20 < ::Ruby20Parser; end
|
90
|
-
class V19 < ::Ruby19Parser; end
|
91
|
-
class V18 < ::Ruby18Parser; end
|
92
96
|
end
|