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

Method visitEntries

parser/parser.cc:1270–1293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1268}
1269
1270std::vector<MapExprEntry> ParserVisitor::visitEntries(
1271 CelParser::MapInitializerListContext* ctx) {
1272 std::vector<MapExprEntry> res;
1273 if (!ctx || ctx->keys.empty()) {
1274 return res;
1275 }
1276
1277 res.reserve(ctx->cols.size());
1278 for (size_t i = 0; i < ctx->cols.size(); ++i) {
1279 auto id = factory_.NextId(SourceRangeFromToken(ctx->cols[i]));
1280 if (!enable_optional_syntax_ && ctx->keys[i]->opt) {
1281 factory_.ReportError(SourceRangeFromParserRuleContext(ctx),
1282 "unsupported syntax '?'");
1283 res.push_back(factory_.NewMapEntry(0, factory_.NewUnspecified(0),
1284 factory_.NewUnspecified(0), false));
1285 continue;
1286 }
1287 auto key = ExprFromAny(visit(ctx->keys[i]->e));
1288 auto value = ExprFromAny(visit(ctx->values[i]));
1289 res.push_back(factory_.NewMapEntry(id, std::move(key), std::move(value),
1290 ctx->keys[i]->opt != nullptr));
1291 }
1292 return res;
1293}
1294
1295std::any ParserVisitor::visitInt(CelParser::IntContext* ctx) {
1296 std::string value;

Callers

nothing calls this directly

Calls 9

SourceRangeFromTokenFunction · 0.85
ExprFromAnyFunction · 0.85
NewMapEntryMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
NextIdMethod · 0.45
ReportErrorMethod · 0.45
NewUnspecifiedMethod · 0.45

Tested by

no test coverage detected