com.ssv.utils.parser
Class ExpressionParser<ExpressionLeaf extends com.ssv.utils.tree.BinaryTree<ExpressionLeaf>>

java.lang.Object
  extended by com.ssv.utils.parser.ExpressionParser<ExpressionLeaf>

public abstract class ExpressionParser<ExpressionLeaf extends com.ssv.utils.tree.BinaryTree<ExpressionLeaf>>
extends java.lang.Object

This class is a helper class to parse ariphmetic expression - PN, RPN and regular infix expressions.

Author:
Sergey Siryk

Nested Class Summary
static class ExpressionParser.IdentExpressionLeaf
           
 
Constructor Summary
ExpressionParser(ExpressionLeafProvider<ExpressionLeaf> provider)
           
 
Method Summary
abstract  boolean isLeaf(int token)
           
static void main(java.lang.String[] args)
           
 ExpressionLeaf parse(Parser parser)
          Parses the ariphmetic expression, infix notation.
abstract  ExpressionLeaf parseLeaf(Parser parser)
           
 ExpressionLeaf parsePN(Parser parser)
           
 ExpressionLeaf parseRPN(Parser parser)
           
 ExpressionLeaf simplify(ExpressionLeaf e)
          After execution, we may try to calculate something on "compile time".
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionParser

public ExpressionParser(ExpressionLeafProvider<ExpressionLeaf> provider)
Method Detail

parse

public ExpressionLeaf parse(Parser parser)
                                                                           throws java.io.IOException,
                                                                                  ParserException
Parses the ariphmetic expression, infix notation.

Throws:
java.io.IOException
ParserException

simplify

public ExpressionLeaf simplify(ExpressionLeaf e)
                                                                              throws ParserException
After execution, we may try to calculate something on "compile time".

Parameters:
parse -
Returns:
Throws:
ParserException

parseRPN

public ExpressionLeaf parseRPN(Parser parser)
                                                                              throws java.io.IOException,
                                                                                     ParserException
Throws:
java.io.IOException
ParserException

parsePN

public ExpressionLeaf parsePN(Parser parser)
                                                                             throws java.io.IOException,
                                                                                    ParserException
Throws:
java.io.IOException
ParserException

parseLeaf

public abstract ExpressionLeaf parseLeaf(Parser parser)
                                                                                        throws ParserException,
                                                                                               java.io.IOException
Throws:
ParserException
java.io.IOException

isLeaf

public abstract boolean isLeaf(int token)
                        throws ParserException,
                               java.io.IOException
Throws:
ParserException
java.io.IOException

main

public static void main(java.lang.String[] args)
Parameters:
args -