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

Improve token precedence classifications #707

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

ahoppen
Copy link
Collaborator

@ahoppen ahoppen commented Sep 5, 2022

Motivated by #704 this adjusts token precedences a little bit to produce better diagnostics. Previously, we had different logic how we classified weak brackets (like () and strong brackets (like {). Unify the two concepts and allow consuming weak punctuators (like . or :) while looking for a weak closing bracket and skipping strong punctuators (like ;) while looking for a strong closing bracket.

@ahoppen
Copy link
Collaborator Author

ahoppen commented Sep 5, 2022

@swift-ci Please test

Comment on lines +161 to +162
DiagnosticSpec(locationMarker: "TEST_1", message: "Unexpected text '@s return' found in function"),
DiagnosticSpec(locationMarker: "TEST_2", message: "Unexpected text '@unknown return' found in function")
Copy link
Contributor

Choose a reason for hiding this comment

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

return is a fairly strong keyword (IMO), should we really consume it as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That would require more recovery logic in parseStatement. I filed #714 to do this later (after I have merged all my other recovery work).

@ahoppen
Copy link
Collaborator Author

ahoppen commented Sep 6, 2022

@swift-ci Please test macOS

@ahoppen ahoppen merged commit fceb672 into apple:main Sep 6, 2022
@ahoppen ahoppen deleted the ahoppen/improve-token-precedence branch September 6, 2022 13:23
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.

None yet

2 participants