org.lsmp.djep.xjep
Class XEvaluatorVisitor

java.lang.Object
  extended by org.nfunk.jep.EvaluatorVisitor
      extended by org.lsmp.djep.xjep.XEvaluatorVisitor
All Implemented Interfaces:
EvaluatorI, 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 handling 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
debug, stack, symTab, trapNullValues
 
Constructor Summary
XEvaluatorVisitor()
           
 
Method Summary
 java.lang.Object visit(ASTVarNode node, java.lang.Object data)
          Visit a variable node.
 
Methods inherited from class org.nfunk.jep.EvaluatorVisitor
eval, eval, getValue, isTrapNullValues, setTrapNullValues, 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()
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 © 2007 Singular Systems