Implement the structure to the check_fail_matcher function.

This commit is contained in:
Tom Alexander 2022-12-03 22:12:13 -05:00
parent 13ee93f31c
commit 1a7bfd23f1
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 33 additions and 2 deletions

View File

@ -25,7 +25,17 @@ impl<T> List<T> {
}
}
pub fn without_front(&self) -> List<T> {
List {
head: self.head.as_ref().map(|node| node.parent.clone()).flatten()
}
}
pub fn get_data(&self) -> Option<&T> {
self.head.as_ref().map(|rc_node| &rc_node.data)
}
pub fn is_empty(&self) -> bool {
self.head.is_none()
}
}

View File

@ -1,3 +1,5 @@
use nom::bytes::complete::take;
use nom::combinator::not;
use nom::error::VerboseError;
use nom::IResult;
@ -21,8 +23,27 @@ impl<'r> ContextTree<'r> {
}
pub fn check_fail_matcher<'s>(&'r self, i: &'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>> {
// todo
todo!()
let mut current_node = &self.tree;
while !current_node.is_empty() {
let context_element = current_node.get_data().expect("While looop proves its Some()");
match context_element {
ContextElement::FailMatcherNode(fail_matcher) => {
match fail_matcher.fail_matcher {
ChainBehavior::AndParent(Some(matcher)) => todo!(),
ChainBehavior::AndParent(None) => todo!(),
ChainBehavior::IgnoreParent(_) => todo!(),
ChainBehavior::IgnoreParent(None) => todo!(),
};
},
ContextElement::PreviousElementNode(_) => todo!(),
};
current_node = &current_node.without_front();
}
// TODO: Make this a custom error
not(take(0usize))(i)?;
unreachable!()
}
}