Skip to content
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

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

Open
stevenengler opened this issue Feb 9, 2025 · 0 comments

Comments

@stevenengler
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant