unit
Class Interpreter

unit.Interpreter

public final class Interpreter

This is the UniT parse tree and interpreter in one class, that is derived from the parser tree node implementation of ANTLR, i.e. the result of the UniT parser is a parser tree of objects of this class, which will be directly used for execution. In the following documentation, single objects of this class will named parse tree node or Interpreter object depending on the context.


Constructor Summary
Interpreter()
           
 
Method Summary
 antlr.Token getToken()
          Returns the input token, that lead to the construction of this parse tree node.
 void initialize(antlr.Token token)
          Saves a reference to the token.
 void initializeForExecution()
          Prepares the interpreter for execution and must be called before run().
 void run(java.util.Hashtable identifiers)
          Processes the whole UniT template and must be called after initializeForExecution().
 

Constructor Detail

Interpreter

public Interpreter()
Method Detail

getToken

public antlr.Token getToken()
Returns the input token, that lead to the construction of this parse tree node. This method and the token will be needed by the parser to add "virtual" tokens to "virtual" parse tree nodes.
See Also:
initialize(Token),

initializeForExecution

public void initializeForExecution()
Prepares the interpreter for execution and must be called before run(). This need to be done only once for each parse tree or interpreter respectively, but before the first execution. All methods of the class UniT, that return an Interpreter object, already called this method!
Throws:
UniTRuntimeException - if an identifier is declared double, if a class that is not derived from Throwable should be catched or if a catch can not be reached.
See Also:
run(Hashtable), UniTRuntimeException

run

public void run(java.util.Hashtable identifiers)
Processes the whole UniT template and must be called after initializeForExecution(). All methods of the class UniT, that return an Interpreter object, already called this method! Each language construct of UniT, that exists in java, too, will be executed as usual as in java, but only with dynamic type checking.
Parameters:
identifiers - all currently valid identifiers and their values.
Throws:
UniTRuntimeException - if any error occurs, e.g. if an identifier is declared double, a type mismatch occurs or an exception is explicitly thrown.
See Also:
initializeForExecution(), UniTRuntimeException

initialize

public void initialize(antlr.Token token)
Saves a reference to the token.
Parameters:
token - the token, that is represented by this Interpreter object/parse tree