Polish parser helpers#580
Merged
AntonyBlakey merged 3 commits intoNomicFoundation:mainfrom Aug 29, 2023
Merged
Conversation
This removes the explicit `loop`-`break` constructs with the Rust's more native std::ops::ControlFlow to prevent accidental infinite loops, in addition to documenting and simplifying the core combination logic.
|
6dab826 to
545a427
Compare
AntonyBlakey
approved these changes
Aug 29, 2023
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 29, 2023
Based on #564 EDIT: As asked, this was split into supporting PRs (#579, #580, merged now), doesn't use the Error CST node anymore and only contains terminated-by recovery. To support error side-channel in a backtracking scenario, `Vec<ParseError>` was added to the `Stream` which serves more as a parse context now. To backtrack, we first record the position of the stream and how many errors are there; then, we reset the errors and the position to the first recorded `Marker` struct (basically copying what `chumsky` does). This wasn't changed everywhere as `Stream::set_position` in the lexer will never emit errors (only parsers do), nor will the optional trivia parsers. I'm happy to polish the lexer interface a bit to accommodate for this change later, if that's okay. First, I wanted to make sure the approach is fine and accepted, until we proceed with the DelimitedBy error recovery.
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
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.
Most importantly, this documents and tries to simplify the parser helpers and improves legibility of the generated parse functions. Done as part of the #567