Sha256: d70f525b0c09f3eeb961fb3b69ada153b896b31f4235f9f6b3b6f39697e0d913
Contents?: true
Size: 631 Bytes
Versions: 7
Compression:
Stored size: 631 Bytes
Contents
module Treetop module Compiler class GrammarCompiler def compile(source_path, target_path = source_path.gsub(/treetop\Z/, 'rb')) File.open(target_path, 'w') do |target_file| target_file.write(ruby_source(source_path)) end end def ruby_source(source_path) File.open(source_path) do |source_file| result = MetagrammarParser.new.parse(source_file.read) if result.failure? raise RuntimeError.new(result.nested_failures.map {|failure| failure.to_s}.join("\n")) end result.compile end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems