# HG changeset patch # User aziz # Date 1184582224 0 # Node ID 8aecf8925c5f21320607b33e9dcdaff5b437dbb0 # Parent 70715b9e21090ada55b64978cb8538100b261fe9 - Added code for parsing AutoDeclaration in parseDeclaration(). diff -r 70715b9e2109 -r 8aecf8925c5f trunk/src/Parser.d --- a/trunk/src/Parser.d Mon Jul 16 09:56:01 2007 +0000 +++ b/trunk/src/Parser.d Mon Jul 16 10:37:04 2007 +0000 @@ -249,16 +249,36 @@ Declaration parseDeclaration() { - auto type = parseType(); - string ident = requireIdentifier(); + Type type; + string ident; - // Type FunctionName ( Parameters ) - if (token.type == T.LParen) + // Check for AutoDeclaration + if (token.type == T.Identifier) { - // It's a function declaration - type = parseDeclaratorSuffix(type); - auto funcBody = parseFunctionBody(new FunctionBody); - return new FunctionDeclaration(ident, type, null, funcBody); + Token next; + lx.peek(next); + if (next.type == T.Comma || next.type == T.Assign) + { + ident = token.identifier; + nT(); + } + else + goto LnonAutoDeclaration; + } + else + { + LnonAutoDeclaration: + type = parseType(); + ident = requireIdentifier(); + + // Type FunctionName ( Parameters ) FunctionBody + if (token.type == T.LParen) + { + // It's a function declaration + type = parseDeclaratorSuffix(type); + auto funcBody = parseFunctionBody(new FunctionBody); + return new FunctionDeclaration(ident, type, null, funcBody); + } } // It's a variable declaration.