org.codehaus.groovy.tools
Class Compiler

java.lang.Object
  extended byorg.codehaus.groovy.tools.Compiler

public class Compiler
extends java.lang.Object

Controls the compilation process, from source to class generation.


Constructor Summary
Compiler()
          Initializes the compiler.
 
Method Summary
protected  ModuleNode buildAST(CSTNode cst, java.lang.String descriptor)
          Creates an Abstract Syntax Tree (AST) from the CST.
 GroovyClass[] compile(CharStream source)
          Compiles a single source.
 GroovyClass[] compile(CharStream[] sources)
          Compiles a set of CharStream sources.
protected  java.util.ArrayList generateClasses(GeneratorContext context, ClassNode classNode, java.lang.String descriptor)
          Generates a class from an AST.
protected  CompilerClassLoader getClassLoader()
          Returns the compiler's class loader.
 CompilerConfig getConfig()
           
protected  CSTNode parseSource(CharStream charStream, java.lang.String descriptor)
          Parses a CharStream source, producing a Concrete Syntax Tree (CST).
 void setClasspath(java.lang.String classpath)
          Adds additional paths to the class loader's search path.
 void setConfig(CompilerConfig config)
           
 void setDebug(boolean debug)
          Controls the presence of debugging output.
 void setVerbose(boolean verbose)
          Controls the output verbosity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

public Compiler()
Initializes the compiler.

Method Detail

getClassLoader

protected CompilerClassLoader getClassLoader()
Returns the compiler's class loader.


setVerbose

public void setVerbose(boolean verbose)
Controls the output verbosity.


setDebug

public void setDebug(boolean debug)
Controls the presence of debugging output.


setClasspath

public void setClasspath(java.lang.String classpath)
                  throws java.lang.Exception
Adds additional paths to the class loader's search path.

Throws:
java.lang.Exception

getConfig

public CompilerConfig getConfig()

setConfig

public void setConfig(CompilerConfig config)

compile

public GroovyClass[] compile(CharStream source)
                      throws CompilationFailuresException,
                             CompilerBugException
Compiles a single source. Collects exceptions during processing and throws a CompilationFailuresException on error. Other exceptions are bugs that need to be caught and encapsulated.

Throws:
CompilationFailuresException
CompilerBugException

compile

public GroovyClass[] compile(CharStream[] sources)
                      throws CompilationFailuresException,
                             CompilerBugException
Compiles a set of CharStream sources. Collects exceptions during processing and throws a CompilationFailuresException on error. Other exceptions are bugs that need to be caught and encapsulated.

Throws:
CompilationFailuresException
CompilerBugException

parseSource

protected CSTNode parseSource(CharStream charStream,
                              java.lang.String descriptor)
                       throws ExceptionCollector,
                              java.lang.Exception
Parses a CharStream source, producing a Concrete Syntax Tree (CST). Lexing and parsing errors will be collected in an ExceptionCollector.

Throws:
ExceptionCollector
java.lang.Exception

buildAST

protected ModuleNode buildAST(CSTNode cst,
                              java.lang.String descriptor)
                       throws java.lang.Exception
Creates an Abstract Syntax Tree (AST) from the CST.

Throws:
java.lang.Exception

generateClasses

protected java.util.ArrayList generateClasses(GeneratorContext context,
                                              ClassNode classNode,
                                              java.lang.String descriptor)
                                       throws java.lang.Exception
Generates a class from an AST.

Throws:
java.lang.Exception


Copyright © 2003-2004 The Codehaus. All Rights Reserved.