public class EvaluatorVisitor extends Object implements ParserVisitor
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.
| 构造器和说明 |
|---|
EvaluatorVisitor()
Constructor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
Object |
getValue(Node topNode,
Vector errorList_in,
SymbolTable symTab_in)
Returns the value of the expression as an object.
|
Object |
visit(ASTConstant node,
Object data)
Visit a constant node.
|
Object |
visit(ASTFunNode node,
Object data)
Visit a function node.
|
Object |
visit(ASTStart node,
Object data)
This method should never be called when evaluating a normal
expression.
|
Object |
visit(ASTVarNode node,
Object data)
Visit a variable node.
|
Object |
visit(SimpleNode node,
Object data)
This method should never be called when evaluation a normal
expression.
|
public Object getValue(Node topNode, Vector errorList_in, SymbolTable symTab_in) throws Exception
The errorList_in parameter is used to
add error information that may occur during the evaluation. It is not
required, and may be set to null if no error information is
needed.
The symTab parameter can be null, if no variables are expected in the expression. If a variable is found, an error is added to the error list.
An exception is thrown, if an error occurs during evaluation.
Exceptionpublic Object visit(SimpleNode node, Object data)
visit 在接口中 ParserVisitorpublic Object visit(ASTStart node, Object data)
visit 在接口中 ParserVisitorpublic Object visit(ASTFunNode node, Object data)
visit 在接口中 ParserVisitorpublic Object visit(ASTVarNode node, Object data)
visit 在接口中 ParserVisitorpublic Object visit(ASTConstant node, Object data)
visit 在接口中 ParserVisitorCopyright © 2023 onecode. All rights reserved.