uk.ac.man.cs.rainbow.temp
Class JSCompiler

java.lang.Object
  |
  +--uk.ac.man.cs.rainbow.Compiler
        |
        +--uk.ac.man.cs.rainbow.temp.JSCompiler

public class JSCompiler
extends Compiler

A simple compiler. This uses John Sargeant's semproc to implement its main functionality. Note that this class is only public for documentation purposes - it has no useful public features beyond that of its superclass.

See Also:
Rainbow Implementors Guide

Inner Class Summary
protected static class JSCompiler.JSSemanticErrors
          Specialised error parsing and generating subclass.
 
Inner classes inherited from class uk.ac.man.cs.rainbow.Compiler
Compiler.Error, Compiler.Errors, Compiler.Exception, Compiler.ParseError, Compiler.PreciseError, Compiler.SemanticError, Compiler.Warning
 
Field Summary
static String encoding
          The encoding of messages passed to and from the external compiler.
 
Constructor Summary
JSCompiler()
          Create a new compiler object connected to the external compiler specified in the rainbow.compiler.js.command property.
JSCompiler(String compilerCmd)
          Create a new compiler object connected to the specified external compiler.
 
Method Summary
protected  void close()
          Shut down the objects connection to its external compiler.
protected  void finalize()
           
static String getCompilerCommand()
          Read the command line to use to invoke an external compiler from the system properties list.
 String rainbow2rif(String rainbow)
          Convert Rainbow text to RIF text.
 String rif2rasm(String rif)
          Convert RIF text into RASM text.
 
Methods inherited from class uk.ac.man.cs.rainbow.Compiler
getInstance, rainbow2code, rainbow2rapa, rainbow2rasm, rasm2code, rif2code
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encoding

public static final String encoding
The encoding of messages passed to and from the external compiler.
Constructor Detail

JSCompiler

public JSCompiler(String compilerCmd)
           throws IOException
Create a new compiler object connected to the specified external compiler.

JSCompiler

public JSCompiler()
           throws IOException
Create a new compiler object connected to the external compiler specified in the rainbow.compiler.js.command property.
See Also:
getCompilerCommand()
Method Detail

close

protected void close()
Shut down the objects connection to its external compiler.

finalize

protected void finalize()
Overrides:
finalize in class Object

getCompilerCommand

public static String getCompilerCommand()
Read the command line to use to invoke an external compiler from the system properties list. The name of the property looked up is rainbow.compiler.js.command and it is assumed to exist.

rainbow2rif

public String rainbow2rif(String rainbow)
                   throws RainbowException
Convert Rainbow text to RIF text. Except we don't, always failing with an exception instead.
Overrides:
rainbow2rif in class Compiler
Throws:
Compiler.Exception - Always! This method isn't really implemented at all.

rif2rasm

public String rif2rasm(String rif)
                throws IOException,
                       RainbowException
Convert RIF text into RASM text.
Overrides:
rif2rasm in class Compiler
Parameters:
rif - The RIF text to convert.
Returns:
The converted RASM text.
Throws:
IOException - If contact with the external compiler is lost or something else goes wrong with the external communications.
Compiler.Errors - If there were (semantic) errors in the RIF text.
RainbowException - If something else goes wrong (like the compiler not following the correct communication protocol.)