summaryrefslogtreecommitdiff
path: root/usr/gri/pretty/astprinter.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-05-13 15:18:05 -0700
committerRobert Griesemer <gri@golang.org>2009-05-13 15:18:05 -0700
commitf3b08744a257f2798255956ebb109c0615b494ad (patch)
treefa2bb84b28616d5f295c3a0f649f72cd53e3cd7c /usr/gri/pretty/astprinter.go
parent6fa6f134f1c0b64f5a52e2a39e2bcb009d877cc3 (diff)
downloadgo-git-f3b08744a257f2798255956ebb109c0615b494ad.tar.gz
Simplified AST:
- one node for array and slice types - one node for index and slice expressions - simplified parser, astprinter, and ast.txt R=r DELTA=71 (0 added, 43 deleted, 28 changed) OCL=28768 CL=28768
Diffstat (limited to 'usr/gri/pretty/astprinter.go')
-rw-r--r--usr/gri/pretty/astprinter.go25
1 files changed, 7 insertions, 18 deletions
diff --git a/usr/gri/pretty/astprinter.go b/usr/gri/pretty/astprinter.go
index c45508868f..9c1fe74394 100644
--- a/usr/gri/pretty/astprinter.go
+++ b/usr/gri/pretty/astprinter.go
@@ -735,16 +735,10 @@ func (P *Printer) DoIndexExpr(x *ast.IndexExpr) {
P.Expr1(x.X, token.HighestPrec);
P.Token(noPos, token.LBRACK);
P.Expr(x.Index);
- P.Token(noPos, token.RBRACK);
-}
-
-
-func (P *Printer) DoSliceExpr(x *ast.SliceExpr) {
- P.Expr1(x.X, token.HighestPrec);
- P.Token(noPos, token.LBRACK);
- P.Expr(x.Begin);
- P.Token(noPos, token.COLON);
- P.Expr(x.End);
+ if x.End != nil {
+ P.Token(noPos, token.COLON);
+ P.Expr(x.End);
+ }
P.Token(noPos, token.RBRACK);
}
@@ -772,14 +766,9 @@ func (P *Printer) DoEllipsis(x *ast.Ellipsis) {
func (P *Printer) DoArrayType(x *ast.ArrayType) {
P.Token(x.Pos(), token.LBRACK);
- P.Expr(x.Len);
- P.Token(noPos, token.RBRACK);
- P.Expr(x.Elt);
-}
-
-
-func (P *Printer) DoSliceType(x *ast.SliceType) {
- P.Token(x.Pos(), token.LBRACK);
+ if x.Len != nil {
+ P.Expr(x.Len);
+ }
P.Token(noPos, token.RBRACK);
P.Expr(x.Elt);
}