orc
Class OrcCompiler

java.lang.Object
  extended by orc.OrcCompiler
All Implemented Interfaces:
java.util.concurrent.Callable<Expression>

public class OrcCompiler
extends java.lang.Object
implements java.util.concurrent.Callable<Expression>

Provides Orc's compilation functions.

To use, construct with an Orc config, then invoke call()


Constructor Summary
OrcCompiler(Config config)
          Constructs an object of class OrcCompiler.
 
Method Summary
 Expression call()
          Run the compiler, using the configuration supplied to the constructor.
 Expression compileAstToOil(ASTNode astRoot)
          Translate an Orc extended AST into an OIL AST
 Expression loadOil(java.io.Reader oilReader)
          Read an OIL file into an OIL AST and resolve the sites.
 ASTNode parse(java.io.Reader sourceReader)
          Parse the Orc program text supplied by the reader into an Orc extended AST.
protected  Expression refineOilAfterCompileBeforeSave(Expression oilAst)
          Subclass hook for modifying the OIL AST before it is saved to an OIL XML file and before the OIL AST is run.
protected  Expression refineOilAfterLoadSaveBeforeDag(Expression oilAst)
          Subclass hook for modifying the OIL AST after it is loaded from an OIL XML file (or generated from source code) and before the OIL AST is run.
 void saveOil(Expression oilAst, java.io.Writer oilWriter)
          Write an OIL AST into an OIL file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrcCompiler

public OrcCompiler(Config config)
Constructs an object of class OrcCompiler.

Parameters:
config - The Orc configuration to use for compilation
Method Detail

call

public Expression call()
                throws java.io.IOException
Run the compiler, using the configuration supplied to the constructor.

Specified by:
call in interface java.util.concurrent.Callable<Expression>
Returns:
OIL AST for the compiled Orc program
Throws:
java.io.IOException
See Also:
Callable.call()

parse

public ASTNode parse(java.io.Reader sourceReader)
              throws ParsingException,
                     java.io.IOException
Parse the Orc program text supplied by the reader into an Orc extended AST.

Parameters:
sourceReader - Reader that supplies the Orc source program text
Returns:
Orc Extended AST corresponding to the supplied text
Throws:
ParsingException - If the text could not be successfully parsed
java.io.IOException - If an include file could not be read

compileAstToOil

public Expression compileAstToOil(ASTNode astRoot)
                           throws CompilationException
Translate an Orc extended AST into an OIL AST

Parameters:
astRoot - Root node of the Orc extended AST
Returns:
OIL AST corresponding to the supplied extended AST
Throws:
CompilationException - If the AST contains compilation errors

loadOil

public Expression loadOil(java.io.Reader oilReader)
                   throws java.io.IOException,
                          CompilationException
Read an OIL file into an OIL AST and resolve the sites.

Parameters:
oilReader - Reader supplying the OIL file to be loaded
Returns:
OIL AST corresponding to the file
Throws:
java.io.IOException - If the file could not be read
CompilationException - If the sites on the OIL could not be resolved

saveOil

public void saveOil(Expression oilAst,
                    java.io.Writer oilWriter)
             throws CompilationException
Write an OIL AST into an OIL file

Parameters:
oilAst - OIL AST to be saved
oilWriter - Destination for OIL file
Throws:
CompilationException - If the OIL AST could not be marshaled for saving

refineOilAfterCompileBeforeSave

protected Expression refineOilAfterCompileBeforeSave(Expression oilAst)
Subclass hook for modifying the OIL AST before it is saved to an OIL XML file and before the OIL AST is run. This hook is not called for loaded OIL XML files.

Parameters:
oilAst - OIL AST generated from Orc source text
Returns:
Refined OIL AST to be saved (and run)

refineOilAfterLoadSaveBeforeDag

protected Expression refineOilAfterLoadSaveBeforeDag(Expression oilAst)
Subclass hook for modifying the OIL AST after it is loaded from an OIL XML file (or generated from source code) and before the OIL AST is run. This hook is called for loaded OIL XML files.

Parameters:
oilAst - OIL AST read from file or compiled from text
Returns:
Refined OIL AST to be run