Skip to content

nom::character contains only a subset of parsers from complete/streaming #1824

Open
@stevenengler

Description

@stevenengler

In nom 8.0, there is a new way of writing parsers using a Parser trait. Some of nom's parsers are now written using this Parser trait, and some using the older function syntax.

In nom::character::complete and nom::character::streaming, there are many parsers:

  • alpha0
  • alpha1
  • digit0
  • digit1
  • newline
  • etc

These all seem to be written using the old function syntax. For example:

pub fn digit1<T, E: ParseError<T>>(input: T) -> IResult<T, T, E>
where
    T: Input,
    <T as Input>::Item: AsChar,

In nom::character, there are a small subset of these parsers:

  • digit1
  • char
  • etc

These seem to be written using the new Parser trait. For example:

pub fn digit1<T, E: ParseError<T>>() -> impl Parser<T, Output = T, Error = E>
where
    T: Input,
    <T as Input>::Item: AsChar,

But notably many of the parsers from the complete and streaming modules like digit0, alpha0, alpha1, etc are missing. For example this module has a digit1 but not a digit0.

So as a user, it's unclear when parsers should be used from the parent nom::character or the child complete/streaming. And it's also not clear why nom::character is missing so many compared to complete/streaming. I think this could be documented better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions