class Treetop::Compiler::GrammarCompiler

def compile(source_path, target_path = source_path.gsub(/\.(treetop|tt)\Z/, '.rb'))

def compile(source_path, target_path = source_path.gsub(/\.(treetop|tt)\Z/, '.rb'))
  File.open(target_path, 'w') do |target_file|
    ruby = ruby_source(source_path)
    if ruby =~ /\A#.*\n/
      ruby.sub!(/\n/, "\n"+AUTOGENERATED+"\n\n")
    else
      ruby = AUTOGENERATED+"\n\n"+ruby
    end
    target_file.write(ruby)
  end
end