story.scheherazade.parameters
Class SCHSymbolTable

java.lang.Object
  extended by story.scheherazade.parameters.SCHSymbolTable
All Implemented Interfaces:
java.lang.Cloneable

public class SCHSymbolTable
extends java.lang.Object
implements java.lang.Cloneable

Shameless duplication of DBCore's SymbolTable that only swaps out SCHVariableType for VariableType and otherwise customizes to Scheherazade's types.


Constructor Summary
SCHSymbolTable()
          Constructor with no outer scope
SCHSymbolTable(SCHSymbolTable outerScope)
          Constructor with pointer to outer scope
 
Method Summary
 java.lang.Object clone()
          Make a deep copy of the symbol table.
 void declare(VariableID ID, SCHVariableType variableType)
          Declare a variable
 java.lang.Object define(VariableID ID, java.lang.Object value)
          Define a variable.
 java.lang.Object get(VariableID ID)
          Retrieve a variable
 SCHVariableType getType(VariableID ID)
          Returns the SCHVariableType of a variable.
 boolean isDeclared(VariableID ID)
          Returns whether a variable has been declared.
 boolean isDefined(VariableID ID)
          Returns whether a variable has been defined.
static SCHSymbolTable mergeTables(SCHSymbolTable first, SCHSymbolTable second)
          Merge two symbol tables.
 int numDeclarations()
           
 java.lang.StringBuffer render()
          Render the symbol table (without any supertables) as a StringBuffer table with newline.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SCHSymbolTable

public SCHSymbolTable()
Constructor with no outer scope


SCHSymbolTable

public SCHSymbolTable(SCHSymbolTable outerScope)
Constructor with pointer to outer scope

Method Detail

declare

public void declare(VariableID ID,
                    SCHVariableType variableType)
             throws Scheherexception
Declare a variable

Throws:
Scheherexception

isDeclared

public boolean isDeclared(VariableID ID)
Returns whether a variable has been declared.


isDefined

public boolean isDefined(VariableID ID)
Returns whether a variable has been defined.


getType

public SCHVariableType getType(VariableID ID)
                        throws Scheherexception
Returns the SCHVariableType of a variable.

Throws:
Scheherexception

define

public java.lang.Object define(VariableID ID,
                               java.lang.Object value)
                        throws Scheherexception
Define a variable. Returns the value, possibly converted to a different type.

Throws:
Scheherexception

get

public java.lang.Object get(VariableID ID)
                     throws Scheherexception
Retrieve a variable

Throws:
Scheherexception

clone

public java.lang.Object clone()
Make a deep copy of the symbol table.

Overrides:
clone in class java.lang.Object

render

public java.lang.StringBuffer render()
                              throws Scheherexception
Render the symbol table (without any supertables) as a StringBuffer table with newline.

Throws:
Scheherexception

mergeTables

public static SCHSymbolTable mergeTables(SCHSymbolTable first,
                                         SCHSymbolTable second)
                                  throws Scheherexception
Merge two symbol tables. In case of duplicate variables, the second overwrites the first (even if the second is undefined and the first is defined). Note that this has the effect of flattening both tables; any outer-scope supertables will have their values copied into the new composite table.

Throws:
Scheherexception

numDeclarations

public int numDeclarations()


Copyright © 2011 David K. Elson. All Rights Reserved.