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

Method visitCallBinary

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

Source from the content-addressed store, hash-verified

191}
192
193func (un *unparser) visitCallBinary(expr ast.Expr) error {
194 c := expr.AsCall()
195 fun := c.FunctionName()
196 args := c.Args()
197 lhs := args[0]
198 // add parens if the current operator is lower precedence than the lhs expr operator.
199 lhsParen := isComplexOperatorWithRespectTo(fun, lhs)
200 rhs := args[1]
201 // add parens if the current operator is lower precedence than the rhs expr operator,
202 // or the same precedence and the operator is left recursive.
203 rhsParen := isComplexOperatorWithRespectTo(fun, rhs)
204 if !rhsParen && isLeftRecursive(fun) {
205 rhsParen = isSamePrecedence(fun, rhs)
206 }
207 err := un.visitMaybeNested(lhs, lhsParen)
208 if err != nil {
209 return err
210 }
211 unmangled, found := operators.FindReverseBinaryOperator(fun)
212 if !found {
213 return fmt.Errorf("cannot unmangle operator: %s", fun)
214 }
215
216 un.writeOperatorWithWrapping(fun, unmangled)
217 return un.visitMaybeNested(rhs, rhsParen)
218}
219
220func (un *unparser) visitCallConditional(expr ast.Expr) error {
221 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