com.singularsys.jep.walkers
Class PostfixTreeWalker
java.lang.Object
com.singularsys.jep.walkers.PostfixTreeWalker
- Direct Known Subclasses:
- ExpressionSerializer, PostfixEvaluator, TreeAnalyzer
public abstract class PostfixTreeWalker
- extends java.lang.Object
Base class for routines which use a non recursive tree walker strategy.
The typical recursive strategy can use a lot of stack frames
for very large expressions these can cause a stack overflow exception.
Subclasses should implement the visit methods.
to transverse the various nodes. In general these methods should not recursively walk the child nodes.
This class uses a postfix transversal scheme hence the nodes of '1+2' will be visited in the order
1,2,+.
- Author:
- Richard Morris
- See Also:
PrefixTreeWalker
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PostfixTreeWalker
public PostfixTreeWalker()
walk
protected void walk(Node top)
throws EvaluationException
- Start transversal of the expression.
- Parameters:
top
- top node for the expression
- Throws:
java.lang.Exception
EvaluationException
supressExaminingChildren
protected boolean supressExaminingChildren(Node child)
walkSubEquations
protected void walkSubEquations(Node top)
throws EvaluationException
- Throws:
EvaluationException
visit
protected abstract void visit(ASTFunNode node,
int nchildren,
int depth)
throws EvaluationException
- Throws:
EvaluationException
visit
protected abstract void visit(ASTVarNode node,
int nchildren,
int depth)
throws EvaluationException
- Throws:
EvaluationException
visit
protected abstract void visit(ASTConstant node,
int nchildren,
int depth)
throws EvaluationException
- Throws:
EvaluationException
Copyright © 2007 Singular Systems http://www.singularsys.com/jep