-
-
Notifications
You must be signed in to change notification settings - Fork 113
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): Fix grouping of expressions on LHS of fn application, record access etc #1562
Conversation
@ospencer does this look like it covers all the cases you can think of? |
I would probably reverse the logic and group everything that isn't one of the things to be grouped. Then you can just follow this: https://github.com/grain-lang/grain/blob/main/compiler/src/parsing/parser.mly#L545 So if it is not a:
Then it needs parens. That'll help us in the future too if we ever add more constructs; it's easier to tell what needs to be updated. Maybe you might want to make a helper function for the above, so it's easy to modify if we update the parser rules. |
That'll also err on the side of being ugly but correct in the worst case. |
Thanks, that makes sense! |
Thanks @ospencer that's done I think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great! Just some thoughts around naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small bug (related to the marshal format change)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, excellent work @marcusroberts!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent!
Look for the special case of expressions on the left hand side of function application, record/array accessors and group with parens as appropriate.
Fixes #1559