module Treetop

def self.load(path)

compile a treetop source file and load it
def self.load(path)
  adjusted_path = path =~ /\.(treetop|tt)\Z/ ? path : path + '.treetop'
  File.open(adjusted_path) do |source_file|
    load_from_string(source_file.read)
  end
end

def self.load_from_string(s)

compile a treetop source string and load it
def self.load_from_string(s)
  compiler = Treetop::Compiler::GrammarCompiler.new
  Object.class_eval(compiler.ruby_source_from_string(s))
end