Starting to write my own many_till with context.
This commit is contained in:
parent
4d58ed3bea
commit
45904044e3
@ -35,13 +35,23 @@ use nom::IResult;
|
|||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
fn context_many_till() {
|
fn context_many_till<'r, M, T>(
|
||||||
todo!()
|
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)>> {
|
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
|
||||||
let initial_context = ContextTree::new();
|
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
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +63,8 @@ pub fn paragraph<'s, 'r>(
|
|||||||
not(eof)(i)?;
|
not(eof)(i)?;
|
||||||
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 = many_till(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);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user