Class: Markdownplus::DirectiveParser

Inherits:
Object
  • Object
show all
Defined in:
lib/markdownplus/directive_parser.rb

Class Method Summary collapse

Class Method Details

.parse(data) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/markdownplus/directive_parser.rb', line 5

def self.parse(data)
  Treetop.load(File.expand_path("../directives", __FILE__))
  @@parser ||= TransformationParser.new
  tree = @@parser.parse(data)
  # If the AST is nil then there was an error during parsing
  # we need to report a simple error message to help the user
  raise "Parse error at offset: #{@@parser.index}" if(tree.nil?)

  return tree
end