public final class VisitorRunner
extends java.lang.Object
The scenario to visit a parse tree is as follows:
Visitors;The order in which the nodes of a parse tree are visited depend on the
visit order that you define. By default, this will be a
postorder traversal.
When you run() the visitors, you determine an order to traverse
the node; the order is an instance of VisitOrder which, given the
root node, will generate an Iterable over all the nodes using its
visit() method.
The nodes are then fed to an EventBus, to which the visitors you
will have registered in the runner will subscribe to. When a node is posted
on the bus (see EventBus.post(Object)), the appropriate methods will
be invoked with this node as an argument.
Visitor,
VisitOrder| Constructor and Description |
|---|
VisitorRunner(ParseNode node)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
registerVisitor(Visitor visitor)
Add one visitor to this runner
|
void |
run()
Visit all nodes of the parse tree using a
postorder traversal |
void |
run(VisitOrder visitOrder)
Visit all nodes of the parse tree in a given visit order
|
public VisitorRunner(ParseNode node)
node - the node at the root of the parse treepublic void registerVisitor(Visitor visitor)
visitor - the visitorpublic void run(VisitOrder visitOrder)
visitOrder - the orderpublic void run()
postorder traversal