Package edu.cornell.cs.cs4120.util
Class CodeWriterSExpPrinter
java.lang.Object
edu.cornell.cs.cs4120.util.CodeWriterSExpPrinter
- All Implemented Interfaces:
SExpPrinter
,AutoCloseable
An SExpPrinter implementation designed to print ASTs through a provided
CodeWriter
.-
Constructor Summary
ConstructorDescriptionDeprecated.Constructs a new SExpPrinter instance that prints programs using the given writer.CodeWriterSExpPrinter
(polyglot.util.CodeWriter writer) Constructs a new SExpPrinter instance that prints programs using the givenCodeWriter
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Flushes and closes both this printer and any underlying output stream to which it is attached.void
endList()
Prints the close parenthesis of an S-expression list.void
flush()
Flushes all formatted text to the underlying writer.void
Prints an atom.protected void
protected void
startEveryList
(boolean unified) void
Prints the open parenthesis of an S-expression list.void
Prints the open parenthesis of an S-expression list, and requires that if a line break is required to separate any two elements of this list, then all elements of this list must be separated by a line break (optional operation).
-
Constructor Details
-
CodeWriterSExpPrinter
public CodeWriterSExpPrinter(polyglot.util.CodeWriter writer) Constructs a new SExpPrinter instance that prints programs using the givenCodeWriter
.- Parameters:
writer
- theCodeWriter
to print to
-
CodeWriterSExpPrinter
Constructs a new SExpPrinter instance that prints programs using the given writer. Output is kept to 80 columns if possible.- Parameters:
w
- the writer to write to
-
CodeWriterSExpPrinter
Deprecated.Constructs a new SExpPrinter instance that prints programs using the given stream. Output is kept to 80 columns if possible. Deprecated: use the previous constructor instead.- Parameters:
o
- the output stream to print to
-
-
Method Details
-
printAtom
Description copied from interface:SExpPrinter
Prints an atom.- Specified by:
printAtom
in interfaceSExpPrinter
- Parameters:
atom
- the atom to print
-
startList
public void startList()Description copied from interface:SExpPrinter
Prints the open parenthesis of an S-expression list.- Specified by:
startList
in interfaceSExpPrinter
-
startUnifiedList
public void startUnifiedList()Description copied from interface:SExpPrinter
Prints the open parenthesis of an S-expression list, and requires that if a line break is required to separate any two elements of this list, then all elements of this list must be separated by a line break (optional operation).- Specified by:
startUnifiedList
in interfaceSExpPrinter
-
startEveryList
protected void startEveryList(boolean unified) -
endList
public void endList()Description copied from interface:SExpPrinter
Prints the close parenthesis of an S-expression list.- Specified by:
endList
in interfaceSExpPrinter
-
startElement
protected void startElement() -
flush
public void flush()Description copied from interface:SExpPrinter
Flushes all formatted text to the underlying writer. This method should be called when printing is complete.- Specified by:
flush
in interfaceSExpPrinter
-
close
public void close()Description copied from interface:SExpPrinter
Flushes and closes both this printer and any underlying output stream to which it is attached. It is an error to perform any subsequent operations on the same printer.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSExpPrinter
-