]> Cypherpunks repositories - gostls13.git/commitdiff
- support for [...] parsing and pretty printing
authorRobert Griesemer <gri@golang.org>
Wed, 7 Jan 2009 01:39:25 +0000 (17:39 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 7 Jan 2009 01:39:25 +0000 (17:39 -0800)
R=r
OCL=22185
CL=22185

usr/gri/pretty/parser.go
usr/gri/pretty/selftest2.go

index 1e7821505868fb6daa1ae75af7c052d26e970fc1..4bd8e193c23089a53a604ae22394517d2dd260e1 100644 (file)
@@ -268,7 +268,10 @@ func (P *Parser) ParseArrayType() *AST.Type {
 
        t := AST.NewType(P.pos, 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);
        }
        P.Expect(Scanner.RBRACK);
index af449ed1aca2e3760e2ce36d5e6dfbc4c4d0f90e..9b63fd5e9b002b73a2a2a24d7369e22c7763c970 100644 (file)
@@ -46,6 +46,9 @@ var (
        A = 5;
        u, v, w int = 0, 0, 0;
        foo = "foo";
+       fixed_array0 = [10]int{};
+       fixed_array1 = [10]int{0, 1, 2};
+       fixed_array2 = [...]string{"foo", "bar"};
 )