Mercurial > projects > dil
changeset 202:8aecf8925c5f
- Added code for parsing AutoDeclaration in parseDeclaration().
author | aziz |
---|---|
date | Mon, 16 Jul 2007 10:37:04 +0000 |
parents | 70715b9e2109 |
children | 4f949a3a394b |
files | trunk/src/Parser.d |
diffstat | 1 files changed, 28 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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.