creator.compiler
Class XmlCompiler

java.lang.Object
  |
  +--creator.compiler.XmlCompiler
Direct Known Subclasses:
SimCompiler

public abstract class XmlCompiler
extends java.lang.Object

This is the a base XML compiler. It must be extended by a specific compiler. Users of an extended class will call the compile() method in this class, which will first parse the XML then call the abstract method build(). An extended class must override the build() method and use to to compile from the xml document tree. This will load/cache the DTD by providing a new Resolver that will return a string reader to the cached DTD. WARNING!!! For the compiler to work, the FIRST element of the java CLASSPATH must be the root for the autohit installation. The compiler needs to find the XML DTD files in the "./lib" directory.


Field Summary
 XmlParseErrorHandler err
          Handles parse/compile errors and warnings.
protected  com.sun.xml.parser.Parser parser
          The XML parser.
 
Constructor Summary
XmlCompiler(java.lang.String dtdURI)
          Constructor.
 
Method Summary
abstract  java.lang.Object build(com.sun.xml.tree.XmlDocument xd)
          Abstract build method.
 java.lang.Object compile(java.io.InputStream is)
          Compile a stream into a new Sim object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

err

public XmlParseErrorHandler err
Handles parse/compile errors and warnings. Also serves as the ErrorHandler for the XML parser. A new one will be/must be created for each compile.
See Also:
XmlParseErrorHandler

parser

protected com.sun.xml.parser.Parser parser
The XML parser.
Constructor Detail

XmlCompiler

public XmlCompiler(java.lang.String dtdURI)
            throws java.lang.Exception
Constructor. You must use this and NOT the default. It will make sure that the DTD for the SimLanguage is available. If you use the defaulty constructor, the compiler will not know which DTD to use.
Parameters:
dtdURI - URI of the DTD used in the !DOCTYPE * SYSTEM clause in the compile targets.
Throws:
java.lang.Exception - any exception invalidates the compiler.
Method Detail

compile

public java.lang.Object compile(java.io.InputStream is)
Compile a stream into a new Sim object. It will abort on a major error and return a null instead of a Sim instance. Any compile errors or warnings can be found in the errors field.
Parameters:
is - An input stream to the text that is to be compiled.
Returns:
a reference to the target object.
See Also:
Sim

build

public abstract java.lang.Object build(com.sun.xml.tree.XmlDocument xd)
Abstract build method. Override with a method that builds the object code from the XML parse tree.
Parameters:
xd - A parsed XML document.
Returns:
Object reference to the object code.