# HG changeset patch # User Aziz K?ksal # Date 1200271544 -3600 # Node ID 1b1315ac27a406ad587a6adfa6a577a6a0f7a921 # Parent 7131c07997f969ff9c33d9bf7bfb53478dfd0d04 Added two error messages. diff -r 7131c07997f9 -r 1b1315ac27a4 trunk/src/dil/Messages.d --- a/trunk/src/dil/Messages.d Mon Jan 14 01:12:28 2008 +0100 +++ b/trunk/src/dil/Messages.d Mon Jan 14 01:45:44 2008 +0100 @@ -119,6 +119,8 @@ auto ExpectedClassBody = "expected class body, not '{}'"; auto ExpectedInterfaceName = "expected interface name, not '{}'"; auto ExpectedInterfaceBody = "expected interface body, not '{}'"; + auto ExpectedStructBody = "expected struct body, not '{}'"; + auto ExpectedUnionBody = "expected union body, not '{}'"; auto ExpectedTemplateName = "expected template name, not '{}'"; auto ExpectedAnIdentifier = "expected an identifier, not '{}'"; auto IllegalStatement = "illegal Statement found: {}"; diff -r 7131c07997f9 -r 1b1315ac27a4 trunk/src/dil/parser/Parser.d --- a/trunk/src/dil/parser/Parser.d Mon Jan 14 01:12:28 2008 +0100 +++ b/trunk/src/dil/parser/Parser.d Mon Jan 14 01:45:44 2008 +0100 @@ -364,9 +364,6 @@ case T.Identifier, T.Dot, T.Typeof: case_Declaration: return parseVariableOrFunction(this.storageClass, this.protection, this.linkageType); - /+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; @@ -1009,11 +1006,8 @@ if (skipped(T.Colon)) baseType = parseBasicType(); - if (skipped(T.Semicolon)) - { - if (enumName is null) - expected(T.Identifier); - } + if (enumName && skipped(T.Semicolon)) + {} else if (skipped(T.LBrace)) { hasBody = true; @@ -1060,11 +1054,8 @@ if (token.type == T.Colon) bases = parseBaseClasses(); - if (skipped(T.Semicolon)) - { - if (bases.length != 0) - error(MID.BaseClassInForwardDeclaration); - } + if (bases.length == 0 && skipped(T.Semicolon)) + {} else if (token.type == T.LBrace) decls = parseDeclarationDefinitionsBody(); else @@ -1129,11 +1120,8 @@ if (token.type == T.Colon) bases = parseBaseClasses(); - if (skipped(T.Semicolon)) - { - if (bases.length != 0) - error(MID.BaseClassInForwardDeclaration); - } + if (bases.length == 0 && skipped(T.Semicolon)) + {} else if (token.type == T.LBrace) decls = parseDeclarationDefinitionsBody(); else @@ -1157,15 +1145,14 @@ if (name && token.type == T.LParen) tparams = parseTemplateParameterList(); - if (skipped(T.Semicolon)) - { - //if (name.length == 0) - // TODO: error: forward declarations must have a name. - } + if (name && skipped(T.Semicolon)) + {} else if (token.type == T.LBrace) decls = parseDeclarationDefinitionsBody(); else - expected(T.LBrace); // TODO: better error msg + error(token, tok == T.Struct ? + MSG.ExpectedStructBody : + MSG.ExpectedUnionBody, token.srcText); if (tok == T.Struct) {