// parse a list of types
i0 := list.len();
for {
- list.Add(P.ParseVarDecl(i0 > 0));
+ list.Add(P.ParseVarDecl(ellipsis_ok /* param list */ && i0 > 0));
if P.tok == Scanner.COMMA {
P.Next();
} else {
P.Next();
}
- if i0 > 0 && typ == nil {
+ if ellipsis_ok /* param list */ && i0 > 0 && typ == nil {
// not the first parameter section; we must have a type
P.Error(P.pos, "type expected");
typ = AST.BadType;
} else {
// all list entries are types
// convert all type entries into type expressions
- if i0 > 0 {
- panic("internal parser error");
- }
-
- for i, n := 0, list.len(); i < n; i++ {
+ for i, n := i0, list.len(); i < n; i++ {
t := list.at(i).(*AST.Type);
list.set(i, AST.NewTypeExpr(t));
}
-
- if P.tok == Scanner.COMMA {
- panic("internal parser error");
- }
}
P.Ecart();
}
+func (P *Parser) ParseOperand() *AST.Expr
+
func (P *Parser) ParseStructType() *AST.Type {
P.Trace("StructType");
if P.tok == Scanner.LBRACE {
P.Next();
t.list = AST.NewList();
- for P.tok == Scanner.IDENT {
+ for P.tok != Scanner.RBRACE && P.tok != Scanner.EOF {
P.ParseVarDeclList(t.list, false);
- if P.tok != Scanner.RBRACE {
- P.Expect(Scanner.SEMICOLON);
+ if P.tok == Scanner.STRING {
+ // ParseOperand takes care of string concatenation
+ t.list.Add(P.ParseOperand());
+ }
+ if P.tok == Scanner.SEMICOLON {
+ P.Next();
+ } else {
+ break;
}
}
P.OptSemicolon();
for i, n := 0, list.len(); i < n; i++ {
x := list.at(i).(*AST.Expr);
if i > 0 {
- if prev == Scanner.TYPE {
+ if prev == Scanner.TYPE && x.tok != Scanner.STRING || prev == Scanner.STRING {
P.semi, P.newl = true, 1;
} else if prev == x.tok {
P.String(0, ", ");
--- /dev/null
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+type Proto struct {
+ a int "a tag";
+ b, c, d *Proto "bcd" "tag";
+ *Proto "proto tag"
+}
apply1() {
#echo $1 $2
case `basename $F` in
- selftest.go | func3.go | bug014.go | bug029.go | bug032.go | bug050.go | \
+ selftest1.go | func3.go | bug014.go | bug029.go | bug032.go | bug050.go | \
bug068.go | bug088.go | bug083.go | bug106.go ) ;; # skip - files contain syntax errors
* ) $1 $2; count ;;
esac
}
-# run selftest always
-./pretty -t selftest.go > $TMP1
+# run selftest1 always
+./pretty -t selftest1.go > $TMP1
if [ $? != 0 ]; then
cat $TMP1
- echo "Error (selftest): pretty -t selftest.go"
+ echo "Error (selftest1): pretty -t selftest1.go"
exit 1
fi
count