Mercurial > projects > dil
changeset 256:8f27920ae17a
- Made parseMixinDeclaration() a template.
- Changed MixinStatement class. Added members templateIdent and mixinIdent.
author | aziz |
---|---|
date | Wed, 01 Aug 2007 20:13:03 +0000 |
parents | 7ba0229af908 |
children | 6c58366ba1eb |
files | trunk/src/Parser.d trunk/src/Statements.d |
diffstat | 2 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Parser.d Wed Aug 01 19:27:02 2007 +0000 +++ b/trunk/src/Parser.d Wed Aug 01 20:13:03 2007 +0000 @@ -253,7 +253,7 @@ decl = parseDeleteDeclaration(); break; case T.Mixin: - decl = parseMixinDeclaration(); + decl = parseMixin!(MixinDeclaration)(); break; case T.Semicolon: nT(); @@ -1395,11 +1395,13 @@ mixin TemplateIdentifier !( TemplateArguments ) ; mixin TemplateIdentifier !( TemplateArguments ) MixinIdentifier ; */ - Declaration parseMixinDeclaration() + Class parseMixin(Class)() { assert(token.type == T.Mixin); + auto begin = token; nT(); // Skip mixin keyword. + static if (is(Class == MixinDeclaration)) if (token.type == T.LParen) { // TODO: What about mixin(...).ident;? @@ -1407,7 +1409,7 @@ auto e = parseAssignExpression(); require(T.RParen); require(T.Semicolon); - return new MixinDeclaration(e); + return set(new MixinDeclaration(e), begin); } Expression[] templateIdent; @@ -1448,7 +1450,7 @@ require(T.Semicolon); - return new MixinDeclaration(templateIdent, mixinIdent); + return set(new Class(templateIdent, mixinIdent), begin); } /+++++++++++++++++++++++++++++ @@ -1587,7 +1589,7 @@ case T.Mixin: if (peekNext() == T.LParen) goto default; // Parse as expression. - s = new MixinStatement(parseMixinDeclaration()); + s = parseMixin!(MixinStatement)(); break; case T.Static: switch (peekNext())
--- a/trunk/src/Statements.d Wed Aug 01 19:27:02 2007 +0000 +++ b/trunk/src/Statements.d Wed Aug 01 20:13:03 2007 +0000 @@ -336,10 +336,12 @@ class MixinStatement : Statement { - Declaration decl; - this(Declaration decl) + Expression[] templateIdent; + Token* mixinIdent; + this(Expression[] templateIdent, Token* mixinIdent) { - this.decl = decl; + this.templateIdent = templateIdent; + this.mixinIdent = mixinIdent; } }