edu.toronto.cs.cparser
Class CSymbolTable

java.lang.Object
  extended by edu.toronto.cs.cparser.CSymbolTable

public class CSymbolTable
extends java.lang.Object


Constructor Summary
CSymbolTable()
           
 
Method Summary
 TNode add(java.lang.String name, TNode node)
          add a node to the table with it's key as the current scope and the name
 java.lang.String addCurrentScopeToName(java.lang.String name)
          given a name for a type, append it with the current scope.
 java.lang.String addScopeToName(java.lang.String scope, java.lang.String name)
          given a name for a type, append it with the given scope.
 java.lang.String currentScopeAsString()
          return the current scope as a string
 TNode lookupNameInCurrentScope(java.lang.String name)
          lookup an unscoped name in the table by prepending the current scope.
 TNode lookupScopedName(java.lang.String scopedName)
          lookup a fully scoped name in the symbol table
 java.lang.String lookupScopedNameInCurrentScope(java.lang.String name)
           
 void popScope()
          pop the last scope off the scope stack.
 void pushScope(java.lang.String s)
          push a new scope onto the scope stack.
 java.lang.String removeOneLevelScope(java.lang.String scopeName)
          remove one level of scope from name MBZ
 java.lang.String toString()
          convert this table to a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CSymbolTable

public CSymbolTable()
Method Detail

pushScope

public void pushScope(java.lang.String s)
push a new scope onto the scope stack.


popScope

public void popScope()
pop the last scope off the scope stack.


currentScopeAsString

public java.lang.String currentScopeAsString()
return the current scope as a string


addCurrentScopeToName

public java.lang.String addCurrentScopeToName(java.lang.String name)
given a name for a type, append it with the current scope.


addScopeToName

public java.lang.String addScopeToName(java.lang.String scope,
                                       java.lang.String name)
given a name for a type, append it with the given scope. MBZ


removeOneLevelScope

public java.lang.String removeOneLevelScope(java.lang.String scopeName)
remove one level of scope from name MBZ


add

public TNode add(java.lang.String name,
                 TNode node)
add a node to the table with it's key as the current scope and the name


lookupScopedName

public TNode lookupScopedName(java.lang.String scopedName)
lookup a fully scoped name in the symbol table


lookupNameInCurrentScope

public TNode lookupNameInCurrentScope(java.lang.String name)
lookup an unscoped name in the table by prepending the current scope. MBZ -- if not found, pop scopes and look again


lookupScopedNameInCurrentScope

public java.lang.String lookupScopedNameInCurrentScope(java.lang.String name)

toString

public java.lang.String toString()
convert this table to a string

Overrides:
toString in class java.lang.Object