Expression tree traversal classes.
These classes implement various methods of traversing trees representing equations.
For very large equations with 10,000+ nodes the standard ParserVisitor
class
can encounter problems with stack overflows due to recursions. The PostfixTreeWalker
offers a base class for
a traversal strategy which minimises the number of stack frames
used and the PostfixEvaluator
is an evaluator which uses this strategy. These methods visit each node in postfix fashion
hence for 1+cos(x)
the nodes are visited in the order
1, x, cos, +
.
PrefixTreeWalker
is similar but visits nodes in a prefix fashion
for 1+cos(x)
the nodes are visited in the order
+, 1, cos, x
.
DoNothingVisitor
and DeepCopyVisitor
are two base classes for classes which manipulate
expressions using a standard recursive traversal. DoNothingVisitor
visits each node
in turn performing no action and returning the node.
DeepCopyVisitor
visits each node returning a copy of that node.