Mercurial > lcfOS
comparison python/ppci/c3/parser.py @ 308:2e7f55319858
Merged analyse into codegenerator
author | Windel Bouwman |
---|---|
date | Fri, 13 Dec 2013 11:53:29 +0100 |
parents | e609d5296ee9 |
children | ff665880a6b0 |
comparison
equal
deleted
inserted
replaced
307:e609d5296ee9 | 308:2e7f55319858 |
---|---|
344 else: | 344 else: |
345 return self.PostFixExpression() | 345 return self.PostFixExpression() |
346 | 346 |
347 def PostFixExpression(self): | 347 def PostFixExpression(self): |
348 pfe = self.PrimaryExpression() | 348 pfe = self.PrimaryExpression() |
349 if self.hasConsumed('('): | 349 while self.Peak in ['[', '.', '->', '(']: |
350 # Function call | 350 if self.hasConsumed('['): |
351 args = [] | 351 raise NotImplementedError('Array not yet implemented') |
352 if not self.hasConsumed(')'): | 352 elif self.hasConsumed('->'): |
353 args.append(self.Expression()) | 353 field = self.Consume('ID') |
354 while self.hasConsumed(','): | 354 pfe = Deref(pfe, pfe.loc) |
355 pfe = Member(pfe, field.val, field.loc) | |
356 elif self.hasConsumed('.'): | |
357 field = self.Consume('ID') | |
358 pfe = Member(pfe, field.val, field.loc) | |
359 elif self.hasConsumed('('): | |
360 # Function call | |
361 args = [] | |
362 if not self.hasConsumed(')'): | |
355 args.append(self.Expression()) | 363 args.append(self.Expression()) |
356 self.Consume(')') | 364 while self.hasConsumed(','): |
357 pfe = FunctionCall(pfe, args, pfe.loc) | 365 args.append(self.Expression()) |
358 else: | 366 self.Consume(')') |
359 while self.Peak in ['[', '.', '->']: | 367 pfe = FunctionCall(pfe, args, pfe.loc) |
360 if self.hasConsumed('['): | 368 else: |
361 raise NotImplementedError('Array not yet implemented') | 369 raise Exception() |
362 elif self.hasConsumed('->'): | |
363 field = self.Consume('ID') | |
364 pfe = Deref(pfe, pfe.loc) | |
365 pfe = Member(pfe, field.val, field.loc) | |
366 elif self.hasConsumed('.'): | |
367 field = self.Consume('ID') | |
368 pfe = Member(pfe, field.val, field.loc) | |
369 return pfe | 370 return pfe |
370 | 371 |
371 def PrimaryExpression(self): | 372 def PrimaryExpression(self): |
372 if self.hasConsumed('('): | 373 if self.hasConsumed('('): |
373 e = self.Expression() | 374 e = self.Expression() |