]> Cypherpunks repositories - gostls13.git/commitdiff
go/ast: add Slice3 field to SliceExpr
authorRobert Griesemer <gri@golang.org>
Tue, 24 Sep 2013 23:35:35 +0000 (16:35 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 24 Sep 2013 23:35:35 +0000 (16:35 -0700)
If Slice3 is set, the expression is
a 3-index slice expression (2 colons).
Required for type-checking.

Backward-compatible API extension.

R=r, rsc
CC=golang-dev
https://golang.org/cl/13826050

src/pkg/go/ast/ast.go
src/pkg/go/parser/parser.go

index a6ce674e740a3199aa88d4c76df5311c1afe4b6a..6e635cd0166962670fe7317674a67c53a4d3a596 100644 (file)
@@ -298,6 +298,7 @@ type (
                Low    Expr      // begin of slice range; or nil
                High   Expr      // end of slice range; or nil
                Max    Expr      // maximum capacity of slice; or nil
+               Slice3 bool      // true if 3-index slice (2 colons present)
                Rbrack token.Pos // position of "]"
        }
 
index c3245e375d4137c671e347b71a7092d448684eb8..c4523318f2614773d54b5b856931f79495a9f333 100644 (file)
@@ -1187,7 +1187,7 @@ func (p *parser) parseIndexOrSlice(x ast.Expr) ast.Expr {
 
        if ncolons > 0 {
                // slice expression
-               return &ast.SliceExpr{X: x, Lbrack: lbrack, Low: index[0], High: index[1], Max: index[2], Rbrack: rbrack}
+               return &ast.SliceExpr{X: x, Lbrack: lbrack, Low: index[0], High: index[1], Max: index[2], Slice3: ncolons == 2, Rbrack: rbrack}
        }
 
        return &ast.IndexExpr{X: x, Lbrack: lbrack, Index: index[0], Rbrack: rbrack}