Package org.codehaus.janino
Class Unparser
- java.lang.Object
-
- org.codehaus.janino.Unparser
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Unparser extends java.lang.Object implements java.lang.AutoCloseable
Unparses (un-compiles) an AST to aWriter
. Seemain(String[])
for a usage example.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.PrintWriter
pw
Where thevisit...()
methods print their text.
-
Constructor Summary
Constructors Constructor Description Unparser(java.io.Writer w)
-
Method Summary
-
-
-
Field Detail
-
pw
protected final java.io.PrintWriter pw
Where thevisit...()
methods print their text. Notice that thisPrintWriter
does not print to the output directly, but through anAutoIndentWriter
.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
Testing of parsing/unparsing.Reads compilation units from the files named on the command line and unparses them to
System.out
.- Throws:
java.lang.Exception
-
unparse
public static void unparse(Java.AbstractCompilationUnit acu, java.io.Writer w)
Unparses the givenJava.AbstractCompilationUnit
to the givenWriter
.
-
flush
public void flush()
Flushes all generated code.
-
close
public void close()
Flushes all generated code.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
unparseAbstractCompilationUnit
public void unparseAbstractCompilationUnit(Java.AbstractCompilationUnit cu)
- Parameters:
cu
- The compilation unit to unparse
-
unparseImportDeclaration
public void unparseImportDeclaration(Java.AbstractCompilationUnit.ImportDeclaration id)
-
unparseStatements
public void unparseStatements(java.util.List<? extends Java.BlockStatement> statements)
Generates Java code from a sequence ofJava.BlockStatement
s.
-
unparseLambdaParameters
public void unparseLambdaParameters(Java.LambdaParameters lp)
-
unparseLambdaBody
public void unparseLambdaBody(Java.LambdaBody body)
-
unparseBlock
public void unparseBlock(Java.Block b)
Generates Java code from aJava.Block
.
-
unparseBlockStatement
public void unparseBlockStatement(Java.BlockStatement bs)
-
unparseTypeDeclaration
public void unparseTypeDeclaration(Java.TypeDeclaration td)
-
unparseType
public void unparseType(Java.Type t)
-
unparseAtom
public void unparseAtom(Java.Atom a)
-
unparseRvalue
public void unparseRvalue(Java.Rvalue rv)
-
unparseLvalue
public void unparseLvalue(Java.Lvalue lv)
-
unparseClassDeclarationBody
public void unparseClassDeclarationBody(Java.AbstractClassDeclaration cd)
Generates Java code from aJava.AbstractClassDeclaration
.
-
-