diff --git a/src/context/mod.rs b/src/context/mod.rs index 175f67e..6738246 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -7,9 +7,14 @@ mod list; mod parser_context; mod parser_with_context; -type RefContext<'r, 's> = &'r Context<'r, 's>; +pub type RefContext<'r, 's> = &'r Context<'r, 's>; trait ContextMatcher = for<'r, 's> Fn(RefContext<'r, 's>, OrgSource<'s>) -> Res, OrgSource<'s>>; type DynContextMatcher<'c> = dyn ContextMatcher + 'c; trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res, OrgSource<'s>>; type DynMatcher<'c> = dyn Matcher + 'c; + +pub use exiting::ExitClass; +pub use parser_context::ContextElement; +pub use parser_context::ExitMatcherNode; +pub(crate) use parser_with_context::parser_with_context; diff --git a/src/context/parser_context.rs b/src/context/parser_context.rs index 1dce6e9..99f3b24 100644 --- a/src/context/parser_context.rs +++ b/src/context/parser_context.rs @@ -1,12 +1,11 @@ use nom::combinator::eof; +use super::exiting::ExitClass; use super::list::List; -use super::org_source::OrgSource; use super::DynContextMatcher; -use super::Object; use crate::error::Res; -use crate::parser::exiting::ExitClass; -use crate::parser::list::ListType; +use crate::parser::OrgSource; +use crate::types::Object; // type Matcher = // dyn for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res, OrgSource<'s>>; @@ -173,7 +172,7 @@ impl<'r, 's> Context<'r, 's> { ) } - pub fn push(&self, data: ContextElement<'r, 's>) -> Self { + pub fn with_additional_node(&self, data: ContextElement<'r, 's>) -> Self { let new_tree = self.tree.push(data); Self { global_settings: self.global_settings, @@ -182,18 +181,6 @@ impl<'r, 's> Context<'r, 's> { } } -impl<'r, 's> Default for Context<'r, 's> { - fn default() -> Self { - Context::new( - GlobalSettings::default(), - List::new(ContextElement::ExitMatcherNode(ExitMatcherNode { - exit_matcher: &document_end, - class: ExitClass::Document, - })), - ) - } -} - #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn document_end<'r, 's>( _context: Context<'r, 's>, diff --git a/src/parser/timestamp.rs b/src/parser/timestamp.rs index dd719cb..d924330 100644 --- a/src/parser/timestamp.rs +++ b/src/parser/timestamp.rs @@ -11,11 +11,16 @@ use nom::multi::many_till; use nom::sequence::tuple; use super::org_source::OrgSource; +use super::util::exit_matcher_parser; use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting; -use super::Context; +use crate::context::parser_with_context; +use crate::context::ContextElement; +use crate::context::ExitClass; +use crate::context::ExitMatcherNode; +use crate::context::RefContext; use crate::error::Res; use crate::parser::util::get_consumed; -use crate::parser::Timestamp; +use crate::types::Timestamp; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] pub fn timestamp<'r, 's>(