mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 13:41:49 +03:00
7c56377b40
* Field alignment
38 lines
775 B
Go
38 lines
775 B
Go
package ast
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/neilotoole/sq/libsq/ast/internal/slq"
|
|
)
|
|
|
|
// ArgNode implements the SQL "DISTINCT" clause.
|
|
type ArgNode struct {
|
|
key string
|
|
baseNode
|
|
}
|
|
|
|
// String returns a log/debug-friendly representation.
|
|
func (n *ArgNode) String() string {
|
|
return nodeString(n)
|
|
}
|
|
|
|
// Key returns the arg key. If the arg is "$name", the key is "name".
|
|
func (n *ArgNode) Key() string {
|
|
return n.key
|
|
}
|
|
|
|
// VisitArg implements slq.SLQVisitor.
|
|
func (v *parseTreeVisitor) VisitArg(ctx *slq.ArgContext) interface{} {
|
|
node := &ArgNode{}
|
|
node.ctx = ctx
|
|
node.text = ctx.GetText()
|
|
|
|
if ctx.ARG() != nil {
|
|
// The node text will be "$key". We need to trim the $ prefix.
|
|
node.key = strings.TrimPrefix(ctx.ARG().GetText(), "$")
|
|
}
|
|
|
|
return v.cur.AddChild(node)
|
|
}
|