sq/libsq/ast/range.go
Neil O'Toole 980e49358e tidy up
2016-10-16 22:14:01 -06:00

40 lines
638 B
Go

package ast
import "github.com/neilotoole/sq/libsq/slq"
type RowRange struct {
BaseNode
Offset int
Limit int
}
func NewRowRange(ctx *slq.RowRangeContext, offset int, 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 int, 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
}