Mercurial > lcfOS
comparison python/c3/parser.py @ 232:e621e3ba78d2
Added left shift instruction
author | Windel Bouwman |
---|---|
date | Sun, 14 Jul 2013 11:50:58 +0200 |
parents | 88a1e0baef65 |
children | 6ed3d3a82a63 |
comparison
equal
deleted
inserted
replaced
231:521567d17388 | 232:e621e3ba78d2 |
---|---|
268 ee2 = self.SimpleExpression() | 268 ee2 = self.SimpleExpression() |
269 ee = astnodes.Binop(ee, op.typ, ee2, op.loc) | 269 ee = astnodes.Binop(ee, op.typ, ee2, op.loc) |
270 return ee | 270 return ee |
271 | 271 |
272 def SimpleExpression(self): | 272 def SimpleExpression(self): |
273 """ Shift operations before + and - ? """ | |
274 e = self.AddExpression() | |
275 while self.Peak in ['>>', '<<']: | |
276 op = self.Consume(self.Peak) | |
277 e2 = self.AddExpression() | |
278 e = astnodes.Binop(e, op.typ, e2, op.loc) | |
279 return e | |
280 | |
281 def AddExpression(self): | |
273 e = self.Term() | 282 e = self.Term() |
274 while self.Peak in ['+', '-']: | 283 while self.Peak in ['+', '-']: |
275 op = self.Consume(self.Peak) | 284 op = self.Consume(self.Peak) |
276 e2 = self.Term() | 285 e2 = self.Term() |
277 e = astnodes.Binop(e, op.typ, e2, op.loc) | 286 e = astnodes.Binop(e, op.typ, e2, op.loc) |
312 loc = self.Consume('cast').loc | 321 loc = self.Consume('cast').loc |
313 self.Consume('<') | 322 self.Consume('<') |
314 t = self.parseTypeSpec() | 323 t = self.parseTypeSpec() |
315 self.Consume('>') | 324 self.Consume('>') |
316 self.Consume('(') | 325 self.Consume('(') |
317 ce = self.CastExpression() | 326 ce = self.Expression() |
318 self.Consume(')') | 327 self.Consume(')') |
319 return astnodes.TypeCast(t, ce, loc) | 328 return astnodes.TypeCast(t, ce, loc) |
320 else: | 329 else: |
321 return self.UnaryExpression() | 330 return self.UnaryExpression() |
322 | 331 |