Object
# File lib/treetop/compiler/grammar_compiler.rb, line 5
5: def compile(source_path, target_path = source_path.gsub(/\.(treetop|tt)\Z/, '.rb'))
6: File.open(target_path, 'w') do |target_file|
7: target_file.write(AUTOGENERATED+"\n\n")
8: target_file.write(ruby_source(source_path))
9: end
10: end
compile a treetop file into ruby
# File lib/treetop/compiler/grammar_compiler.rb, line 13
13: def ruby_source(source_path)
14: ruby_source_from_string(File.read(source_path))
15: end
compile a string containing treetop source into ruby
# File lib/treetop/compiler/grammar_compiler.rb, line 18
18: def ruby_source_from_string(s)
19: parser = MetagrammarParser.new
20: result = parser.parse(s)
21: unless result
22: raise RuntimeError.new(parser.failure_reason)
23: end
24: result.compile
25: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.