| 1318 | } |
| 1319 | |
| 1320 | std::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 | |
| 1345 | std::any ParserVisitor::visitDouble(CelParser::DoubleContext* ctx) { |
| 1346 | std::string value; |
nothing calls this directly
no test coverage detected