MCPcopy Create free account
hub / github.com/expr-lang/expr / String

Method String

ast/print.go:51–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49}
50
51func (n *UnaryNode) String() string {
52 op := n.Operator
53 if n.Operator == "not" {
54 op = fmt.Sprintf("%s ", n.Operator)
55 }
56 wrap := false
57 switch b := n.Node.(type) {
58 case *BinaryNode:
59 if operator.Binary[b.Operator].Precedence <
60 operator.Unary[n.Operator].Precedence {
61 wrap = true
62 }
63 case *ConditionalNode:
64 wrap = true
65 }
66 if wrap {
67 return fmt.Sprintf("%s(%s)", op, n.Node.String())
68 }
69 return fmt.Sprintf("%s%s", op, n.Node.String())
70}
71
72func (n *BinaryNode) String() string {
73 if n.Operator == ".." {

Callers

nothing calls this directly

Calls 2

SprintfMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected