comparison python/ppci/c3/astnodes.py @ 307:e609d5296ee9

Massive rewrite of codegenerator
author Windel Bouwman
date Thu, 12 Dec 2013 20:42:56 +0100
parents b145f8e6050b
children 2e7f55319858
comparison
equal deleted inserted replaced
306:b145f8e6050b 307:e609d5296ee9
282 """ Base class of all statements """ 282 """ Base class of all statements """
283 def __init__(self, loc): 283 def __init__(self, loc):
284 self.loc = loc 284 self.loc = loc
285 285
286 286
287 class EmptyStatement(Statement): 287 class Empty(Statement):
288 """ Empty statement which does nothing! """ 288 """ Empty statement which does nothing! """
289 def __init__(self): 289 def __init__(self):
290 super().__init__(None) 290 super().__init__(None)
291 291
292 def __repr__(self): 292 def __repr__(self):
293 return 'NOP' 293 return 'NOP'
294 294
295 295
296 class CompoundStatement(Statement): 296 class Compound(Statement):
297 """ Statement consisting of a sequence of other statements """ 297 """ Statement consisting of a sequence of other statements """
298 def __init__(self, statements): 298 def __init__(self, statements):
299 super().__init__(None) 299 super().__init__(None)
300 self.statements = statements 300 self.statements = statements
301 for s in self.statements: 301 for s in self.statements:
303 303
304 def __repr__(self): 304 def __repr__(self):
305 return 'COMPOUND STATEMENT' 305 return 'COMPOUND STATEMENT'
306 306
307 307
308 class ReturnStatement(Statement): 308 class Return(Statement):
309 def __init__(self, expr, loc): 309 def __init__(self, expr, loc):
310 super().__init__(loc) 310 super().__init__(loc)
311 self.expr = expr 311 self.expr = expr
312 312
313 def __repr__(self): 313 def __repr__(self):
333 333
334 def __repr__(self): 334 def __repr__(self):
335 return 'Epression' 335 return 'Epression'
336 336
337 337
338 class IfStatement(Statement): 338 class If(Statement):
339 def __init__(self, condition, truestatement, falsestatement, loc): 339 def __init__(self, condition, truestatement, falsestatement, loc):
340 super().__init__(loc) 340 super().__init__(loc)
341 self.condition = condition 341 self.condition = condition
342 self.truestatement = truestatement 342 self.truestatement = truestatement
343 self.falsestatement = falsestatement 343 self.falsestatement = falsestatement
344 344
345 def __repr__(self): 345 def __repr__(self):
346 return 'IF-statement' 346 return 'IF-statement'
347 347
348 348
349 class WhileStatement(Statement): 349 class While(Statement):
350 def __init__(self, condition, statement, loc): 350 def __init__(self, condition, statement, loc):
351 super().__init__(loc) 351 super().__init__(loc)
352 self.condition = condition 352 self.condition = condition
353 self.statement = statement 353 self.statement = statement
354 354