org.lsmp.djep.xjep
Class XEvaluatorVisitor

java.lang.Object
  extended byorg.nfunk.jep.EvaluatorVisitor
      extended byorg.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.


Field Summary
 
Fields inherited from class org.nfunk.jep.EvaluatorVisitor
errorFlag, errorList, stack, symTab
 
Constructor Summary
XEvaluatorVisitor()
          Constructor.
 
Method Summary
 java.lang.Object visit(ASTVarNode node, java.lang.Object data)
          Visit a variable node.
 
Methods inherited from class org.nfunk.jep.EvaluatorVisitor
addToErrorList, getValue, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XEvaluatorVisitor

public XEvaluatorVisitor()
Constructor. Initialize the stack member

Method Detail

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