Skip to content

[DO NOT MERGE] Backlog for recovery-related changes #718

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 44 commits into from

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 6, 2022

This is the backlog of my changes that improve recovery for reference. I‘ll create separate PRs for these commits.

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.
Use one of the following alternatives instead:
- `expect` (mostly at start of productions)
- `consume(if:)` where this paradigm is applicable
- `consume(if:followedBy:)` to consume two tokens at once
- A new `at(anyIn:)` paradigm that allows the parser to check if it is currently positioned at a known token kind, which can be exhausitively switched. If this is the case, the token can be safely consumed using a handle.
  - This function might seem overly complicated at the moment but it should allow us to later switch to a similar function that also does recovery.
Also change `text` to `where` so the signature matches `consume(if:where:)`
This makes it easier to call it from other functions and forward the expected token kinds.
We aren’t using this anywhere, but it seems like useful functionality in general.
…entation

This allows us to share a few token kinds betewen `isStartOfDeclaration` and the actual parser.
If the item is not an expression, we can try skipping more tokens to parse a declaration.

# Conflicts:
#	Sources/SwiftParser/TokenClassification.swift
This is no longer satisfied if the token text is synthesized from a StaticString.
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.

# Conflicts:
#	Tests/SwiftParserTest/Statements.swift
This makes it easier to implement recovery in the future.
@ahoppen ahoppen changed the title [WIP] Backlog for recovery-related changes [DO NOT MERGE] Backlog for recovery-related changes Sep 7, 2022
@ahoppen ahoppen closed this Oct 15, 2022
@ahoppen ahoppen deleted the ahoppen/recovery-backlog 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