-
Notifications
You must be signed in to change notification settings - Fork 440
[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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
…overy` and `expect`
For consistency
…houtRecovery` and `expect`
… higher-level parser primitives
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
The token was mis-classified
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.
… instead of `SyntaxText`
This was referenced Sep 7, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the backlog of my changes that improve recovery for reference. I‘ll create separate PRs for these commits.