Skip to content

Polish parser helpers#580

Merged
AntonyBlakey merged 3 commits intoNomicFoundation:mainfrom
Xanewok:polish-parser-helpers
Aug 29, 2023
Merged

Polish parser helpers#580
AntonyBlakey merged 3 commits intoNomicFoundation:mainfrom
Xanewok:polish-parser-helpers

Conversation

@Xanewok
Copy link
Copy Markdown
Contributor

@Xanewok Xanewok commented Aug 28, 2023

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

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.
@Xanewok Xanewok requested a review from a team as a code owner August 28, 2023 15:41
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Aug 28, 2023

⚠️ No Changeset found

Latest commit: 545a427

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

@Xanewok Xanewok force-pushed the polish-parser-helpers branch from 6dab826 to 545a427 Compare August 28, 2023 15:54
@AntonyBlakey AntonyBlakey added this pull request to the merge queue Aug 29, 2023
Merged via the queue into NomicFoundation:main with commit 8125d65 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.
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