marf.nlp.Parsing
Class SymbolTable

java.lang.Object
  |
  +--marf.nlp.Parsing.SymbolTable

public class SymbolTable
extends java.lang.Object

Symbol Table implementation. $Id: SymbolTable.java,v 1.7 2005/06/01 05:35:09 mokhov Exp $

Since:
0.3.0
Version:
$Revision: 1.7 $
Author:
Serguei Mokhov

Field Summary
protected  java.lang.String Name
          Name of the table, must be unique.
protected  marf.nlp.Parsing.SymbolTable ParentSymTab
          Backward reference.
protected static java.util.Hashtable SymTabIndex
          Global Index 'pointing' to all SymbolTables to speedup search.
 
Constructor Summary
SymbolTable()
          Default Constructor.
SymbolTable(java.lang.String pstrName)
           
SymbolTable(java.lang.String pstrName, marf.nlp.Parsing.SymbolTable poParentSymTab)
           
 
Method Summary
 void addEntry(int piEntryType, marf.nlp.Parsing.Token poToken)
           
 int addSymbol(marf.nlp.Parsing.Token poToken)
          Returns an ID of the entry inserted, so one can access it faster.
 int addSymbol(marf.nlp.Parsing.Token oToken, boolean bResolved)
          Deprecated.  
 int addSymbol(marf.nlp.Parsing.Token oToken, int iSymDataType)
          Deprecated.  
 void create(java.lang.String pstrNewTableName)
           
 void delete(java.lang.String pstrTable)
           
static java.lang.String getRevision()
          Retrieves class' revision.
 java.util.Hashtable getSymTabEntries()
          Retunrns the hashtable with SymTab entries.
 marf.nlp.Parsing.SymTabEntry getSymTabEntry(int iID)
          Returns a symbol table entry by an entry ID.
 marf.nlp.Parsing.SymTabEntry getSymTabEntry(java.lang.String strLexeme)
          Thes methods returns the entry by token's lexeme.
 java.lang.Object insert(java.lang.String pstrTable, java.lang.String pstrID)
           
 void print(java.lang.String pstrTable)
           
 java.lang.Object search(java.lang.String pstrTable, java.lang.String pstrID)
           
 java.lang.Object search(java.lang.String pstrTable, java.lang.String pstrID, boolean pbReserveEntry)
          Looks up an entry in either this table or in index.
 boolean serialize(int piOpertation)
           
 boolean setResolved(int iID, boolean bResolved)
          By ID.
 boolean setResolved(java.lang.String strLexeme, boolean bResolved)
          Using string.
 boolean setType(int iID, int iType)
           
 boolean setType(java.lang.String strLexeme, int iType)
           
 void updateEntry(java.lang.String pstrScope, java.lang.String pstrName, boolean bDeclare)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SymTabIndex

protected static java.util.Hashtable SymTabIndex
Global Index 'pointing' to all SymbolTables to speedup search.


ParentSymTab

protected marf.nlp.Parsing.SymbolTable ParentSymTab
Backward reference.


Name

protected java.lang.String Name
Name of the table, must be unique.

Constructor Detail

SymbolTable

public SymbolTable()
Default Constructor.


SymbolTable

public SymbolTable(java.lang.String pstrName)

SymbolTable

public SymbolTable(java.lang.String pstrName,
                   marf.nlp.Parsing.SymbolTable poParentSymTab)
Method Detail

addSymbol

public int addSymbol(marf.nlp.Parsing.Token poToken)
Returns an ID of the entry inserted, so one can access it faster. The access is still possible by the lexeme string itself, of course.


addSymbol

public int addSymbol(marf.nlp.Parsing.Token oToken,
                     boolean bResolved)
Deprecated.  

The same as above, just has an extra parameter for convenience if on the time of insertion the symbol is defined.


addSymbol

public int addSymbol(marf.nlp.Parsing.Token oToken,
                     int iSymDataType)
Deprecated.  

This method adds also a type along with the token. This as well assumes that the token is defined because invokation o fthe method can happen only during the declaration of a symbol in the source code.


addEntry

public void addEntry(int piEntryType,
                     marf.nlp.Parsing.Token poToken)

updateEntry

public void updateEntry(java.lang.String pstrScope,
                        java.lang.String pstrName,
                        boolean bDeclare)

create

public void create(java.lang.String pstrNewTableName)

search

public java.lang.Object search(java.lang.String pstrTable,
                               java.lang.String pstrID)

search

public java.lang.Object search(java.lang.String pstrTable,
                               java.lang.String pstrID,
                               boolean pbReserveEntry)
Looks up an entry in either this table or in index.


insert

public java.lang.Object insert(java.lang.String pstrTable,
                               java.lang.String pstrID)

delete

public void delete(java.lang.String pstrTable)

print

public void print(java.lang.String pstrTable)

getSymTabEntries

public java.util.Hashtable getSymTabEntries()
Retunrns the hashtable with SymTab entries.


getSymTabEntry

public marf.nlp.Parsing.SymTabEntry getSymTabEntry(int iID)
Returns a symbol table entry by an entry ID. 'null' means there is no entry with such an ID.


getSymTabEntry

public marf.nlp.Parsing.SymTabEntry getSymTabEntry(java.lang.String strLexeme)
Thes methods returns the entry by token's lexeme.


setResolved

public boolean setResolved(int iID,
                           boolean bResolved)
By ID.


setResolved

public boolean setResolved(java.lang.String strLexeme,
                           boolean bResolved)
Using string.


setType

public boolean setType(int iID,
                       int iType)

setType

public boolean setType(java.lang.String strLexeme,
                       int iType)

serialize

public boolean serialize(int piOpertation)

getRevision

public static java.lang.String getRevision()
Retrieves class' revision.

Returns:
revision string