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

Successfully parse 'a + b /= c' #259

Closed
wants to merge 2 commits into from
Closed

Successfully parse 'a + b /= c' #259

wants to merge 2 commits into from

Conversation

jfmengels
Copy link
Collaborator

Fixes #258

We usually attempt to parse '/=' before we parse '/', which parses successfully.
But because in this expression we previously encountered a '+', we're at a precedence leve where we are only evaluating operators with a higher precedence than '/='. So we don't check for '/=', and then we see a '/' which commits, and then we get stuck because we don't expect a '='.

This fixes the issue by checking, for the '/' operator, that it is not followed by a '='. Ideally we should only do this if the operator
precedence is higher than the precendence for '/=', but that data is not available for the parser.

Similarly, this fixes the parsing of 'a && b <| c' which has the same problem.

cc @lue-bird, let me know if I missed something or if there is a better or more performant way to do this.


On top of this, I also made a small improvement to the printing of DeadEnds in the tests.

We attempt to parse '/=' before we parse '/', which parses successfully.
But because in this expression we previously encountered a '+', we're at a precedence leve where we are only evaluating operators with a higher precedence than '/='. So we don't check for '/=', and then we see a '/' which commits, and then we get stuck because we don't expect a '='.

This fixes the issue by checking, for the '/' operator, that it is not
followed by a '='. Ideally we should only do this if the operator
precedence is higher than the precendence for '/=', but that data is not
available for the parser.

Similarly, this fixes the parsing of 'a && b <| c' which has the same
problem.
@jfmengels jfmengels changed the title Make test failure message easier to read Successfully parse 'a + b /= c' Sep 10, 2024
@jfmengels
Copy link
Collaborator Author

jfmengels commented Sep 11, 2024

Superseded by #260.

@jfmengels jfmengels closed this Sep 11, 2024
@jfmengels jfmengels deleted the binary branch September 11, 2024 16:26
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.

Binary operator parsing precedence bug
1 participant