# HG changeset patch # User aziz # Date 1186688943 0 # Node ID dc8bed242db5c6280715d20c6853c3a9312b3733 # Parent b16dda92c3dd49b7cbb98021cfd9017ccd2ae200 - Fixed parsing ImportDeclaration. diff -r b16dda92c3dd -r dc8bed242db5 trunk/src/Parser.d --- a/trunk/src/Parser.d Thu Aug 09 16:41:00 2007 +0000 +++ b/trunk/src/Parser.d Thu Aug 09 19:49:03 2007 +0000 @@ -290,7 +290,6 @@ // TODO: Error: module is optional and can appear only once at the top of the source file. break;+/ default: - // TODO: issue error msg. error(MID.ExpectedButFound, "Declaration", token.srcText); decl = new IllegalDeclaration(token); nT(); @@ -737,7 +736,6 @@ { assert(token.type == T.Import || token.type == T.Static); - Declaration decl; bool isStatic; if (token.type == T.Static) @@ -752,7 +750,7 @@ Token*[] bindAliases; nT(); // Skip import keyword. - do + while (1) { ModuleName moduleName; Token* moduleAlias; @@ -771,8 +769,7 @@ moduleAlias = null; } - - // parse Identifier(.Identifier)* + // Identifier(.Identifier)* while (token.type == T.Dot) { nT(); @@ -783,35 +780,44 @@ moduleNames ~= moduleName; moduleAliases ~= moduleAlias; - // parse : BindAlias = BindName(, BindAlias = BindName)*; - // : BindName(, BindName)*; if (token.type == T.Colon) + break; + if (token.type != T.Comma) + break; + nT(); + } + + if (token.type == T.Colon) + { + // BindAlias = BindName(, BindAlias = BindName)*; + // BindName(, BindName)*; + Token* bindName, bindAlias; + while (1) { - Token* bindName, bindAlias; - do + nT(); + bindAlias = requireId(); + + if (token.type == T.Assign) { nT(); - bindAlias = requireId(); - - if (token.type == T.Assign) - { - nT(); - bindName = requireId(); - } - else - { - bindName = bindAlias; - bindAlias = null; - } - - // Push identifiers. - bindNames ~= bindName; - bindAliases ~= bindAlias; - - } while (token.type == T.Comma) - break; + bindName = requireId(); + } + else + { + bindName = bindAlias; + bindAlias = null; + } + + // Push identifiers. + bindNames ~= bindName; + bindAliases ~= bindAlias; + + if (token.type != T.Comma) + break; + nT(); } - } while (token.type == T.Comma) + } + require(T.Semicolon); return new ImportDeclaration(moduleNames, moduleAliases, bindNames, bindAliases); @@ -989,8 +995,6 @@ else expected(T.LBrace); // TODO: better error msg - // TODO: error if decls.length == 0 - return new InterfaceDeclaration(name, tparams, bases, decls, hasBody); } @@ -1031,8 +1035,6 @@ else expected(T.LBrace); // TODO: better error msg - // TODO: error if decls.length == 0 - if (tok == T.Struct) return new StructDeclaration(name, tparams, decls, hasBody); else