From a88117f731736aaa17d0b69df4237efa415c8815 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 10 Dec 2022 22:20:29 -0500 Subject: [PATCH] Type issue with returning the elements. --- src/parser/nom_context.rs | 5 +++++ src/parser/text_element_parser.rs | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index 64e3422e..5e470436 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -27,6 +27,11 @@ impl<'r> ContextTree<'r> { ContextTree { tree: new_list } } + pub fn pop_front(&mut self) -> (Option>, ContextTree<'r>) { + // todo + todo!() + } + pub fn check_fail_matcher<'s>( &'r self, i: &'s str, diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index f30ead29..e5386ea9 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -63,10 +63,23 @@ where Ok((remaining, finish)) => { let mut ret = Vec::new(); while !current_context.ptr_eq(context) { - // todo - todo!() + let (context_element, next_context) = current_context.pop_front(); + let context_element = context_element.expect("We only pop off context elements created in this function, so they are all Some()"); + current_context = next_context; + match context_element { + ContextElement::FailMatcherNode(_) => {} + ContextElement::PreviousElementNode(PreviousElementNode { + element: token, + }) => { + match token { + Token::TextElement(text_element) => { + ret.push(text_element); + } + }; + } + }; + } - // 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))); }