func (self *quantifiedExpr) Match(m Position) (Position, interface{}) { var item interface{} cur := m res := new(vector.Vector) // guaranteed minimum for i := 0; i < self.min; i++ { cur, item = self.e.Match(cur) if cur.Failed() { return cur, nil } res.Push(item) } last := cur // optional (up to a maximum) for i := self.min; self.max == -1 || i < self.max; i++ { cur, item = self.e.Match(last) if cur.Failed() { return last, []interface{}(*res.Slice(0, res.Len())) } res.Push(item) last = cur } return cur, []interface{}(*res.Slice(0, res.Len())) }