From df79cbd0b73230b83b116f7fe7ccf71ed61bbcb6 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 3 Sep 2023 15:44:18 -0400 Subject: [PATCH] Give global options their own lifetime. --- Cargo.toml | 2 +- build.rs | 2 +- src/context/mod.rs | 8 ++- src/context/parser_context.rs | 22 +++---- src/main.rs | 14 ++--- src/parser/angle_link.rs | 12 ++-- src/parser/citation.rs | 26 ++++---- src/parser/citation_reference.rs | 24 ++++---- src/parser/clock.rs | 12 ++-- src/parser/comment.rs | 8 +-- src/parser/diary_sexp.rs | 4 +- src/parser/document.rs | 43 ++++++------- src/parser/drawer.rs | 8 +-- src/parser/dynamic_block.rs | 8 +-- src/parser/element_parser.rs | 17 +++--- src/parser/entity.rs | 8 +-- src/parser/export_snippet.rs | 16 ++--- src/parser/fixed_width_area.rs | 8 +-- src/parser/footnote_definition.rs | 8 +-- src/parser/footnote_reference.rs | 20 +++---- src/parser/greater_block.rs | 8 +-- src/parser/horizontal_rule.rs | 4 +- src/parser/inline_babel_call.rs | 28 ++++----- src/parser/inline_source_block.rs | 28 ++++----- src/parser/keyword.rs | 8 +-- src/parser/latex_environment.rs | 14 ++--- src/parser/latex_fragment.rs | 52 ++++++++-------- src/parser/lesser_block.rs | 32 +++++----- src/parser/line_break.rs | 9 ++- src/parser/object_parser.rs | 20 +++---- src/parser/org_macro.rs | 16 ++--- src/parser/paragraph.rs | 8 +-- src/parser/plain_link.rs | 26 ++++---- src/parser/plain_list.rs | 48 +++++++-------- src/parser/plain_text.rs | 12 ++-- src/parser/planning.rs | 4 +- src/parser/property_drawer.rs | 20 +++---- src/parser/radio_link.rs | 20 +++---- src/parser/regular_link.rs | 24 ++++---- src/parser/statistics_cookie.rs | 12 ++-- src/parser/subscript_and_superscript.rs | 47 ++++++++------- src/parser/table.rs | 28 ++++----- src/parser/target.rs | 8 +-- src/parser/text_markup.rs | 76 ++++++++++++----------- src/parser/timestamp.rs | 80 ++++++++++++------------- src/parser/util.rs | 29 +++++---- src/types/mod.rs | 2 +- tests/test_template | 3 +- 48 files changed, 470 insertions(+), 466 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aa83298..638017e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-fil walkdir = "2.3.3" [features] -default = ["compare"] +default = [] compare = [] tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"] diff --git a/build.rs b/build.rs index d76733e..d920305 100644 --- a/build.rs +++ b/build.rs @@ -72,7 +72,7 @@ fn write_header(test_file: &mut File) { r#" #[feature(exit_status_error)] use organic::compare_document; -use organic::parser::document; +use organic::parser::parse; use organic::emacs_parse_anonymous_org_document; use organic::parser::sexp::sexp_with_padding; diff --git a/src/context/mod.rs b/src/context/mod.rs index 9d9c362..32e04f0 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -7,9 +7,11 @@ mod list; mod parser_context; mod parser_with_context; -pub type RefContext<'b, 'r, 's> = &'b Context<'r, 's>; -pub trait ContextMatcher = - for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res, OrgSource<'s>>; +pub type RefContext<'b, 'g, 'r, 's> = &'b Context<'g, 'r, 's>; +pub trait ContextMatcher = for<'b, 'g, 'r, 's> Fn( + RefContext<'b, 'g, 'r, 's>, + OrgSource<'s>, +) -> Res, OrgSource<'s>>; pub type DynContextMatcher<'c> = dyn ContextMatcher + 'c; pub trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res, OrgSource<'s>>; #[allow(dead_code)] diff --git a/src/context/parser_context.rs b/src/context/parser_context.rs index e5cc87b..34623b4 100644 --- a/src/context/parser_context.rs +++ b/src/context/parser_context.rs @@ -134,14 +134,14 @@ impl<'r> std::fmt::Debug for ExitMatcherNode<'r> { } #[derive(Debug)] -pub struct Context<'r, 's> { - global_settings: &'s GlobalSettings<'s>, +pub struct Context<'g, 'r, 's> { + global_settings: &'g GlobalSettings<'g>, tree: List<'r, &'r ContextElement<'r, 's>>, } -impl<'r, 's> Context<'r, 's> { +impl<'g, 'r, 's> Context<'g, 'r, 's> { pub fn new( - global_settings: &'s GlobalSettings<'s>, + global_settings: &'g GlobalSettings<'g>, tree: List<'r, &'r ContextElement<'r, 's>>, ) -> Self { Self { @@ -159,7 +159,7 @@ impl<'r, 's> Context<'r, 's> { self.tree.iter() } - pub fn iter_context(&'r self) -> Iter<'r, 's> { + pub fn iter_context(&'r self) -> Iter<'g, 'r, 's> { Iter { next: self.tree.iter_list(), global_settings: self.global_settings, @@ -225,20 +225,20 @@ impl<'r, 's> Context<'r, 's> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn document_end<'b, 'r, 's>( - _context: RefContext<'b, 'r, 's>, +fn document_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { eof(input) } -pub struct Iter<'r, 's> { - global_settings: &'s GlobalSettings<'s>, +pub struct Iter<'g, 'r, 's> { + global_settings: &'g GlobalSettings<'g>, next: super::list::IterList<'r, &'r ContextElement<'r, 's>>, } -impl<'r, 's> Iterator for Iter<'r, 's> { - type Item = Context<'r, 's>; +impl<'g, 'r, 's> Iterator for Iter<'g, 'r, 's> { + type Item = Context<'g, 'r, 's>; fn next(&mut self) -> Option { let next_tree = self.next.next(); diff --git a/src/main.rs b/src/main.rs index 1eff473..edb1544 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,7 @@ fn run_anonymous_parse>(org_contents: P) -> Result<(), Box>(org_contents: P) -> Result<(), Box>(org_contents: P) -> Result<(), Box>(org_path: P) -> Result<(), Box>(org_path: P) -> Result<(), Box>(org_path: P) -> Result<(), Box( - context: RefContext<'_, 'r, 's>, +pub fn angle_link<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, AngleLink<'s>> { let (remaining, _) = tag("<")(input)?; @@ -41,8 +41,8 @@ pub fn angle_link<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn path_angle<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn path_angle<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -58,8 +58,8 @@ fn path_angle<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn path_angle_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn path_angle_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { tag(">")(input) diff --git a/src/parser/citation.rs b/src/parser/citation.rs index 1b9f65c..d1ebdb2 100644 --- a/src/parser/citation.rs +++ b/src/parser/citation.rs @@ -31,8 +31,8 @@ use crate::types::Citation; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn citation<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn citation<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Citation<'s>> { // TODO: Despite being a standard object, citations cannot exist inside the global prefix/suffix for other citations because citations must contain something that matches @key which is forbidden inside the global prefix/suffix. This TODO is to evaluate if its worth putting in an explicit check for this (which can be easily accomplished by checking the output of `get_bracket_depth()`). I suspect its not worth it because I expect, outside of intentionally crafted inputs, this parser will exit immediately inside a citation since it is unlikely to find the "[cite" substring inside a citation global prefix/suffix. @@ -61,7 +61,7 @@ pub fn citation<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn citestyle<'r, 's>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { +fn citestyle<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { let (remaining, _) = tuple((tag("/"), style))(input)?; let (remaining, _) = opt(tuple((tag("/"), variant)))(remaining)?; let source = get_consumed(input, remaining); @@ -69,22 +69,22 @@ fn citestyle<'r, 's>(input: OrgSource<'s>) -> Res, OrgSource<'s>> } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn style<'r, 's>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { +fn style<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { recognize(many1(verify(anychar, |c| { c.is_alphanumeric() || "_-".contains(*c) })))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn variant<'r, 's>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { +fn variant<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { recognize(many1(verify(anychar, |c| { c.is_alphanumeric() || "_-/".contains(*c) })))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn global_prefix<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn global_prefix<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { let exit_with_depth = global_prefix_end(input.get_bracket_depth()); @@ -109,8 +109,8 @@ fn global_prefix_end(starting_bracket_depth: BracketDepth) -> impl ContextMatche } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _global_prefix_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn _global_prefix_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_bracket_depth: BracketDepth, ) -> Res, OrgSource<'s>> { @@ -132,8 +132,8 @@ fn _global_prefix_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn global_suffix<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn global_suffix<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { let exit_with_depth = global_suffix_end(input.get_bracket_depth()); @@ -157,8 +157,8 @@ fn global_suffix_end(starting_bracket_depth: BracketDepth) -> impl ContextMatche } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _global_suffix_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn _global_suffix_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_bracket_depth: BracketDepth, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/citation_reference.rs b/src/parser/citation_reference.rs index 3a55adf..50697e2 100644 --- a/src/parser/citation_reference.rs +++ b/src/parser/citation_reference.rs @@ -29,8 +29,8 @@ use crate::types::CitationReference; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn citation_reference<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn citation_reference<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, CitationReference<'s>> { let (remaining, _prefix) = @@ -49,8 +49,8 @@ pub fn citation_reference<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn citation_reference_key<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn citation_reference_key<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, source) = recognize(tuple(( @@ -69,8 +69,8 @@ pub fn citation_reference_key<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn key_prefix<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn key_prefix<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { let exit_with_depth = key_prefix_end(input.get_bracket_depth()); @@ -90,8 +90,8 @@ fn key_prefix<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn key_suffix<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn key_suffix<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { let exit_with_depth = key_suffix_end(input.get_bracket_depth()); @@ -115,8 +115,8 @@ fn key_prefix_end(starting_bracket_depth: BracketDepth) -> impl ContextMatcher { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _key_prefix_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn _key_prefix_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_bracket_depth: BracketDepth, ) -> Res, OrgSource<'s>> { @@ -142,8 +142,8 @@ fn key_suffix_end(starting_bracket_depth: BracketDepth) -> impl ContextMatcher { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _key_suffix_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn _key_suffix_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_bracket_depth: BracketDepth, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/clock.rs b/src/parser/clock.rs index e527877..7f13d25 100644 --- a/src/parser/clock.rs +++ b/src/parser/clock.rs @@ -20,8 +20,8 @@ use crate::parser::util::start_of_line; use crate::types::Clock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn clock<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn clock<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Clock<'s>> { start_of_line(input)?; @@ -44,8 +44,8 @@ pub fn clock<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn inactive_timestamp_range_duration<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn inactive_timestamp_range_duration<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(tuple(( @@ -66,8 +66,8 @@ fn inactive_timestamp_range_duration<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn inactive_timestamp<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn inactive_timestamp<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(tuple(( diff --git a/src/parser/comment.rs b/src/parser/comment.rs index 74c3639..a6d539c 100644 --- a/src/parser/comment.rs +++ b/src/parser/comment.rs @@ -25,8 +25,8 @@ use crate::parser::util::start_of_line; use crate::types::Comment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn comment<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn comment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Comment<'s>> { if immediate_in_section(context, "comment") { @@ -52,8 +52,8 @@ pub fn comment<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn comment_line<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn comment_line<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { start_of_line(input)?; diff --git a/src/parser/diary_sexp.rs b/src/parser/diary_sexp.rs index 862a0b8..abadd4d 100644 --- a/src/parser/diary_sexp.rs +++ b/src/parser/diary_sexp.rs @@ -18,8 +18,8 @@ use crate::parser::util::start_of_line; use crate::types::DiarySexp; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn diary_sexp<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn diary_sexp<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, DiarySexp<'s>> { start_of_line(input)?; diff --git a/src/parser/document.rs b/src/parser/document.rs index f509414..3b467a2 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -4,6 +4,7 @@ use nom::character::complete::anychar; use nom::character::complete::line_ending; use nom::character::complete::space0; use nom::character::complete::space1; +use nom::combinator::all_consuming; use nom::combinator::eof; use nom::combinator::map; use nom::combinator::not; @@ -53,16 +54,16 @@ pub fn parse<'s>(input: &'s str) -> Result, String> { let initial_context = ContextElement::document_context(); let initial_context = Context::new(&global_settings, List::new(&initial_context)); let wrapped_input = OrgSource::new(input); - let ret = document(&initial_context, wrapped_input) + let ret = all_consuming(parser_with_context!(document)(&initial_context))(wrapped_input) .map_err(|err| err.to_string()) - .map(|(remaining, parsed_document)| parsed_document); + .map(|(_remaining, parsed_document)| parsed_document); ret } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[allow(dead_code)] -pub fn document<'b, 'r, 's>( - context: RefContext<'b, 'r, 's>, +pub fn document<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Document<'s>> { let (remaining, document) = @@ -93,8 +94,8 @@ pub fn document<'b, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _document<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn _document<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Document<'s>> { let zeroth_section_matcher = parser_with_context!(zeroth_section)(context); @@ -114,8 +115,8 @@ fn _document<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn zeroth_section<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn zeroth_section<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Section<'s>> { // TODO: The zeroth section is specialized so it probably needs its own parser @@ -173,8 +174,8 @@ fn zeroth_section<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn section<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn section<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, mut input: OrgSource<'s>, ) -> Res, Section<'s>> { // TODO: The zeroth section is specialized so it probably needs its own parser @@ -227,8 +228,8 @@ fn section<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn section_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn section_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(detect_headline)(input) @@ -236,14 +237,16 @@ fn section_end<'r, 's>( const fn heading( parent_stars: usize, -) -> impl for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res, Heading<'s>> -{ +) -> impl for<'b, 'g, 'r, 's> Fn( + RefContext<'b, 'g, 'r, 's>, + OrgSource<'s>, +) -> Res, Heading<'s>> { move |context, input: OrgSource<'_>| _heading(context, input, parent_stars) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _heading<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn _heading<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, parent_stars: usize, ) -> Res, Heading<'s>> { @@ -289,8 +292,8 @@ fn detect_headline<'s>(input: OrgSource<'s>) -> Res, ()> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn headline<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn headline<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, parent_stars: usize, ) -> Res< @@ -344,8 +347,8 @@ fn headline<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn headline_title_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn headline_title_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(tuple(( diff --git a/src/parser/drawer.rs b/src/parser/drawer.rs index 0d1b140..1cdabe2 100644 --- a/src/parser/drawer.rs +++ b/src/parser/drawer.rs @@ -32,8 +32,8 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn drawer<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn drawer<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Drawer<'s>> { if immediate_in_section(context, "drawer") { @@ -102,8 +102,8 @@ fn name<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn drawer_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn drawer_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { start_of_line(input)?; diff --git a/src/parser/dynamic_block.rs b/src/parser/dynamic_block.rs index 504609d..083b26c 100644 --- a/src/parser/dynamic_block.rs +++ b/src/parser/dynamic_block.rs @@ -32,8 +32,8 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn dynamic_block<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn dynamic_block<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, DynamicBlock<'s>> { // TODO: Do I need to differentiate between different dynamic block types. @@ -110,8 +110,8 @@ fn parameters<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn dynamic_block_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn dynamic_block_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { start_of_line(input)?; diff --git a/src/parser/element_parser.rs b/src/parser/element_parser.rs index dd5e012..fe20fa1 100644 --- a/src/parser/element_parser.rs +++ b/src/parser/element_parser.rs @@ -36,14 +36,16 @@ use crate::types::SetSource; pub const fn element( can_be_paragraph: bool, -) -> impl for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res, Element<'s>> -{ +) -> impl for<'b, 'g, 'r, 's> Fn( + RefContext<'b, 'g, 'r, 's>, + OrgSource<'s>, +) -> Res, Element<'s>> { move |context, input: OrgSource<'_>| _element(context, input, can_be_paragraph) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _element<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn _element<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, can_be_paragraph: bool, ) -> Res, Element<'s>> { @@ -119,13 +121,14 @@ fn _element<'r, 's>( pub const fn detect_element( can_be_paragraph: bool, -) -> impl for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res, ()> { +) -> impl for<'b, 'g, 'r, 's> Fn(RefContext<'b, 'g, 'r, 's>, OrgSource<'s>) -> Res, ()> +{ move |context, input: OrgSource<'_>| _detect_element(context, input, can_be_paragraph) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _detect_element<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn _detect_element<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, can_be_paragraph: bool, ) -> Res, ()> { diff --git a/src/parser/entity.rs b/src/parser/entity.rs index 0752600..ca8403a 100644 --- a/src/parser/entity.rs +++ b/src/parser/entity.rs @@ -433,8 +433,8 @@ const ORG_ENTITIES: [&'static str; 413] = [ ]; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn entity<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn entity<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Entity<'s>> { let (remaining, _) = tag("\\")(input)?; @@ -454,8 +454,8 @@ pub fn entity<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn name<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn name<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { // TODO: This should be defined by org-entities and optionally org-entities-user diff --git a/src/parser/export_snippet.rs b/src/parser/export_snippet.rs index 23d1251..2b40619 100644 --- a/src/parser/export_snippet.rs +++ b/src/parser/export_snippet.rs @@ -20,8 +20,8 @@ use crate::parser::util::get_consumed; use crate::types::ExportSnippet; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn export_snippet<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn export_snippet<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExportSnippet<'s>> { let (remaining, _) = tag("@@")(input)?; @@ -50,8 +50,8 @@ pub fn export_snippet<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn backend<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn backend<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, backend_name) = @@ -61,8 +61,8 @@ fn backend<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn contents<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn contents<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, source) = recognize(verify( @@ -73,8 +73,8 @@ fn contents<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn export_snippet_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn export_snippet_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { tag("@@")(input) diff --git a/src/parser/fixed_width_area.rs b/src/parser/fixed_width_area.rs index 03a144b..b579ced 100644 --- a/src/parser/fixed_width_area.rs +++ b/src/parser/fixed_width_area.rs @@ -21,8 +21,8 @@ use crate::parser::util::start_of_line; use crate::types::FixedWidthArea; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn fixed_width_area<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn fixed_width_area<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FixedWidthArea<'s>> { let fixed_width_area_line_matcher = parser_with_context!(fixed_width_area_line)(context); @@ -41,8 +41,8 @@ pub fn fixed_width_area<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn fixed_width_area_line<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn fixed_width_area_line<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { start_of_line(input)?; diff --git a/src/parser/footnote_definition.rs b/src/parser/footnote_definition.rs index 767088e..e413d9d 100644 --- a/src/parser/footnote_definition.rs +++ b/src/parser/footnote_definition.rs @@ -30,8 +30,8 @@ use crate::parser::util::start_of_line; use crate::types::FootnoteDefinition; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn footnote_definition<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn footnote_definition<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteDefinition<'s>> { if immediate_in_section(context, "footnote definition") { @@ -80,8 +80,8 @@ pub fn label<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn footnote_definition_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn footnote_definition_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, source) = alt(( diff --git a/src/parser/footnote_reference.rs b/src/parser/footnote_reference.rs index bea3d94..0f3738c 100644 --- a/src/parser/footnote_reference.rs +++ b/src/parser/footnote_reference.rs @@ -23,8 +23,8 @@ use crate::parser::util::get_consumed; use crate::types::FootnoteReference; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn footnote_reference<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn footnote_reference<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteReference<'s>> { alt(( @@ -35,8 +35,8 @@ pub fn footnote_reference<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn anonymous_footnote<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn anonymous_footnote<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteReference<'s>> { let (remaining, _) = tag_no_case("[fn::")(input)?; @@ -69,8 +69,8 @@ fn anonymous_footnote<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn inline_footnote<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn inline_footnote<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteReference<'s>> { let (remaining, _) = tag_no_case("[fn:")(input)?; @@ -105,8 +105,8 @@ fn inline_footnote<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn footnote_reference_only<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn footnote_reference_only<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteReference<'s>> { let (remaining, _) = tag_no_case("[fn:")(input)?; @@ -132,8 +132,8 @@ fn footnote_definition_end(starting_bracket_depth: BracketDepth) -> impl Context } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _footnote_definition_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn _footnote_definition_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_bracket_depth: BracketDepth, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/greater_block.rs b/src/parser/greater_block.rs index 279d90a..8e973de 100644 --- a/src/parser/greater_block.rs +++ b/src/parser/greater_block.rs @@ -33,8 +33,8 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn greater_block<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn greater_block<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, GreaterBlock<'s>> { // TODO: Do I need to differentiate between different greater block types. @@ -131,8 +131,8 @@ fn greater_block_end<'c>(name: &'c str) -> impl ContextMatcher + 'c { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _greater_block_end<'r, 's, 'c>( - _context: RefContext<'_, 'r, 's>, +fn _greater_block_end<'b, 'g, 'r, 's, 'c>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, name: &'c str, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/horizontal_rule.rs b/src/parser/horizontal_rule.rs index fe75084..c4c054a 100644 --- a/src/parser/horizontal_rule.rs +++ b/src/parser/horizontal_rule.rs @@ -15,8 +15,8 @@ use crate::parser::util::start_of_line; use crate::types::HorizontalRule; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn horizontal_rule<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn horizontal_rule<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, HorizontalRule<'s>> { start_of_line(input)?; diff --git a/src/parser/inline_babel_call.rs b/src/parser/inline_babel_call.rs index 74bf9ca..78cc953 100644 --- a/src/parser/inline_babel_call.rs +++ b/src/parser/inline_babel_call.rs @@ -26,8 +26,8 @@ use crate::parser::util::get_consumed; use crate::types::InlineBabelCall; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn inline_babel_call<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn inline_babel_call<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, InlineBabelCall<'s>> { let (remaining, _) = tag_no_case("call_")(input)?; @@ -47,8 +47,8 @@ pub fn inline_babel_call<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn name<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn name<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -64,16 +64,16 @@ fn name<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn name_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn name_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(one_of("[("))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn header<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn header<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _) = tag("[")(input)?; @@ -98,8 +98,8 @@ fn header_end(starting_bracket_depth: BracketDepth) -> impl ContextMatcher { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _header_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn _header_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_bracket_depth: BracketDepth, ) -> Res, OrgSource<'s>> { @@ -118,8 +118,8 @@ fn _header_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn argument<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn argument<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _) = tag("(")(input)?; @@ -144,8 +144,8 @@ fn argument_end(starting_parenthesis_depth: BracketDepth) -> impl ContextMatcher } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _argument_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn _argument_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_parenthesis_depth: BracketDepth, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/inline_source_block.rs b/src/parser/inline_source_block.rs index cd1cad9..4589124 100644 --- a/src/parser/inline_source_block.rs +++ b/src/parser/inline_source_block.rs @@ -28,8 +28,8 @@ use crate::parser::util::get_consumed; use crate::types::InlineSourceBlock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn inline_source_block<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn inline_source_block<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, InlineSourceBlock<'s>> { let (remaining, _) = tag_no_case("src_")(input)?; @@ -48,8 +48,8 @@ pub fn inline_source_block<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn lang<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn lang<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -65,16 +65,16 @@ fn lang<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn lang_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn lang_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(one_of("[{"))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn header<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn header<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _) = tag("[")(input)?; @@ -99,8 +99,8 @@ fn header_end(starting_bracket_depth: BracketDepth) -> impl ContextMatcher { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _header_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn _header_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_bracket_depth: BracketDepth, ) -> Res, OrgSource<'s>> { @@ -119,8 +119,8 @@ fn _header_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn body<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn body<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _) = tag("{")(input)?; @@ -155,8 +155,8 @@ fn body_end(starting_brace_depth: BracketDepth) -> impl ContextMatcher { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _body_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn _body_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_brace_depth: BracketDepth, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/keyword.rs b/src/parser/keyword.rs index d68982b..ee7a22d 100644 --- a/src/parser/keyword.rs +++ b/src/parser/keyword.rs @@ -30,8 +30,8 @@ const ORG_ELEMENT_AFFILIATED_KEYWORDS: [&'static str; 13] = [ const ORG_ELEMENT_DUAL_KEYWORDS: [&'static str; 2] = ["caption", "results"]; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn keyword<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn keyword<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { start_of_line(input)?; @@ -55,8 +55,8 @@ pub fn keyword<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn affiliated_keyword<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn affiliated_keyword<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { start_of_line(input)?; diff --git a/src/parser/latex_environment.rs b/src/parser/latex_environment.rs index 78299b0..a5d379a 100644 --- a/src/parser/latex_environment.rs +++ b/src/parser/latex_environment.rs @@ -25,8 +25,8 @@ use crate::parser::util::start_of_line; use crate::types::LatexEnvironment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn latex_environment<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn latex_environment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LatexEnvironment<'s>> { start_of_line(input)?; @@ -71,9 +71,9 @@ fn contents(end_matcher: F) -> impl ContextMatcher { feature = "tracing", tracing::instrument(ret, level = "debug", skip(end_matcher)) )] -fn _contents<'b, 'r, 's, F: ContextMatcher>( +fn _contents<'b, 'g, 'r, 's, F: ContextMatcher>( end_matcher: F, - context: RefContext<'b, 'r, 's>, + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, source) = recognize(many_till( @@ -95,10 +95,10 @@ fn latex_environment_end(current_name: &str) -> impl ContextMatcher { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _latex_environment_end<'r, 's, 'x>( - _context: RefContext<'_, 'r, 's>, +fn _latex_environment_end<'b, 'g, 'r, 's, 'c>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, - current_name_lower: &'x str, + current_name_lower: &'c str, ) -> Res, OrgSource<'s>> { start_of_line(input)?; let (remaining, _leading_whitespace) = space0(input)?; diff --git a/src/parser/latex_fragment.rs b/src/parser/latex_fragment.rs index 1da7fbd..7a142d2 100644 --- a/src/parser/latex_fragment.rs +++ b/src/parser/latex_fragment.rs @@ -24,8 +24,8 @@ use crate::parser::util::get_consumed; use crate::types::LatexFragment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn latex_fragment<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn latex_fragment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LatexFragment<'s>> { let (remaining, _) = alt(( @@ -48,8 +48,8 @@ pub fn latex_fragment<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn raw_latex_fragment<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn raw_latex_fragment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _) = tag("\\")(input)?; @@ -61,16 +61,16 @@ fn raw_latex_fragment<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn name<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn name<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { alpha1(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn brackets<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn brackets<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, body) = alt(( @@ -101,8 +101,8 @@ fn brackets<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn escaped_parenthesis_fragment<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn escaped_parenthesis_fragment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _) = tag("\\(")(input)?; @@ -120,8 +120,8 @@ fn escaped_parenthesis_fragment<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn escaped_bracket_fragment<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn escaped_bracket_fragment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _) = tag("\\[")(input)?; @@ -139,8 +139,8 @@ fn escaped_bracket_fragment<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn double_dollar_fragment<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn double_dollar_fragment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { // TODO: The documentation on the dollar sign versions is incomplete. Test to figure out what the real requirements are. For example, can this span more than 3 lines and can this contain a single $ since its terminated by $$? @@ -159,8 +159,8 @@ fn double_dollar_fragment<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn dollar_char_fragment<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn dollar_char_fragment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (_, _) = pre(context, input)?; @@ -174,8 +174,8 @@ fn dollar_char_fragment<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn pre<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn pre<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { let preceding_character = input.get_preceding_character(); @@ -188,8 +188,8 @@ pub fn pre<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn post<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn post<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { // TODO: What about eof? Test to find out. @@ -200,8 +200,8 @@ pub fn post<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn bordered_dollar_fragment<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn bordered_dollar_fragment<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (_, _) = pre(context, input)?; @@ -226,16 +226,16 @@ fn bordered_dollar_fragment<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn open_border<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn open_border<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(verify(none_of(".,;$"), |c| !c.is_whitespace()))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn close_border<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn close_border<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { let preceding_character = input.get_preceding_character(); diff --git a/src/parser/lesser_block.rs b/src/parser/lesser_block.rs index cd5fd94..0caaca0 100644 --- a/src/parser/lesser_block.rs +++ b/src/parser/lesser_block.rs @@ -34,8 +34,8 @@ use crate::types::SrcBlock; use crate::types::VerseBlock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn verse_block<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn verse_block<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, VerseBlock<'s>> { let (remaining, name) = lesser_block_begin("verse")(context, input)?; @@ -89,8 +89,8 @@ pub fn verse_block<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn comment_block<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn comment_block<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, CommentBlock<'s>> { let (remaining, name) = lesser_block_begin("comment")(context, input)?; @@ -129,8 +129,8 @@ pub fn comment_block<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn example_block<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn example_block<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExampleBlock<'s>> { let (remaining, _name) = lesser_block_begin("example")(context, input)?; @@ -169,8 +169,8 @@ pub fn example_block<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn export_block<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn export_block<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExportBlock<'s>> { let (remaining, name) = lesser_block_begin("export")(context, input)?; @@ -210,8 +210,8 @@ pub fn export_block<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn src_block<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn src_block<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, SrcBlock<'s>> { let (remaining, name) = lesser_block_begin("src")(context, input)?; @@ -268,10 +268,10 @@ fn lesser_block_end(current_name: &str) -> impl ContextMatcher { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _lesser_block_end<'r, 's, 'x>( - _context: RefContext<'_, 'r, 's>, +fn _lesser_block_end<'b, 'g, 'r, 's, 'c>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, - current_name_lower: &'x str, + current_name_lower: &'c str, ) -> Res, OrgSource<'s>> { start_of_line(input)?; let (remaining, _leading_whitespace) = space0(input)?; @@ -293,10 +293,10 @@ const fn lesser_block_begin<'c>(current_name: &'c str) -> impl ContextMatcher + } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _lesser_block_begin<'r, 's, 'x>( - _context: RefContext<'_, 'r, 's>, +fn _lesser_block_begin<'b, 'g, 'r, 's, 'c>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, - current_name_lower: &'x str, + current_name_lower: &'c str, ) -> Res, OrgSource<'s>> { start_of_line(input)?; let (remaining, _leading_whitespace) = space0(input)?; diff --git a/src/parser/line_break.rs b/src/parser/line_break.rs index 5ce792b..a0c721a 100644 --- a/src/parser/line_break.rs +++ b/src/parser/line_break.rs @@ -13,8 +13,8 @@ use crate::parser::util::get_consumed; use crate::types::LineBreak; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn line_break<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn line_break<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LineBreak<'s>> { let (remaining, _) = pre(context, input)?; @@ -31,7 +31,10 @@ pub fn line_break<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn pre<'r, 's>(_context: RefContext<'_, 'r, 's>, input: OrgSource<'s>) -> Res, ()> { +fn pre<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, + input: OrgSource<'s>, +) -> Res, ()> { let preceding_character = input.get_preceding_character(); match preceding_character { // If None, we are at the start of the file diff --git a/src/parser/object_parser.rs b/src/parser/object_parser.rs index 1ae5189..e3db553 100644 --- a/src/parser/object_parser.rs +++ b/src/parser/object_parser.rs @@ -29,8 +29,8 @@ use crate::parser::timestamp::timestamp; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn standard_set_object<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn standard_set_object<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { let (remaining, object) = alt(( @@ -87,8 +87,8 @@ pub fn standard_set_object<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn minimal_set_object<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn minimal_set_object<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { let (remaining, object) = alt(( @@ -109,8 +109,8 @@ pub fn minimal_set_object<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn any_object_except_plain_text<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn any_object_except_plain_text<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { let (remaining, object) = alt(( @@ -166,8 +166,8 @@ pub fn any_object_except_plain_text<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn regular_link_description_object_set<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn regular_link_description_object_set<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { // TODO: It can also contain another link, but only when it is a plain or angle link. It can contain square brackets, but not ]] @@ -195,8 +195,8 @@ pub fn regular_link_description_object_set<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn table_cell_set_object<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn table_cell_set_object<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { let (remaining, object) = alt(( diff --git a/src/parser/org_macro.rs b/src/parser/org_macro.rs index b23d246..cf89c3b 100644 --- a/src/parser/org_macro.rs +++ b/src/parser/org_macro.rs @@ -18,8 +18,8 @@ use crate::parser::util::get_consumed; use crate::types::OrgMacro; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_macro<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn org_macro<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgMacro<'s>> { let (remaining, _) = tag("{{{")(input)?; @@ -45,8 +45,8 @@ pub fn org_macro<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn org_macro_name<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn org_macro_name<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _) = verify(anychar, |c| c.is_alphabetic())(input)?; @@ -58,8 +58,8 @@ fn org_macro_name<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn org_macro_args<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn org_macro_args<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { let (remaining, _) = tag("(")(input)?; @@ -71,8 +71,8 @@ fn org_macro_args<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn org_macro_arg<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn org_macro_arg<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let mut remaining = input; diff --git a/src/parser/paragraph.rs b/src/parser/paragraph.rs index 86515d4..2f7345a 100644 --- a/src/parser/paragraph.rs +++ b/src/parser/paragraph.rs @@ -22,8 +22,8 @@ use crate::parser::util::start_of_line; use crate::types::Paragraph; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn paragraph<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn paragraph<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Paragraph<'s>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -53,8 +53,8 @@ pub fn paragraph<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn paragraph_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn paragraph_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let non_paragraph_element_matcher = parser_with_context!(detect_element(false))(context); diff --git a/src/parser/plain_link.rs b/src/parser/plain_link.rs index 2515aff..0c7735a 100644 --- a/src/parser/plain_link.rs +++ b/src/parser/plain_link.rs @@ -52,8 +52,8 @@ const ORG_LINK_PARAMETERS: [&'static str; 23] = [ ]; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn plain_link<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn plain_link<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainLink<'s>> { let (remaining, _) = pre(context, input)?; @@ -73,7 +73,10 @@ pub fn plain_link<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn pre<'r, 's>(_context: RefContext<'_, 'r, 's>, input: OrgSource<'s>) -> Res, ()> { +fn pre<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, + input: OrgSource<'s>, +) -> Res, ()> { let preceding_character = input.get_preceding_character(); match preceding_character { // If None, we are at the start of the file which is fine @@ -90,14 +93,17 @@ fn pre<'r, 's>(_context: RefContext<'_, 'r, 's>, input: OrgSource<'s>) -> Res(_context: RefContext<'_, 'r, 's>, input: OrgSource<'s>) -> Res, ()> { +fn post<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, + input: OrgSource<'s>, +) -> Res, ()> { let (remaining, _) = alt((eof, recognize(none_of(WORD_CONSTITUENT_CHARACTERS))))(input)?; Ok((remaining, ())) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn protocol<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn protocol<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { // TODO: This should be defined by org-link-parameters @@ -117,8 +123,8 @@ pub fn protocol<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn path_plain<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn path_plain<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { // TODO: "optionally containing parenthesis-wrapped non-whitespace non-bracket substrings up to a depth of two. The string must end with either a non-punctation non-whitespace character, a forwards slash, or a parenthesis-wrapped substring" @@ -139,8 +145,8 @@ fn path_plain<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn path_plain_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn path_plain_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(many_till( diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 0b7c37b..f387951 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -22,6 +22,7 @@ use super::org_source::OrgSource; use super::util::non_whitespace_character; use crate::context::parser_with_context; use crate::context::ContextElement; +use crate::context::ContextMatcher; use crate::context::ExitClass; use crate::context::ExitMatcherNode; use crate::context::RefContext; @@ -60,8 +61,8 @@ pub fn detect_plain_list<'s>(input: OrgSource<'s>) -> Res, ()> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn plain_list<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn plain_list<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainList<'s>> { let contexts = [ @@ -134,8 +135,8 @@ pub fn plain_list<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn plain_list_item<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn plain_list_item<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainListItem<'s>> { start_of_line(input)?; @@ -248,8 +249,8 @@ fn counter<'s>(i: OrgSource<'s>) -> Res, OrgSource<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn plain_list_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn plain_list_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(tuple(( @@ -260,10 +261,7 @@ fn plain_list_end<'r, 's>( )))(input) } -const fn plain_list_item_end( - indent_level: usize, -) -> impl for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res, OrgSource<'s>> -{ +const fn plain_list_item_end(indent_level: usize) -> impl ContextMatcher { let line_indented_lte_matcher = line_indented_lte(indent_level); move |context, input: OrgSource<'_>| { _plain_list_item_end(context, input, &line_indented_lte_matcher) @@ -274,13 +272,10 @@ const fn plain_list_item_end( feature = "tracing", tracing::instrument(ret, level = "debug", skip(line_indented_lte_matcher)) )] -fn _plain_list_item_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn _plain_list_item_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, - line_indented_lte_matcher: impl for<'bb, 'rr, 'ss> Fn( - RefContext<'bb, 'rr, 'ss>, - OrgSource<'ss>, - ) -> Res, OrgSource<'ss>>, + line_indented_lte_matcher: impl ContextMatcher, ) -> Res, OrgSource<'s>> { start_of_line(input)?; recognize(tuple(( @@ -289,16 +284,13 @@ fn _plain_list_item_end<'r, 's>( )))(input) } -const fn line_indented_lte( - indent_level: usize, -) -> impl for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res, OrgSource<'s>> -{ +const fn line_indented_lte(indent_level: usize) -> impl ContextMatcher { move |context, input: OrgSource<'_>| _line_indented_lte(context, input, indent_level) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _line_indented_lte<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn _line_indented_lte<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, indent_level: usize, ) -> Res, OrgSource<'s>> { @@ -312,8 +304,8 @@ fn _line_indented_lte<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn item_tag<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn item_tag<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -333,8 +325,8 @@ fn item_tag<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn item_tag_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn item_tag_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(alt(( @@ -345,8 +337,8 @@ fn item_tag_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn item_tag_post_gap<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn item_tag_post_gap<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { verify( diff --git a/src/parser/plain_text.rs b/src/parser/plain_text.rs index aeea58d..1dbc295 100644 --- a/src/parser/plain_text.rs +++ b/src/parser/plain_text.rs @@ -18,8 +18,8 @@ use crate::types::Object; use crate::types::PlainText; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn plain_text<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn plain_text<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainText<'s>> { let (remaining, source) = recognize(verify( @@ -42,8 +42,8 @@ pub fn plain_text<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn plain_text_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn plain_text_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(parser_with_context!(any_object_except_plain_text)(context))(input) @@ -51,9 +51,9 @@ fn plain_text_end<'r, 's>( impl<'x> RematchObject<'x> for PlainText<'x> { #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn rematch_object<'r, 's>( + fn rematch_object<'b, 'g, 'r, 's>( &'x self, - _context: RefContext<'_, 'r, 's>, + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { map(tag(self.source), |s| { diff --git a/src/parser/planning.rs b/src/parser/planning.rs index 5d9a7e4..77e70c1 100644 --- a/src/parser/planning.rs +++ b/src/parser/planning.rs @@ -17,8 +17,8 @@ use crate::parser::util::start_of_line; use crate::types::Planning; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn planning<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn planning<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Planning<'s>> { start_of_line(input)?; diff --git a/src/parser/property_drawer.rs b/src/parser/property_drawer.rs index a0d2ba2..ca0938f 100644 --- a/src/parser/property_drawer.rs +++ b/src/parser/property_drawer.rs @@ -31,8 +31,8 @@ use crate::types::NodeProperty; use crate::types::PropertyDrawer; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn property_drawer<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn property_drawer<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PropertyDrawer<'s>> { if immediate_in_section(context, "property-drawer") { @@ -83,8 +83,8 @@ pub fn property_drawer<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn property_drawer_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn property_drawer_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(tuple(( @@ -97,8 +97,8 @@ fn property_drawer_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn node_property<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn node_property<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, NodeProperty<'s>> { let (remaining, (_start_of_line, _leading_whitespace, _open_colon, _name, _close_colon)) = @@ -140,8 +140,8 @@ fn node_property<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn node_property_name<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn node_property_name<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -165,8 +165,8 @@ fn node_property_name<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn node_property_name_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn node_property_name_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { alt((tag("+:"), tag(":")))(input) diff --git a/src/parser/radio_link.rs b/src/parser/radio_link.rs index 977d8d9..ec1e444 100644 --- a/src/parser/radio_link.rs +++ b/src/parser/radio_link.rs @@ -23,8 +23,8 @@ use crate::types::RadioLink; use crate::types::RadioTarget; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn radio_link<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn radio_link<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RadioLink<'s>> { let radio_targets = context @@ -54,8 +54,8 @@ pub fn radio_link<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn rematch_target<'x, 'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn rematch_target<'x, 'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, target: &'x Vec>, input: OrgSource<'s>, ) -> Res, Vec>> { @@ -85,8 +85,8 @@ pub fn rematch_target<'x, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn radio_target<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn radio_target<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RadioTarget<'s>> { let (remaining, _opening) = tag("<<<")(input)?; @@ -118,17 +118,17 @@ pub fn radio_target<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn radio_target_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn radio_target_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { alt((tag("<"), tag(">"), line_ending))(input) } pub trait RematchObject<'x> { - fn rematch_object<'r, 's>( + fn rematch_object<'b, 'g, 'r, 's>( &'x self, - context: RefContext<'_, 'r, 's>, + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>>; } diff --git a/src/parser/regular_link.rs b/src/parser/regular_link.rs index ce83bea..615e77f 100644 --- a/src/parser/regular_link.rs +++ b/src/parser/regular_link.rs @@ -21,8 +21,8 @@ use crate::types::Object; use crate::types::RegularLink; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn regular_link<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn regular_link<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { alt(( @@ -32,8 +32,8 @@ pub fn regular_link<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn regular_link_without_description<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn regular_link_without_description<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { let (remaining, _opening_bracket) = tag("[[")(input)?; @@ -51,8 +51,8 @@ pub fn regular_link_without_description<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn regular_link_with_description<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn regular_link_with_description<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { let (remaining, _opening_bracket) = tag("[[")(input)?; @@ -72,8 +72,8 @@ pub fn regular_link_with_description<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn pathreg<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn pathreg<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, path) = escaped( @@ -88,8 +88,8 @@ pub fn pathreg<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn description<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn description<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -109,8 +109,8 @@ pub fn description<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn description_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn description_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { tag("]]")(input) diff --git a/src/parser/statistics_cookie.rs b/src/parser/statistics_cookie.rs index f477ff0..22ec3f5 100644 --- a/src/parser/statistics_cookie.rs +++ b/src/parser/statistics_cookie.rs @@ -11,8 +11,8 @@ use crate::error::Res; use crate::types::StatisticsCookie; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn statistics_cookie<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn statistics_cookie<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { alt(( @@ -22,8 +22,8 @@ pub fn statistics_cookie<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn percent_statistics_cookie<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn percent_statistics_cookie<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { let (remaining, source) = @@ -39,8 +39,8 @@ pub fn percent_statistics_cookie<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn fraction_statistics_cookie<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn fraction_statistics_cookie<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { let (remaining, source) = recognize(tuple(( diff --git a/src/parser/subscript_and_superscript.rs b/src/parser/subscript_and_superscript.rs index 3fb3ee3..9ad8906 100644 --- a/src/parser/subscript_and_superscript.rs +++ b/src/parser/subscript_and_superscript.rs @@ -17,6 +17,7 @@ use super::util::exit_matcher_parser; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; use crate::context::parser_with_context; use crate::context::ContextElement; +use crate::context::ContextMatcher; use crate::context::ExitClass; use crate::context::ExitMatcherNode; use crate::context::RefContext; @@ -29,8 +30,8 @@ use crate::types::Subscript; use crate::types::Superscript; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn subscript<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn subscript<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Subscript<'s>> { // We check for the underscore first before checking the pre-character as a minor optimization to avoid walking up the context tree to find the document root unnecessarily. @@ -49,8 +50,8 @@ pub fn subscript<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn superscript<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn superscript<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Superscript<'s>> { // We check for the circumflex first before checking the pre-character as a minor optimization to avoid walking up the context tree to find the document root unnecessarily. @@ -69,7 +70,10 @@ pub fn superscript<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn pre<'r, 's>(_context: RefContext<'_, 'r, 's>, input: OrgSource<'s>) -> Res, ()> { +fn pre<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, + input: OrgSource<'s>, +) -> Res, ()> { let preceding_character = input.get_preceding_character(); match preceding_character { Some(c) if !c.is_whitespace() => {} @@ -89,8 +93,8 @@ enum ScriptBody<'s> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn script_body<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn script_body<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ScriptBody<'s>> { alt(( @@ -107,16 +111,16 @@ fn script_body<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn script_asterisk<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn script_asterisk<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { tag("*")(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn script_alphanum<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn script_alphanum<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _sign) = opt(recognize(one_of("+-")))(input)?; @@ -129,8 +133,8 @@ fn script_alphanum<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn script_alphanum_character<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn script_alphanum_character<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(verify(anychar, |c| { @@ -139,8 +143,8 @@ fn script_alphanum_character<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn end_script_alphanum_character<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn end_script_alphanum_character<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, final_char) = recognize(verify(anychar, |c| c.is_alphanumeric()))(input)?; @@ -151,8 +155,8 @@ fn end_script_alphanum_character<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn script_with_braces<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn script_with_braces<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { let (remaining, _) = tag("{")(input)?; @@ -172,18 +176,15 @@ fn script_with_braces<'r, 's>( Ok((remaining, children)) } -fn script_with_braces_end( - starting_brace_depth: BracketDepth, -) -> impl for<'b, 'r, 's> Fn(RefContext<'b, 'r, 's>, OrgSource<'s>) -> Res, OrgSource<'s>> -{ +fn script_with_braces_end(starting_brace_depth: BracketDepth) -> impl ContextMatcher { move |context, input: OrgSource<'_>| { _script_with_braces_end(context, input, starting_brace_depth) } } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _script_with_braces_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn _script_with_braces_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, starting_brace_depth: BracketDepth, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/table.rs b/src/parser/table.rs index 84692db..2dbe014 100644 --- a/src/parser/table.rs +++ b/src/parser/table.rs @@ -31,8 +31,8 @@ use crate::types::TableRow; /// /// This is not the table.el style. #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn org_mode_table<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Table<'s>> { start_of_line(input)?; @@ -69,8 +69,8 @@ pub fn org_mode_table<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn table_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn table_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { start_of_line(input)?; @@ -78,8 +78,8 @@ fn table_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table_row<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn org_mode_table_row<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { alt(( @@ -89,8 +89,8 @@ pub fn org_mode_table_row<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table_row_rule<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn org_mode_table_row_rule<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { start_of_line(input)?; @@ -106,8 +106,8 @@ pub fn org_mode_table_row_rule<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table_row_regular<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn org_mode_table_row_regular<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { start_of_line(input)?; @@ -126,8 +126,8 @@ pub fn org_mode_table_row_regular<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table_cell<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn org_mode_table_cell<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableCell<'s>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -159,8 +159,8 @@ pub fn org_mode_table_cell<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn org_mode_table_cell_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn org_mode_table_cell_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(tuple((space0, alt((tag("|"), peek(line_ending))))))(input) diff --git a/src/parser/target.rs b/src/parser/target.rs index 8f2627b..b978966 100644 --- a/src/parser/target.rs +++ b/src/parser/target.rs @@ -21,8 +21,8 @@ use crate::parser::util::get_consumed; use crate::types::Target; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn target<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn target<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Target<'s>> { let (remaining, _) = tag("<<")(input)?; @@ -62,8 +62,8 @@ pub fn target<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn target_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn target_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(one_of("<>\n"))(input) diff --git a/src/parser/text_markup.rs b/src/parser/text_markup.rs index 3b976ef..f339fdd 100644 --- a/src/parser/text_markup.rs +++ b/src/parser/text_markup.rs @@ -21,6 +21,7 @@ use super::radio_link::RematchObject; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; use crate::context::parser_with_context; use crate::context::ContextElement; +use crate::context::ContextMatcher; use crate::context::ExitClass; use crate::context::ExitMatcherNode; use crate::context::RefContext; @@ -40,8 +41,8 @@ use crate::types::Underline; use crate::types::Verbatim; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn text_markup<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn text_markup<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { alt(( @@ -58,8 +59,8 @@ pub fn text_markup<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn bold<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn bold<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Bold<'s>> { let text_markup_object_specialized = text_markup_object("*"); @@ -75,8 +76,8 @@ pub fn bold<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn italic<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn italic<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Italic<'s>> { let text_markup_object_specialized = text_markup_object("/"); @@ -92,8 +93,8 @@ pub fn italic<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn underline<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn underline<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Underline<'s>> { let text_markup_object_specialized = text_markup_object("_"); @@ -109,8 +110,8 @@ pub fn underline<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn strike_through<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn strike_through<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StrikeThrough<'s>> { let text_markup_object_specialized = text_markup_object("+"); @@ -126,8 +127,8 @@ pub fn strike_through<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn verbatim<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn verbatim<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Verbatim<'s>> { let text_markup_string_specialized = text_markup_string("="); @@ -143,8 +144,8 @@ pub fn verbatim<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn code<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn code<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Code<'s>> { let text_markup_string_specialized = text_markup_string("~"); @@ -161,8 +162,8 @@ pub fn code<'r, 's>( fn text_markup_object<'c>( marker_symbol: &'c str, -) -> impl for<'b, 'r, 's> Fn( - RefContext<'b, 'r, 's>, +) -> impl for<'b, 'g, 'r, 's> Fn( + RefContext<'b, 'g, 'r, 's>, OrgSource<'s>, ) -> Res, Vec>> + 'c { @@ -171,10 +172,10 @@ fn text_markup_object<'c>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _text_markup_object<'r, 's, 'x>( - context: RefContext<'_, 'r, 's>, +fn _text_markup_object<'b, 'g, 'r, 's, 'c>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, - marker_symbol: &'x str, + marker_symbol: &'c str, ) -> Res, Vec>> { let (remaining, _) = pre(context, input)?; let (remaining, open) = tag(marker_symbol)(remaining)?; @@ -214,8 +215,8 @@ fn _text_markup_object<'r, 's, 'x>( fn text_markup_string<'c>( marker_symbol: &'c str, -) -> impl for<'b, 'r, 's> Fn( - RefContext<'b, 'r, 's>, +) -> impl for<'b, 'g, 'r, 's> Fn( + RefContext<'b, 'g, 'r, 's>, OrgSource<'s>, ) -> Res, OrgSource<'s>> + 'c { @@ -223,10 +224,10 @@ fn text_markup_string<'c>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _text_markup_string<'r, 's, 'x>( - context: RefContext<'_, 'r, 's>, +fn _text_markup_string<'b, 'g, 'r, 's, 'c>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, - marker_symbol: &'x str, + marker_symbol: &'c str, ) -> Res, OrgSource<'s>> { let (remaining, _) = pre(context, input)?; let (remaining, open) = tag(marker_symbol)(remaining)?; @@ -265,8 +266,8 @@ fn _text_markup_string<'r, 's, 'x>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn pre<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn pre<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { let preceding_character = input.get_preceding_character(); @@ -285,26 +286,23 @@ pub fn pre<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn post<'r, 's>( - _context: RefContext<'_, 'r, 's>, +pub fn post<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { let (remaining, _) = alt((recognize(one_of(" \r\n\t-.,;:!?')}[\"")), line_ending))(input)?; Ok((remaining, ())) } -fn text_markup_end<'c>( - marker_symbol: &'c str, -) -> impl for<'r, 's> Fn(RefContext<'_, 'r, 's>, OrgSource<'s>) -> Res, OrgSource<'s>> + 'c -{ +fn text_markup_end<'c>(marker_symbol: &'c str) -> impl ContextMatcher + 'c { move |context, input: OrgSource<'_>| _text_markup_end(context, input, marker_symbol) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _text_markup_end<'r, 's, 'x>( - context: RefContext<'_, 'r, 's>, +fn _text_markup_end<'b, 'g, 'r, 's, 'c>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, - marker_symbol: &'x str, + marker_symbol: &'c str, ) -> Res, OrgSource<'s>> { not(preceded_by_whitespace)(input)?; let (remaining, _marker) = terminated( @@ -317,9 +315,9 @@ fn _text_markup_end<'r, 's, 'x>( impl<'x> RematchObject<'x> for Bold<'x> { #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn rematch_object<'r, 's>( + fn rematch_object<'b, 'g, 'r, 's>( &'x self, - _context: RefContext<'_, 'r, 's>, + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { let (remaining, children) = @@ -336,8 +334,8 @@ impl<'x> RematchObject<'x> for Bold<'x> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn _rematch_text_markup_object<'r, 's, 'x>( - context: RefContext<'_, 'r, 's>, +fn _rematch_text_markup_object<'b, 'g, 'r, 's, 'x>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, marker_symbol: &'static str, original_match_children: &'x Vec>, diff --git a/src/parser/timestamp.rs b/src/parser/timestamp.rs index 19c1b6d..a1fff17 100644 --- a/src/parser/timestamp.rs +++ b/src/parser/timestamp.rs @@ -23,8 +23,8 @@ use crate::parser::util::get_consumed; use crate::types::Timestamp; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn timestamp<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn timestamp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { // TODO: This would be more efficient if we didn't throw away the parse result of the first half of an active/inactive date range timestamp if the parse fails (as in, the first thing active_date_range_timestamp parses is a active_timestamp but then we throw that away if it doesn't turn out to be a full active_date_range_timestamp despite the active_timestamp parse being completely valid). I am going with the simplest/cleanest approach for the first implementation. @@ -41,8 +41,8 @@ pub fn timestamp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn diary_timestamp<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn diary_timestamp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { let (remaining, _) = tag("<%%(")(input)?; @@ -61,8 +61,8 @@ fn diary_timestamp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn sexp<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn sexp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -83,16 +83,16 @@ fn sexp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn sexp_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn sexp_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { alt((tag(")>"), recognize(one_of(">\n"))))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn active_timestamp<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn active_timestamp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { let (remaining, _) = tag("<")(input)?; @@ -125,8 +125,8 @@ fn active_timestamp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn inactive_timestamp<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn inactive_timestamp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { let (remaining, _) = tag("[")(input)?; @@ -159,8 +159,8 @@ fn inactive_timestamp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn active_date_range_timestamp<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn active_date_range_timestamp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { let (remaining, _first_timestamp) = active_timestamp(context, input)?; @@ -181,8 +181,8 @@ fn active_date_range_timestamp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn active_time_range_timestamp<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn active_time_range_timestamp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { let (remaining, _) = tag("<")(input)?; @@ -222,8 +222,8 @@ fn active_time_range_timestamp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn inactive_date_range_timestamp<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn inactive_date_range_timestamp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { let (remaining, _first_timestamp) = inactive_timestamp(context, input)?; @@ -244,8 +244,8 @@ fn inactive_date_range_timestamp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn inactive_time_range_timestamp<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn inactive_time_range_timestamp<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { let (remaining, _) = tag("[")(input)?; @@ -285,8 +285,8 @@ fn inactive_time_range_timestamp<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn date<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn date<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _year) = verify(digit1, |year: &OrgSource<'_>| year.len() == 4)(input)?; @@ -303,8 +303,8 @@ fn date<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn dayname<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn dayname<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -325,8 +325,8 @@ fn dayname<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn dayname_end<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn dayname_end<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(verify(anychar, |c| { @@ -335,8 +335,8 @@ fn dayname_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn time<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn time<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, _hour) = verify(digit1, |hour: &OrgSource<'_>| { @@ -351,8 +351,8 @@ fn time<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn time_rest<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn time_rest<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { let (remaining, body) = recognize(verify( @@ -364,8 +364,8 @@ fn time_rest<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn active_time_rest_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn active_time_rest_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { alt(( @@ -379,8 +379,8 @@ fn active_time_rest_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn inactive_time_rest_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn inactive_time_rest_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { alt(( @@ -394,8 +394,8 @@ fn inactive_time_rest_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn time_range_rest_end<'r, 's>( - context: RefContext<'_, 'r, 's>, +fn time_range_rest_end<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { // We pop off the most recent context element to get a context tree with just the active/inactive_time_rest_end exit matcher (removing this function from the exit matcher chain) because the 2nd time in the range does not end when a "-TIME" pattern is found. @@ -406,8 +406,8 @@ fn time_range_rest_end<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn repeater<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn repeater<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { // + for cumulative type @@ -422,8 +422,8 @@ fn repeater<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn warning_delay<'r, 's>( - _context: RefContext<'_, 'r, 's>, +fn warning_delay<'b, 'g, 'r, 's>( + _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { // - for all type diff --git a/src/parser/util.rs b/src/parser/util.rs index f5cab9b..ba84ae1 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -26,7 +26,10 @@ pub const WORD_CONSTITUENT_CHARACTERS: &str = /// Check if we are below a section of the given section type regardless of depth #[allow(dead_code)] -pub fn in_section<'r, 's, 'x>(context: RefContext<'_, 'r, 's>, section_name: &'x str) -> bool { +pub fn in_section<'b, 'g, 'r, 's, 'x>( + context: RefContext<'b, 'g, 'r, 's>, + section_name: &'x str, +) -> bool { for thing in context.iter() { match thing { ContextElement::Context(name) if *name == section_name => return true, @@ -37,8 +40,8 @@ pub fn in_section<'r, 's, 'x>(context: RefContext<'_, 'r, 's>, section_name: &'x } /// Checks if we are currently an immediate child of the given section type -pub fn immediate_in_section<'r, 's, 'x>( - context: RefContext<'_, 'r, 's>, +pub fn immediate_in_section<'b, 'g, 'r, 's, 'x>( + context: RefContext<'b, 'g, 'r, 's>, section_name: &'x str, ) -> bool { for thing in context.iter() { @@ -72,8 +75,8 @@ pub fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res( - context: RefContext<'_, 'r, 's>, +pub fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { if exit_matcher_parser(context, input).is_err() { @@ -84,8 +87,8 @@ pub fn maybe_consume_object_trailing_whitespace_if_not_exiting<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { if context.should_consume_trailing_whitespace() && exit_matcher_parser(context, input).is_err() @@ -97,8 +100,8 @@ pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn maybe_consume_trailing_whitespace<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { if context.should_consume_trailing_whitespace() { @@ -146,16 +149,16 @@ pub fn non_whitespace_character(input: OrgSource<'_>) -> Res, char /// Check that we are at the start of a line #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn exit_matcher_parser<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn exit_matcher_parser<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { peek(|i| context.check_exit_matcher(i))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn text_until_exit<'r, 's>( - context: RefContext<'_, 'r, 's>, +pub fn text_until_exit<'b, 'g, 'r, 's>( + context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { recognize(verify( diff --git a/src/types/mod.rs b/src/types/mod.rs index 8011bb2..4ab8c17 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -13,11 +13,11 @@ pub use greater_element::Drawer; pub use greater_element::DynamicBlock; pub use greater_element::FootnoteDefinition; pub use greater_element::GreaterBlock; +pub use greater_element::NodeProperty; pub use greater_element::PlainList; pub use greater_element::PlainListItem; pub use greater_element::PropertyDrawer; pub use greater_element::Table; -pub use greater_element::NodeProperty; pub use greater_element::TableRow; pub use lesser_element::Clock; pub use lesser_element::Comment; diff --git a/tests/test_template b/tests/test_template index 2dd2ed4..776ebbe 100644 --- a/tests/test_template +++ b/tests/test_template @@ -6,7 +6,7 @@ fn {name}() {{ let org_sexp = emacs_parse_anonymous_org_document(org_contents.as_str()).expect("Use emacs to parse org file."); println!("{{}}", org_sexp); let (_remaining, parsed_sexp) = sexp_with_padding(org_sexp.as_str()).expect("Sexp Parse failure"); - let (remaining, rust_parsed) = document(org_contents.as_str()).expect("Org Parse failure"); + let rust_parsed = parse(org_contents.as_str()).expect("Org Parse failure"); println!("{{:#?}}", rust_parsed); let diff_result = compare_document(&parsed_sexp, &rust_parsed).expect("Compare parsed documents."); @@ -14,5 +14,4 @@ fn {name}() {{ .print(org_contents.as_str()) .expect("Print document parse tree diff."); assert!(!diff_result.is_bad()); - assert_eq!(remaining, ""); }}