[Mlir-commits] [mlir] 14078ae - [mlir][OpAsmParser] Add parseString method
Markus Böck
llvmlistbot at llvm.org
Sun Jul 4 08:12:31 PDT 2021
Author: Markus Böck
Date: 2021-07-04T17:12:22+02:00
New Revision: 14078ae8cabf6a3de64ade5fa239b86db848c1c5
URL: https://github.com/llvm/llvm-project/commit/14078ae8cabf6a3de64ade5fa239b86db848c1c5
DIFF: https://github.com/llvm/llvm-project/commit/14078ae8cabf6a3de64ade5fa239b86db848c1c5.diff
LOG: [mlir][OpAsmParser] Add parseString method
Basically every kind of parseOptional* method in DialectAsmParser has a corresponding parse* method which will emit an error if the requested token has not been found. An odd one out of this rule is parseOptionalString which does not have a corresponding parseString method.
This patch adds that method and implements it in basically the same fashion as parseKeyword, by first going through parseOptionalString and emitting an error on failure.
Differential Revision: https://reviews.llvm.org/D105406
Added:
Modified:
mlir/include/mlir/IR/DialectImplementation.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h
index f99d695a50017..6cd99dc4ef357 100644
--- a/mlir/include/mlir/IR/DialectImplementation.h
+++ b/mlir/include/mlir/IR/DialectImplementation.h
@@ -228,6 +228,14 @@ class DialectAsmParser {
/// Parse a `=` token if present.
virtual ParseResult parseOptionalEqual() = 0;
+ /// Parse a quoted string token.
+ ParseResult parseString(StringRef *string) {
+ auto loc = getCurrentLocation();
+ if (parseOptionalString(string))
+ return emitError(loc, "expected string");
+ return success();
+ }
+
/// Parse a quoted string token if present.
virtual ParseResult parseOptionalString(StringRef *string) = 0;
More information about the Mlir-commits
mailing list