Implement the structure to the check_fail_matcher function.
This commit is contained in:
parent
13ee93f31c
commit
1a7bfd23f1
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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 = ¤t_node.without_front();
|
||||
}
|
||||
|
||||
// TODO: Make this a custom error
|
||||
not(take(0usize))(i)?;
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user