Skip to content

Improve error recovery in delimited groups when can't parse anything inside#601

Merged
AntonyBlakey merged 3 commits intoNomicFoundation:mainfrom
Xanewok:error-recovery-null-in-delimited
Sep 27, 2023
Merged

Improve error recovery in delimited groups when can't parse anything inside#601
AntonyBlakey merged 3 commits intoNomicFoundation:mainfrom
Xanewok:error-recovery-null-in-delimited

Conversation

@Xanewok
Copy link
Copy Markdown
Contributor

@Xanewok Xanewok commented Sep 25, 2023

Simpler variant of #594.

While writing an issue for the potential null parse recovery, it just hit me that we might not need to support that generally but rather just limiting that to the delimited group would give us enough bang for the buck.

TerminatedBy null parse recovery can be a bit too greedy, i.e. we might recover some unexpected item definition just because... we recovered at the final terminator. However, the delimited group is a reasonable boundary since it's simple (2-3 kinds of general delimiters versus different kinds of potentially versioned terminated statements) and the opening delimiter must always match the closing one, so it produces more reliable and self-contained recovered phrases, hence attempting to recover from a null parse in a delimited group makes more sense.

TerminatedBy can be a bit too greedy, i.e. we recovered some unexpected
item definition just because... we recovered at a terminator. However,
the delimited group is a reasonable boundary since it's simple (2-3 kinds
of delimiters) and the opening delimiter must always match the closing
one, so it produces more reliable and self-contained recovered phrases,
so attempting to recover from a null parse in a delimited group makes
more sense.
@Xanewok Xanewok requested a review from a team as a code owner September 25, 2023 14:06
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Sep 25, 2023

🦋 Changeset detected

Latest commit: 0246fa5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/slang Patch

Not sure what this means? Click here to learn what changesets are.

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

@Xanewok Xanewok changed the title Improve error recovery in delimited groups when can't parse anything Improve error recovery in delimited groups when can't parse anything inside Sep 25, 2023
@AntonyBlakey AntonyBlakey added this pull request to the merge queue Sep 26, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Sep 26, 2023
@Xanewok
Copy link
Copy Markdown
Contributor Author

Xanewok commented Sep 26, 2023

Updated and added a changeset file (for this and for delimited error recovery in general)

@AntonyBlakey AntonyBlakey added this pull request to the merge queue Sep 27, 2023
Merged via the queue into NomicFoundation:main with commit cbd2a79 Sep 27, 2023
@github-actions github-actions bot mentioned this pull request Sep 27, 2023
github-merge-queue bot pushed a commit that referenced this pull request Sep 27, 2023
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @nomicfoundation/slang@0.10.0

### Minor Changes

- [#595](#595)
[`1a258c4`](1a258c4)
Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery
when parsing incomplete lists

- [#564](#564)
[`e326a06`](e326a06)
Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing
operators with missing operands should no longer panic

- [#564](#564)
[`e326a06`](e326a06)
Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse
rules are no longer exposed to the API.

- [#564](#564)
[`e326a06`](e326a06)
Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are
no longer available as methods - use next_token instead

- [#564](#564)
[`e326a06`](e326a06)
Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are
now grouped into contexts to deal with contextual scanning

### Patch Changes

- [#601](#601)
[`cbd2a79`](cbd2a79)
Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error
recovery between bracket delimiters

- [#599](#599)
[`4bbad48`](4bbad48)
Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions
for the `revert` and `global` keywords

- [#561](#561)
[`cb6a138`](cb6a138)
Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary
documentation for the `solidity_language` Rust package

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
rollup-smithbm0p added a commit to rollup-smithbm0p/slang that referenced this pull request Dec 26, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @nomicfoundation/slang@0.10.0

### Minor Changes

- [#595](NomicFoundation/slang#595)
[`1a258c4`](NomicFoundation/slang@1a258c4)
Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery
when parsing incomplete lists

- [#564](NomicFoundation/slang#564)
[`e326a06`](NomicFoundation/slang@e326a06)
Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing
operators with missing operands should no longer panic

- [#564](NomicFoundation/slang#564)
[`e326a06`](NomicFoundation/slang@e326a06)
Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse
rules are no longer exposed to the API.

- [#564](NomicFoundation/slang#564)
[`e326a06`](NomicFoundation/slang@e326a06)
Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are
no longer available as methods - use next_token instead

- [#564](NomicFoundation/slang#564)
[`e326a06`](NomicFoundation/slang@e326a06)
Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are
now grouped into contexts to deal with contextual scanning

### Patch Changes

- [#601](NomicFoundation/slang#601)
[`cbd2a79`](NomicFoundation/slang@cbd2a79)
Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error
recovery between bracket delimiters

- [#599](NomicFoundation/slang#599)
[`4bbad48`](NomicFoundation/slang@4bbad48)
Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions
for the `revert` and `global` keywords

- [#561](NomicFoundation/slang#561)
[`cb6a138`](NomicFoundation/slang@cb6a138)
Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary
documentation for the `solidity_language` Rust package

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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