marf.nlp.Parsing
Class SymbolTable

java.lang.Object
  extended by marf.nlp.Parsing.SymbolTable

public class SymbolTable
extends java.lang.Object

Symbol Table data structure. TODO: complete implementation.

$Id: SymbolTable.java,v 1.18 2008/01/03 03:21:57 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.18 $
Author:
Serguei Mokhov

Field Summary
protected  SymbolTable oParentSymTab
          Backward reference.
private  java.util.Hashtable oSymTabEntries
          This is a container for SymTabEnries.
protected  java.util.Hashtable oSymTabIndex
          Global Index 'pointing' to all SymbolTables to speedup search.
protected  java.lang.String strName
          Name of the table, must be unique.
 
Constructor Summary
SymbolTable()
          Default Constructor.
SymbolTable(java.lang.String pstrName)
          Accepts scope name.
SymbolTable(java.lang.String pstrName, SymbolTable poParentSymTab)
          Accepts scope name and the reference to the parent.
 
Method Summary
 void addEntry(int piEntryType, Token poToken)
          Not implemented.
 int addSymbol(Token poToken)
          Adds a symbol token to the table.
 int addSymbol(Token poToken, boolean pbResolved)
          Not implemented.
 int addSymbol(Token oToken, int piSymDataType)
          Not implemented.
 void create(java.lang.String pstrNewTableName)
          Creates child symbol table with a given name.
 void delete(java.lang.String pstrTable)
          Not implemented.
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
 java.util.Hashtable getSymTabEntries()
          Allows querying for the contained entries.
 SymTabEntry getSymTabEntry(int piID)
          Not implemented.
 SymTabEntry getSymTabEntry(java.lang.String pstrLexeme)
          This method returns the entry by token's lexeme.
 java.lang.Object insert(java.lang.String pstrTable, java.lang.String pstrID)
          Finds a reserved entry given table and ID and marks it unreserved.
 void print(java.lang.String pstrTable)
          Serializes the named table into STDOUT.
 java.lang.Object search(java.lang.String pstrTable, java.lang.String pstrID)
          Looks up an entry in either this table or in index given the table name an the identifier.
 java.lang.Object search(java.lang.String pstrTable, java.lang.String pstrID, boolean pbReserveEntry)
          Looks up a symbol table entry in either this table or in index.
 boolean serialize(int piOpertation)
          Not implemented.
 boolean setResolved(int piID, boolean pbResolved)
          Not implemented.
 boolean setResolved(java.lang.String pstrLexeme, boolean pbResolved)
          Marks a symbol table entry as resolved/declared (or not) given lexeme.
 boolean setType(int piID, int piType)
          Not implemented.
 boolean setType(java.lang.String pstrLexeme, int piType)
          Not implemented.
 void updateEntry(java.lang.String pstrScope, java.lang.String pstrName, boolean pbDeclared)
          Not implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

oSymTabEntries

private java.util.Hashtable oSymTabEntries
This is a container for SymTabEnries.


oSymTabIndex

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


oParentSymTab

protected SymbolTable oParentSymTab
Backward reference.


strName

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

Constructor Detail

SymbolTable

public SymbolTable()
Default Constructor.


SymbolTable

public SymbolTable(java.lang.String pstrName)
Accepts scope name.

Parameters:
pstrName - name of the scope

SymbolTable

public SymbolTable(java.lang.String pstrName,
                   SymbolTable poParentSymTab)
Accepts scope name and the reference to the parent.

Parameters:
pstrName - scope name
poParentSymTab - parent symbol table reference
Method Detail

addSymbol

public int addSymbol(Token poToken)
Adds a symbol token to the table. If the symbol is already there, its additional location is recorded. Else a new entry is created.

Parameters:
poToken - symbol token to add
Returns:
0 on success

addSymbol

public int addSymbol(Token poToken,
                     boolean pbResolved)
Not implemented. The same as above addSymbol(Token), just has an extra parameter for convenience if on the time of insertion the symbol is already defined.

Parameters:
poToken -
pbResolved -
Returns:
nothing
Throws:
NotImplementedException
See Also:
addSymbol(Token)

addSymbol

public int addSymbol(Token oToken,
                     int piSymDataType)
Not implemented. This method adds also a type along with the token. This as well assumes that the token is defined because invocation of the method can happen only during the declaration of a symbol in the source code.

Parameters:
oToken -
piSymDataType -
Returns:
nothing
Throws:
NotImplementedException

addEntry

public void addEntry(int piEntryType,
                     Token poToken)
Not implemented.

Parameters:
piEntryType -
poToken -
Throws:
NotImplementedException

updateEntry

public void updateEntry(java.lang.String pstrScope,
                        java.lang.String pstrName,
                        boolean pbDeclared)
Not implemented.

Parameters:
pstrScope -
pstrName -
pbDeclared -
Throws:
NotImplementedException

create

public void create(java.lang.String pstrNewTableName)
Creates child symbol table with a given name.

Parameters:
pstrNewTableName - child's symbol table name

search

public java.lang.Object search(java.lang.String pstrTable,
                               java.lang.String pstrID)
Looks up an entry in either this table or in index given the table name an the identifier. Equivalent to search(pstrTable, pstrID, false).

Parameters:
pstrTable - the table name
pstrID - the symbol identifier
Returns:
the object entry
See Also:
search(String, String, boolean)

search

public java.lang.Object search(java.lang.String pstrTable,
                               java.lang.String pstrID,
                               boolean pbReserveEntry)
Looks up a symbol table entry in either this table or in index. Can create a reserved entry in the table if the flag is set and the entry isn't there.

Parameters:
pstrTable - the table name
pstrID - the symbol identifier
pbReserveEntry - mark the symbol table entry reserved or not
Returns:
symbol table entry object

insert

public java.lang.Object insert(java.lang.String pstrTable,
                               java.lang.String pstrID)
Finds a reserved entry given table and ID and marks it unreserved. This completes the insertion (and definition) of the entry in the table.

Parameters:
pstrTable - symbol table name to search for
pstrID - identifier to search for
Returns:
symbol table entry object if found; null otherwise

delete

public void delete(java.lang.String pstrTable)
Not implemented. TODO: implement.

Parameters:
pstrTable - table name to delete

print

public void print(java.lang.String pstrTable)
Serializes the named table into STDOUT.

Parameters:
pstrTable - the symbol table to dump

getSymTabEntries

public java.util.Hashtable getSymTabEntries()
Allows querying for the contained entries.

Returns:
the hashtable with SymTab entries

getSymTabEntry

public SymTabEntry getSymTabEntry(int piID)
Not implemented. Returns a symbol table entry by an entry ID. 'null' means there is no entry with such an ID.

Parameters:
piID -
Returns:
null

getSymTabEntry

public SymTabEntry getSymTabEntry(java.lang.String pstrLexeme)
This method returns the entry by token's lexeme.

Parameters:
pstrLexeme - the lexeme of the entry to look up
Returns:
SymTabEntry reference corresponding to the lexeme

setResolved

public boolean setResolved(int piID,
                           boolean pbResolved)
Not implemented. By ID.

Parameters:
piID -
pbResolved -
Returns:
false

setResolved

public boolean setResolved(java.lang.String pstrLexeme,
                           boolean pbResolved)
Marks a symbol table entry as resolved/declared (or not) given lexeme.

Parameters:
pstrLexeme - the lexeme to look up
pbResolved - flag to set whether the given entry is resolved or not
Returns:
true if the entry was updated (read found and updated)

setType

public boolean setType(int piID,
                       int piType)
Not implemented.

Parameters:
piID -
piType -
Returns:
false

setType

public boolean setType(java.lang.String pstrLexeme,
                       int piType)
Not implemented.

Parameters:
pstrLexeme -
piType -
Returns:
false

serialize

public boolean serialize(int piOpertation)
Not implemented.

Parameters:
piOpertation -
Returns:
false

getMARFSourceCodeRevision

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

Returns:
revision string


SourceForge Logo