}
-func (p *parser) parseIdentList(x ast.Expr) []*ast.Ident {
+func (p *parser) parseIdentList() []*ast.Ident {
if p.trace {
defer un(trace(p, "IdentList"));
}
list := vector.New(0);
- if x == nil {
- x = p.parseIdent();
- }
- list.Push(x);
+ list.Push(p.parseIdent());
for p.tok == token.COMMA {
p.next();
list.Push(p.parseIdent());
for p.tok == token.COMMA {
p.next();
- idents := p.parseIdentList(nil);
+ idents := p.parseIdentList();
typ := p.parseParameterType(ellipsisOk);
list.Push(&ast.Field{nil, idents, typ, nil, nil});
}
var idents []*ast.Ident;
var typ ast.Expr;
x := p.parseQualifiedIdent();
- if _, isIdent := x.(*ast.Ident); isIdent && (p.tok == token.COMMA || p.tok == token.LPAREN) {
- // methods
- idents = p.parseIdentList(x);
+ if ident, isIdent := x.(*ast.Ident); isIdent && p.tok == token.LPAREN {
+ // method
+ idents = []*ast.Ident{ident};
params, results := p.parseSignature();
typ = &ast.FuncType{noPos, params, results};
} else {
defer un(trace(p, "ConstSpec"));
}
- idents := p.parseIdentList(nil);
+ idents := p.parseIdentList();
typ := p.tryType();
var values []ast.Expr;
if typ != nil || p.tok == token.ASSIGN {
defer un(trace(p, "VarSpec"));
}
- idents := p.parseIdentList(nil);
+ idents := p.parseIdentList();
typ := p.tryType();
var values []ast.Expr;
if typ == nil || p.tok == token.ASSIGN {
} else { // interface
for i, f := range list {
p.leadComment(f.Doc);
- p.identList(f.Names);
- if len(f.Names) > 1 {
- p.print(blank);
- }
if ftyp, isFtyp := f.Type.(*ast.FuncType); isFtyp {
- // method(s)
+ // method
+ p.expr(f.Names[0]); // exactly one name
p.signature(ftyp.Params, ftyp.Results);
} else {
// embedded interface
// The I0 interface; no method is exported.
type I0 interface {
- f, g (x int) int; // 2 unexported methods
+ f(x int) int; // unexported method
}
// The I1 interface; some methods are not exported.
type I1 interface {
I0;
- F, G (x float) float; // 2 exported methods
- H, g (x int) int; // 1 unexported method
+ F(x float) float; // exported methods
+ g(x int) int; // unexported method
}
// The I2 interface; all methods are exported.
type I1 interface {
I0;
- F, G (x float) float; // 2 exported methods
+ F(x float) float; // exported method
+ G(x float) float; // exported method
}
// This comment group should be separated
// The I0 interface; no method is exported.
type I0 interface {
- f, g (x int) int; // 2 unexported methods
+ f(x int) int; // unexported method
}
// The I1 interface; some methods are not exported.
type I1 interface {
I0;
- F, G (x float) float; // 2 exported methods
- H, g (x int) int; // 1 unexported method
+ F(x float) float; // exported methods
+ g(x int) int; // unexported method
}
// The I2 interface; all methods are exported.
type I1 interface {
I0;
- F, G (x float) float; // 2 exported methods
+ F(x float) float; // exported method
+ G(x float) float; // exported method
}
// This comment group should be separated
// The I1 interface; some methods are not exported.
type I1 interface {
I0;
- F, G (x float) float;
- H(x int) int;
+ F(x float) float;
// contains unexported methods
}
// The I2 interface; all methods are exported.
type I1 interface {
I0;
- F, G (x float) float;
+ F(x float) float;
+ G(x float) float;
}
type _ interface {
f();
- fffff, g ();
+ fffff();
}
type _ interface {
EI;
f();
- fffff, g ();
+ fffffg();
}
type _ interface { // this comment must not change indentation
EI; // here's a comment
- f(); // no blank between f and ()
- fffff, g (); // blank between identifiers and ()
- gggggggggggg, hhhhhhhhhhhhhh (x, y, z int) (); // hurray
+ f(); // no blank between identifier and ()
+ fffff(); // no blank between identifier and ()
+ gggggggggggg(x, y, z int) (); // hurray
}
type _ interface {
f();
- fffff, g ();
+ fffff();
}
type _ interface {
EI;
f();
- fffff, g ();
+ fffffg();
}
type _ interface { // this comment must not change indentation
- EI; // here's a comment
- f(); // no blank between f and ()
- fffff, g (); // blank between identifiers and ()
- gggggggggggg, hhhhhhhhhhhhhh (x, y, z int); // hurray
+ EI; // here's a comment
+ f(); // no blank between identifier and ()
+ fffff(); // no blank between identifier and ()
+ gggggggggggg(x, y, z int); // hurray
}