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

Nested separated_list for empty input fails? #1063

Closed
zbraniecki opened this issue Nov 8, 2019 · 2 comments
Closed

Nested separated_list for empty input fails? #1063

zbraniecki opened this issue Nov 8, 2019 · 2 comments
Milestone

Comments

@zbraniecki
Copy link

zbraniecki commented Nov 8, 2019

  • Rust version : 1.39
  • nom version : 5.0.1

Test case

fn and_parser(i: &str) -> IResult<&str, Vec<&str>> {
    separated_list(tag(" and "), tag("foo"))(i)
}

fn or_parser(i: &str) -> IResult<&str, Vec<Vec<&str>>> {
    separated_list(tag(" or "), and_parser)(i)
}

assert_eq!(parser("foo and foo or foo"), Ok(("", vec![vec!["foo", "foo"], vec!["foo"]])));

// FAILS with `Err(Error(("", SeparatedList)))`
assert_eq!(or_parser(""), Ok(("", vec![vec![]])));

Why wouldn't that work?

@zbraniecki
Copy link
Author

According to @pcpthm analysis in https://users.rust-lang.org/t/nom-5-and-nested-separated-list/34590/2?u=zbraniecki it seems like a bug in nom

@Geal
Copy link
Collaborator

Geal commented Oct 25, 2020

now that ##1170 is merged, this should be more consistent

@Geal Geal closed this as completed Oct 25, 2020
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

2 participants