public final class PrettyPrinter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
WIDTH
The pretty printer depends on the current printing mode (LINE or BLOCK)
and the current indentation level LEVEL.
|
Constructor and Description |
---|
PrettyPrinter(int width,
java.io.PrintWriter out)
Create pretty printer to print abstract syntax trees.
|
PrettyPrinter(java.io.PrintWriter out)
Create pretty printer for default width WIDTH.
|
Modifier and Type | Method and Description |
---|---|
void |
changeLevel(boolean increase)
Change indentation level.
|
void |
newLine()
Start new (non-overflow)line and indent it appropriately.
|
void |
print(Declaration decl)
Pretty-print declaration.
|
void |
print(Expression exp)
Pretty-print expression.
|
void |
print(java.lang.String text)
Print text.
|
void |
print(Type type)
Pretty-print type.
|
void |
space()
Insert a space (or a newline at the end of the line).
|
public static final int WIDTH
public PrettyPrinter(int width, java.io.PrintWriter out)
width
- the line width (suggestion, not a hard bound).out
- the stream to print on.public PrettyPrinter(java.io.PrintWriter out)
out
- the stream to print on.public void print(Declaration decl)
decl
- a declaration.public void print(Expression exp)
exp
- an expression.public void print(Type type)
type
- a typepublic void print(java.lang.String text)
text
- the text to be printed.public void changeLevel(boolean increase)
increase
- true if level is increased (decreased otherwise)public void newLine()
public void space()