Mercurial > projects > dil
changeset 147:e46b3415ec16
- Implemented parsing pragma declarations.
- Added class PragmaDeclaration.
author | aziz |
---|---|
date | Thu, 12 Jul 2007 14:20:05 +0000 |
parents | 8180eb84e69c |
children | e3e4d3314166 |
files | trunk/src/Declarations.d trunk/src/Parser.d |
diffstat | 2 files changed, 41 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Declarations.d Thu Jul 12 13:55:00 2007 +0000 +++ b/trunk/src/Declarations.d Thu Jul 12 14:20:05 2007 +0000 @@ -327,3 +327,17 @@ this.decls = decls; } } + +class PragmaDeclaration : Declaration +{ + string ident; + Expression[] args; + Declaration[] decls; + this(string ident, Expression[] args, Declaration[] decls) + { + super(true); + this.ident = ident; + this.args = args; + this.decls = decls; + } +}
--- a/trunk/src/Parser.d Thu Jul 12 13:55:00 2007 +0000 +++ b/trunk/src/Parser.d Thu Jul 12 14:20:05 2007 +0000 @@ -266,10 +266,37 @@ decl = new AlignDeclaration(size, parseDeclarationsBlock()); break; case T.Pragma: + // Pragma: + // pragma ( Identifier ) + // pragma ( Identifier , ExpressionList ) + // ExpressionList: + // AssignExpression + // AssignExpression , ExpressionList + nT(); + string ident; + Expression[] args; + Declaration[] decls; + + require(T.LParen); + ident = requireIdentifier(); + + if (token.type == T.Comma) + args = parseArguments(T.RParen); + else + require(T.RParen); + + if (token.type == T.Semicolon) + nT(); + else + decls = parseDeclarationsBlock(); + + decl = new PragmaDeclaration(ident, args, decls); + break; case T.Private: case T.Package: case T.Protected: case T.Public: + break; case T.Export: case T.Override: case T.Deprecated: