mirror of
https://github.com/golang/go
synced 2024-11-25 09:17:57 -07:00
- do not accept forward-declarations for structs and interfaces anymore
R=r DELTA=49 (0 added, 14 deleted, 35 changed) OCL=33272 CL=33272
This commit is contained in:
parent
137c2204db
commit
ce1dd6cce3
@ -457,33 +457,26 @@ func (p *parser) parseStructType() *ast.StructType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pos := p.expect(token.STRUCT);
|
pos := p.expect(token.STRUCT);
|
||||||
var lbrace, rbrace token.Position;
|
lbrace := p.expect(token.LBRACE);
|
||||||
var fields []*ast.Field;
|
list := vector.New(0);
|
||||||
if p.tok == token.LBRACE {
|
for p.tok != token.RBRACE && p.tok != token.EOF {
|
||||||
lbrace = p.pos;
|
f := p.parseFieldDecl();
|
||||||
p.next();
|
list.Push(f);
|
||||||
|
if p.tok == token.SEMICOLON {
|
||||||
list := vector.New(0);
|
p.next();
|
||||||
for p.tok != token.RBRACE && p.tok != token.EOF {
|
f.Comment = p.lineComment;
|
||||||
f := p.parseFieldDecl();
|
} else {
|
||||||
list.Push(f);
|
f.Comment = p.lineComment;
|
||||||
if p.tok == token.SEMICOLON {
|
break;
|
||||||
p.next();
|
|
||||||
f.Comment = p.lineComment;
|
|
||||||
} else {
|
|
||||||
f.Comment = p.lineComment;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
rbrace := p.expect(token.RBRACE);
|
||||||
|
p.optSemi = true;
|
||||||
|
|
||||||
rbrace = p.expect(token.RBRACE);
|
// convert vector
|
||||||
p.optSemi = true;
|
fields := make([]*ast.Field, list.Len());
|
||||||
|
for i := list.Len() - 1; i >= 0; i-- {
|
||||||
// convert vector
|
fields[i] = list.At(i).(*ast.Field);
|
||||||
fields = make([]*ast.Field, list.Len());
|
|
||||||
for i := list.Len() - 1; i >= 0; i-- {
|
|
||||||
fields[i] = list.At(i).(*ast.Field);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ast.StructType{pos, lbrace, fields, rbrace};
|
return &ast.StructType{pos, lbrace, fields, rbrace};
|
||||||
@ -677,28 +670,21 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pos := p.expect(token.INTERFACE);
|
pos := p.expect(token.INTERFACE);
|
||||||
var lbrace, rbrace token.Position;
|
lbrace := p.expect(token.LBRACE);
|
||||||
var methods []*ast.Field;
|
list := vector.New(0);
|
||||||
if p.tok == token.LBRACE {
|
for p.tok == token.IDENT {
|
||||||
lbrace = p.pos;
|
list.Push(p.parseMethodSpec());
|
||||||
p.next();
|
if p.tok != token.RBRACE {
|
||||||
|
p.expect(token.SEMICOLON);
|
||||||
list := vector.New(0);
|
|
||||||
for p.tok == token.IDENT {
|
|
||||||
list.Push(p.parseMethodSpec());
|
|
||||||
if p.tok != token.RBRACE {
|
|
||||||
p.expect(token.SEMICOLON);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
rbrace := p.expect(token.RBRACE);
|
||||||
|
p.optSemi = true;
|
||||||
|
|
||||||
rbrace = p.expect(token.RBRACE);
|
// convert vector
|
||||||
p.optSemi = true;
|
methods := make([]*ast.Field, list.Len());
|
||||||
|
for i := list.Len() - 1; i >= 0; i-- {
|
||||||
// convert vector
|
methods[i] = list.At(i).(*ast.Field);
|
||||||
methods = make([]*ast.Field, list.Len());
|
|
||||||
for i := list.Len() - 1; i >= 0; i-- {
|
|
||||||
methods[i] = list.At(i).(*ast.Field);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ast.InterfaceType{pos, lbrace, methods, rbrace};
|
return &ast.InterfaceType{pos, lbrace, methods, rbrace};
|
||||||
|
Loading…
Reference in New Issue
Block a user