class Eqn::Parser

Primary parser class to convert a string equation to a tree of nodes.

Public Class Methods

parse(equation) click to toggle source
# 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