[Mlir-commits] [mlir] Add AsmParser::parseDecimalInteger. (PR #96255)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jul 10 15:54:12 PDT 2024
================
@@ -308,6 +309,51 @@ OptionalParseResult Parser::parseOptionalInteger(APInt &result) {
return success();
}
+namespace {
+bool isBinOrHexOrOctIndicator(char c) {
+ return (llvm::toLower(c) == 'x' || llvm::toLower(c) == 'b' ||
+ llvm::isDigit(c));
+}
+} // namespace
+
+/// Parse an optional integer value only in decimal format from the stream.
+OptionalParseResult Parser::parseOptionalDecimalInteger(APInt &result) {
+ Token curToken = getToken();
+ if (curToken.isNot(Token::integer, Token::minus)) {
+ return std::nullopt;
+ }
+
+ bool negative = consumeIf(Token::minus);
+ Token curTok = getToken();
+ if (parseToken(Token::integer, "expected integer value")) {
+ return failure();
+ }
+
+ StringRef spelling = curTok.getSpelling();
+ // If the integer is in bin, hex, or oct format, return only the 0 and reset
+ // the lex pointer.
----------------
quartersdg wrote:
done.
https://github.com/llvm/llvm-project/pull/96255
More information about the Mlir-commits
mailing list