Mercurial > projects > dil
changeset 120:e5329dac0405
- Added parseInvariantDeclaration().
- Added InvariantDeclaration class.
author | aziz |
---|---|
date | Mon, 09 Jul 2007 17:48:03 +0000 |
parents | 363cd39022f9 |
children | 030933c6b5f0 |
files | trunk/src/Declarations.d trunk/src/Parser.d |
diffstat | 2 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Declarations.d Mon Jul 09 17:21:05 2007 +0000 +++ b/trunk/src/Declarations.d Mon Jul 09 17:48:03 2007 +0000 @@ -173,3 +173,13 @@ this.statements = statements; } } + +class InvariantDeclaration : Declaration +{ + Statement[] statements; + this(Statement[] statements) + { + super(true); + this.statements = statements; + } +}
--- a/trunk/src/Parser.d Mon Jul 09 17:21:05 2007 +0000 +++ b/trunk/src/Parser.d Mon Jul 09 17:48:03 2007 +0000 @@ -143,6 +143,9 @@ case T.Tilde: decl = parseDestructorDeclaration(); break; + case T.Invariant: + decl = parseInvariantDeclaration(); + break; case T.Module: // Error: module is optional and can only appear once at the top of the source file. break; @@ -523,6 +526,22 @@ return new StaticDestructorDeclaration(statements); } + Declaration parseInvariantDeclaration() + { + assert(token.type == T.Invariant); + nT(); // Skip invariant keyword. + // Optional () for getting ready porting to D 2.0 + if (token.type == T.LParen) + { + nT(); + require(T.RParen); + } + require(T.LBrace); + auto statements = parseStatements(); + require(T.RBrace); + return new InvariantDeclaration(statements); + } + /+++++++++++++++++++++++++++++ + Expression parsing methods + +++++++++++++++++++++++++++++/