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 1379 def self.for_current_ruby case RUBY_VERSION when /^1\.8/ then Ruby18Parser.new when /^1\.9/ then Ruby19Parser.new when /^2.0/ then Ruby20Parser.new when /^2.1/ then Ruby21Parser.new when /^2.2/ then Ruby22Parser.new else raise "unrecognized RUBY_VERSION #{RUBY_VERSION}" end end
new()
click to toggle source
# File lib/ruby_parser_extras.rb, line 1349 def initialize @p18 = Ruby18Parser.new @p19 = Ruby19Parser.new @p20 = Ruby20Parser.new @p21 = Ruby21Parser.new @p22 = Ruby22Parser.new end
Public Instance Methods
process(s, f = "(string)", t = 10)
click to toggle source
# File lib/ruby_parser_extras.rb, line 1357 def process s, f = "(string)", t = 10 e = nil [@p22, @p21, @p20, @p19, @p18].each do |parser| 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_extras.rb, line 1371 def reset @p18.reset @p19.reset @p20.reset @p21.reset @p22.reset end