Method: Eqn::Parser.parse

Defined in:
lib/eqn/parser.rb

.parse(equation) ⇒ Object

Raises:



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

def parse(equation)
  parser = EqnParser.new

  # Pass the equation over to the parser instance.
  root_node = parser.parse(equation)

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

  # Remove extraneous nodes and return tree.
  root_node.clean_tree!

  root_node
end