com.ssv.utils.parser
Class ExpressionParser<ExpressionLeaf extends com.ssv.utils.tree.BinaryTree<ExpressionLeaf>>
java.lang.Object
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
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExpressionParser
public ExpressionParser(ExpressionLeafProvider<ExpressionLeaf> provider)
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
-