MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / VisitTernary

Method VisitTernary

tools/cel_unparser.cc:501–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501absl::Status Unparser::VisitTernary(const Expr::Call& expr) {
502 if (expr.args_size() != 3) {
503 return absl::InvalidArgumentError(
504 absl::StrCat("Unexpected ternary: ", expr.ShortDebugString()));
505 }
506
507 bool nested =
508 IsOperatorSamePrecedence(CelOperator::CONDITIONAL, expr.args(0)) ||
509 IsComplexOperator(expr.args(0));
510 CEL_RETURN_IF_ERROR(VisitMaybeNested(expr.args(0), nested));
511
512 Print(kSpace, kQuestionMark, kSpace);
513
514 nested = IsOperatorSamePrecedence(CelOperator::CONDITIONAL, expr.args(1)) ||
515 IsComplexOperator(expr.args(1));
516 CEL_RETURN_IF_ERROR(VisitMaybeNested(expr.args(1), nested));
517
518 Print(kSpace, kColon, kSpace);
519
520 nested = IsOperatorSamePrecedence(CelOperator::CONDITIONAL, expr.args(2)) ||
521 IsComplexOperator(expr.args(2));
522 return VisitMaybeNested(expr.args(2), nested);
523}
524
525bool Unparser::IsComplexOperatorWithRespectTo(const Expr& expr,
526 const std::string& op) {

Callers

nothing calls this directly

Calls 2

IsOperatorSamePrecedenceFunction · 0.85
argsMethod · 0.80

Tested by

no test coverage detected