llvm-project
da5d4214 - [MLIR][TableGen] Make optional enum parser not consume the token when it is not matched (#188008)

Commit
21 days ago
[MLIR][TableGen] Make optional enum parser not consume the token when it is not matched (#188008) Previously the optional parser would consume the token even when it failed to match a value of the enum and prevented parsers later in the op syntax from having an attempt. This PR changes that so that the token is consumed only when the parsing succeeds. This change is made to the emitted `FieldParser<std::optional<T>>` for enums. This, for example, allows having a simple list of default valued props in the assembly format without needing decorations around them. This mimics the behaviour that is emitted for `DefaultValuedAttribute` when it is used with `EnumAttr`. This PR also adds `parseOptionalString` variant with an allow-list argument as `parseOptionalKeyword` has and adds `parseOptionalKeywordOrString` allow-list variant which combines these two into a single utility wrapper. These methods do not consume the token unless it is from the allow-list.
Author
Parents
Loading