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

Method visitSelect

parser/parser.cc:1025–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1023}
1024
1025std::any ParserVisitor::visitSelect(CelParser::SelectContext* ctx) {
1026 auto operand = ExprFromAny(visit(ctx->member()));
1027 // Handle the error case where no valid identifier is specified.
1028 if (!ctx->id || !ctx->op) {
1029 return ExprToAny(factory_.NewUnspecified(
1030 factory_.NextId(SourceRangeFromParserRuleContext(ctx))));
1031 }
1032 auto id = NormalizeIdentifier(ctx->id);
1033 if (ctx->opt != nullptr) {
1034 if (!enable_optional_syntax_) {
1035 return ExprToAny(factory_.ReportError(
1036 SourceRangeFromParserRuleContext(ctx), "unsupported syntax '.?'"));
1037 }
1038 auto op_id = factory_.NextId(SourceRangeFromToken(ctx->op));
1039 std::vector<Expr> arguments;
1040 arguments.reserve(2);
1041 arguments.push_back(std::move(operand));
1042 arguments.push_back(factory_.NewStringConst(
1043 factory_.NextId(SourceRangeFromParserRuleContext(ctx)), std::move(id)));
1044 return ExprToAny(factory_.NewCall(op_id, "_?._", std::move(arguments)));
1045 }
1046 return ExprToAny(
1047 factory_.NewSelect(factory_.NextId(SourceRangeFromToken(ctx->op)),
1048 std::move(operand), std::move(id)));
1049}
1050
1051std::any ParserVisitor::visitMemberCall(CelParser::MemberCallContext* ctx) {
1052 auto operand = ExprFromAny(visit(ctx->member()));

Callers

nothing calls this directly

Calls 11

ExprFromAnyFunction · 0.85
ExprToAnyFunction · 0.85
SourceRangeFromTokenFunction · 0.85
memberMethod · 0.80
NewUnspecifiedMethod · 0.45
NextIdMethod · 0.45
ReportErrorMethod · 0.45
NewStringConstMethod · 0.45
NewCallMethod · 0.45
NewSelectMethod · 0.45

Tested by

no test coverage detected