Class: RubyParser
- Inherits:
-
Object
show all
- Defined in:
- lib/ruby_parser.rb,
lib/ruby_parser.rb
Overview
Defined Under Namespace
Classes: Parser, SyntaxError, V20, V21, V22, V23, V24, V25, V26
Constant Summary
collapse
- VERSIONS =
[]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
12
13
14
|
# File 'lib/ruby_parser.rb', line 12
def current
@current
end
|
Class Method Details
.for_current_ruby ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/ruby_parser.rb', line 55
def self.for_current_ruby
name = "V#{RUBY_VERSION[/^\d+\.\d+/].delete "."}"
klass = if const_defined? name then
const_get name
else
latest = VERSIONS.first
warn "NOTE: RubyParser::#{name} undefined, using #{latest}."
latest
end
klass.new
end
|
.latest ⇒ Object
51
52
53
|
# File 'lib/ruby_parser.rb', line 51
def self.latest
VERSIONS.first.new
end
|
Instance Method Details
#process(s, f = "(string)", t = 10) ⇒ Object
Also known as:
parse
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/ruby_parser.rb', line 32
def process s, f = "(string)", t = 10
e = nil
VERSIONS.each do |klass|
self.current = parser = klass.new
begin
return parser.process s, f, t
rescue Racc::ParseError, RubyParser::SyntaxError => exc
e ||= exc
end
end
raise e
end
|
#reset ⇒ Object
47
48
49
|
# File 'lib/ruby_parser.rb', line 47
def reset
end
|