Mercurial > lcfOS
diff python/c3/parser.py @ 228:7f18ed9b6b7e
Removal of emptystatement class
author | Windel Bouwman |
---|---|
date | Sat, 13 Jul 2013 11:12:24 +0200 |
parents | 82dfe6a32717 |
children | 88a1e0baef65 |
line wrap: on
line diff
--- a/python/c3/parser.py Fri Jul 12 17:42:39 2013 +0200 +++ b/python/c3/parser.py Sat Jul 13 11:12:24 2013 +0200 @@ -28,6 +28,10 @@ def Peak(self): return self.token.typ + @property + def CurLoc(self): + return self.token.loc + def hasConsumed(self, typ): if self.Peak == typ: self.Consume(typ) @@ -181,7 +185,7 @@ if self.hasConsumed('else'): no = self.parseCompoundStatement() else: - no = astnodes.EmptyStatement() + no = None return astnodes.IfStatement(condition, yes, no, loc) def parseWhileStatement(self): @@ -203,7 +207,7 @@ statements = [] while not self.hasConsumed('}'): s = self.Statement() - if type(s) is astnodes.EmptyStatement: + if s is None: continue statements.append(s) return astnodes.CompoundStatement(statements) @@ -217,10 +221,9 @@ elif self.Peak == '{': return self.parseCompoundStatement() elif self.hasConsumed(';'): - return astnodes.EmptyStatement() + pass elif self.Peak == 'var': self.parseVarDef() - return astnodes.EmptyStatement() elif self.Peak == 'return': return self.parseReturnStatement() else: @@ -301,7 +304,10 @@ # Domain of unary expressions: def CastExpression(self): - # type cast conflicts with '(' expr ')', so introduce extra keyword 'cast' + """ + the C-style type cast conflicts with '(' expr ')' + so introduce extra keyword 'cast' + """ if self.Peak == 'cast': self.Consume('cast') self.Consume('<')