| _topic |
|
|
- |
| _tutorial |
|
|
- |
| ascii |
|
|
- |
| binary |
|
|
- |
| combinator |
|
|
- |
| error.rs |
# Error management
Errors are designed with multiple needs in mind:
- Accumulate more [context][Parser::context] as the error goes up the parser chain
- Distinguish between [recoverable errors,
unrecoverable errors, and more data is needed][ErrMode]
- Have a very low overhead, as errors are often discarded by the calling parser (examples: `repeat`, `alt`)
- Can be modified according to the user's needs, because some languages need a lot more information
- Help thread-through the [stream][crate::stream]
To abstract these needs away from the user, generally `winnow` parsers use the [`ModalResult`]
alias, rather than [`Result`]. [`Parser::parse`] is a top-level operation
that can help convert to a `Result` for integrating with your application's error reporting.
Error types include:
- [`EmptyError`] when the reason for failure doesn't matter
- [`ContextError`]
- [`InputError`] (mostly for testing)
- [`TreeError`] (mostly for testing)
- [Custom errors][crate::_topic::error] |
44906 |
- |
| lib.rs |
> winnow, making parsing a breeze
`winnow` is a parser combinator library
Quick links:
- [List of combinators][crate::combinator]
- [Tutorial][_tutorial::chapter_0]
- [Special Topics][_topic]
- [Discussions](https://github.com/winnow-rs/winnow/discussions)
- [CHANGELOG](https://github.com/winnow-rs/winnow/blob/v0.7.13/CHANGELOG.md) (includes major version migration
guides)
## Aspirations
`winnow` aims to be your "do everything" parser, much like people treat regular expressions.
In roughly priority order:
1. Support writing parser declaratively while not getting in the way of imperative-style
parsing when needed, working as an open-ended toolbox rather than a close-ended framework.
2. Flexible enough to be used for any application, including parsing strings, binary data,
or separate [lexing and parsing phases][_topic::lexing]
3. Zero-cost abstractions, making it easy to write high performance parsers
4. Easy to use, making it trivial for one-off uses
In addition:
- Resilient maintainership, including
- Willing to break compatibility rather than batching up breaking changes in large releases
- Leverage feature flags to keep one active branch
- We will support the last 6 months of rust releases (MSRV, currently 1.64.0)
See also [Special Topic: Why winnow?][crate::_topic::why]
## Example
Run
```console
$ cargo add winnow
```
Then use it to parse:
```rust
# #[cfg(feature = "alloc")] { |
5833 |
- |
| macros |
|
|
- |
| parser.rs |
Basic types to build the parsers |
47579 |
- |
| stream |
|
|
- |
| token |
|
|
- |