def commit(self): if self.tid is None: self.tid = (('symbol', 'int'),) if self.key is not None: namespace.add_type(self.name, type=self.tid, key=self.key) else: namespace.add_type(self.name, type=self.tid)
def commit_template_args(self): self.ns.enter() for tt in self.template_types: namespace.add_type(tt) for tv in self.template_vars: namespace.add_var(tv) self.ns.leave()
def typedef(self, ast): qid = ast[-2] tid = ast[-3] print "TYPEDEF", tid, "AS", qid ns.add_type(qid[1:], type=tid) print self.root return True
def pre_sub(self): #print "PRE SUB VarDeclAnonStrucStatement" #self.ns_name = anon() #self.ns = Namespace(self.ns_name, Namespace.current()) self.type = (('symbol', self.ns_name),) namespace.add_type(self.type, ns=self.ns_name) self.ns = namespace.enter(self.ns_name, key=self.ns_key) self.commit_template_args()
def __init__(self, f): #Scope.__init__(self) self.parent = None lines = cpp_read(f) start = 0 self.sub = [] #self.root = Namespace() self.root = namespace.root() #self.root.enter() for t in ('int', 'float', 'double', 'char', 'wchar_t'): #self[tuple(tokenize(t))] = 'type' #Namespace.current().add_type(('symbol', t)) namespace.add_type((('symbol', t),)) #print self #print str(namespace.current()) while start < len(lines): statement, start = Cpp.parse(self, lines, start, 0) self.sub.append(statement) namespace.leave(self.root)
def commit(self): #print "tid", self.tid #print "name", self.name #print "key", self.key namespace.add_type(self.name, key=self.key, ns=self.tid)
def decl_type(self, qid, tid, **md): ns.add_type(qid[1:], type=tid)