|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.control.ProcessingUnit org.codehaus.groovy.control.SourceUnit
public class SourceUnit extends ProcessingUnit
Provides an anchor for a single source unit (usually a script file) as it passes through the compiler system.
Field Summary | |
---|---|
protected ModuleNode |
ast
The root of the Abstract Syntax Tree for the source |
protected Reduction |
cst
A Concrete Syntax Tree of the source |
protected java.lang.String |
name
A descriptive name of the source unit. |
protected ReaderSource |
source
Where we can get Readers for our source unit |
Fields inherited from class ProcessingUnit | |
---|---|
classLoader, configuration, errorCollector, phase, phaseComplete |
Constructor Summary | |
SourceUnit(java.lang.String name, ReaderSource source, CompilerConfiguration flags, GroovyClassLoader loader, ErrorCollector er)
Initializes the SourceUnit from existing machinery. |
|
SourceUnit(java.io.File source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
Initializes the SourceUnit from the specified file. |
|
SourceUnit(java.net.URL source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
Initializes the SourceUnit from the specified URL. |
|
SourceUnit(java.lang.String name, java.lang.String source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
Initializes the SourceUnit for a string of source. |
Method Summary | |
---|---|
void
|
addError(SyntaxException se)
|
void
|
addException(java.lang.Exception e)
This method adds an exception to the error collector. |
void
|
convert()
Generates an AST from the CST. |
static SourceUnit
|
create(java.lang.String name, java.lang.String source)
A convenience routine to create a standalone SourceUnit on a String with defaults for almost everything that is configurable. |
static SourceUnit
|
create(java.lang.String name, java.lang.String source, int tolerance)
A convenience routine to create a standalone SourceUnit on a String with defaults for almost everything that is configurable. |
boolean
|
failedWithUnexpectedEOF()
Convenience routine, primarily for use by the InteractiveShell, that returns true if parse() failed with an unexpected EOF. |
ModuleNode
|
getAST()
Returns the Abstract Syntax Tree produced during convert()ing and expanded during later phases. |
Reduction
|
getCST()
Returns the Concrete Syntax Tree produced during parse()ing. |
java.lang.String
|
getName()
Returns the name for the SourceUnit. |
java.lang.String
|
getSample(int line, int column, Janitor janitor)
|
ReaderSource
|
getSource()
|
protected boolean
|
isEofToken(antlr.Token token)
|
void
|
parse()
Parses the source to a CST. |
Methods inherited from class ProcessingUnit | |
---|---|
completePhase, configure, getClassLoader, getConfiguration, getErrorCollector, getPhase, getPhaseDescription, gotoPhase, nextPhase, setClassLoader, setConfiguration |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
protected ModuleNode ast
protected Reduction cst
protected java.lang.String name
protected ReaderSource source
Constructor Detail |
---|
public SourceUnit(java.lang.String name, ReaderSource source, CompilerConfiguration flags, GroovyClassLoader loader, ErrorCollector er)
public SourceUnit(java.io.File source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
public SourceUnit(java.net.URL source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
public SourceUnit(java.lang.String name, java.lang.String source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
Method Detail |
---|
public void addError(SyntaxException se)
public void addException(java.lang.Exception e)
e
- the exception that occurred
public void convert()
public static SourceUnit create(java.lang.String name, java.lang.String source)
public static SourceUnit create(java.lang.String name, java.lang.String source, int tolerance)
public boolean failedWithUnexpectedEOF()
public ModuleNode getAST()
public Reduction getCST()
public java.lang.String getName()
public java.lang.String getSample(int line, int column, Janitor janitor)
public ReaderSource getSource()
protected boolean isEofToken(antlr.Token token)
public void parse()
Groovy Documentation