|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.singularsys.jep.walkers.PostfixTreeWalker com.singularsys.jep.walkers.PostfixEvaluator
public class PostfixEvaluator
Evaluation component that avoids excessive use of the stack for large expressions. Instead of using recursion to traverse the expression tree, traversal is based on the PostfixTreeWalker.
Field Summary | |
---|---|
protected java.util.Stack<java.lang.Object> |
stack
|
Constructor Summary | |
---|---|
PostfixEvaluator()
|
Method Summary | |
---|---|
java.lang.Object |
eval(Node node)
Evaluates a sub expression. |
java.lang.Object |
evaluate(Node node)
Evaluates a node and returns and object with the value of the node. |
JepComponent |
getLightWeightInstance()
Return new PostfixEvaluator |
void |
init(Jep jep)
Initialize the component. |
protected boolean |
supressExaminingChildren(Node child)
Whether to examine the children of this nodes. |
protected void |
visit(ASTConstant node,
int nchildren,
int depth)
Visit a constant node |
protected void |
visit(ASTFunNode node,
int nchildren,
int depth)
Visit a function node |
protected void |
visit(ASTOpNode node,
int nchildren,
int depth)
Visit an operator node |
protected void |
visit(ASTVarNode node,
int nchildren,
int depth)
Visit a variable node |
Methods inherited from class com.singularsys.jep.walkers.PostfixTreeWalker |
---|
walk, walkSubEquations |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient java.util.Stack<java.lang.Object> stack
Constructor Detail |
---|
public PostfixEvaluator()
Method Detail |
---|
public java.lang.Object evaluate(Node node) throws EvaluationException
Evaluator
evaluate
in interface Evaluator
EvaluationException
- if errors occur during evaluation;protected void visit(ASTFunNode node, int nchildren, int depth) throws EvaluationException
PostfixTreeWalker
visit
in class PostfixTreeWalker
node
- the current node being visitednchildren
- number of children of the nodedepth
- depth of tree, root node is depth 1.
EvaluationException
protected void visit(ASTOpNode node, int nchildren, int depth) throws EvaluationException
PostfixTreeWalker
visit
in class PostfixTreeWalker
node
- the current node being visitednchildren
- number of children of the nodedepth
- depth of tree, root node is depth 1.
EvaluationException
protected void visit(ASTVarNode node, int nchildren, int depth)
PostfixTreeWalker
visit
in class PostfixTreeWalker
node
- the current node being visitednchildren
- number of children of the nodedepth
- depth of tree, root node is depth 1.protected void visit(ASTConstant node, int nchildren, int depth) throws EvaluationException
PostfixTreeWalker
visit
in class PostfixTreeWalker
node
- the current node being visitednchildren
- number of children of the nodedepth
- depth of tree, root node is depth 1.
EvaluationException
protected boolean supressExaminingChildren(Node child)
PostfixTreeWalker
supressExaminingChildren
in class PostfixTreeWalker
public java.lang.Object eval(Node node) throws EvaluationException
Evaluator
eval
in interface Evaluator
EvaluationException
- if errors occur during evaluation;public void init(Jep jep)
JepComponent
init
in interface JepComponent
jep
- the current Jep instancepublic JepComponent getLightWeightInstance()
getLightWeightInstance
in interface JepComponent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |