Skip to content

Simplify syntax diagrams #1805

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

Open
lukaslueg opened this issue Apr 29, 2025 · 1 comment · May be fixed by #1818
Open

Simplify syntax diagrams #1805

lukaslueg opened this issue Apr 29, 2025 · 1 comment · May be fixed by #1818
Labels
A-grammar Area: Syntax and parsing

Comments

@lukaslueg
Copy link
Contributor

Coming back to the off-topic point in #1798: Some of the syntax diagrams can be simplified quite a bit by removing superfluous elements. There are basically two ways to solve this:

  • Implement an optimizer that takes the grammar's AST and performs the simplification automatically. Such as here.
  • Manually take care not to introduce superfluous elements in the grammar rules themselves. There is a conflict of goals here, as the rules become more compact/nested. That is, the visual representation becomes easier to follow at the cost of the textual representation becoming harder to understand.

See #1798 on what this does to the syntax. Do you fancy a PR for the either of those options? The second one is obviously much more simple to do.

Image

Image

Image

Image

Image

Image

@ehuss ehuss added the A-grammar Area: Syntax and parsing label May 3, 2025
@joshtriplett
Copy link
Member

@lukaslueg I don't think we should do this in an automated fashion, because we then get committed to making sure we're happy with the automated refactors, which might not always produce optimal diagrams.

I think, to the extent we use automation at all, it should be to flag diagrams that aren't maximally simple, or perhaps to suggest possible refactors.

All of the proposed diagram simplifications look great to me. If the resulting text is less readable, I think we have some options to try to improve the readability.

@lukaslueg lukaslueg linked a pull request May 8, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: Syntax and parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants