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

Method visitInt

parser/parser.cc:1295–1318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1293}
1294
1295std::any ParserVisitor::visitInt(CelParser::IntContext* ctx) {
1296 std::string value;
1297 if (ctx->sign) {
1298 value = ctx->sign->getText();
1299 }
1300 value += ctx->tok->getText();
1301 int64_t int_value;
1302 if (absl::StartsWith(ctx->tok->getText(), "0x")) {
1303 if (absl::SimpleHexAtoi(value, &int_value)) {
1304 return ExprToAny(factory_.NewIntConst(
1305 factory_.NextId(SourceRangeFromParserRuleContext(ctx)), int_value));
1306 } else {
1307 return ExprToAny(factory_.ReportError(
1308 SourceRangeFromParserRuleContext(ctx), "invalid hex int literal"));
1309 }
1310 }
1311 if (absl::SimpleAtoi(value, &int_value)) {
1312 return ExprToAny(factory_.NewIntConst(
1313 factory_.NextId(SourceRangeFromParserRuleContext(ctx)), int_value));
1314 } else {
1315 return ExprToAny(factory_.ReportError(SourceRangeFromParserRuleContext(ctx),
1316 "invalid int literal"));
1317 }
1318}
1319
1320std::any ParserVisitor::visitUint(CelParser::UintContext* ctx) {
1321 std::string value = ctx->tok->getText();

Callers

nothing calls this directly

Calls 6

ExprToAnyFunction · 0.85
getTextMethod · 0.80
NewIntConstMethod · 0.45
NextIdMethod · 0.45
ReportErrorMethod · 0.45

Tested by

no test coverage detected