1
0
mirror of https://github.com/golang/go synced 2024-11-26 03:57:57 -07:00

- support for [...] parsing and pretty printing

R=r
OCL=22185
CL=22185
This commit is contained in:
Robert Griesemer 2009-01-06 17:39:25 -08:00
parent b0f627a6e1
commit 5bd3c3b755
2 changed files with 7 additions and 1 deletions

View File

@ -268,7 +268,10 @@ func (P *Parser) ParseArrayType() *AST.Type {
t := AST.NewType(P.pos, Scanner.LBRACK); t := AST.NewType(P.pos, Scanner.LBRACK);
P.Expect(Scanner.LBRACK); P.Expect(Scanner.LBRACK);
if P.tok != Scanner.RBRACK { if P.tok == Scanner.ELLIPSIS {
t.expr = P.NewExpr(P.pos, Scanner.ELLIPSIS, nil, nil);
P.Next();
} else if P.tok != Scanner.RBRACK {
t.expr = P.ParseExpression(1); t.expr = P.ParseExpression(1);
} }
P.Expect(Scanner.RBRACK); P.Expect(Scanner.RBRACK);

View File

@ -46,6 +46,9 @@ var (
A = 5; A = 5;
u, v, w int = 0, 0, 0; u, v, w int = 0, 0, 0;
foo = "foo"; foo = "foo";
fixed_array0 = [10]int{};
fixed_array1 = [10]int{0, 1, 2};
fixed_array2 = [...]string{"foo", "bar"};
) )