From 1d571acc179d634523fb46f57fcbb8f388127c2c Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 15 Oct 2022 14:20:40 -0400 Subject: [PATCH] Add accessors for booleans on what we are allowed to match. --- src/parser/nom_context.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index 52c86d5..3a0ada8 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -26,8 +26,8 @@ pub struct NomContext<'r> { parent: Option<&'r Self>, fail_matcher: ChainBehavior, /// You can't have nested bolds or links in org-mode - can_match_bold: bool, - can_match_link: bool, + match_bold_allowed: bool, + match_link_allowed: bool, } impl<'r> NomContext<'r> { @@ -35,8 +35,8 @@ impl<'r> NomContext<'r> { NomContext { parent: None, fail_matcher: ChainBehavior::IgnoreParent(Some(fail_matcher)), - can_match_bold: true, - can_match_link: true, + match_bold_allowed: true, + match_link_allowed: true, } } @@ -44,14 +44,22 @@ impl<'r> NomContext<'r> { NomContext { parent: Some(&self), fail_matcher: ChainBehavior::AndParent(Some(other)), - can_match_bold: self.can_match_bold, - can_match_link: self.can_match_link, + match_bold_allowed: self.match_bold_allowed, + match_link_allowed: self.match_link_allowed, } } pub fn not_matching_fail<'s>(&self, i: &'s str) -> IResult<&'s str, (), VerboseError<&'s str>> { not(FailChecker::new(self))(i) } + + pub fn can_match_bold(&self) -> bool { + self.match_bold_allowed + } + + pub fn can_match_link(&self) -> bool { + self.match_link_allowed + } } impl<'a, 'b> Parser<&'b str, &'b str, VerboseError<&'b str>> for FailChecker<'a> {