Match fail logic implemented.
This commit is contained in:
		
							parent
							
								
									109a013057
								
							
						
					
					
						commit
						f84fa09871
					
				| @ -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!() | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander