MCPcopy Create free account
hub / github.com/cel-expr/cel-go / visitCallBinary

Method visitCallBinary

parser/unparser.go:157–182  ·  view source on GitHub ↗
(expr ast.Expr)

Source from the content-addressed store, hash-verified

155}
156
157func (un *unparser) visitCallBinary(expr ast.Expr) error {
158 c := expr.AsCall()
159 fun := c.FunctionName()
160 args := c.Args()
161 lhs := args[0]
162 // add parens if the current operator is lower precedence than the lhs expr operator.
163 lhsParen := isComplexOperatorWithRespectTo(fun, lhs)
164 rhs := args[1]
165 // add parens if the current operator is lower precedence than the rhs expr operator,
166 // or the same precedence and the operator is left recursive.
167 rhsParen := isComplexOperatorWithRespectTo(fun, rhs)
168 if !rhsParen && isLeftRecursive(fun) {
169 rhsParen = isSamePrecedence(fun, rhs)
170 }
171 err := un.visitMaybeNested(lhs, lhsParen)
172 if err != nil {
173 return err
174 }
175 unmangled, found := operators.FindReverseBinaryOperator(fun)
176 if !found {
177 return fmt.Errorf("cannot unmangle operator: %s", fun)
178 }
179
180 un.writeOperatorWithWrapping(fun, unmangled)
181 return un.visitMaybeNested(rhs, rhsParen)
182}
183
184func (un *unparser) visitCallConditional(expr ast.Expr) error {
185 c := expr.AsCall()

Callers 1

visitCallMethod · 0.95

Calls 9

visitMaybeNestedMethod · 0.95
isLeftRecursiveFunction · 0.85
isSamePrecedenceFunction · 0.85
AsCallMethod · 0.65
FunctionNameMethod · 0.65
ArgsMethod · 0.65

Tested by

no test coverage detected