-
Notifications
You must be signed in to change notification settings - Fork 833
buggy (or unexpected) interaction between iterator
and parse_complete
#1835
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
Comments
What happens is that the impl<Input, Output, Error, F> core::iter::Iterator for ParserIterator<Input, Error, F>
where
F: Parser<Input, Output = Output, Error = Error>,
Input: Clone,
{
type Item = Output;
fn next(&mut self) -> Option<Self::Item> {
if let State::Running = self.state.take().unwrap() {
let input = self.input.clone();
match (self.iterator).parse(input) { <--- Problem here
Ok((i, o)) => {
self.input = i;
self.state = Some(State::Running);
Some(o)
}
Err(Err::Error(_)) => {
self.state = Some(State::Done);
None
}
Err(Err::Failure(e)) => {
self.state = Some(State::Failure(e));
None
}
Err(Err::Incomplete(i)) => {
self.state = Some(State::Incomplete(i));
None
}
}
} else {
None
}
}
} You could fix this by using I am not sure how to deal with this nicely given the large amount of functions inside nom which still return IResult. It would help to get some guidance on the next steps for nom :) |
I guess one argument might be that |
iterator
and all_consuming
iterator
and parse_complete
I have come up with a potential solution by adding a generic https://github.com/asibahi/nom/tree/iterator Edit 2: kept the old |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I ran into an unexpected panic. I managed to reduce into this code:
error message:
Considering neither
all_consuming
norparse_complete
should returnIncomplete
, this was a bit of a surprise. I am not sure where the mishap is.In my actual code I managed to avoid it by doing this.
The text was updated successfully, but these errors were encountered: