diff --git a/src/parser/list.rs b/src/parser/list.rs index b2df6de6..bd891b1e 100644 --- a/src/parser/list.rs +++ b/src/parser/list.rs @@ -64,4 +64,12 @@ impl List { pub fn is_empty(&self) -> bool { self.head.is_none() } + + pub fn ptr_eq(&self, other: &List) -> bool { + match (self.head.as_ref(), other.head.as_ref()) { + (None, None) => true, + (None, Some(_)) | (Some(_), None) => false, + (Some(me), Some(them)) => Rc::ptr_eq(me, them), + } + } } diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index 3d72600a..64e3422e 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -18,6 +18,10 @@ impl<'r> ContextTree<'r> { ContextTree { tree: List::new() } } + pub fn ptr_eq<'x>(&self, other: &ContextTree<'x>) -> bool { + self.tree.ptr_eq(&other.tree) + } + pub fn with_additional_node(&self, data: ContextElement<'r>) -> ContextTree<'r> { let new_list = self.tree.push_front(data); ContextTree { tree: new_list } diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index c6215337..f30ead29 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -62,6 +62,11 @@ where match till_matcher(¤t_context, i.clone()) { Ok((remaining, finish)) => { let mut ret = Vec::new(); + while !current_context.ptr_eq(context) { + // todo + todo!() + } + // while current_context.tr // TODO build a vec of the elements by popping off the newest elements of the context return Ok((remaining, (ret, finish))); }