Mercurial > lcfOS
diff python/c3/parser.py @ 222:c3f1ce8b638f
Fixup of parser
author | Windel Bouwman |
---|---|
date | Tue, 09 Jul 2013 17:36:31 +0200 |
parents | 848c4b15fd0b |
children | 1c7364bd74c7 |
line wrap: on
line diff
--- a/python/c3/parser.py Mon Jul 08 22:21:44 2013 +0200 +++ b/python/c3/parser.py Tue Jul 09 17:36:31 2013 +0200 @@ -235,7 +235,7 @@ rhs = self.Expression() return astnodes.Assignment(x, rhs, loc) else: - return x + return astnodes.ExpressionStatement(x, x.loc) # Expression section: # We not implement these C constructs: @@ -302,20 +302,16 @@ # Domain of unary expressions: def CastExpression(self): - # TODO: cast conflicts with '(' expr ')', so introduce extra keyword 'cast' + # type cast conflicts with '(' expr ')', so introduce extra keyword 'cast' if self.Peak == 'cast': self.Consume('cast') self.Consume('<') - print('TODO: implement type cast') t = self.parseTypeSpec() - - # Type self.Consume('>') self.Consume('(') ce = self.CastExpression() self.Consume(')') - # TODO: use type spec here - return ce + return astnodes.TypeCast(t, ce) else: return self.UnaryExpression()