sq/libsq/ast/range.go
Neil O'Toole e4cc68b714
Slq move (#67)
* moved it

* what used to be libsq/slq in now libsq/ast/internal/slq
2020-08-23 05:16:16 -06:00

38 lines
696 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
}
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
}