Attempt error recovery from partial matches in separated lists#595
Attempt error recovery from partial matches in separated lists#595AntonyBlakey merged 16 commits intoNomicFoundation:mainfrom
Conversation
Parsing *some* input in when the first element is optional shouldn't be accepted as empty.
This changed because of the NomicFoundation#586 that was merged in the meantime.
To reduce ident gluing in the codegen.
In preparation for the custom recovery logic, to make sure that we don't regress anything by introducing the custom SeparatedBy helper/parser.
🦋 Changeset detectedLatest commit: 3c4146e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
c67216b to
ddfd506
Compare
|
@OmarTawfik looks like a spurious sccache failure: |
Looks like it recovered on retry. Please let me know if you see it again and I can look into it. |
|
Updated and CI is green |
|
I added a test with error recovery for the identifier path lists (so nested separated-by lists) in the function definition and in the individual expressions of the following body, which shows that we recover individually everywhere: function all() override(some.ident unexpected tokens, ISomeInterface, Other) public {
msg.sender.call{do: 1, arg: 1 }();
msg.sender.call{, empty: 1, parse: 2 }();
msg.sender.call{arg: 1, missing_expr: , no_semicolon, , }();
msg.sender.call{arg: 1 unexpected tokens, not: 2, recovered, yet: 3, }();
}
function empty() override(some.ident, /* empty */, other.arg.here, and.here);
function nested_lists() override(some.ident, next.do.that, other.while, next.one, final, ultimate);
function nested_lists() override(some., next.arg, next.one, ultimate);Do you want me to also fill the bodies of these functions for completeness' sake and/or find a more complete example for the recovery implemented here? |
No, I just wanted to show that we recovered and continued. |
|
Updated |
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>
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>
Based on #593.
Implements a dedicated
SeparatedHelper(no state, can change to a free function) that implements recovering from partial matches in separated lists.There are 3 ways we can recover:
Ideally we should recover in all three cases, however because the the trailing separator is not mandatory (nor legal), cases 1. and 3. are tricky. In case 2 The separated-by lists are not always in a delimited group (e.g.
IdentifierPath) and so there's no sure way to bound the recovery, as the unexpected tokens (i.e. not a separator) can be already part of the outer parse.For instance,
0.0.0 || 0.0.0(case 1) or0.0. || 0.0.0(case 3) might attempt to recover by skipping the|| 0part. Until we constrain the error recovery with a la FOLLOW for the recovering parser, we can't reliably recover errors for now in these cases.