This adds a new parser and printer for text which may be a keyword or a
string. When printing, it will attempt to print the text as a keyword,
but if it has any special or non-printable characters, it will be
printed as an escaped string. When parsing, it will parse either a
valid keyword or a potentially escaped string. The printer allows for an
empty string, in which case it prints "".
This new function is used for printing the name in NamedAttributes, and
for printing the symbol name after the @. In CIRCT we are using this
to print module port names, which are conceptually similar to named
function arguments.
I would have the default methods take a std::string * parameter, and potentially add additional overloads that construct a StringAttr. This is the base AsmParser class, which is also used by attributes/types and those generally don't want to go through StringAttr.