Only use a local context when checking exit matchers.
This prevents context tree from deeper in the parse impacting exit checks for earlier in the parse. This is needed due to the trailing whitespace context element.
This commit is contained in:
		
							parent
							
								
									9a0172e1a4
								
							
						
					
					
						commit
						137815dbaf
					
				| @ -31,6 +31,12 @@ impl<T> List<T> { | ||||
|         List { head: None } | ||||
|     } | ||||
| 
 | ||||
|     pub fn branch_from(trunk: &Rc<Node<T>>) -> Self { | ||||
|         List { | ||||
|             head: Some(trunk.clone()), | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pub fn push_front(&self, data: T) -> List<T> { | ||||
|         List { | ||||
|             head: Some(Rc::new(Node { | ||||
|  | ||||
| @ -22,6 +22,12 @@ impl<'r, 's> ContextTree<'r, 's> { | ||||
|         ContextTree { tree: List::new() } | ||||
|     } | ||||
| 
 | ||||
|     pub fn branch_from(trunk: &Rc<Node<ContextElement<'r, 's>>>) -> Self { | ||||
|         ContextTree { | ||||
|             tree: List::branch_from(trunk) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     pub fn ptr_eq<'x, 'y>(&self, other: &ContextTree<'x, 'y>) -> bool { | ||||
|         self.tree.ptr_eq(&other.tree) | ||||
|     } | ||||
| @ -76,14 +82,16 @@ impl<'r, 's> ContextTree<'r, 's> { | ||||
|                 ContextElement::ExitMatcherNode(exit_matcher) => { | ||||
|                     match exit_matcher.exit_matcher { | ||||
|                         ChainBehavior::AndParent(Some(matcher)) => { | ||||
|                             let local_result = matcher(self, i); | ||||
|                             let local_context = ContextTree::branch_from(current_node); | ||||
|                             let local_result = matcher(&local_context, i); | ||||
|                             if local_result.is_ok() { | ||||
|                                 return local_result; | ||||
|                             } | ||||
|                         } | ||||
|                         ChainBehavior::AndParent(None) => {} | ||||
|                         ChainBehavior::IgnoreParent(Some(matcher)) => { | ||||
|                             let local_result = matcher(self, i); | ||||
|                             let local_context = ContextTree::branch_from(current_node); | ||||
|                             let local_result = matcher(&local_context, i); | ||||
|                             if local_result.is_ok() { | ||||
|                                 return local_result; | ||||
|                             } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander