polyglot.visit
Class DumpAst

java.lang.Object
  extended by polyglot.visit.NodeVisitor
      extended by polyglot.visit.DumpAst

public class DumpAst
extends NodeVisitor

Visitor which dumps the AST to a file.


Field Summary
protected  java.io.Writer fw
           
protected  CodeWriter w
           
 
Constructor Summary
DumpAst(CodeWriter w)
           
DumpAst(java.lang.String name, int width)
           
 
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 polyglot.visit.NodeVisitor
begin, enter, finish, leave, override, override, toString, visitEdge
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fw

protected java.io.Writer fw

w

protected CodeWriter w
Constructor Detail

DumpAst

public DumpAst(java.lang.String name,
               int width)
        throws java.io.IOException
Throws:
java.io.IOException

DumpAst

public DumpAst(CodeWriter w)
Method Detail

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