| Modifier and Type | Field and Description |
|---|---|
| protected ModuleNode | ast
The root of the Abstract Syntax Tree for the source |
| protected Reduction | cst
A Concrete Syntax Tree of the source |
| protected String | name
A descriptive name of the source unit. |
| private ParserPlugin | parserPlugin
The pluggable parser used to generate the AST - we allow pluggability currently as we need to have Classic and JSR support |
| protected ReaderSource | source
Where we can get Readers for our source unit |
| Access | Constructor and Description |
|---|---|
| public | SourceUnit(String name, ReaderSource source, CompilerConfiguration flags, GroovyClassLoader loader, ErrorCollector er)
Initializes the SourceUnit from existing machinery. |
| public | SourceUnit(File source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
Initializes the SourceUnit from the specified file. |
| public | SourceUnit(URL source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
Initializes the SourceUnit from the specified URL. |
| public | SourceUnit(String name, String source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er)
Initializes the SourceUnit for a string of source. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addError(SyntaxException
the exception, which should have line and column information se)This method adds a SyntaxException to the error collector. |
| public void | |
| public void | addException(Exception
the exception that occurred e)This method adds an exception to the error collector. |
| public void | addFatalError(String
the error message msg, ASTNode the AST node node)Convenience wrapper for |
| public ModuleNode | |
| public void | |
| public static SourceUnit | |
| public static SourceUnit | |
| public boolean | failedWithUnexpectedEOF()
Convenience routine, primarily for use by the InteractiveShell, that returns true if parse() failed with an unexpected EOF. |
| public ModuleNode | getAST()
Returns the Abstract Syntax Tree produced during convert()ing and expanded during later phases. |
| public Reduction | |
| public String | |
| public String | |
| public ReaderSource | |
| protected boolean | |
| public void | |
| public void |
| ast | back to summary |
|---|---|
| protected ModuleNode ast The root of the Abstract Syntax Tree for the source | |
| cst | back to summary |
|---|---|
| protected Reduction cst A Concrete Syntax Tree of the source | |
| name | back to summary |
|---|---|
| protected String name A descriptive name of the source unit. This name shouldn't be used for controlling the SourceUnit, it is only for error messages and to determine the name of the class for a script. | |
| parserPlugin | back to summary |
|---|---|
| private ParserPlugin parserPlugin The pluggable parser used to generate the AST - we allow pluggability currently as we need to have Classic and JSR support | |
| source | back to summary |
|---|---|
| protected ReaderSource source Where we can get Readers for our source unit | |
| SourceUnit | back to summary |
|---|---|
| public SourceUnit(String name, ReaderSource source, CompilerConfiguration flags, GroovyClassLoader loader, ErrorCollector er) Initializes the SourceUnit from existing machinery. | |
| SourceUnit | back to summary |
|---|---|
| public SourceUnit(File source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er) Initializes the SourceUnit from the specified file. | |
| SourceUnit | back to summary |
|---|---|
| public SourceUnit(URL source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er) Initializes the SourceUnit from the specified URL. | |
| SourceUnit | back to summary |
|---|---|
| public SourceUnit(String name, String source, CompilerConfiguration configuration, GroovyClassLoader loader, ErrorCollector er) Initializes the SourceUnit for a string of source. | |
| addError | back to summary |
|---|---|
| public void addError(SyntaxException se) throws CompilationFailedException This method adds a SyntaxException to the error collector. The exception should specify the line and column number of the error. This method should be reserved for real errors in the syntax of the SourceUnit. If your error is not in syntax, and is a semantic error, or more general error, then use addException or use the error collector directly by retrieving it with getErrorCollector().
| |
| addErrorAndContinue | back to summary |
|---|---|
| public void addErrorAndContinue(SyntaxException se) throws CompilationFailedException | |
| addException | back to summary |
|---|---|
| public void addException(Exception e) throws CompilationFailedException This method adds an exception to the error collector. The Exception most likely has no line number attached to it.
For this reason you should use this method sparingly. Prefer using addError for syntax errors or add an error
to the
| |
| addFatalError | back to summary |
|---|---|
| public void addFatalError(String msg, ASTNode node) throws CompilationFailedException Convenience wrapper for
| |
| buildAST | back to summary |
|---|---|
| public ModuleNode buildAST() Builds the AST. | |
| convert | back to summary |
|---|---|
| public void convert() throws CompilationFailedException Generates an AST from the CST. You can retrieve it with getAST(). | |
| create | back to summary |
|---|---|
| public static SourceUnit create(String name, String source) A convenience routine to create a standalone SourceUnit on a String with defaults for almost everything that is configurable. | |
| create | back to summary |
|---|---|
| public static SourceUnit create(String name, String source, int tolerance) A convenience routine to create a standalone SourceUnit on a String with defaults for almost everything that is configurable. | |
| failedWithUnexpectedEOF | back to summary |
|---|---|
| public boolean failedWithUnexpectedEOF() Convenience routine, primarily for use by the InteractiveShell, that returns true if parse() failed with an unexpected EOF. | |
| getAST | back to summary |
|---|---|
| public ModuleNode getAST() Returns the Abstract Syntax Tree produced during convert()ing and expanded during later phases. | |
| getCST | back to summary |
|---|---|
| public Reduction getCST() Returns the Concrete Syntax Tree produced during parse()ing. | |
| getName | back to summary |
|---|---|
| public String getName() Returns the name for the SourceUnit. This name shouldn't be used for controlling the SourceUnit, it is only for error messages | |
| getSample | back to summary |
|---|---|
| public String getSample(int line, int column, Janitor janitor) Returns a sampling of the source at the specified line and column, or null if it is unavailable. | |
| getSource | back to summary |
|---|---|
| public ReaderSource getSource() | |
| isEofToken | back to summary |
|---|---|
| protected boolean isEofToken(Token token)
Deprecated
| |
| parse | back to summary |
|---|---|
| public void parse() throws CompilationFailedException Parses the source to a CST. You can retrieve it with getCST(). | |
| setSource | back to summary |
|---|---|
| public void setSource(ReaderSource source) | |