Match fail logic implemented.

This commit is contained in:
Tom Alexander 2022-11-24 16:24:49 -05:00
parent 109a013057
commit f84fa09871
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -2,7 +2,11 @@ use std::cell::RefCell;
use std::rc::Rc;
use nom::branch::alt;
use nom::bytes::complete::take;
use nom::combinator::not;
use nom::error::ContextError;
use nom::error::ErrorKind;
use nom::error::ParseError;
use nom::error::VerboseError;
use nom::IResult;
use nom::Parser;
@ -65,20 +69,34 @@ impl<'r> OrgModeContextTree<'r> for OrgModeContext<'r> {
fn match_fail<'s>(&'r self, i: &'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>> {
let mut current_node = self.head.as_ref();
while current_node.is_some() {
let current_node_unwrapped = current_node.as_ref().expect("while loop asserts current_node is some.");
let current_node_unwrapped = current_node
.as_ref()
.expect("while loop asserts current_node is some.");
match current_node_unwrapped.elem.fail_matcher {
ChainBehavior::AndParent(Some(matcher)) => {
let local_result = matcher(i);
if local_result.is_ok() {
return local_result;
}
},
ChainBehavior::AndParent(None) => {},
ChainBehavior::IgnoreParent(Some(matcher)) => todo!(),
ChainBehavior::IgnoreParent(None) => todo!(),
}
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)?;
}
};
current_node = current_node.map(|current_head| current_head.next).flatten();
}
todo!()
// TODO: Make this a custom error
not(take(0usize))(i)?;
unreachable!()
}
}