- import java.util.Hashtable;
- import java.util.ArrayList;
- Public class SymbolTable
- {
- boolean isEmpty;
- ArrayList myArray = new ArrayList();
- // Constructor
- public void SymbolTable(Source source)
- {
- }
- public static void main(String args[])
- {
- // this is our main
- // create hashtable..
- Hashtable scope = new Hashtable();
- Source mySource = new Source(args[0]);
- SymbolTable mySymbolTable = new SymbolTable (mySource);
- }
- public boolean isEmpty()
- {
- // check if symbol table has no scopes, no exceptions
- if(myArray[myArray.length-1] == null)
- {
- isEmpty = true;
- {
- else
- {
- isEmpty = false;
- }
- return(isEmpty);
- }
- public Descriptor getDescriptor(String name)
- {
- //check for emptylist!
- if(isEmpty())
- {
- throw RuntimeException("Empty list!");
- }
- else
- {
- //search hash table scopes from top to bottom
- // return the first descriptor your find that is // associated with name
- // if name not found then call error noting
- // that name is not declared.
- }
- return(Descriptorvariable);
- }
- public void setDescriptor(String name, Descriptor descriptor)
- {
- //
- if(isEmpty())
- {
- throw RuntimeException("Empty list!");
- }
- else
- {
- //if descripter does not appear
- // in top most scope, add it to topmost
- // then associate with descriptor.
- // else if name already exists in topmost scope
- // then call error indicating that name
- // is declared twice.
- }
- }
- public void push()
- {
- myStack.push(Hashtable mySymbols = new Hashtable());
- }
- public void pop()
- {
- // Removes top scope..
- myStack.pop();
- }
- }
yea
By: jake is pussy | Date: Nov 19 2010 17:21 | Format: None | Expires: never | Size: 1.63 KB | Hits: 804
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago