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

Method visitCalc

parser/parser.cc:961–979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

959}
960
961std::any ParserVisitor::visitCalc(CelParser::CalcContext* ctx) {
962 if (ctx->unary()) {
963 return visit(ctx->unary());
964 }
965 std::string op_text;
966 if (ctx->op) {
967 op_text = ctx->op->getText();
968 }
969 auto op = ReverseLookupOperator(op_text);
970 if (op) {
971 auto lhs = ExprFromAny(visit(ctx->calc(0)));
972 int64_t op_id = factory_.NextId(SourceRangeFromToken(ctx->op));
973 auto rhs = ExprFromAny(visit(ctx->calc(1)));
974 return ExprToAny(
975 GlobalCallOrMacro(op_id, *op, std::move(lhs), std::move(rhs)));
976 }
977 return ExprToAny(factory_.ReportError(SourceRangeFromParserRuleContext(ctx),
978 "operator not found"));
979}
980
981std::any ParserVisitor::visitUnary(CelParser::UnaryContext* ctx) {
982 return ExprToAny(factory_.NewStringConst(

Callers

nothing calls this directly

Calls 8

ReverseLookupOperatorFunction · 0.85
ExprFromAnyFunction · 0.85
SourceRangeFromTokenFunction · 0.85
ExprToAnyFunction · 0.85
getTextMethod · 0.80
NextIdMethod · 0.45
ReportErrorMethod · 0.45

Tested by

no test coverage detected