mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-19 14:11:45 +03:00
44d27207f8
* Column-only queries
45 lines
1017 B
Go
45 lines
1017 B
Go
package ast
|
|
|
|
import "github.com/neilotoole/sq/libsq/ast/internal/slq"
|
|
|
|
// HandleNode models a source handle such as "@sakila".
|
|
type HandleNode struct {
|
|
baseNode
|
|
}
|
|
|
|
// Handle returns the handle value, e.g. "@sakila".
|
|
func (d *HandleNode) Handle() string {
|
|
return d.text
|
|
}
|
|
|
|
// String returns a log/debug-friendly representation.
|
|
func (d *HandleNode) String() string {
|
|
return nodeString(d)
|
|
}
|
|
|
|
// VisitHandle implements slq.SLQVisitor.
|
|
func (v *parseTreeVisitor) VisitHandle(ctx *slq.HandleContext) any {
|
|
node := &HandleNode{}
|
|
node.text = ctx.GetText()
|
|
node.parent = v.cur
|
|
node.ctx = ctx.HANDLE()
|
|
return v.cur.AddChild(node)
|
|
}
|
|
|
|
// VisitHandleTable implements slq.SLQVisitor.
|
|
func (v *parseTreeVisitor) VisitHandleTable(ctx *slq.HandleTableContext) any {
|
|
node := &TblSelectorNode{}
|
|
node.parent = v.cur
|
|
node.ctx = ctx
|
|
node.text = ctx.GetText()
|
|
|
|
node.handle = ctx.HANDLE().GetText()
|
|
|
|
var err error
|
|
if node.tblName, err = extractSelVal(ctx.NAME()); err != nil {
|
|
return err
|
|
}
|
|
|
|
return v.cur.AddChild(node)
|
|
}
|