# HG changeset patch # User Aziz K?ksal # Date 1200327705 -3600 # Node ID 68953760d569171ff8c6fd9f6da95da6325cbb60 # Parent 89ee7802c9783c2f4a26e050678a30dc5688a9d7 Added class ParenExpression. diff -r 89ee7802c978 -r 68953760d569 trunk/src/dil/ast/Expressions.d --- a/trunk/src/dil/ast/Expressions.d Mon Jan 14 16:01:21 2008 +0100 +++ b/trunk/src/dil/ast/Expressions.d Mon Jan 14 17:21:45 2008 +0100 @@ -926,6 +926,17 @@ } } +/// ParenthesisExpression := "(" Expression ")" +class ParenExpression : Expression +{ + Expression next; + this(Expression next) + { + mixin(set_kind); + this.next = next; + } +} + // version(D2) // { class TraitsExpression : Expression diff -r 89ee7802c978 -r 68953760d569 trunk/src/dil/ast/NodesEnum.d --- a/trunk/src/dil/ast/NodesEnum.d Mon Jan 14 16:01:21 2008 +0100 +++ b/trunk/src/dil/ast/NodesEnum.d Mon Jan 14 17:21:45 2008 +0100 @@ -169,6 +169,7 @@ "TypeDotIdExpression", "TypeidExpression", "IsExpression", + "ParenExpression", "FunctionLiteralExpression", "TraitsExpression", // D2.0 "VoidInitializer", diff -r 89ee7802c978 -r 68953760d569 trunk/src/dil/parser/Parser.d --- a/trunk/src/dil/parser/Parser.d Mon Jan 14 16:01:21 2008 +0100 +++ b/trunk/src/dil/parser/Parser.d Mon Jan 14 17:21:45 2008 +0100 @@ -741,7 +741,6 @@ if (prev_lt == LinkageType.None) prev_lt = lt; else - // TODO: create new msg RedundantLinkageType. error(begin, MSG.RedundantLinkageType, Token.textSpan(begin, this.prevToken)); } @@ -1074,7 +1073,7 @@ BaseClass[] bases; - while (1) + do { Protection prot = Protection.Public; switch (token.type) @@ -1092,13 +1091,8 @@ LparseBasicType: auto begin = token; auto type = parseBasicType(); - //if (type.tid != TID.DotList) - // TODO: issue error msg. base classes can only be one or more identifiers or template instances separated by dots. bases ~= set(new BaseClass(prot, type), begin); - if (token.type != T.Comma) - break; - nT(); - } + } while (skipped(T.Comma)) return bases; } @@ -1357,7 +1351,6 @@ assert(token.type == T.Delete); nT(); // Skip delete keyword. auto parameters = parseParameterList(); - // TODO: only one parameter of type void* allowed. Check in parsing or semantic phase? auto funcBody = parseFunctionBody(); return new DeleteDeclaration(parameters, funcBody); } @@ -1402,7 +1395,6 @@ { if (skipped(T.LParen)) { - // TODO: What about mixin(...).ident;? auto e = parseAssignExpression(); require(T.RParen); require(T.Semicolon); @@ -2152,7 +2144,6 @@ case ID.exit, ID.success, ID.failure: break; default: - // TODO: create MID.InvalidScopeIdentifier error(this.prevToken, MSG.InvalidScopeIdentifier, this.prevToken.srcText); } require(T.RParen); @@ -3364,7 +3355,7 @@ e = new IsExpression(type, ident, opTok, specTok, specType, tparams); break; case T.LParen: - if (tokenAfterParenIs(T.LBrace)) + if (tokenAfterParenIs(T.LBrace)) // Check for "(...) {" { auto parameters = parseParameterList(); // ( ParameterList ) FunctionBody @@ -3377,7 +3368,7 @@ nT(); e = parseExpression(); require(T.RParen); - // TODO: create ParenExpression? + e = new ParenExpression(e); } break; version(D2) diff -r 89ee7802c978 -r 68953760d569 trunk/src/dil/semantic/Pass1.d --- a/trunk/src/dil/semantic/Pass1.d Mon Jan 14 16:01:21 2008 +0100 +++ b/trunk/src/dil/semantic/Pass1.d Mon Jan 14 17:21:45 2008 +0100 @@ -176,6 +176,16 @@ Declaration visit(MixinDeclaration) { return null; } + Expression visit(ParenExpression e) + { + if (!e.type) + { + e.next = visitE(e.next); + e.type = e.next.type; + } + return e; + } + Expression visit(CommaExpression e) { if (!e.type)