Mercurial > lcfOS
comparison python/c3/astnodes.py @ 222:c3f1ce8b638f
Fixup of parser
author | Windel Bouwman |
---|---|
date | Tue, 09 Jul 2013 17:36:31 +0200 |
parents | 848c4b15fd0b |
children | 1c7364bd74c7 |
comparison
equal
deleted
inserted
replaced
221:848c4b15fd0b | 222:c3f1ce8b638f |
---|---|
72 self.name = name | 72 self.name = name |
73 self.typ = typ | 73 self.typ = typ |
74 def __repr__(self): | 74 def __repr__(self): |
75 return 'Named type {0} of type {1}'.format(self.name, self.typ) | 75 return 'Named type {0} of type {1}'.format(self.name, self.typ) |
76 | 76 |
77 #class TypeCast(Node): | 77 class TypeCast(Node): |
78 # def __init__(self, | 78 def __init__(self, to_type, x): |
79 self.to_type = to_type | |
80 self.a = x | |
81 def __repr__(self): | |
82 return 'TYPECAST' | |
79 | 83 |
80 # Variables, parameters, local variables, constants: | 84 # Variables, parameters, local variables, constants: |
81 class Symbol(Node): | 85 class Symbol(Node): |
82 def __init__(self, name): | 86 def __init__(self, name): |
83 self.name = name | 87 self.name = name |
188 self.expr = expr | 192 self.expr = expr |
189 self.loc = loc | 193 self.loc = loc |
190 def __repr__(self): | 194 def __repr__(self): |
191 return 'RETURN STATEMENT' | 195 return 'RETURN STATEMENT' |
192 | 196 |
193 class Assignment(Node): | 197 class Assignment(Statement): |
194 def __init__(self, lval, rval, loc): | 198 def __init__(self, lval, rval, loc): |
195 assert isinstance(lval, Node) | 199 assert isinstance(lval, Node) |
196 assert isinstance(rval, Node) | 200 assert isinstance(rval, Node) |
197 assert isinstance(loc, SourceLocation) | 201 assert isinstance(loc, SourceLocation) |
198 self.lval = lval | 202 self.lval = lval |
200 self.loc = loc | 204 self.loc = loc |
201 | 205 |
202 def __repr__(self): | 206 def __repr__(self): |
203 return 'ASSIGNMENT' | 207 return 'ASSIGNMENT' |
204 | 208 |
209 class ExpressionStatement(Statement): | |
210 def __init__(self, ex, loc): | |
211 self.ex = ex | |
212 self.loc = loc | |
213 assert isinstance(loc, SourceLocation) | |
214 def __repr__(self): | |
215 return 'Epression' | |
216 | |
205 class IfStatement(Statement): | 217 class IfStatement(Statement): |
206 def __init__(self, condition, truestatement, falsestatement, loc): | 218 def __init__(self, condition, truestatement, falsestatement, loc): |
207 self.condition = condition | 219 self.condition = condition |
208 self.truestatement = truestatement | 220 self.truestatement = truestatement |
209 self.falsestatement = falsestatement | 221 self.falsestatement = falsestatement |