Tweak to the pretty type parser to recognize that ->
is a special token.
Tweak to the pretty type parser to recognize that `->` is a special token that shouldn't be split into two characters. This change allows dialect types to wrap function types as in `!my.ptr_type<(i32) -> i32>`. Closes #105 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/105 from schweitzpgi:parse-arrow 8b2d768053f419daae5a1a864121a44c4319acbe PiperOrigin-RevId: 265986240
This commit is contained in:
parent
92fbb834c5
commit
fee62e2186
7
third_party/mlir/lib/IR/AsmPrinter.cpp
vendored
7
third_party/mlir/lib/IR/AsmPrinter.cpp
vendored
@ -544,6 +544,13 @@ static bool isDialectSymbolSimpleEnoughForPrettyForm(StringRef symName) {
|
|||||||
case '{':
|
case '{':
|
||||||
nestedPunctuation.push_back(c);
|
nestedPunctuation.push_back(c);
|
||||||
continue;
|
continue;
|
||||||
|
case '-':
|
||||||
|
// Treat `->` as a special token.
|
||||||
|
if (!symName.empty() && symName.front() == '>') {
|
||||||
|
symName = symName.drop_front();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
// Reject types with mismatched brackets.
|
// Reject types with mismatched brackets.
|
||||||
case '>':
|
case '>':
|
||||||
if (nestedPunctuation.pop_back_val() != '<')
|
if (nestedPunctuation.pop_back_val() != '<')
|
||||||
|
6
third_party/mlir/lib/Parser/Parser.cpp
vendored
6
third_party/mlir/lib/Parser/Parser.cpp
vendored
@ -379,6 +379,12 @@ ParseResult Parser::parsePrettyDialectSymbolName(StringRef &prettyName) {
|
|||||||
nestedPunctuation.push_back(c);
|
nestedPunctuation.push_back(c);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
case '-':
|
||||||
|
// The sequence `->` is treated as special token.
|
||||||
|
if (*curPtr == '>')
|
||||||
|
++curPtr;
|
||||||
|
continue;
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
if (nestedPunctuation.pop_back_val() != '<')
|
if (nestedPunctuation.pop_back_val() != '<')
|
||||||
return emitError("unbalanced '>' character in pretty dialect name");
|
return emitError("unbalanced '>' character in pretty dialect name");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user