Skip to content
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

Separate lexer utilities #579

Merged
merged 7 commits into from
Aug 29, 2023

Conversation

Xanewok
Copy link
Contributor

@Xanewok Xanewok commented Aug 28, 2023

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.

@Xanewok Xanewok requested a review from a team as a code owner August 28, 2023 14:37
@changeset-bot
Copy link

changeset-bot bot commented Aug 28, 2023

⚠️ No Changeset found

Latest commit: b00f751

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@AntonyBlakey AntonyBlakey added this pull request to the merge queue Aug 29, 2023
Merged via the queue into NomicFoundation:main with commit 0bdec2d Aug 29, 2023
1 check passed
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.
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.

2 participants