public class PostfixEvaluator extends PostfixTreeWalker implements Evaluator
Modifier and Type | Field and Description |
---|---|
protected java.util.Stack<java.lang.Object> |
stack |
Constructor and Description |
---|
PostfixEvaluator() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
eval(Node node)
Evaluates a sub expression.
|
java.lang.Object |
evaluate(Node node)
Main entry point, 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
|
walk, walkSubEquations
public java.lang.Object evaluate(Node node) throws EvaluationException
Evaluator
evaluate
in interface Evaluator
node
- node to evaluateEvaluationException
- 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
CallbackEvaluationI
eval
in interface Evaluator
node
- node to evaluateEvaluationException
- 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
Copyright © 2018 Singular Systems http://www.singularsys.com/jep