prolog.implementation
Class SymbolTable

java.lang.Object
  |
  +--prolog.implementation.SymbolTable
All Implemented Interfaces:
ISymbolTable

public class SymbolTable
extends java.lang.Object
implements ISymbolTable

The symboltable is created by the scanner and parser during parsing. All identifiers and strings of the sourceprogram are replaced by a number. In the symboltable, the relation between the number and the original string is stored


Field Summary
(package private) static int instanceCount
          a instance counter for hacked debug purpose
protected  java.util.Map wordMap
          a map storing all words found in program the key is the word, the index in the word list the value
protected  java.util.List words
          a list storing all words with their index found in program
 
Constructor Summary
SymbolTable()
          create a symboltable
 
Method Summary
 void clear()
          clears the symboltyble
 java.lang.String decode(IAtom index)
          decodes the given word
 java.lang.String decode(int index)
          decodes the given word
 java.lang.String decode(java.lang.Object obj)
          decodes the given word
 int encode(java.lang.String word)
          encodes the given word
 void genXml(java.io.Writer out)
          generates a xml representation of this symboltable
private  int getIndex(java.lang.String word)
          returns the index of the given word in the symboltable
 java.lang.String toString()
          returns a string representation of this symboltable
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

instanceCount

static int instanceCount
a instance counter for hacked debug purpose

words

protected java.util.List words
a list storing all words with their index found in program

wordMap

protected java.util.Map wordMap
a map storing all words found in program the key is the word, the index in the word list the value
Constructor Detail

SymbolTable

public SymbolTable()
create a symboltable
Method Detail

clear

public void clear()
clears the symboltyble
Specified by:
clear in interface ISymbolTable

encode

public int encode(java.lang.String word)
encodes the given word
Specified by:
encode in interface ISymbolTable
Parameters:
word -  
Returns:
 

decode

public java.lang.String decode(IAtom index)
decodes the given word
Specified by:
decode in interface ISymbolTable
Following copied from interface: prolog.model.ISymbolTable
Parameters:
index -  
Returns:
 

decode

public java.lang.String decode(int index)
decodes the given word
Specified by:
decode in interface ISymbolTable
Following copied from interface: prolog.model.ISymbolTable
Parameters:
index -  
Returns:
 

decode

public java.lang.String decode(java.lang.Object obj)
decodes the given word

getIndex

private int getIndex(java.lang.String word)
returns the index of the given word in the symboltable
Returns:
 

genXml

public void genXml(java.io.Writer out)
            throws java.io.IOException
generates a xml representation of this symboltable
Specified by:
genXml in interface ISymbolTable
Throws:
java.io.IOException -  

toString

public java.lang.String toString()
returns a string representation of this symboltable
Overrides:
toString in class java.lang.Object