Mercurial > projects > dil
changeset 118:379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
author | aziz |
---|---|
date | Mon, 09 Jul 2007 16:59:05 +0000 |
parents | 79857de26e86 |
children | 363cd39022f9 |
files | trunk/src/Declarations.d trunk/src/Parser.d |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Declarations.d Mon Jul 09 16:36:05 2007 +0000 +++ b/trunk/src/Declarations.d Mon Jul 09 16:59:05 2007 +0000 @@ -143,3 +143,13 @@ this.statements = statements; } } + +class DestructorDeclaration : Declaration +{ + Statement[] statements; + this(Statement[] statements) + { + super(true); + this.statements = statements; + } +}
--- a/trunk/src/Parser.d Mon Jul 09 16:36:05 2007 +0000 +++ b/trunk/src/Parser.d Mon Jul 09 16:59:05 2007 +0000 @@ -133,6 +133,9 @@ case T.This: decl = parseConstructorDeclaration(); break; + case T.Tilde: + decl = parseDestructorDeclaration(); + break; case T.Module: // Error: module is optional and can only appear once at the top of the source file. break; @@ -473,6 +476,19 @@ return new ConstructorDeclaration(parameters, statements); } + Declaration parseDestructorDeclaration() + { + assert(token.type == T.Tilde); + nT(); // Skip ~ + require(T.This); + require(T.LParen); + require(T.RParen); + require(T.LBrace); + auto statements = parseStatements(); + require(T.RBrace); + return new DestructorDeclaration(statements); + } + /+++++++++++++++++++++++++++++ + Expression parsing methods + +++++++++++++++++++++++++++++/