org.lsmp.djep.xjep
Class XEvaluatorVisitor
java.lang.Object
org.nfunk.jep.EvaluatorVisitor
org.lsmp.djep.xjep.XEvaluatorVisitor
- All Implemented Interfaces:
- ParserVisitor
- public class XEvaluatorVisitor
- extends EvaluatorVisitor
This class is used for the evaluation of an expression. It uses the Visitor
design pattern to traverse the function tree and evaluate the expression
using a stack.
Function nodes are evaluated by first evaluating all the children nodes,
then applying the function class associated with the node. Variable and
constant nodes are evaluated by pushing their value onto the stack.
Some changes implemented by rjm. Nov 03.
Added hook to SpecialEvaluationI.
Clears stack before evaluation.
Simplifies error handeling by making visit methods throw ParseException.
Changed visit(ASTVarNode node) so messages not calculated every time.
Method Summary |
java.lang.Object |
visit(ASTVarNode node,
java.lang.Object data)
Visit a variable node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XEvaluatorVisitor
public XEvaluatorVisitor()
- Constructor. Initialize the stack member
visit
public java.lang.Object visit(ASTVarNode node,
java.lang.Object data)
throws ParseException
- Visit a variable node. The value of the variable is obtained from the
symbol table (symTab) and pushed onto the stack.
- Specified by:
visit
in interface ParserVisitor
- Overrides:
visit
in class EvaluatorVisitor
- Throws:
ParseException
http://www.singularsys.com/jep Copyright © 2004 Singular Systems