diff python/c3/parser.py @ 158:9683a4cd848f

Added some functions for code generation
author Windel Bouwman
date Fri, 08 Mar 2013 16:52:44 +0100
parents 8f3924b6076e
children 8104fc8b5e90
line wrap: on
line diff
--- a/python/c3/parser.py	Sun Mar 03 18:14:35 2013 +0100
+++ b/python/c3/parser.py	Fri Mar 08 16:52:44 2013 +0100
@@ -111,7 +111,7 @@
 
    # Statements:
    def parseAssignment(self, lval):
-      lval = astnodes.VariableUse(lval)
+      lval = self.sema.actOnVariableUse(lval)
       self.Consume('=')
       rval = self.parseExpression()
       self.Consume(';')
@@ -136,7 +136,7 @@
       if self.hasConsumed('else'):
          no = self.parseCompoundStatement()
          return astnodes.IfStatement(condition, yes, no)
-      return astnodes.IfStatement(condition, yes)
+      return astnodes.IfStatement(condition, yes, astnodes.EmptyStatement())
 
    def parseWhileStatement(self):
       self.Consume('while')
@@ -167,11 +167,11 @@
          return self.parseWhileStatement()
       elif self.Peak == '{':
          return self.parseCompoundStatement()
-      elif self.Peak == ';':
-         self.Consume(';')
+      elif self.hasConsumed(';'):
          return astnodes.EmptyStatement()
       elif self.Peak == 'var':
-         return self.parseVarDef()
+         self.parseVarDef()
+         return astnodes.EmptyStatement()
       elif self.Peak == 'return':
          return self.parseReturnStatement()
       elif self.Peak == 'ID':