Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
CXWorks committed Jul 31, 2024
2 parents 03c9fbe + 561fb6b commit d0e2173
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion doc/error_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl ContextError<&str> for DebugError {
```

So when calling our JSON parser with this error type, we will get a trace
of all the times a parser stoppped and backtracked:
of all the times a parser stopped and backtracked:

```rust
println!("debug: {:#?}", root::<DebugError>(data));
Expand Down
16 changes: 7 additions & 9 deletions doc/nom_recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ use nom::{

/// A combinator that takes a parser `inner` and produces a parser that also consumes both leading and
/// trailing whitespace, returning the output of `inner`.
fn ws<'a, F, O, E: ParseError<&'a str>>(inner: F) -> impl Parser<&'a str>
where
F: Parser<&'a str>,
pub fn ws<'a, O, E: ParseError<&'a str>, F>(
inner: F,
) -> impl FnMut(&'a str) -> IResult<&'a str, O, E>
where
F: Parser<&'a str, O, E>,
{
delimited(
multispace0,
inner,
multispace0
)
delimited(multispace0, inner, multispace0)
}
```

Expand Down Expand Up @@ -155,7 +153,7 @@ integer value instead is demonstrated for hexadecimal integers. The others are s
The parsers allow the grouping character `_`, which allows one to group the digits by byte, for
example: `0xA4_3F_11_28`. If you prefer to exclude the `_` character, the lambda to convert from a
string slice to an integer value is slightly simpler. You can also strip the `_` from the string
slice that is returned, which is demonstrated in the second hexdecimal number parser.
slice that is returned, which is demonstrated in the second hexadecimal number parser.

If you wish to limit the number of digits in a valid integer literal, replace `many1` with
`many_m_n` in the recipes.
Expand Down
6 changes: 3 additions & 3 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Mode for Emit {
/// Applies the parser, but do not a produce a value
///
/// This has the effect of greatly reducing the amount of code generated and the
/// parser memory usage. Some combinators chek for an error in a child parser but
/// parser memory usage. Some combinators check for an error in a child parser but
/// discard the error, and for those, using [Check] makes sure the error is not
/// even generated, only the fact that an error happened remains
pub struct Check;
Expand Down Expand Up @@ -331,7 +331,7 @@ pub type PResult<OM, I, O, E> = Result<
/// output mode
pub trait OutputMode {
/// Defines the [Mode] for the output type. [Emit] will generate the value, [Check] will
/// apply the parser but will only generate `()` if successul. This can be used when
/// apply the parser but will only generate `()` if successful. This can be used when
/// verifying that the input data conforms to the format without having to generate any
/// output data
type Output: Mode;
Expand All @@ -351,7 +351,7 @@ pub trait OutputMode {
/// Specifies the behaviour when a parser encounters an error that could be due to partial ata
pub trait IsStreaming {
/// called by parsers on partial data errors
/// * `needed` can hold the amount of dditional data the parser would need to decide
/// * `needed` can hold the amount of additional data the parser would need to decide
/// * `err_f`: produces the error when in "complete" mode
fn incomplete<E, F: FnOnce() -> E>(needed: Needed, err_f: F) -> Err<E>;
/// Indicates whether the data is in streaming mode or not
Expand Down

0 comments on commit d0e2173

Please sign in to comment.