| 1293 | } |
| 1294 | |
| 1295 | std::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 | |
| 1320 | std::any ParserVisitor::visitUint(CelParser::UintContext* ctx) { |
| 1321 | std::string value = ctx->tok->getText(); |
nothing calls this directly
no test coverage detected