module Treetop
def self.load(path)
def self.load(path) unless path =~ Treetop::Polyglot::VALID_GRAMMAR_EXT_REGEXP ext = Treetop::Polyglot::VALID_GRAMMAR_EXT.select {|ext| File.exist?(path+".#{ext}")}.shift path += ".#{ext}" unless ext.nil? end File.open(path) do |source_file| source = source_file.read source.gsub!(/\b__FILE__\b/, %Q{"#{path}"}) load_from_string(source) end end