class RubyParserStuff::RubyParser

RubyParser is a compound parser that first attempts to parse using the 1.9 syntax parser and falls back to the 1.8 syntax parser on a parse error.

Public Class Methods

for_current_ruby() click to toggle source
# File lib/ruby_parser_extras.rb, line 1301
def self.for_current_ruby
  case RUBY_VERSION
  when /^1\.8/ then
    Ruby18Parser.new
  when /^1\.9/ then
    Ruby19Parser.new
  else
    raise "unrecognized RUBY_VERSION #{RUBY_VERSION}"
  end
end
new() click to toggle source
# File lib/ruby_parser_extras.rb, line 1283
def initialize
  @p18 = Ruby18Parser.new
  @p19 = Ruby19Parser.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_extras.rb, line 1288
def process(s, f = "(string)", t = 10) # parens for emacs *sigh*
  @p19.process s, f, t
rescue Racc::ParseError
  @p18.process s, f, t
end
Also aliased as: parse
reset() click to toggle source
# File lib/ruby_parser_extras.rb, line 1296
def reset
  @p18.reset
  @p19.reset
end