comparison python/c3/parser.py @ 230:88a1e0baef65

Added some tests for IR-code
author Windel Bouwman
date Sat, 13 Jul 2013 19:53:44 +0200
parents 7f18ed9b6b7e
children e621e3ba78d2
comparison
equal deleted inserted replaced
229:51d5ed1bd503 230:88a1e0baef65
307 """ 307 """
308 the C-style type cast conflicts with '(' expr ')' 308 the C-style type cast conflicts with '(' expr ')'
309 so introduce extra keyword 'cast' 309 so introduce extra keyword 'cast'
310 """ 310 """
311 if self.Peak == 'cast': 311 if self.Peak == 'cast':
312 self.Consume('cast') 312 loc = self.Consume('cast').loc
313 self.Consume('<') 313 self.Consume('<')
314 t = self.parseTypeSpec() 314 t = self.parseTypeSpec()
315 self.Consume('>') 315 self.Consume('>')
316 self.Consume('(') 316 self.Consume('(')
317 ce = self.CastExpression() 317 ce = self.CastExpression()
318 self.Consume(')') 318 self.Consume(')')
319 return astnodes.TypeCast(t, ce) 319 return astnodes.TypeCast(t, ce, loc)
320 else: 320 else:
321 return self.UnaryExpression() 321 return self.UnaryExpression()
322 322
323 def UnaryExpression(self): 323 def UnaryExpression(self):
324 if self.Peak in ['&', '*']: 324 if self.Peak in ['&', '*']:
325 op = self.Consume(self.Peak) 325 op = self.Consume(self.Peak)
326 ce = self.CastExpression() 326 ce = self.CastExpression()
327 if op.val == '*': 327 if op.val == '*':