You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
468 B
Ruby
19 lines
468 B
Ruby
9 years ago
|
require 'sanitize'
|
||
|
require 'treetop'
|
||
|
|
||
|
base_path = File.expand_path(File.dirname(__FILE__))
|
||
|
require File.join(base_path, 'bristlecode_nodes.rb')
|
||
|
|
||
|
class Bristle
|
||
|
Treetop.load(File.join(File.expand_path(File.dirname(__FILE__)), 'bristlecode_parser.treetop'))
|
||
|
@@parser = BristlecodeParser.new
|
||
|
|
||
|
def self.parse(doc)
|
||
|
tree = @@parser.parse(doc)
|
||
|
if tree.nil?
|
||
|
raise Exception, "Bristlecode parse error at offset: #{@@parser.index}"
|
||
|
end
|
||
|
tree
|
||
|
end
|
||
|
end
|