MCPcopy Create free account
hub / github.com/araddon/qlbridge / FromExpr

Method FromExpr

expr/node.go:608–642  ·  view source on GitHub ↗
(e *Expr)

Source from the content-addressed store, hash-verified

606 return fe
607}
608func (m *FuncNode) FromExpr(e *Expr) error {
609 if e.Op != lex.TokenUdfExpr.String() {
610 return fmt.Errorf("Expected 'expr' but got %v", e.Op)
611 }
612 if len(e.Args) < 1 {
613 return fmt.Errorf("Expected function name in args but got none")
614 }
615
616 m.Name = e.Args[0].Identity
617
618 if len(e.Args) > 1 {
619 args, err := NodesFromExprs(e.Args[1:])
620 if err != nil {
621 return err
622 }
623 m.Args = args
624 }
625 s := m.String()
626 n, err := ParseExpression(s)
627 if err != nil {
628 return fmt.Errorf("Could not round-trip parse func: %s err=%v", s, err)
629 }
630 fn, ok := n.(*FuncNode)
631 if !ok {
632 return fmt.Errorf("Expected funcnode but got %T", n)
633 }
634 m.F = fn.F
635 if err = fn.Validate(); err != nil {
636 return err
637 }
638 if m.Eval == nil {
639 m.Eval = fn.Eval
640 }
641 return nil
642}
643func (m *FuncNode) Equal(n Node) bool {
644 if m == nil && n == nil {
645 return true

Callers

nothing calls this directly

Calls 6

StringMethod · 0.95
NodesFromExprsFunction · 0.85
ParseExpressionFunction · 0.85
ErrorfMethod · 0.80
StringMethod · 0.65
ValidateMethod · 0.65

Tested by

no test coverage detected