-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error recovery support #96
Comments
See also rust-bakery/nom#499 |
https://eyalkalderon.com/blog/nom-error-recovery/
https://arxiv.org/pdf/1806.11150.pdf
https://docs.rs/chumsky/latest/chumsky/
|
ProposalAdd pub trait Recover<I: Stream, E> {
// For `Stream`s other than `Recoverable` (like `&str`), this will reset the stream to `err_start` and return `err` back to the caller causing `Parser::parse` to behave as it does today.
// If performance is bad, maybe we could have a `is_recoverable` function to skip running the `recover` parser...
fn record_err(&mut self, token_start: I::Checkpoint, err_start: I::Checkpoint, err: E) -> Result<(), E>;
}
pub struct Recoverable<I, E> {
input: I,
errors: Vec<E>,
is_recoverable: bool, // allow runtime deactivation so people don't have to make their parser generic over it if they need both modes, avoiding bloating the binary / compile times
}
pub trait Parser<I, O, E> {
// ...
fn parse_recovery<I1>(&mut self, input: I1) -> (O, Vec<E>) {
// ... implicitly wraps `input` with `Recoverable` and then pulls out `Recoverable::Errors` and adds any trailing errors to it
}
fn resume_after(self, recover: impl Parser<I, O, E>)
where I: Recover<I, E> {
// ...
}
fn retry_after(self, recover: impl Parser<I, (), E>)
where I: Recover<I, E> {
// ...
}
}
We might also want to consider modifying our An unknown to me is how to handle
|
|
The main things this leave out include: - A happy path for error reporting - Examples First step towards winnow-rs#96
The main things this leave out include: - A happy path for error reporting - Examples First step towards winnow-rs#96
The main things this leave out include: - A happy path for error reporting - Examples First step towards winnow-rs#96
Please complete the following tasks
winnow version
0.2.0
Describe your use case
Some times a user will want to collect and report all errors or append semantic errors, like compilers do. See toml-rs/toml#371
Describe the solution you'd like
Error recovery support
https://eyalkalderon.com/blog/nom-error-recovery/ started to experiment with it based on the papers at https://arxiv.org/pdf/1806.11150.pdf
Alternatives, if applicable
No response
Additional Context
Tasks
The text was updated successfully, but these errors were encountered: