Mercurial > projects > dil
changeset 639:1b1315ac27a4
Added two error messages.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Mon, 14 Jan 2008 01:45:44 +0100 |
parents | 7131c07997f9 |
children | 05645f5613c1 |
files | trunk/src/dil/Messages.d trunk/src/dil/parser/Parser.d |
diffstat | 2 files changed, 13 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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: {}";
--- 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) {