Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: split out MLIR-independent printing into BasePrinter and use in STIM [NFC] #3613

Merged
merged 3 commits into from
Dec 11, 2024

Conversation

superlopuh
Copy link
Member

I'd also like to use the indentation logic in ASL, WGSL, and the assembly dialects, PRs incoming.

@superlopuh superlopuh added the API Related to changes regarding API of constructs label Dec 10, 2024
@superlopuh superlopuh self-assigned this Dec 10, 2024
@superlopuh superlopuh changed the title API: split out MLIR-independent printing into BasePrinter and use in STIM API: split out MLIR-independent printing into BasePrinter and use in STIM [NFC] Dec 10, 2024
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.15%. Comparing base (f7d39a1) to head (cb51b8c).
Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3613      +/-   ##
==========================================
- Coverage   90.41%   90.15%   -0.27%     
==========================================
  Files         471      465       -6     
  Lines       59138    58716     -422     
  Branches     5611     5625      +14     
==========================================
- Hits        53471    52934     -537     
- Misses       4224     4344     +120     
+ Partials     1443     1438       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@alexarice alexarice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a great change to me


@dataclass(eq=False, repr=False)
class StimPrinter(BasePrinter):
@contextmanager
def in_braces(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly for a future PR, but I wonder if context managers for each delimiter pair should be added to BasePrinter. It's always annoyed me that there is in_angle_brackets (at least in the parser) but not the equivalents for braces, square brackets, and parentheses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hundo p, just trying to make the API changes small, so we can have a focused discussion about the API in a separate PR

Copy link
Collaborator

@math-fehr math-fehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me'

from dataclasses import dataclass, field
from typing import IO, Any, TypeVar

indentNumSpaces = 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O think this should stay in the printer no? Or as an option?

@superlopuh superlopuh merged commit 414bcb0 into main Dec 11, 2024
15 checks passed
@superlopuh superlopuh deleted the sasha/printer/print-any branch December 11, 2024 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Related to changes regarding API of constructs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants