1
0
mirror of https://github.com/golang/go synced 2024-09-25 03:10:12 -06:00

Handle presence of illegal semicolon after package clause better.

R=r, r1
https://golang.org/cl/157167
This commit is contained in:
Robert Griesemer 2009-11-24 17:34:08 -08:00
parent a38ec58df0
commit 28f1914023

View File

@ -1977,6 +1977,14 @@ func (p *parser) parseFile() *ast.File {
doc := p.leadComment; doc := p.leadComment;
pos := p.expect(token.PACKAGE); pos := p.expect(token.PACKAGE);
ident := p.parseIdent(); ident := p.parseIdent();
// Common error: semicolon after package clause.
// Accept and report it for better error synchronization.
if p.tok == token.SEMICOLON {
p.Error(p.pos, "expected declaration, found ';'");
p.next();
}
var decls []ast.Decl; var decls []ast.Decl;
// Don't bother parsing the rest if we had errors already. // Don't bother parsing the rest if we had errors already.