Mercurial > lcfOS
comparison python/ppci/c3/parser.py @ 362:c05ab629976a
Added CPUID for arm
author | Windel Bouwman |
---|---|
date | Sat, 15 Mar 2014 10:56:34 +0100 |
parents | 5477e499b039 |
children | 6ae782a085e0 |
comparison
equal
deleted
inserted
replaced
361:614a7f6d4d4d | 362:c05ab629976a |
---|---|
78 self.parseTopLevel() | 78 self.parseTopLevel() |
79 self.Consume('END') | 79 self.Consume('END') |
80 | 80 |
81 def parseTopLevel(self): | 81 def parseTopLevel(self): |
82 if self.Peak == 'function': | 82 if self.Peak == 'function': |
83 self.parseFunctionDef() | 83 self.parse_function_def() |
84 elif self.Peak == 'var': | 84 elif self.Peak == 'var': |
85 self.parseVarDef() | 85 self.parseVarDef() |
86 # TODO handle variable initialization | 86 # TODO handle variable initialization |
87 elif self.Peak == 'const': | 87 elif self.Peak == 'const': |
88 self.parseConstDef() | 88 self.parseConstDef() |
186 c.loc = name.loc | 186 c.loc = name.loc |
187 if not self.hasConsumed(','): | 187 if not self.hasConsumed(','): |
188 break | 188 break |
189 self.Consume(';') | 189 self.Consume(';') |
190 | 190 |
191 def parseFunctionDef(self): | 191 def parse_function_def(self): |
192 loc = self.Consume('function').loc | 192 loc = self.Consume('function').loc |
193 returntype = self.parse_type_spec() | 193 returntype = self.parse_type_spec() |
194 fname = self.Consume('ID').val | 194 fname = self.Consume('ID').val |
195 f = Function(fname, loc) | 195 f = Function(fname, loc) |
196 self.addDeclaration(f) | 196 self.addDeclaration(f) |
209 if not self.hasConsumed(','): | 209 if not self.hasConsumed(','): |
210 break | 210 break |
211 self.Consume(')') | 211 self.Consume(')') |
212 paramtypes = [p.typ for p in parameters] | 212 paramtypes = [p.typ for p in parameters] |
213 f.typ = FunctionType(paramtypes, returntype) | 213 f.typ = FunctionType(paramtypes, returntype) |
214 f.body = self.parseCompound() | 214 if self.Peak == ';': |
215 self.Consume(';') | |
216 f.body = None | |
217 else: | |
218 f.body = self.parseCompound() | |
215 self.currentPart = savePart | 219 self.currentPart = savePart |
216 | 220 |
217 def parse_if(self): | 221 def parse_if(self): |
218 loc = self.Consume('if').loc | 222 loc = self.Consume('if').loc |
219 self.Consume('(') | 223 self.Consume('(') |