picasso.parser
Class ExpressionTreeGenerator

java.lang.Object
  extended by picasso.parser.ExpressionTreeGenerator

public class ExpressionTreeGenerator
extends java.lang.Object

Parses a string into an expression tree based on rules for arithmetic.

Author:
former student solution, Robert C. Duvall (added comments, exceptions), Sara Sprenkle modified for Picasso

Constructor Summary
ExpressionTreeGenerator()
           
 
Method Summary
 java.util.Stack<Token> infixToPostfix(java.lang.String infix)
          This method converts the String infix expression to a Stack of tokens, which are in postfix.
 ExpressionTreeNode makeExpression(java.lang.String infix)
          Converts the given string into expression tree for easier manipulation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionTreeGenerator

public ExpressionTreeGenerator()
Method Detail

makeExpression

public ExpressionTreeNode makeExpression(java.lang.String infix)
Converts the given string into expression tree for easier manipulation.

Parameters:
infix - - a non-empty expression to parse.
Returns:
ExpressionTreeNode representing the root node of the given infix formula

infixToPostfix

public java.util.Stack<Token> infixToPostfix(java.lang.String infix)
This method converts the String infix expression to a Stack of tokens, which are in postfix.

Parameters:
infix -
Returns:
a stack of tokens, in postfix order