Replies: 1 comment 2 replies
-
|
The most general approach is a.or(b)
a.recover_with(via_parser(b))With the exception that the error from There are other error recovery strategies, such as |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all! I've been using chumsky to make an LSP for a custom language, but one thing that has me confused for a while is how to make proper error recovery. Currently, my parser stops as soon as a lexer/parser error is encountered, and this isn't ideal for an LSP, or autocomplete. I've tried a few things:
recover_with()API, but the only strategy that I got to work was.recover_with(skip_then_retry_until(any().ignored(), end()))which isn't ideal, because it lets you insert invalid syntax between otherwise valid syntax.recover_with()API gave me massive "trait bounds not satisfied" errors, which I don't really understandparser.repeated()andparser.delimited_by()will incorrectly consume delimiters themselves because theparserhas a general fallback which will consume any token until the defined resync points. I realised that delimited_by and similar parsers require the inner parser to fail so that it stops consuming tokens.So my question is: What is the proper way to go about error recovery?
Beta Was this translation helpful? Give feedback.
All reactions