Class ExpressionTreeGenerator


  • public class ExpressionTreeGenerator
    extends Object
    Parses a string into an expression tree based on rules for arithmetic.
    • Constructor Detail

      • ExpressionTreeGenerator

        public ExpressionTreeGenerator()
    • Method Detail

      • makeExpression

        public ExpressionTreeNode makeExpression​(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 Stack<Token> infixToPostfix​(String infix)
        This method converts the String infix expression to a Stack of tokens, which are in postfix.
        Parameters:
        infix - the String to parse, as we would typically write it
        Returns:
        a stack of tokens, in postfix order