polyglot.visit
Class DumpAst
java.lang.Object
polyglot.visit.NodeVisitor
polyglot.visit.DumpAst
public class DumpAst
- extends NodeVisitor
Visitor which dumps the AST to a file.
Method Summary |
NodeVisitor |
enter(Node n)
Visit each node before traversal of children. |
void |
finish()
The finish method is called after the entire tree has been visited. |
Node |
leave(Node old,
Node n,
NodeVisitor v)
This method is called only after normal traversal of the children. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
fw
protected java.io.Writer fw
w
protected CodeWriter w
DumpAst
public DumpAst(java.lang.String name,
int width)
throws java.io.IOException
- Throws:
java.io.IOException
DumpAst
public DumpAst(CodeWriter w)
enter
public NodeVisitor enter(Node n)
- Visit each node before traversal of children. Call
dump
for
that node. Then we begin a new CodeWriter
block and traverse
the children.
- Overrides:
enter
in class NodeVisitor
- Parameters:
n
- The root of the subtree to be traversed.
- Returns:
- The
NodeVisitor
which should be used to visit the
children of n
.
leave
public Node leave(Node old,
Node n,
NodeVisitor v)
- This method is called only after normal traversal of the children. Thus
we must end the
CodeWriter
block that was begun in
enter
.
- Overrides:
leave
in class NodeVisitor
- Parameters:
old
- The original state of root of the current subtree.n
- The current state of the root of the current subtree.v
- The NodeVisitor
object used to visit the children.
- Returns:
- The final result of the traversal of the tree rooted at
n
.
finish
public void finish()
- Description copied from class:
NodeVisitor
- The finish method is called after the entire tree has been visited.
This method allows the visitor to perform any last minute cleanup,
including flushing buffers and I/O connections.
- Overrides:
finish
in class NodeVisitor