diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index 3e0bdac..624027d 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -7,17 +7,33 @@ use nom::error::VerboseError; use nom::IResult; use nom::Parser; -pub struct TestContext { - head: ContextReference, +pub struct ContextLayer { + data: T, + parent: Option>>, +} + +impl ContextLayer { + pub fn with_new_layer(self: Rc, new_layer: T) -> ContextLayer { + ContextLayer { + data: new_layer, + parent: Some(self), + } + } } type ContextReference = Option>>; -struct ContextLayer { - data: T, - parent: ContextReference, +pub struct TestContext { + head: ContextReference, } +// type ContextReference = Option>>; + +// struct ContextLayer { +// data: T, +// parent: ContextReference, +// } + pub struct ContextData { fail_matcher: ChainBehavior, } @@ -46,7 +62,8 @@ impl TestContext { ///// OLD ///// -type MatcherRef = Rc IResult<&str, &str, VerboseError<&str>>>>; +type MatcherRef = + Rc FnMut(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>>>; struct FailChecker<'r>(&'r NomContext<'r>); diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index cfc6d59..0154061 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -46,8 +46,8 @@ fn flat_bold<'s, 'r>( i: &'s str, context: &'r TestContext, ) -> Res<&'s str, TextElement<'s>> { - let new_context = - context.with_additional_fail_matcher(Rc::new(RefCell::new(recognize(bold_end)))); + let fail_matcher = recognize(bold_end); + let new_context = context.with_additional_fail_matcher(Rc::new(RefCell::new(paragraph_end))); // let new_context = context.without_bold(Rc::new(RefCell::new(recognize(bold_end)))); todo!() }