Commit ce1dd6cc authored by Robert Griesemer's avatar Robert Griesemer

- do not accept forward-declarations for structs and interfaces anymore

R=r
DELTA=49  (0 added, 14 deleted, 35 changed)
OCL=33272
CL=33272
parent 137c2204
...@@ -457,12 +457,7 @@ func (p *parser) parseStructType() *ast.StructType { ...@@ -457,12 +457,7 @@ 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;
if p.tok == token.LBRACE {
lbrace = p.pos;
p.next();
list := vector.New(0); list := vector.New(0);
for p.tok != token.RBRACE && p.tok != token.EOF { for p.tok != token.RBRACE && p.tok != token.EOF {
f := p.parseFieldDecl(); f := p.parseFieldDecl();
...@@ -475,16 +470,14 @@ func (p *parser) parseStructType() *ast.StructType { ...@@ -475,16 +470,14 @@ func (p *parser) parseStructType() *ast.StructType {
break; break;
} }
} }
rbrace := p.expect(token.RBRACE);
rbrace = p.expect(token.RBRACE);
p.optSemi = true; p.optSemi = true;
// convert vector // convert vector
fields = make([]*ast.Field, list.Len()); fields := make([]*ast.Field, list.Len());
for i := list.Len() - 1; i >= 0; i-- { for i := list.Len() - 1; i >= 0; i-- {
fields[i] = list.At(i).(*ast.Field); fields[i] = list.At(i).(*ast.Field);
} }
}
return &ast.StructType{pos, lbrace, fields, rbrace}; return &ast.StructType{pos, lbrace, fields, rbrace};
} }
...@@ -677,12 +670,7 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType { ...@@ -677,12 +670,7 @@ 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;
if p.tok == token.LBRACE {
lbrace = p.pos;
p.next();
list := vector.New(0); list := vector.New(0);
for p.tok == token.IDENT { for p.tok == token.IDENT {
list.Push(p.parseMethodSpec()); list.Push(p.parseMethodSpec());
...@@ -690,16 +678,14 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType { ...@@ -690,16 +678,14 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType {
p.expect(token.SEMICOLON); p.expect(token.SEMICOLON);
} }
} }
rbrace := p.expect(token.RBRACE);
rbrace = p.expect(token.RBRACE);
p.optSemi = true; p.optSemi = true;
// convert vector // convert vector
methods = make([]*ast.Field, list.Len()); methods := make([]*ast.Field, list.Len());
for i := list.Len() - 1; i >= 0; i-- { for i := list.Len() - 1; i >= 0; i-- {
methods[i] = list.At(i).(*ast.Field); methods[i] = list.At(i).(*ast.Field);
} }
}
return &ast.InterfaceType{pos, lbrace, methods, rbrace}; return &ast.InterfaceType{pos, lbrace, methods, rbrace};
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment