Mercurial > projects > dil
changeset 127:cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
author | aziz |
---|---|
date | Mon, 09 Jul 2007 22:02:01 +0000 |
parents | 0f0e7352e91d |
children | e02b87281b4e |
files | trunk/src/Declarations.d trunk/src/Parser.d |
diffstat | 2 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Declarations.d Mon Jul 09 21:54:05 2007 +0000 +++ b/trunk/src/Declarations.d Mon Jul 09 22:02:01 2007 +0000 @@ -246,3 +246,14 @@ this.elseDecls = elseDecls; } } + +class StaticAssertDeclaration : Declaration +{ + Expression condition, message; + this(Expression condition, Expression message) + { + super(true); + this.condition = condition; + this.message = message; + } +}
--- a/trunk/src/Parser.d Mon Jul 09 21:54:05 2007 +0000 +++ b/trunk/src/Parser.d Mon Jul 09 22:02:01 2007 +0000 @@ -126,6 +126,9 @@ case T.If: decl = parseStaticIfDeclaration(); break; + case T.Assert: + decl = parseStaticAssertDeclaration(); + break; default: goto case_AttributeSpecifier; } @@ -743,6 +746,30 @@ return new StaticIfDeclaration(condition, ifDecls, elseDecls); } + Declaration parseStaticAssertDeclaration() + { + assert(token.type == T.Static); + + nT(); // Skip static keyword. + nT(); // Skip assert keyword. + + Expression condition, message; + + require(T.LParen); + + condition = parseAssignExpression(); + + if (token.type == T.Comma) + { + nT(); + message = parseAssignExpression(); + } + + require(T.RParen); + + return new StaticAssertDeclaration(condition, message); + } + /+++++++++++++++++++++++++++++ + Expression parsing methods + +++++++++++++++++++++++++++++/