Starting to write my own many_till with context.

This commit is contained in:
Tom Alexander 2022-11-26 19:35:02 -05:00
parent 4d58ed3bea
commit 45904044e3
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -35,13 +35,23 @@ use nom::IResult;
use tracing::instrument;
use tracing::trace;
fn context_many_till() {
todo!()
fn context_many_till<'r, M, T>(
context: &'r OrgModeContextNode<'r>,
many_matcher: M,
till_matcher: T,
) -> impl for<'s> FnMut(
&'s str,
) -> IResult<&'s str, (Vec<TextElement<'s>>, &'s str), VerboseError<&'s str>> {
|i| {
// todo
todo!()
}
}
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
let initial_context = ContextTree::new();
let ret = many1(parser_with_context!(paragraph)(&initial_context))(input);
let paragraph_parser = parser_with_context!(paragraph);
let ret = many1(paragraph_parser(&initial_context))(input);
ret
}
@ -53,7 +63,8 @@ pub fn paragraph<'s, 'r>(
not(eof)(i)?;
let paragraph_context = context.with_additional_fail_matcher(&paragraph_end);
let text_element_parser = parser_with_context!(flat_text_element)(&paragraph_context);
let ret = many_till(text_element_parser, paragraph_end)(i);
let ret = context_many_till(&paragraph_context, text_element_parser, paragraph_end)(i);
// let ret = many_till(text_element_parser, paragraph_end)(i);
ret
}