diff 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
line wrap: on
line diff
--- a/python/ppci/c3/parser.py	Thu Dec 12 20:42:56 2013 +0100
+++ b/python/ppci/c3/parser.py	Fri Dec 13 11:53:29 2013 +0100
@@ -346,26 +346,27 @@
 
     def PostFixExpression(self):
         pfe = self.PrimaryExpression()
-        if self.hasConsumed('('):
-            # Function call
-            args = []
-            if not self.hasConsumed(')'):
-                args.append(self.Expression())
-                while self.hasConsumed(','):
+        while self.Peak in ['[', '.', '->', '(']:
+            if self.hasConsumed('['):
+                raise NotImplementedError('Array not yet implemented')
+            elif self.hasConsumed('->'):
+                field = self.Consume('ID')
+                pfe = Deref(pfe, pfe.loc)
+                pfe = Member(pfe, field.val, field.loc)
+            elif self.hasConsumed('.'):
+                field = self.Consume('ID')
+                pfe = Member(pfe, field.val, field.loc)
+            elif self.hasConsumed('('):
+                # Function call
+                args = []
+                if not self.hasConsumed(')'):
                     args.append(self.Expression())
-                self.Consume(')')
-            pfe = FunctionCall(pfe, args, pfe.loc)
-        else:
-            while self.Peak in ['[', '.', '->']:
-                if self.hasConsumed('['):
-                    raise NotImplementedError('Array not yet implemented')
-                elif self.hasConsumed('->'):
-                    field = self.Consume('ID')
-                    pfe = Deref(pfe, pfe.loc)
-                    pfe = Member(pfe, field.val, field.loc)
-                elif self.hasConsumed('.'):
-                    field = self.Consume('ID')
-                    pfe = Member(pfe, field.val, field.loc)
+                    while self.hasConsumed(','):
+                        args.append(self.Expression())
+                    self.Consume(')')
+                pfe = FunctionCall(pfe, args, pfe.loc)
+            else:
+                raise Exception()
         return pfe
 
     def PrimaryExpression(self):