Public paste
yea
By: jake is pussy | Date: Nov 19 2010 17:21 | Format: None | Expires: never | Size: 1.63 KB | Hits: 739

  1. import java.util.Hashtable;
  2. import java.util.ArrayList;
  3. Public class SymbolTable
  4. {
  5.        
  6.         boolean isEmpty;
  7.         ArrayList myArray = new ArrayList();
  8.  
  9.         // Constructor
  10.         public void SymbolTable(Source source)
  11.         {
  12.  
  13.         }
  14.         public static void main(String args[])
  15.         {
  16.                 // this is our main
  17.                
  18.                 // create hashtable..
  19.                 Hashtable scope = new Hashtable();
  20.  
  21.                 Source mySource = new Source(args[0]);
  22.                 SymbolTable mySymbolTable = new SymbolTable (mySource);
  23.         }
  24.         public boolean isEmpty()
  25.         {
  26.                 // check if symbol table has no scopes, no exceptions
  27.                 if(myArray[myArray.length-1] == null)
  28.                 {
  29.                         isEmpty = true;
  30.                 {
  31.                 else
  32.                 {
  33.                         isEmpty = false;
  34.                 }
  35.                 return(isEmpty);       
  36.         }
  37.         public Descriptor getDescriptor(String name)
  38.         {
  39.                 //check for emptylist!
  40.                 if(isEmpty())
  41.                 {
  42.                         throw RuntimeException("Empty list!");
  43.                 }
  44.                 else
  45.                 {
  46.                         //search hash table scopes from top to bottom
  47.                         // return the first descriptor your find that is                                // associated with name
  48.  
  49.                         // if name not found then call error noting
  50.                         // that name is not declared.
  51.                 }
  52.  
  53.  
  54.                 return(Descriptorvariable);
  55.         }
  56.         public void setDescriptor(String name, Descriptor descriptor)
  57.         {
  58.                 //
  59.                 if(isEmpty())
  60.                 {
  61.                         throw RuntimeException("Empty list!");
  62.                 }
  63.                 else
  64.                 {
  65.                         //if descripter does not appear
  66.                         // in top most scope, add it to topmost
  67.                         // then associate with descriptor.
  68.  
  69.                         // else if name already exists in topmost scope
  70.                         // then call error indicating that name
  71.                         // is declared twice.
  72.                 }
  73.  
  74.         }
  75.         public void push()
  76.         {
  77.                 myStack.push(Hashtable mySymbols = new Hashtable());
  78.         }
  79.         public void pop()
  80.         {
  81.                 // Removes top scope..
  82.                 myStack.pop();
  83.         }
  84. }