Mercurial > lcfOS
diff python/c3/parser.py @ 165:598d3888a11c
Added front class and fided AST view
author | Windel Bouwman |
---|---|
date | Fri, 22 Mar 2013 15:12:38 +0100 |
parents | e023d3ce1d63 |
children | da0087b82fbe |
line wrap: on
line diff
--- a/python/c3/parser.py Mon Mar 18 22:15:57 2013 +0100 +++ b/python/c3/parser.py Fri Mar 22 15:12:38 2013 +0100 @@ -126,7 +126,7 @@ # Statements: def parseAssignment(self, lval): - lval = self.sema.actOnVariableUse(lval) + lval = self.sema.actOnVariableUse(lval, lval.loc) loc = self.Consume('=').loc rval = self.parseExpression() self.Consume(';') @@ -143,15 +143,16 @@ return astnodes.ProcedureCall(procedure, args) def parseIfStatement(self): - self.Consume('if') + loc = self.Consume('if').loc self.Consume('(') condition = self.parseExpression() self.Consume(')') yes = self.parseCompoundStatement() if self.hasConsumed('else'): no = self.parseCompoundStatement() - return astnodes.IfStatement(condition, yes, no) - return astnodes.IfStatement(condition, yes, astnodes.EmptyStatement()) + else: + no = astnodes.EmptyStatement() + return self.sema.actOnIfStatement(condition, yes, no, loc) def parseWhileStatement(self): self.Consume('while') @@ -216,7 +217,7 @@ if self.Peak == '(': return self.parseProcedureCall(d) else: - return self.sema.actOnVariableUse(d) + return self.sema.actOnVariableUse(d, d.loc) self.Error('Expected NUM, ID or (expr), got {0}'.format(self.Peak)) def parseBinopRhs(self, lhs, min_prec):