autohit.creator.compiler
Class SimCompiler

java.lang.Object
  extended byautohit.creator.compiler.XmlCompiler
      extended byautohit.creator.compiler.SimCompiler
All Implemented Interfaces:
SimLanguage

public class SimCompiler
extends XmlCompiler
implements SimLanguage

This is the a Sim compiler. It will compile xml documents that conform to the "%autohit.dtd.location%/sim.dtd" dtd into a Sim object.

WARNING!!! For the compiler to work, the sim.dtd must be at the location specified in the system property autohit.dtd.location.

The private methods translate Token() matches the textual tokens, as defined in the dtd to numerics that are used by the rest of the compiler. Any new tokens need to be added to that method.

I can think of several more elegant approaches to making this compiler, but until the XML parsers settle a bit, I'm not going to bother...

IMPORTANT NOTE!!!! The XML parser WITH DTD ensure instructions are coded in the proper order. ALL of the code below assumes this!!! If instructions come out of order or in disallowed places (like a seek outside of a get), I GUARANTEE you'll get a runaway compiler...

Logging will be done to the autohit.creator.sim namespace. It is set for pretty and

Version:
1.1 Version History EPG - Initial - 14Apr03
EPG - Update to add goto and references - 13Jul03
Author:
Erich P. Gatejen

Field Summary
protected  java.util.Stack fixupstack
          Stack for fixups
protected  VMExecutableWrapper ob
          The work-in-progress object code
protected  java.util.HashMap symboltable
          Symbol table for lookups
 
Fields inherited from class autohit.creator.compiler.XmlCompiler
myErrorHandler, myLog, runtimeLog
 
Fields inherited from interface autohit.creator.SimLanguage
ATTR_BUFFER, ATTR_CLEAR, ATTR_COUNT, ATTR_EVALUATOR, ATTR_ITEM, ATTR_LABEL, ATTR_LEFT, ATTR_METHOD, ATTR_NAME, ATTR_NEW, ATTR_OPERATOR, ATTR_OUTPUT, ATTR_REFERENCE, ATTR_RESULT, ATTR_TYPE, ATTR_UID, ATTR_VALUE, ATTR_VERSIONNUMBER, cEQ_OPERATION, EQ, EQ_OPERATION, EQ_STRING, GT, GT_STRING, IF_OPERATION, LITERAL_ONE, LITERAL_ZERO, LT, LT_STRING, MINUS_OPERATION, NOT, NOT_STRING, NOT_ZERO, ZERO
 
Constructor Summary
SimCompiler()
          Default Constructor.
SimCompiler(SystemContext sc)
          Constructor.
 
Method Summary
 java.lang.Object build(org.w3c.dom.Document xd)
          Compile the xml tree into an VMExecutable object.
 
Methods inherited from class autohit.creator.compiler.XmlCompiler
compile, numberErrors, numberWarnings, resetRuntimeLog, runtimeDebug, runtimeError, runtimeWarning, setRuntimeLog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ob

protected VMExecutableWrapper ob
The work-in-progress object code


symboltable

protected java.util.HashMap symboltable
Symbol table for lookups


fixupstack

protected java.util.Stack fixupstack
Stack for fixups

Constructor Detail

SimCompiler

public SimCompiler()
            throws java.lang.Exception
Default Constructor. This is the only and default constructor.

Throws:
java.lang.Exception - any exception invalidates the compiler.

SimCompiler

public SimCompiler(SystemContext sc)
            throws java.lang.Exception
Constructor. This is the only and default constructor.

Throws:
java.lang.Exception - any exception invalidates the compiler.
Method Detail

build

public java.lang.Object build(org.w3c.dom.Document xd)
Compile the xml tree into an VMExecutable object. We will create a new log for each run, so that we can uniquely identify them.

Specified by:
build in class XmlCompiler
Parameters:
xd - A parsed XML document.
Returns:
a reference to the target object, in this case it will be a VMExecutableWrapper, or null if it failed.
See Also:
VMExecutableWrapper


Test.