Mercurial > lcfOS
diff python/c3/parser.py @ 155:b28a11c01dbe
Simplified IR classes
author | Windel Bouwman |
---|---|
date | Sun, 03 Mar 2013 13:20:03 +0100 |
parents | b73bc14a3aa3 |
children | 8f3924b6076e |
line wrap: on
line diff
--- a/python/c3/parser.py Sat Mar 02 10:19:38 2013 +0100 +++ b/python/c3/parser.py Sun Mar 03 13:20:03 2013 +0100 @@ -124,7 +124,7 @@ while self.hasConsumed(','): args.append(self.parseExpression()) self.Consume(')') - return ProcedureCall(procedure, args) + return astnodes.ProcedureCall(procedure, args) def parseIfStatement(self): self.Consume('if') @@ -154,6 +154,7 @@ self.Consume('{') statements = [self.parseStatement()] while self.hasConsumed(';'): + if self.Peak == '}': break # Permit last ';' statements.append(self.parseStatement()) self.Consume('}') return astnodes.CompoundStatement(statements) @@ -166,6 +167,8 @@ return self.parseWhileStatement() elif self.Peak == '{': return self.parseCompoundStatement() + elif self.Peak == ';': + return astnodes.EmptyStatement() elif self.Peak == 'var': return self.parseVarDef() elif self.Peak == 'return': @@ -191,7 +194,10 @@ return self.sema.actOnNumber(val.val, val.loc) elif self.Peak == 'ID': d = self.parseDesignator() - return self.sema.actOnVariableUse(d) + if self.Peak == '(': + return self.parseProcedureCall(d) + else: + return self.sema.actOnVariableUse(d) self.Error('Expected NUM, ID or (expr), got {0}'.format(self.Peak)) def parseBinopRhs(self, lhs, min_prec):