comparison python/c3/parser.py @ 219:1fa3e0050b49

Expanded ad hoc code generator
author Windel Bouwman
date Sat, 06 Jul 2013 12:38:09 +0200
parents c1ccb1cb4cef
children 3f6c30a5d234
comparison
equal deleted inserted replaced
218:494828a7adf1 219:1fa3e0050b49
39 self.Consume(typ) 39 self.Consume(typ)
40 return True 40 return True
41 return False 41 return False
42 42
43 def NextToken(self): 43 def NextToken(self):
44 t = self.token 44 t = self.token
45 if t.typ != 'END': 45 if t.typ != 'END':
46 self.token = self.tokens.__next__() 46 self.token = self.tokens.__next__()
47 return t 47 return t
48 48
49 def initLex(self, source): 49 def initLex(self, source):
50 self.tokens = lexer.tokenize(source) # Lexical stage 50 self.tokens = lexer.tokenize(source) # Lexical stage
51 self.token = self.tokens.__next__() 51 self.token = self.tokens.__next__()
52 def addDeclaration(self, decl): 52 def addDeclaration(self, decl):
53 self.currentPart.declarations.append(decl) 53 self.currentPart.declarations.append(decl)
54 54
55 def parseUses(self): 55 def parseUses(self):
56 pass 56 pass
86 return d 86 return d
87 87
88 # Type system 88 # Type system
89 def parseTypeSpec(self): 89 def parseTypeSpec(self):
90 # For now, do simple type spec, just parse an ID: 90 # For now, do simple type spec, just parse an ID:
91 return self.parseDesignator() 91 #return self.parseDesignator()
92 if self.Peak == 'struct': 92 if self.Peak == 'struct':
93 self.Consume('struct') 93 self.Consume('struct')
94 self.Consume('{') 94 self.Consume('{')
95 mems = [] 95 mems = []
96 while self.Peak != '}': 96 while self.Peak != '}':