Mercurial > projects > dil
diff trunk/src/dil/parser/Parser.d @ 637:fe66cecb6ec9
Reporting error if module declaration is not first.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Mon, 14 Jan 2008 01:06:17 +0100 |
parents | 14e99ce74d06 |
children | 7131c07997f9 |
line wrap: on
line diff
--- a/trunk/src/dil/parser/Parser.d Mon Jan 14 00:21:13 2008 +0100 +++ b/trunk/src/dil/parser/Parser.d Mon Jan 14 01:06:17 2008 +0100 @@ -173,6 +173,7 @@ Declaration parseModuleDeclaration() { + assert(token.type == T.Module); auto begin = token; ModuleFQN moduleFQN; do @@ -268,12 +269,10 @@ return parseStorageAttribute(); case T.Alias: nT(); - // TODO: parse StorageClasses? decl = new AliasDeclaration(parseVariableOrFunction()); break; case T.Typedef: nT(); - // TODO: parse StorageClasses? decl = new TypedefDeclaration(parseVariableOrFunction()); break; case T.Static: @@ -365,12 +364,18 @@ case T.Identifier, T.Dot, T.Typeof: case_Declaration: return parseVariableOrFunction(this.storageClass, this.protection, this.linkageType); - /+case T.Module: + /+case : // TODO: Error: module is optional and can appear only once at the top of the source file. break;+/ default: if (token.isIntegralType) goto case_Declaration; + else if (token.type == T.Module) + { + decl = parseModuleDeclaration(); + error(begin, MSG.ModuleDeclarationNotFirst); + return decl; + } decl = new IllegalDeclaration(); // Skip to next valid token.