cue/ast: get rid of unused ast.Ellipses
Change-Id: Id307e99cf4532b79bca3ea6d8daabf193ab28878
Reviewed-on: https://cue-review.googlesource.com/c/1560
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cue/ast/ast.go b/cue/ast/ast.go
index 91c9dcb..a468a8a 100644
--- a/cue/ast/ast.go
+++ b/cue/ast/ast.go
@@ -57,7 +57,6 @@
func (*BadExpr) exprNode() {}
func (*Ident) exprNode() {}
-func (*Ellipsis) exprNode() {}
func (*BasicLit) exprNode() {}
func (*Interpolation) exprNode() {}
func (*StructLit) exprNode() {}
@@ -349,14 +348,6 @@
Rangle token.Pos
}
-// An Ellipsis node stands for the "..." type in a
-// parameter list or the "..." length in an array type.
-type Ellipsis struct {
- comments
- Ellipsis token.Pos // position of "..."
- Elt Expr // ellipsis element type (parameter lists only); or nil
-}
-
// A BasicLit node represents a literal of basic type.
type BasicLit struct {
comments
@@ -481,7 +472,6 @@
func (x *BadExpr) Pos() token.Pos { return x.From }
func (x *Ident) Pos() token.Pos { return x.NamePos }
func (x *TemplateLabel) Pos() token.Pos { return x.Langle }
-func (x *Ellipsis) Pos() token.Pos { return x.Ellipsis }
func (x *BasicLit) Pos() token.Pos { return x.ValuePos }
func (x *Interpolation) Pos() token.Pos { return x.Elts[0].Pos() }
func (x *StructLit) Pos() token.Pos {
@@ -509,12 +499,6 @@
return x.NamePos.Add(len(x.Name))
}
func (x *TemplateLabel) End() token.Pos { return x.Rangle }
-func (x *Ellipsis) End() token.Pos {
- if x.Elt != nil {
- return x.Elt.End()
- }
- return x.Ellipsis + 3 // len("...")
-}
func (x *BasicLit) End() token.Pos { return token.Pos(int(x.ValuePos) + len(x.Value)) }
func (x *Interpolation) End() token.Pos { return x.Elts[len(x.Elts)-1].Pos() }
func (x *StructLit) End() token.Pos {
diff --git a/cue/ast/walk.go b/cue/ast/walk.go
index 9869e5d..4e53391 100644
--- a/cue/ast/walk.go
+++ b/cue/ast/walk.go
@@ -110,11 +110,6 @@
walk(v, e)
}
- case *Ellipsis:
- if n.Elt != nil {
- walk(v, n.Elt)
- }
-
case *ListLit:
walkExprList(v, n.Elts)
if n.Type != nil {
diff --git a/cue/format/node.go b/cue/format/node.go
index 85035a5..2a1464f 100644
--- a/cue/format/node.go
+++ b/cue/format/node.go
@@ -387,12 +387,6 @@
f.print(unindent)
}
- case *ast.Ellipsis:
- f.print(x.Ellipsis, token.ELLIPSIS)
- if x.Elt != nil {
- f.expr(x.Elt) // TODO
- }
-
case *ast.StructLit:
f.print(x.Lbrace, token.LBRACE, noblank, f.formfeed(), indent)
f.walkDeclList(x.Elts)
diff --git a/cue/parser/parser.go b/cue/parser/parser.go
index 77f483b..30b6114 100644
--- a/cue/parser/parser.go
+++ b/cue/parser/parser.go
@@ -1011,12 +1011,7 @@
c := p.openComments()
defer func() { c.closeNode(p, expr) }()
- e := p.parseRHS()
- switch p.tok {
- case token.ELLIPSIS:
- return &ast.Ellipsis{Ellipsis: p.expect(token.ELLIPSIS), Elt: e}
- }
- return e
+ return p.parseRHS()
}
// checkExpr checks that x is an expression (and not a type).
diff --git a/cue/parser/parser_test.go b/cue/parser/parser_test.go
index 77e7cb3..2d3d587 100644
--- a/cue/parser/parser_test.go
+++ b/cue/parser/parser_test.go
@@ -170,7 +170,7 @@
}, {
"lists",
`{
- a: [ 1, 2, 3, b..., c... ]
+ a: [ 1, 2, 3, b, c, ... ]
b: [ 1, 2, 3, ],
c: [ 1,
2,
@@ -178,7 +178,7 @@
],
d: [ 1+2, 2, 4,]
}`,
- `{a: [1, 2, 3, b..., c...], b: [1, 2, 3], c: [1, 2, 3], d: [1+2, 2, 4]}`,
+ `{a: [1, 2, 3, b, c, ...], b: [1, 2, 3], c: [1, 2, 3], d: [1+2, 2, 4]}`,
}, {
"list types",
`{
diff --git a/cue/parser/print.go b/cue/parser/print.go
index bf9ca8d..01d5d1c 100644
--- a/cue/parser/print.go
+++ b/cue/parser/print.go
@@ -162,9 +162,6 @@
out += ")"
return out
- case *ast.Ellipsis:
- return debugStr(v.Elt) + "..."
-
case *ast.ParenExpr:
out := "("
out += debugStr(v.X)
diff --git a/cue/parser/walk.go b/cue/parser/walk.go
index 29adad7..8589b09 100644
--- a/cue/parser/walk.go
+++ b/cue/parser/walk.go
@@ -104,11 +104,6 @@
walk(v, e)
}
- case *ast.Ellipsis:
- if n.Elt != nil {
- walk(v, n.Elt)
- }
-
case *ast.ListLit:
walkExprList(v, n.Elts)
if n.Type != nil {