chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

Missing documentation with example of the recovery system

Open bew opened this issue 2 years ago • 4 comments

AFAIK there's not a lot of documentation (except few lines), nor examples on how to use the recovery module and the parse_recovery_* functions https://docs.rs/chumsky/latest/chumsky/recovery/index.html

Especially on the functions nested_delimiters skip_then_retry_until skip_until

bew avatar Dec 05 '21 00:12 bew

Adding on, it would also be nice to see an example of how to construct a partial syntax tree with Error nodes like in the README screenshot. It seems like none of the current examples do this and it is crucial to having a good IDE experience

Scoder12 avatar Jun 17 '22 02:06 Scoder12

Currently, the following examples do parser error recovery:

There is also documentation on Parser::recover_with, the main method used to invoke recovery.

It's true that this is somewhat hard to find though: the recovery module docs should probably point to it and give a little overview of the various recovery options available.

zesterer avatar Jun 17 '22 09:06 zesterer

nested_delimiters works great but I'm not sure to how apply the other strategies. For example, say I have a statement parser that is separtated_by(Semicolon). How could I recover valid statements with syntax errors in-between? Or, at least recover statements before a syntax error?

Scoder12 avatar Jun 18 '22 23:06 Scoder12

How could I recover valid statements with syntax errors in-between?

skip_until will probably serve your needs.

I'm intending to refactor the recovery system when zero-copy merged to make it more flexible and easier to work with.

zesterer avatar Jun 19 '22 16:06 zesterer