From 15dedc8ee9ba21804cf88710a9590aad8f5515f9 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 27 Nov 2022 00:12:33 -0500 Subject: [PATCH] Add with_additional_fail_matcher. --- src/parser/new_context.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/parser/new_context.rs b/src/parser/new_context.rs index 882310c8..18981009 100644 --- a/src/parser/new_context.rs +++ b/src/parser/new_context.rs @@ -46,11 +46,11 @@ pub trait ContextElement { fn get_fail_matcher<'r>(&'r self) -> ChainBehavior<'r>; } -struct FailMatcherNode<'r> { +pub struct FailMatcherNode<'r> { fail_matcher: ChainBehavior<'r>, } -struct PreviousElementNode<'r> { +pub struct PreviousElementNode<'r> { dummy: &'r str, } @@ -101,6 +101,15 @@ where head: Some(new_node), } } + + pub fn with_additional_fail_matcher( + &'r self, + fail_matcher: &'r Matcher, + ) -> ContextTree<'r, FailMatcherNode> { + self.with_additional_node(FailMatcherNode { + fail_matcher: ChainBehavior::AndParent(Some(fail_matcher)) + }) + } } fn test_context() {