Optional tokens in the DialectAsmParser API

Hi all,

I’m implementing some dialect-specific types, and implementing the parser logic for it. I was previously using getFullSymbolSpec() and writing my own type parser, but got to the point of wanting better caret diagnostics etc, and felt like using the parser hooks was the right thing.

Specifically I have types with optional arguments, along the lines of:

mydialect.foo

and

mydialect.foo<42>

The challenge I have is that the “optional” parsing methods, e.g. parseOptionalLess return a ParseResult, instead of a OptionalParseResult, so my parsing logic can’t tell if it was present.

Would there be any objection to changing these over to return OptionalParseResult instead? If not, I can prepare a patch to switch them over and update the LLVM monorepo to use it.

-Chris

Oh actually, nevermind. I see it is using ParserResult to return failure if the token wasn’t present. This should work just fine, thanks!

FWIW this has confused me in the past too. using “success/failure” to mean “token was/wasn’t present” is really confusing.