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

Raises:



8
9
10
11
12
13
14
15
16
17
# File 'lib/eqn/parser.rb', line 8

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

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

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