1
0
mirror of https://github.com/golang/go synced 2024-11-11 23:20:24 -07:00

go/ast: add Slice3 field to SliceExpr

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
This commit is contained in:
Robert Griesemer 2013-09-24 16:35:35 -07:00
parent b0ef6aeff9
commit 20db0f428a
2 changed files with 2 additions and 1 deletions

View 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 "]"
}

View 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}