polyglot.visit
Class PrettyPrinter

java.lang.Object
  extended by polyglot.visit.PrettyPrinter
Direct Known Subclasses:
StringPrettyPrinter, Translator

public class PrettyPrinter
extends java.lang.Object

A PrettyPrinter generates output code from the processed AST. Output is sent to a code writer passes into the printAst method. To use: new PrettyPrinter().printAst(node, new CodeWriter(out));


Field Summary
protected  boolean appendSemicolon
           
protected  boolean printType
           
 
Constructor Summary
PrettyPrinter()
           
 
Method Summary
 boolean appendSemicolon()
          Flag indicating whether to print a ';' after certain statements.
 boolean appendSemicolon(boolean a)
          Set a flag indicating whether to print a ';' after certain statements.
 void print(Node parent, Node child, CodeWriter w)
          Print an AST node using the given code writer.
 void printAst(Node ast, CodeWriter w)
          Print an AST node using the given code writer.
 boolean printType()
          Flag indicating whether to print the type in a local declaration.
 boolean printType(boolean a)
          Set a flag indicating whether to print type type in a local declaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

appendSemicolon

protected boolean appendSemicolon

printType

protected boolean printType
Constructor Detail

PrettyPrinter

public PrettyPrinter()
Method Detail

appendSemicolon

public boolean appendSemicolon()
Flag indicating whether to print a ';' after certain statements. This is used when pretty-printing for loops.


appendSemicolon

public boolean appendSemicolon(boolean a)
Set a flag indicating whether to print a ';' after certain statements. This is used when pretty-printing for loops.


printType

public boolean printType()
Flag indicating whether to print the type in a local declaration. This is used when pretty-printing for loops.


printType

public boolean printType(boolean a)
Set a flag indicating whether to print type type in a local declaration. This is used when pretty-printing for loops.


print

public void print(Node parent,
                  Node child,
                  CodeWriter w)
Print an AST node using the given code writer. The CodeWriter.flush() method must be called after this method to ensure code is output. Use printAst rather than this method to print the entire AST; this method should only be called by nodes to print their children.


printAst

public void printAst(Node ast,
                     CodeWriter w)
Print an AST node using the given code writer. The code writer is flushed by this method.