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

fix(grainfmt): nicer pretty printing of binops #1514

Merged
merged 5 commits into from
Dec 3, 2022
Merged

fix(grainfmt): nicer pretty printing of binops #1514

merged 5 commits into from
Dec 3, 2022

Conversation

marcusroberts
Copy link
Member

@marcusroberts marcusroberts commented Dec 3, 2022

Fixes #1391

Add additional parens to binary operators for clarity when precedence is the same but operators are different.
Except for maths operators, and when the right hand operator is a logical operator

@marcusroberts marcusroberts changed the title fix(grainfmt) nicer pretty printing of binops fix(grainfmt): nicer pretty printing of binops Dec 3, 2022
| "&&"
| "||" => true
| _ => false
};
Copy link
Member

Choose a reason for hiding this comment

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

These two functions need to be extended to the start of the operators in the same way that op_precedence does, but otherwise this looks good.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's done.


let ya = 1 / (2 + 3)

let y1 = 1 + 2 /3
Copy link
Member

Choose a reason for hiding this comment

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

extra space in here?

Copy link
Member

Choose a reason for hiding this comment

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

Oh that's because constants are formatted as-is and it's a rational literal. I'll open an issue about that separately.

Copy link
Member

Choose a reason for hiding this comment

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

Marcus Roberts and others added 3 commits December 3, 2022 17:31
Copy link
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

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

Looks awesome, I've been excited for this one! :D

Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

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

Very nice!

@phated phated merged commit 3ac27cc into main Dec 3, 2022
@phated phated deleted the marcus/binops branch December 3, 2022 23:57
@github-actions github-actions bot mentioned this pull request Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grainfmt: Use Prettier's logic for infix operators
3 participants