uk.ac.man.cs.rainbow
Class Compiler

java.lang.Object
  |
  +--uk.ac.man.cs.rainbow.Compiler
Direct Known Subclasses:
JSCompiler, RainbowToRASM

public abstract class Compiler
extends Object

Basic operations that should be supported by a compiler. Defines a factory method to get a useable version.

See Also:
RASMCode, ProcessTerm

Inner Class Summary
static class Compiler.Error
          A single error generated by a compiler.
static class Compiler.Errors
          When there are compiler errors, this class is thrown.
static class Compiler.Exception
          Exceptions generated by the compilation stage itself.
static class Compiler.ParseError
          A single parse error generated by a compiler.
static class Compiler.PreciseError
          A precisely-located error.
static class Compiler.SemanticError
          A single semantic error generated by a compiler.
static class Compiler.Warning
          A warning.
 
Constructor Summary
protected Compiler()
          Do-nothing constructor.
 
Method Summary
static Compiler getInstance()
          Manufacture a standard compiler.
 RASMCode rainbow2code(String rainbow, Hashtable context)
          Compile and assemble Rainbow text into a block of code.
 ProcessTerm rainbow2rapa(String rainbow)
          Compile Rainbow text into a RAPA process term.
 String rainbow2rasm(String rainbow)
          Compile Rainbow text into RASM text.
abstract  String rainbow2rif(String rainbow)
          Convert Rainbow text to RIF text.
 RASMCode rasm2code(String rasm, Hashtable context)
          Assemble RASM text into a code block.
 RASMCode rif2code(String rif, Hashtable context)
          Compile and assemble RIF text into a block of code.
abstract  String rif2rasm(String rif)
          Convert RIF text to RASM text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

protected Compiler()
Do-nothing constructor. You must subclass this class.
Method Detail

getInstance

public static Compiler getInstance()
                            throws RainbowException
Manufacture a standard compiler. The name of the compiler to manufacture is given by the rainbow.compiler.class system property, and it must be a subclass of this class. If that property is unspecified, an instance of the default of JSCompiler is provided. The class must have a no-argument constructor.
Returns:
A compiler object.
Throws:
RainbowException - If things go wrong during compiler creation. Usually because of a bad compiler specification.

rainbow2rif

public abstract String rainbow2rif(String rainbow)
                            throws RainbowException
Convert Rainbow text to RIF text.
Parameters:
rainbow - The Rainbow text to convert.
Returns:
RIF text suitable for the next stage of compilation.
Throws:
RainbowException - If the conversion is impossible for some reason.

rif2rasm

public abstract String rif2rasm(String rif)
                         throws IOException,
                                RainbowException
Convert RIF text to RASM text.
Parameters:
rif - The RIF text to convert.
Returns:
RASM text suitable for assembly.
Throws:
IOException - If a compiler fails some external I/O access.
RainbowException - If something goes wrong during compilation.
Compiler.Errors - If there were semantic errors during compilation.

rasm2code

public RASMCode rasm2code(String rasm,
                          Hashtable context)
                   throws RainbowException
Assemble RASM text into a code block.
Parameters:
rasm - The RASM text to assemble.
context - The library context to assemble in.
Returns:
A block of RASM code.
Throws:
RainbowException - If the RASM text was ill-formatted, or if anything else unexpected went wrong!
See Also:
RASMCode.RASMCode(Hashtable,BufferedReader,boolean)

rainbow2code

public RASMCode rainbow2code(String rainbow,
                             Hashtable context)
                      throws IOException,
                             RainbowException
Compile and assemble Rainbow text into a block of code.
Parameters:
rainbow - The Rainbow text to convert.
context - The library context to assemble in.
Returns:
A block of RASM code.
Throws:
IOException - If some external I/O access fails unexpectedly.
RainbowException - If some internal error happens in the compilation or assembly stages.
Compiler.Errors - If there were semantic errors during compilation.
See Also:
rainbow2rif(String), rif2rasm(String), rasm2code(String,Hashtable)

rainbow2rapa

public ProcessTerm rainbow2rapa(String rainbow)
                         throws IOException,
                                RainbowException
Compile Rainbow text into a RAPA process term.
Parameters:
rainbow - The Rainbow text to convert.
Returns:
A RAPA process term with the calls bound to their definitions.
Throws:
IOException - If some external I/O access fails unexpectedly.
RainbowException - If some internal error happens in the compilation or assembly stages.
Compiler.Errors - If there were semantic errors during compilation.

rif2code

public RASMCode rif2code(String rif,
                         Hashtable context)
                  throws IOException,
                         RainbowException
Compile and assemble RIF text into a block of code.
Parameters:
rif - The RIF text to convert.
context - The library context to assemble in.
Returns:
A block of RASM code.
Throws:
IOException - If some external I/O access fails unexpectedly.
RainbowException - If some internal error happens in the compilation or assembly stages.
Compiler.Errors - If there were semantic errors during compilation.
See Also:
rif2rasm(String), rasm2code(String,Hashtable)

rainbow2rasm

public String rainbow2rasm(String rainbow)
                    throws IOException,
                           RainbowException
Compile Rainbow text into RASM text.
Parameters:
rainbow - The Rainbow text to convert.
Returns:
RASM text suitable for assembly.
Throws:
IOException - If a compiler fails some external I/O access.
RainbowException - If something goes wrong during compilation.
Compiler.Errors - If there were semantic errors during compilation.
See Also:
rainbow2rif(String), rif2rasm(String)