mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 13:41:49 +03:00
42 lines
784 B
Go
42 lines
784 B
Go
|
package ast
|
||
|
|
||
|
var _ Node = (*Func)(nil)
|
||
|
var _ ColExpr = (*Func)(nil)
|
||
|
|
||
|
// Func models a function. For example, "COUNT()".
|
||
|
type Func struct {
|
||
|
baseNode
|
||
|
fnName string
|
||
|
}
|
||
|
|
||
|
// FuncName returns the function name.
|
||
|
func (fn *Func) FuncName() string {
|
||
|
return fn.fnName
|
||
|
}
|
||
|
|
||
|
func (fn *Func) String() string {
|
||
|
return nodeString(fn)
|
||
|
}
|
||
|
|
||
|
// ColExpr implements ColExpr.
|
||
|
func (fn *Func) ColExpr() (string, error) {
|
||
|
return fn.ctx.GetText(), nil
|
||
|
}
|
||
|
|
||
|
// SetChildren implements Node.
|
||
|
func (fn *Func) SetChildren(children []Node) error {
|
||
|
fn.setChildren(children)
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// IsColName implements ColExpr.
|
||
|
func (fn *Func) IsColName() bool {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
func (fn *Func) AddChild(child Node) error {
|
||
|
// TODO: add check for valid Func child types
|
||
|
fn.addChild(child)
|
||
|
return child.SetParent(fn)
|
||
|
}
|