Mercurial > projects > dil
diff trunk/src/Parser.d @ 283:df657dd98ffa
- Fix: added member type to VariableDeclaration.
- Changed class IfStatement. parseIfStatement() parses a DeclarationStatement if the condition is not an expression.
author | aziz |
---|---|
date | Tue, 07 Aug 2007 14:56:02 +0000 |
parents | 74113a9aa77c |
children | 00c887e6c0aa |
line wrap: on
line diff
--- a/trunk/src/Parser.d Tue Aug 07 09:09:03 2007 +0000 +++ b/trunk/src/Parser.d Tue Aug 07 14:56:02 2007 +0000 @@ -383,7 +383,7 @@ values ~= null; } require(T.Semicolon); - return new VariableDeclaration(idents, values); + return new VariableDeclaration(type, idents, values); } Expression parseInitializer() @@ -1870,18 +1870,23 @@ assert(token.type == T.If); nT(); - Type type; - Token* ident; + Statement variable; Expression condition; Statement ifBody, elseBody; require(T.LParen); + + Token* ident; // auto Identifier = Expression if (token.type == T.Auto) { + auto a = new AttributeStatement(token.type, null); nT(); ident = requireId(); require(T.Assign); + auto init = parseExpression(); + a.statement = new DeclarationStatement(new VariableDeclaration(null, [ident], [init])); + variable = a; } else { @@ -1893,14 +1898,15 @@ return type; } bool success; - type = try_(parseDeclaratorAssign(), success); - if (!success) + auto type = try_(parseDeclaratorAssign(), success); + if (success) { - type = null; - ident = null; + auto init = parseExpression(); + variable = new DeclarationStatement(new VariableDeclaration(type, [ident], [init])); } + else + condition = parseExpression(); } - condition = parseExpression(); require(T.RParen); ifBody = parseScopeStatement(); if (token.type == T.Else) @@ -1908,7 +1914,7 @@ nT(); elseBody = parseScopeStatement(); } - return new IfStatement(type, ident, condition, ifBody, elseBody); + return new IfStatement(variable, condition, ifBody, elseBody); } Statement parseWhileStatement()