Class: Eqn::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/eqn/parser.rb

Constant Summary collapse

@@parser =
EqnParser.new

Class Method Summary collapse

Class Method Details

.parse(data) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/eqn/parser.rb', line 14

def self.parse(data)
  # Pass the data over to the parser instance.
  tree = @@parser.parse(data.downcase)

  # Raise any errors.
  fail ParseError, "Parse error at offset: #{@@parser.index}" + @@parser.failure_reason if tree.nil?

  # Remove extraneous nodes and return tree.
  clean_tree(tree)
end