diff python/c3/astnodes.py @ 149:74241ca312cc

Fixes on parser and semantics
author Windel Bouwman
date Fri, 01 Mar 2013 11:43:52 +0100
parents e5263f74b287
children 4ae0e02599de
line wrap: on
line diff
--- a/python/c3/astnodes.py	Fri Mar 01 10:24:01 2013 +0100
+++ b/python/c3/astnodes.py	Fri Mar 01 11:43:52 2013 +0100
@@ -64,7 +64,7 @@
    else:
       return False
 
-class Type:
+class Type(Node):
    def isType(self, b):
       return isType(self, b)
 
@@ -93,25 +93,21 @@
    pass
 
 class Constant(Symbol):
-   def __init__(self, value, typ, name=None, public=False):
+   def __init__(self, value, name=None):
       self.name = name
       self.value = value
-      self.typ = typ
-      self.public = public
    def __repr__(self):
       return 'CONSTANT {0} = {1}'.format(self.name, self.value)
 
 class Variable(Symbol):
-   def __init__(self, name, typ, public):
+   def __init__(self, name, typ):
       self.name = name
       self.typ = typ
-      self.public = public
       self.isLocal = False
       self.isReadOnly = False
       self.isParameter = False
    def __repr__(self):
-      txt = '[public] ' if self.public else ''
-      return '{2}VAR {0} : {1}'.format(self.name, self.typ, txt)
+      return 'VAR {0} : {1}'.format(self.name, self.typ)
 
 class Parameter(Node):
    """ A parameter has a passing method, name and typ """
@@ -135,7 +131,7 @@
       self.b = b
       self.op = op # Operation: '+', '-', '*', '/', 'mod'
    def __repr__(self):
-      return 'BINOP {0} {1}'.format(self.op, self.typ)
+      return 'BINOP {0}'.format(self.op)
 
 # Modules
 class Package(Node):
@@ -147,9 +143,9 @@
 # Procedure types
 class Procedure(Symbol):
    """ Actual implementation of a function """
-   def __init__(self, name, typ, block):
+   def __init__(self, name, typ=None, block=None):
       self.name = name
-      self.block = block
+      self.body = block
       self.typ = typ
    def __repr__(self):
       return 'PROCEDURE {0} {1}'.format(self.name, self.typ)
@@ -161,9 +157,11 @@
    def __repr__(self):
       return 'COMPOUND STATEMENT'
 
-class EmptyStatement(Node):
+class ReturnStatement(Node):
+   def __init__(self, expr):
+      self.expr = expr
    def __repr__(self):
-      return 'EMPTY STATEMENT'
+      return 'RETURN STATEMENT'
 
 class Assignment(Node):
    def __init__(self, lval, rval):