# HG changeset patch # User aziz # Date 1184525344 0 # Node ID b3604b23729225747c38ca057cd7328356d3054f # Parent 2a2975b6d5396b7ffb09a172f7964d8ebd029cd2 - Implemented parsing variable declarations. - Added parseInitializer() stub. diff -r 2a2975b6d539 -r b3604b237292 trunk/src/Declarations.d --- 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; diff -r 2a2975b6d539 -r b3604b237292 trunk/src/Parser.d --- 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; }