many_till ignoring context.
This commit is contained in:
parent
c1778a4f12
commit
d9f0eda5b7
@ -49,8 +49,34 @@ where
|
|||||||
E: ParseError<I>,
|
E: ParseError<I>,
|
||||||
{
|
{
|
||||||
move |mut i: I| {
|
move |mut i: I| {
|
||||||
// todo
|
let mut ret = Vec::new();
|
||||||
todo!()
|
loop {
|
||||||
|
let len = i.input_len();
|
||||||
|
match till_matcher.parse(i.clone()) {
|
||||||
|
Ok((remaining, finish)) => return Ok((remaining, (ret, finish))),
|
||||||
|
Err(nom::Err::Error(_)) => {
|
||||||
|
match many_matcher.parse(i.clone()) {
|
||||||
|
Err(nom::Err::Error(err)) => {
|
||||||
|
return Err(nom::Err::Error(E::append(i, ErrorKind::ManyTill, err)))
|
||||||
|
}
|
||||||
|
Err(e) => return Err(e),
|
||||||
|
Ok((remaining, many_elem)) => {
|
||||||
|
// infinite loop check: the parser must always consume
|
||||||
|
if remaining.input_len() == len {
|
||||||
|
return Err(nom::Err::Error(E::from_error_kind(
|
||||||
|
remaining,
|
||||||
|
ErrorKind::ManyTill,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.push(many_elem);
|
||||||
|
i = remaining;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => return Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +96,7 @@ pub fn paragraph<'s, 'r>(
|
|||||||
let paragraph_context = context.with_additional_fail_matcher(¶graph_end);
|
let paragraph_context = context.with_additional_fail_matcher(¶graph_end);
|
||||||
let text_element_parser = parser_with_context!(flat_text_element)(¶graph_context);
|
let text_element_parser = parser_with_context!(flat_text_element)(¶graph_context);
|
||||||
let ret = context_many_till(¶graph_context, text_element_parser, paragraph_end)(i);
|
let ret = context_many_till(¶graph_context, text_element_parser, paragraph_end)(i);
|
||||||
let ret = many_till(text_element_parser, paragraph_end)(i);
|
// let ret = many_till(text_element_parser, paragraph_end)(i);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user