Skip to content

Implement recovery for declaration parsing #689

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

Closed
wants to merge 8 commits into from

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 1, 2022

Depends on #688


The basic idea is that isStartOfDeclaration now has a recover argument and returns true if it’s possible to recover to a declaration. Other than that, we needed some recovery infrastructure. The productions themself only needed minor changes to continue along the right path and skip the unexpected tokens.

At the moment this doesn’t change anything because all places that call `eat` have previous checks that make sure the parser is currently positioned at the expected token.

In the future, this will allow us to start parsing functions that `eat` a token at a different token and this function is responsible for eating all intermediate tokens until the expected one.
…entation

This makes it easier to implement recovery in the future.
If the item is not an expression, we can try skipping more tokens to parse a declaration.
If the current token is not the start of a declaration, check if we can consume unexpected tokens to reach the declaration’s introducer.
…t of a layout node

This helps us produce better error messages for declaration recovery.
This makes it easier to implement recovery in the future.
@ahoppen ahoppen requested a review from CodaFi September 1, 2022 20:48
@ahoppen
Copy link
Member Author

ahoppen commented Sep 7, 2022

This has become part of my recovery backlog #718. I’ll open a new PR for that change once all the prerequisites have been merged.

@ahoppen ahoppen closed this Sep 7, 2022
@ahoppen ahoppen deleted the ahoppen/more-recovery branch January 14, 2023 08:27
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.

1 participant