| 959 | } |
| 960 | |
| 961 | std::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 | |
| 981 | std::any ParserVisitor::visitUnary(CelParser::UnaryContext* ctx) { |
| 982 | return ExprToAny(factory_.NewStringConst( |
nothing calls this directly
no test coverage detected