From ceb7788cfa0db46e9c9c89bb85a856c74b3fe9cf Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 23 Mar 2023 20:12:42 -0400 Subject: [PATCH] Check the exit matcher in more places. --- src/parser/document.rs | 5 +++++ src/parser/object.rs | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/parser/document.rs b/src/parser/document.rs index e1feb20f..ebfb4814 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -3,6 +3,7 @@ use nom::bytes::complete::tag; use nom::character::complete::line_ending; use nom::character::complete::space1; use nom::combinator::eof; +use nom::combinator::not; use nom::combinator::recognize; use nom::multi::many1; use nom::multi::many1_count; @@ -63,6 +64,7 @@ impl<'s> Source<'s> for DocumentElement<'s> { } } +#[allow(dead_code)] pub fn document(input: &str) -> Res<&str, Document> { let initial_context: ContextTree<'_, '_> = ContextTree::new(); let document_context = @@ -78,6 +80,7 @@ fn section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Sec exit_matcher: ChainBehavior::AndParent(Some(§ion_end)), })) .with_additional_node(ContextElement::Context("section")); + not(|i| parser_context.check_exit_matcher(i))(input)?; todo!() } @@ -87,6 +90,8 @@ fn section_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, } fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Heading<'s>> { + not(|i| context.check_exit_matcher(i))(input)?; + let (remaining, (star_count, _ws, title, _ws2)) = headline(context, input)?; todo!() } diff --git a/src/parser/object.rs b/src/parser/object.rs index 407e891e..417bb78d 100644 --- a/src/parser/object.rs +++ b/src/parser/object.rs @@ -1,3 +1,5 @@ +use nom::combinator::not; + use super::error::Res; use super::source::Source; use super::Context; @@ -38,5 +40,6 @@ pub fn standard_set_object<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, Object<'s>> { + not(|i| context.check_exit_matcher(i))(input)?; todo!() }