Separate lexer utilities#579
Merged
AntonyBlakey merged 7 commits intoNomicFoundation:mainfrom Aug 29, 2023
Merged
Conversation
|
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.
The 59645e6 change is unrelated but I hope it's simple enough that I can squeeze it in as well here.
This includes some smaller, some bigger refactorings while I worked on #567. I hope they are useful on their own and this will help with later work related to #567, as I'll need more lexer-related utilities (i.e. skipping or consuming until a token is found) and it got somewhat unwieldy when I left it in the language.tera.
Next up, I can separate lexer-related bits out of the language.tera into a dedicated lexer.tera that may contain
LexicalContext(cc @AntonyBlakey wrt #567 (comment)) if if you think it's worthwhile.