class Symtable: ''' Symtable class stores and manages nested scopes. Parametes : none''' # class variable for keeping symbol table stack scope = Stack() # class initialiser def __init__(self): # copy all symbols from next most nested scope self.symbols = Symtable.scope.peek().symbols.copy() # push current scope symtable onto the stack Symtable.scope.push(self) # class deconstructor def __del__(self): # remove most nested scope symtable from stack and if it # isn't the symtable being deconstructed raise a warning if Symbtable.scope.pop() is not self: raise Warning('Deleted scope was not most nested scope')