module Treetop
Autogenerated from a Treetop grammar. Edits may be lost.
Public Class Methods
load(path)
click to toggle source
compile a treetop source file and load it
# File lib/treetop/compiler/grammar_compiler.rb, line 35 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
load_from_string(s)
click to toggle source
compile a treetop source string and load it
# File lib/treetop/compiler/grammar_compiler.rb, line 48 def self.load_from_string(s) compiler = Treetop::Compiler::GrammarCompiler.new Object.class_eval(compiler.ruby_source_from_string(s)) end