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

Method visitUint

parser/parser.cc:1320–1343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1318}
1319
1320std::any ParserVisitor::visitUint(CelParser::UintContext* ctx) {
1321 std::string value = ctx->tok->getText();
1322 // trim the 'u' designator included in the uint literal.
1323 if (!value.empty()) {
1324 value.resize(value.size() - 1);
1325 }
1326 uint64_t uint_value;
1327 if (absl::StartsWith(ctx->tok->getText(), "0x")) {
1328 if (absl::SimpleHexAtoi(value, &uint_value)) {
1329 return ExprToAny(factory_.NewUintConst(
1330 factory_.NextId(SourceRangeFromParserRuleContext(ctx)), uint_value));
1331 } else {
1332 return ExprToAny(factory_.ReportError(
1333 SourceRangeFromParserRuleContext(ctx), "invalid hex uint literal"));
1334 }
1335 }
1336 if (absl::SimpleAtoi(value, &uint_value)) {
1337 return ExprToAny(factory_.NewUintConst(
1338 factory_.NextId(SourceRangeFromParserRuleContext(ctx)), uint_value));
1339 } else {
1340 return ExprToAny(factory_.ReportError(SourceRangeFromParserRuleContext(ctx),
1341 "invalid uint literal"));
1342 }
1343}
1344
1345std::any ParserVisitor::visitDouble(CelParser::DoubleContext* ctx) {
1346 std::string value;

Callers

nothing calls this directly

Calls 8

ExprToAnyFunction · 0.85
getTextMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
NewUintConstMethod · 0.45
NextIdMethod · 0.45
ReportErrorMethod · 0.45

Tested by

no test coverage detected