Package com.singularsys.jep.walkers
Class PrefixTreeWalker
java.lang.Object
com.singularsys.jep.walkers.PrefixTreeWalker
- Direct Known Subclasses:
PrefixTreeDumper
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 of
ParserVisitor
to traverse the various nodes. In general these methods should not
recursively walk the child nodes.
This class uses a prefix traversal scheme hence the nodes of '1+2'
will be visited in the order
+,1,2.- Author:
- Richard Morris
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
visit
(ASTConstant node, int nchildren, int depth1) protected abstract void
visit
(ASTFunNode node, int nchildren, int depth1) protected abstract void
protected abstract void
visit
(ASTVarNode node, int nchildren, int depth1) void
Uses a non-recursive method to traverse the tree under the node 'top'.
-
Constructor Details
-
PrefixTreeWalker
public PrefixTreeWalker()
-
-
Method Details
-
walk
Uses a non-recursive method to traverse the tree under the node 'top'.- Parameters:
top
- the top node of the parse tree.- Throws:
JepException
-
visit
- Throws:
JepException
-
visit
- Throws:
JepException
-
visit
- Throws:
JepException
-
visit
- Throws:
JepException
-