core: (attr assembly fmt) add wiring into irdl_param_attr_def (pt2) - #5901
core: (attr assembly fmt) add wiring into irdl_param_attr_def (pt2)#5901n-io wants to merge 2 commits into
Conversation
Add the foundational classes for a declarative assembly format system for ParametrizedAttribute types, mirroring the existing op-side system: AttrFormatDirective ABC, structural directives (whitespace, punctuation, keyword), ParameterVariable, AttrFormatProgram, and AttrFormatParser.
…nition Integrate the attr declarative assembly format into the attribute definition system. ParametrizedAttribute subclasses can now set assembly_format = "..." to auto-generate parse_parameters and print_parameters methods.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## nicolai/attr-asm-fmt-pt1-core-directives #5901 +/- ##
=========================================================================
Coverage 86.20% 86.21%
=========================================================================
Files 418 418
Lines 60077 60104 +27
Branches 6950 6955 +5
=========================================================================
+ Hits 51791 51818 +27
+ Misses 6689 6688 -1
- Partials 1597 1598 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
377ba90 to
b8e73f1
Compare
|
Happy to review this as soon as merge conflicts are resolved. |
Samielakkad
left a comment
There was a problem hiding this comment.
I think required structural directives are currently too permissive during parsing.
AttrFormatProgram.parse ignores the boolean returned by each directive:
for stmt in self.stmts:
stmt.parse(parser, state)but AttrPunctuationDirective.parse and AttrKeywordDirective.parse use optional parsers and only return False when the token is missing. That means a format like:
assembly_format = "$first `,` $second"may accept an input without the comma, as long as $second can still be parsed afterwards, because the missing punctuation does not raise. The same applies to required keywords.
I think required punctuation/keyword directives should call the non-optional parser variant, or AttrFormatProgram.parse should treat False as an error for non-optional directives. Optional groups can still use parse_optional for the speculative path.
Integrate the attr declarative assembly format into the attribute definition system. ParametrizedAttribute subclasses can now set assembly_format = "..." to auto-generate parse_parameters and print_parameters methods.
Stacked on top of: #5900