Impleemnt the behavior for check_fail_matcher.
This commit is contained in:
parent
1a7bfd23f1
commit
84fa1c3aae
@ -22,23 +22,44 @@ impl<'r> ContextTree<'r> {
|
|||||||
ContextTree { tree: new_list }
|
ContextTree { tree: new_list }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_fail_matcher<'s>(&'r self, i: &'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>> {
|
pub fn check_fail_matcher<'s>(
|
||||||
let mut current_node = &self.tree;
|
&'r self,
|
||||||
|
i: &'s str,
|
||||||
|
) -> IResult<&'s str, &'s str, VerboseError<&'s str>> {
|
||||||
|
// TODO: Can I do this without incrementing reference counters? Perhaps via implementing an iterator over the list?
|
||||||
|
let mut current_node = self.tree.clone();
|
||||||
while !current_node.is_empty() {
|
while !current_node.is_empty() {
|
||||||
let context_element = current_node.get_data().expect("While looop proves its Some()");
|
let context_element = current_node
|
||||||
|
.get_data()
|
||||||
|
.expect("While looop proves its Some()");
|
||||||
match context_element {
|
match context_element {
|
||||||
ContextElement::FailMatcherNode(fail_matcher) => {
|
ContextElement::FailMatcherNode(fail_matcher) => {
|
||||||
match fail_matcher.fail_matcher {
|
match fail_matcher.fail_matcher {
|
||||||
ChainBehavior::AndParent(Some(matcher)) => todo!(),
|
ChainBehavior::AndParent(Some(matcher)) => {
|
||||||
ChainBehavior::AndParent(None) => todo!(),
|
let local_result = matcher(i);
|
||||||
ChainBehavior::IgnoreParent(_) => todo!(),
|
if local_result.is_ok() {
|
||||||
ChainBehavior::IgnoreParent(None) => todo!(),
|
return local_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ChainBehavior::AndParent(None) => {}
|
||||||
|
ChainBehavior::IgnoreParent(Some(matcher)) => {
|
||||||
|
let local_result = matcher(i);
|
||||||
|
if local_result.is_ok() {
|
||||||
|
return local_result;
|
||||||
|
}
|
||||||
|
// TODO: Make this a custom error
|
||||||
|
not(take(0usize))(i)?;
|
||||||
|
}
|
||||||
|
ChainBehavior::IgnoreParent(None) => {
|
||||||
|
// TODO: Make this a custom error
|
||||||
|
not(take(0usize))(i)?;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
ContextElement::PreviousElementNode(_) => todo!(),
|
ContextElement::PreviousElementNode(_) => todo!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
current_node = ¤t_node.without_front();
|
current_node = current_node.without_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make this a custom error
|
// TODO: Make this a custom error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user