Mercurial > projects > dil
changeset 555:d9e328c3bab9
Fixed infinite loop in dil.Parser.parseMixin().
Fixed MSG.ExpectedNonEmptyStatement.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 22 Dec 2007 20:16:30 +0100 |
parents | d6212e3b9f36 |
children | 19554e79e6d2 |
files | trunk/src/dil/Messages.d trunk/src/dil/Parser.d |
diffstat | 2 files changed, 14 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/dil/Messages.d Thu Dec 20 23:33:30 2007 +0100 +++ b/trunk/src/dil/Messages.d Sat Dec 22 20:16:30 2007 +0100 @@ -131,7 +131,7 @@ auto ExpectedTemplateName = "expected template name, not '{}'"; auto ExpectedAnIdentifier = "expected an identifier, not '{}'"; auto IllegalStatement = "illegal Statement found: "; - auto ExpectedNonEmptyStatement = "didn't expect ';', use {{ }} instead"; + auto ExpectedNonEmptyStatement = "didn't expect ';', use {{ } instead"; auto ExpectedScopeIdentifier = "expected 'exit', 'success' or 'failure', not '{}'"; auto InvalidScopeIdentifier = "'exit', 'success', 'failure' are valid scope identifiers, but not '{}';"; auto ExpectedIntegerAfterAlign = "expected an integer after align, not '{}'";
--- a/trunk/src/dil/Parser.d Thu Dec 20 23:33:30 2007 +0100 +++ b/trunk/src/dil/Parser.d Sat Dec 22 20:16:30 2007 +0100 @@ -432,7 +432,10 @@ /++ Parses either a VariableDeclaration or a FunctionDeclaration. Params: - stc = the previously parsed storage classes + stc = previously parsed storage classes + protection = previously parsed protection attribute + linkType = previously parsed linkage type + testAutoDeclaration = whether to check for an AutoDeclaration optionalParameterList = a hint for how to parse C-style function pointers +/ Declaration parseVariableOrFunction(StorageClass stc = StorageClass.None, @@ -921,13 +924,13 @@ assert(token.type == T.Import || token.type == T.Static); bool isStatic = skipped(T.Static); assert(token.type == T.Import); + nT(); // Skip import keyword. ModuleFQN[] moduleFQNs; Identifier*[] moduleAliases; Identifier*[] bindNames; Identifier*[] bindAliases; - nT(); // Skip import keyword. while (1) { ModuleFQN moduleFQN; @@ -986,14 +989,13 @@ Declaration parseEnumDeclaration() { assert(token.type == T.Enum); + nT(); // Skip enum keyword. Identifier* enumName; Type baseType; EnumMember[] members; bool hasBody; - nT(); // Skip enum keyword. - enumName = optionalIdentifier(); if (skipped(T.Colon)) @@ -1035,13 +1037,13 @@ Declaration parseClassDeclaration() { assert(token.type == T.Class); + nT(); // Skip class keyword. Identifier* className; TemplateParameters tparams; BaseClass[] bases; Declarations decls; - nT(); // Skip class keyword. className = requireIdentifier(MSG.ExpectedClassName); if (token.type == T.LParen) @@ -1104,13 +1106,13 @@ Declaration parseInterfaceDeclaration() { assert(token.type == T.Interface); + nT(); // Skip interface keyword. Identifier* name; TemplateParameters tparams; BaseClass[] bases; Declarations decls; - nT(); // Skip interface keyword. name = requireIdentifier(MSG.ExpectedInterfaceName); if (token.type == T.LParen) @@ -1135,15 +1137,13 @@ Declaration parseAggregateDeclaration() { assert(token.type == T.Struct || token.type == T.Union); - TOK tok = token.type; + nT(); // Skip struct or union keyword. Identifier* name; TemplateParameters tparams; Declarations decls; - nT(); // Skip struct or union keyword. - name = optionalIdentifier(); if (name && token.type == T.LParen) @@ -1529,7 +1529,7 @@ if (skipped(T.Dot)) templateIdent ~= set(new DotExpression(), begin); - while (1) + do { begin = token; auto ident = requireIdentifier(MSG.ExpectedAnIdentifier); @@ -2154,6 +2154,7 @@ assert(token.type == T.Break); nT(); auto ident = optionalIdentifier(); + require(T.Semicolon); return new BreakStatement(ident); } @@ -2352,9 +2353,9 @@ nT(); Expression condition, message; require(T.LParen); - condition = parseAssignExpression(); + condition = parseAssignExpression(); // Condition. if (skipped(T.Comma)) - message = parseAssignExpression(); + message = parseAssignExpression(); // Error message. require(T.RParen); require(T.Semicolon); return new StaticAssertStatement(condition, message);