sq/libsq/ast/range.go
Neil O'Toole f9c19785e3
Almost at the end of the linting road (#120)
* yet more linting

* yet more linting

* yet more linting

* yet more linting

* yet more linting

* yet more linting

* yet more linting

* yet more linting
2022-12-17 23:42:11 -07:00

38 lines
710 B
Go

package ast
import "github.com/neilotoole/sq/libsq/ast/internal/slq"
// RowRange models a range, effectively {OFFSET,LIMIT}.
type RowRange struct {
baseNode
Offset int
Limit int
}
func newRowRange(ctx *slq.RowRangeContext, offset, limit int) *RowRange {
rr := &RowRange{}
rr.ctx = ctx
rr.Offset = offset
rr.Limit = limit
return rr
}
func (rr *RowRange) String() string {
return rr.Text()
}
func (rr *RowRange) Range() (offset, limit int) {
offset = rr.Offset
limit = rr.Limit
return offset, limit
}
func (rr *RowRange) SetParent(parent Node) error {
seg, ok := parent.(*Segment)
if !ok {
return errorf("%T requires parent of type *%s", rr, typeSegment)
}
rr.parent = seg
return nil
}