comparison python/ks/symboltable.py @ 182:e9b27f7193e3

Replace clear function by function also supported in python 3.2
author Windel Bouwman
date Sat, 18 May 2013 18:24:42 +0200
parents 91af0e40f868
children
comparison
equal deleted inserted replaced
181:216da5e46efc 182:e9b27f7193e3
1 from .nodes import * 1 from .nodes import *
2 from ...core.errors import Error
3 2
4 class SymbolTable: 3 class SymbolTable:
5 """ 4 """
6 Symbol table for a current scope. 5 Symbol table for a current scope.
7 It has functions: 6 It has functions:
65 return self.syms[name] 64 return self.syms[name]
66 else: 65 else:
67 if self.parent: 66 if self.parent:
68 return self.parent.getSymbol(name) 67 return self.parent.getSymbol(name)
69 else: 68 else:
70 Error('Symbol "{0}" undeclared!'.format(name)) 69 raise Exception('Symbol "{0}" undeclared!'.format(name))
71 70
72 def hasSymbol(self, name): 71 def hasSymbol(self, name):
73 if name in self.syms.keys(): 72 if name in self.syms.keys():
74 return True 73 return True
75 else: 74 else: