Mercurial > projects > dil
changeset 194:b3604b237292
- Implemented parsing variable declarations.
- Added parseInitializer() stub.
author | aziz |
---|---|
date | Sun, 15 Jul 2007 18:49:04 +0000 |
parents | 2a2975b6d539 |
children | 37c2ffd649c4 |
files | trunk/src/Declarations.d trunk/src/Parser.d |
diffstat | 2 files changed, 31 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Declarations.d Sun Jul 15 18:19:01 2007 +0000 +++ b/trunk/src/Declarations.d Sun Jul 15 18:49:04 2007 +0000 @@ -191,13 +191,25 @@ FunctionBody funcBody; this(string funcName, Type funcType, TemplateParameter[] tparams, FunctionBody funcBody) { - super(hasBody); + super(funcBody.funcBody !is null); this.funcName = funcName; this.funcType = funcType; this.funcBody = funcBody; } } +class VariableDeclaration : Declaration +{ + string[] idents; + Expression[] values; + this(string[] idents, Expression[] values) + { + super(false); + this.idents = idents; + this.values = values; + } +} + class InvariantDeclaration : Declaration { Statements statements;
--- a/trunk/src/Parser.d Sun Jul 15 18:19:01 2007 +0000 +++ b/trunk/src/Parser.d Sun Jul 15 18:49:04 2007 +0000 @@ -262,7 +262,25 @@ } // It's a variable declaration. + string[] idents = [ident]; + Expression[] values; + goto LenterLoop; + while (token.type == T.Comma) + { + idents ~= requireIdentifier(); + LenterLoop: + if (token.type == T.Assign) + { + nT(); + values ~= parseInitializer(); + } + } + require(T.Semicolon); + return new VariableDeclaration(idents, values); + } + Expression parseInitializer() + { return null; }