Mercurial > projects > dil
changeset 164:8ec99326752b
- Implemented parseWhileStatement().
- Renamed parseScopeBlockStatement() to parseScopeStatement().
author | aziz |
---|---|
date | Fri, 13 Jul 2007 22:55:05 +0000 |
parents | f27a98bb17c7 |
children | 797074d143d7 |
files | trunk/src/Parser.d trunk/src/Statements.d |
diffstat | 2 files changed, 24 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Parser.d Fri Jul 13 22:41:03 2007 +0000 +++ b/trunk/src/Parser.d Fri Jul 13 22:55:05 2007 +0000 @@ -1139,7 +1139,11 @@ case T.If: s = parseIfStatement(); break; + case T.While: + s = parseWhileStatement(); + break; default: + // TODO: issue error msg and return IllegalStatement. } return s; } @@ -1152,7 +1156,7 @@ { } { StatementList } +/ - Statement parseScopeBlockStatement() + Statement parseScopeStatement() { Statement s; if (token.type == T.LBrace) @@ -1204,15 +1208,25 @@ } condition = parseExpression(); require(T.RParen); - ifBody = parseScopeBlockStatement(); + ifBody = parseScopeStatement(); if (token.type == T.Else) { nT(); - elseBody = parseScopeBlockStatement(); + elseBody = parseScopeStatement(); } return new IfStatement(type, ident, condition, ifBody, elseBody); } + Statement parseWhileStatement() + { + assert(token.type == T.While); + nT(); + require(T.RParen); + auto condition = parseExpression(); + require(T.LParen); + return new WhileStatement(condition, parseScopeStatement()); + } + /+++++++++++++++++++++++++++++ + Expression parsing methods + +++++++++++++++++++++++++++++/
--- a/trunk/src/Statements.d Fri Jul 13 22:41:03 2007 +0000 +++ b/trunk/src/Statements.d Fri Jul 13 22:55:05 2007 +0000 @@ -74,7 +74,13 @@ class WhileStatement : Statement { - + Expression condition; + Statement whileBody; + this(Expression condition, Statement whileBody) + { + this.condition = condition; + this.whileBody = whileBody; + } } class DoStatement : Statement