class RubyParser

Constants

VERSIONS

Public Class Methods

for_current_ruby() click to toggle source
# File lib/ruby_parser.rb, line 49
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() click to toggle source
# File lib/ruby_parser.rb, line 45
def self.latest
  VERSIONS.first.new
end

Public Instance Methods

parse(s, f = "(string)", t = 10)
Alias for: process
process(s, f = "(string)", t = 10) click to toggle source
# File lib/ruby_parser.rb, line 26
def process s, f = "(string)", t = 10
  e = nil
  VERSIONS.each do |klass|
    parser = klass.new
    begin
      return parser.process s, f, t
    rescue Racc::ParseError, RubyParser::SyntaxError => exc
      e = exc
    end
  end
  raise e
end
Also aliased as: parse
reset() click to toggle source
# File lib/ruby_parser.rb, line 41
def reset
  # do nothing
end