From 7650a9edff280813bd16dea551771bb4497bc76b Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 11 Sep 2023 13:11:08 -0400 Subject: [PATCH 1/5] Remove all pub. --- src/compare/diff.rs | 14 +-- src/compare/mod.rs | 10 +- src/compare/parse.rs | 8 +- src/compare/util.rs | 6 +- src/context/context.rs | 34 +++--- src/context/exiting.rs | 2 +- src/context/file_access_interface.rs | 6 +- src/context/global_settings.rs | 12 +- src/context/list.rs | 18 +-- src/context/mod.rs | 28 ++--- src/context/parser_with_context.rs | 2 +- src/error/error.rs | 6 +- src/error/mod.rs | 6 +- src/init_tracing.rs | 8 +- src/lib.rs | 18 +-- src/parser/angle_link.rs | 2 +- src/parser/citation.rs | 2 +- src/parser/citation_reference.rs | 6 +- src/parser/clock.rs | 2 +- src/parser/comment.rs | 4 +- src/parser/diary_sexp.rs | 4 +- src/parser/document.rs | 8 +- src/parser/drawer.rs | 2 +- src/parser/dynamic_block.rs | 2 +- src/parser/element_parser.rs | 4 +- src/parser/entity.rs | 2 +- src/parser/export_snippet.rs | 2 +- src/parser/fixed_width_area.rs | 4 +- src/parser/footnote_definition.rs | 6 +- src/parser/footnote_reference.rs | 2 +- src/parser/greater_block.rs | 2 +- src/parser/headline.rs | 4 +- src/parser/horizontal_rule.rs | 2 +- src/parser/in_buffer_settings.rs | 4 +- src/parser/inline_babel_call.rs | 2 +- src/parser/inline_source_block.rs | 2 +- src/parser/keyword.rs | 10 +- src/parser/keyword_todo.rs | 2 +- src/parser/latex_environment.rs | 2 +- src/parser/latex_fragment.rs | 10 +- src/parser/lesser_block.rs | 10 +- src/parser/line_break.rs | 2 +- src/parser/mod.rs | 10 +- src/parser/object_parser.rs | 16 +-- src/parser/org_macro.rs | 2 +- src/parser/org_source.rs | 24 ++-- src/parser/paragraph.rs | 2 +- src/parser/plain_link.rs | 4 +- src/parser/plain_list.rs | 6 +- src/parser/plain_text.rs | 2 +- src/parser/planning.rs | 2 +- src/parser/property_drawer.rs | 2 +- src/parser/radio_link.rs | 8 +- src/parser/regular_link.rs | 10 +- src/parser/section.rs | 4 +- src/parser/sexp.rs | 24 ++-- src/parser/statistics_cookie.rs | 6 +- src/parser/subscript_and_superscript.rs | 6 +- src/parser/table.rs | 12 +- src/parser/target.rs | 2 +- src/parser/text_markup.rs | 18 +-- src/parser/timestamp.rs | 2 +- src/parser/token.rs | 8 +- src/parser/util.rs | 36 +++--- src/types/document.rs | 40 +++---- src/types/element.rs | 2 +- src/types/greater_element.rs | 80 ++++++------- src/types/lesser_element.rs | 100 ++++++++-------- src/types/mod.rs | 124 ++++++++++---------- src/types/object.rs | 148 ++++++++++++------------ src/types/source.rs | 4 +- 71 files changed, 493 insertions(+), 493 deletions(-) diff --git a/src/compare/diff.rs b/src/compare/diff.rs index c7289d1..aa9610a 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -69,13 +69,13 @@ use crate::types::Verbatim; use crate::types::VerseBlock; #[derive(Debug)] -pub enum DiffEntry<'s> { + enum DiffEntry<'s> { DiffResult(DiffResult<'s>), DiffLayer(DiffLayer<'s>), } #[derive(Debug)] -pub struct DiffResult<'s> { + struct DiffResult<'s> { status: DiffStatus, name: String, message: Option, @@ -86,13 +86,13 @@ pub struct DiffResult<'s> { } #[derive(Debug, PartialEq)] -pub enum DiffStatus { + enum DiffStatus { Good, Bad, } #[derive(Debug)] -pub struct DiffLayer<'s> { + struct DiffLayer<'s> { name: String, children: Vec>, } @@ -126,11 +126,11 @@ impl<'s> DiffEntry<'s> { } } - pub fn is_bad(&self) -> bool { + fn is_bad(&self) -> bool { self.is_immediately_bad() || self.has_bad_children() } - pub fn print(&self, original_document: &str) -> Result<(), Box> { + fn print(&self, original_document: &str) -> Result<(), Box> { self.print_indented(0, original_document) } @@ -374,7 +374,7 @@ fn compare_object<'s>( } } -pub fn compare_document<'s>( + fn compare_document<'s>( emacs: &'s Token<'s>, rust: &'s Document<'s>, ) -> Result, Box> { diff --git a/src/compare/mod.rs b/src/compare/mod.rs index 094dda5..8f3ebf0 100644 --- a/src/compare/mod.rs +++ b/src/compare/mod.rs @@ -1,8 +1,8 @@ mod diff; mod parse; mod util; -pub use diff::compare_document; -pub use parse::emacs_parse_anonymous_org_document; -pub use parse::emacs_parse_file_org_document; -pub use parse::get_emacs_version; -pub use parse::get_org_mode_version; + use diff::compare_document; + use parse::emacs_parse_anonymous_org_document; + use parse::emacs_parse_file_org_document; + use parse::get_emacs_version; + use parse::get_org_mode_version; diff --git a/src/compare/parse.rs b/src/compare/parse.rs index 700b5b1..e8a5f5e 100644 --- a/src/compare/parse.rs +++ b/src/compare/parse.rs @@ -1,7 +1,7 @@ use std::path::Path; use std::process::Command; -pub fn emacs_parse_anonymous_org_document( + fn emacs_parse_anonymous_org_document( file_contents: C, ) -> Result> where @@ -31,7 +31,7 @@ where Ok(String::from_utf8(org_sexp)?) } -pub fn emacs_parse_file_org_document

(file_path: P) -> Result> + fn emacs_parse_file_org_document

(file_path: P) -> Result> where P: AsRef, { @@ -85,7 +85,7 @@ where output } -pub fn get_emacs_version() -> Result> { + fn get_emacs_version() -> Result> { let elisp_script = r#"(progn (message "%s" (version)) )"#; @@ -103,7 +103,7 @@ pub fn get_emacs_version() -> Result> { Ok(String::from_utf8(out.stderr)?) } -pub fn get_org_mode_version() -> Result> { + fn get_org_mode_version() -> Result> { let elisp_script = r#"(progn (org-mode) (message "%s" (org-version nil t nil)) diff --git a/src/compare/util.rs b/src/compare/util.rs index 173ecd0..f9a75f9 100644 --- a/src/compare/util.rs +++ b/src/compare/util.rs @@ -21,7 +21,7 @@ fn get_offsets<'s, S: Source<'s>>(source: &'s str, rust_object: &'s S) -> (usize (offset, end) } -pub fn assert_name<'s>(emacs: &'s Token<'s>, name: &str) -> Result<(), Box> { + fn assert_name<'s>(emacs: &'s Token<'s>, name: &str) -> Result<(), Box> { let children = emacs.as_list()?; let first_child = children .first() @@ -37,7 +37,7 @@ pub fn assert_name<'s>(emacs: &'s Token<'s>, name: &str) -> Result<(), Box>( + fn assert_bounds<'s, S: Source<'s>>( source: &'s str, emacs: &'s Token<'s>, rust: &'s S, @@ -146,7 +146,7 @@ fn maybe_token_to_usize( /// Returns Ok(None) if value is nil. /// /// Returns error if the attribute is not specified on the token at all. -pub fn get_property<'s, 'x>( + fn get_property<'s, 'x>( emacs: &'s Token<'s>, key: &'x str, ) -> Result>, Box> { diff --git a/src/context/context.rs b/src/context/context.rs index 0baa2e8..75a9e9f 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -14,7 +14,7 @@ use crate::error::Res; use crate::parser::OrgSource; #[derive(Debug)] -pub enum ContextElement<'r, 's> { + enum ContextElement<'r, 's> { /// Stores a parser that indicates that children should exit upon matching an exit matcher. ExitMatcherNode(ExitMatcherNode<'r>), @@ -31,10 +31,10 @@ pub enum ContextElement<'r, 's> { Placeholder(PhantomData<&'s str>), } -pub struct ExitMatcherNode<'r> { + struct ExitMatcherNode<'r> { // TODO: Should this be "&'r DynContextMatcher<'c>" ? - pub exit_matcher: &'r DynContextMatcher<'r>, - pub class: ExitClass, + exit_matcher: &'r DynContextMatcher<'r>, + class: ExitClass, } impl<'r> std::fmt::Debug for ExitMatcherNode<'r> { @@ -46,13 +46,13 @@ impl<'r> std::fmt::Debug for ExitMatcherNode<'r> { } #[derive(Debug)] -pub struct Context<'g, 'r, 's> { + struct Context<'g, 'r, 's> { global_settings: &'g GlobalSettings<'g, 's>, tree: List<'r, &'r ContextElement<'r, 's>>, } impl<'g, 'r, 's> Context<'g, 'r, 's> { - pub fn new( + fn new( global_settings: &'g GlobalSettings<'g, 's>, tree: List<'r, &'r ContextElement<'r, 's>>, ) -> Self { @@ -62,38 +62,38 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { } } - pub fn with_additional_node(&'r self, new_element: &'r ContextElement<'r, 's>) -> Self { + fn with_additional_node(&'r self, new_element: &'r ContextElement<'r, 's>) -> Self { let new_tree = self.tree.push(new_element); Self::new(self.global_settings, new_tree) } - pub fn iter(&'r self) -> super::list::Iter<'r, &'r ContextElement<'r, 's>> { + fn iter(&'r self) -> super::list::Iter<'r, &'r ContextElement<'r, 's>> { self.tree.iter() } - pub fn iter_context(&'r self) -> Iter<'g, 'r, 's> { + fn iter_context(&'r self) -> Iter<'g, 'r, 's> { Iter { next: self.tree.iter_list(), global_settings: self.global_settings, } } - pub fn get_parent(&'r self) -> Option { + fn get_parent(&'r self) -> Option { self.tree.get_parent().map(|parent_tree| Self { global_settings: self.global_settings, tree: parent_tree.clone(), }) } - pub fn get_data(&self) -> &ContextElement<'r, 's> { + fn get_data(&self) -> &ContextElement<'r, 's> { self.tree.get_data() } - pub fn get_global_settings(&self) -> &'g GlobalSettings<'g, 's> { + fn get_global_settings(&self) -> &'g GlobalSettings<'g, 's> { self.global_settings } - pub fn with_global_settings<'gg>( + fn with_global_settings<'gg>( &self, new_settings: &'gg GlobalSettings<'gg, 's>, ) -> Context<'gg, 'r, 's> { @@ -104,7 +104,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - pub fn check_exit_matcher( + fn check_exit_matcher( &'r self, i: OrgSource<'s>, ) -> IResult, OrgSource<'s>, CustomError>> { @@ -133,7 +133,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { /// Indicates if elements should consume the whitespace after them. /// /// Defaults to true. - pub fn should_consume_trailing_whitespace(&self) -> bool { + fn should_consume_trailing_whitespace(&self) -> bool { self._should_consume_trailing_whitespace().unwrap_or(true) } @@ -158,7 +158,7 @@ fn document_end<'b, 'g, 'r, 's>( eof(input) } -pub struct Iter<'g, 'r, 's> { + struct Iter<'g, 'r, 's> { global_settings: &'g GlobalSettings<'g, 's>, next: super::list::IterList<'r, &'r ContextElement<'r, 's>>, } @@ -175,7 +175,7 @@ impl<'g, 'r, 's> Iterator for Iter<'g, 'r, 's> { } impl<'r, 's> ContextElement<'r, 's> { - pub fn document_context() -> Self { + fn document_context() -> Self { Self::ExitMatcherNode(ExitMatcherNode { exit_matcher: &document_end, class: ExitClass::Document, diff --git a/src/context/exiting.rs b/src/context/exiting.rs index 44585c9..f1b37a0 100644 --- a/src/context/exiting.rs +++ b/src/context/exiting.rs @@ -1,5 +1,5 @@ #[derive(Debug, Copy, Clone)] -pub enum ExitClass { + enum ExitClass { Document = 1, Alpha = 2, Beta = 3, diff --git a/src/context/file_access_interface.rs b/src/context/file_access_interface.rs index d54c7cf..85e7d51 100644 --- a/src/context/file_access_interface.rs +++ b/src/context/file_access_interface.rs @@ -1,13 +1,13 @@ use std::fmt::Debug; use std::path::PathBuf; -pub trait FileAccessInterface: Debug { + trait FileAccessInterface: Debug { fn read_file(&self, path: &str) -> Result; } #[derive(Debug, Clone)] -pub struct LocalFileAccessInterface { - pub working_directory: Option, + struct LocalFileAccessInterface { + working_directory: Option, } impl FileAccessInterface for LocalFileAccessInterface { diff --git a/src/context/global_settings.rs b/src/context/global_settings.rs index 4231d42..76acd58 100644 --- a/src/context/global_settings.rs +++ b/src/context/global_settings.rs @@ -7,15 +7,15 @@ use crate::types::Object; // TODO: Ultimately, I think we'll need most of this: https://orgmode.org/manual/In_002dbuffer-Settings.html #[derive(Debug, Clone)] -pub struct GlobalSettings<'g, 's> { - pub radio_targets: Vec<&'g Vec>>, - pub file_access: &'g dyn FileAccessInterface, - pub in_progress_todo_keywords: BTreeSet, - pub complete_todo_keywords: BTreeSet, + struct GlobalSettings<'g, 's> { + radio_targets: Vec<&'g Vec>>, + file_access: &'g dyn FileAccessInterface, + in_progress_todo_keywords: BTreeSet, + complete_todo_keywords: BTreeSet, } impl<'g, 's> GlobalSettings<'g, 's> { - pub fn new() -> GlobalSettings<'g, 's> { + fn new() -> GlobalSettings<'g, 's> { GlobalSettings { radio_targets: Vec::new(), file_access: &LocalFileAccessInterface { diff --git a/src/context/list.rs b/src/context/list.rs index 98ee212..0033883 100644 --- a/src/context/list.rs +++ b/src/context/list.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; #[derive(Debug, Clone)] -pub struct List<'parent, T> { + struct List<'parent, T> { data: T, parent: Link<'parent, T>, } @@ -9,30 +9,30 @@ pub struct List<'parent, T> { type Link<'parent, T> = Option<&'parent List<'parent, T>>; impl<'parent, T> List<'parent, T> { - pub fn new(first_item: T) -> Self { + fn new(first_item: T) -> Self { Self { data: first_item, parent: None, } } - pub fn get_data(&self) -> &T { + fn get_data(&self) -> &T { &self.data } - pub fn get_parent(&'parent self) -> Link<'parent, T> { + fn get_parent(&'parent self) -> Link<'parent, T> { self.parent } - pub fn iter(&self) -> Iter<'_, T> { + fn iter(&self) -> Iter<'_, T> { Iter { next: Some(self) } } - pub fn iter_list(&self) -> IterList<'_, T> { + fn iter_list(&self) -> IterList<'_, T> { IterList { next: Some(self) } } - pub fn push(&'parent self, item: T) -> Self { + fn push(&'parent self, item: T) -> Self { Self { data: item, parent: Some(self), @@ -40,7 +40,7 @@ impl<'parent, T> List<'parent, T> { } } -pub struct Iter<'a, T> { + struct Iter<'a, T> { next: Link<'a, T>, } @@ -54,7 +54,7 @@ impl<'a, T> Iterator for Iter<'a, T> { } } -pub struct IterList<'a, T> { + struct IterList<'a, T> { next: Link<'a, T>, } diff --git a/src/context/mod.rs b/src/context/mod.rs index 42f63fd..bc1368a 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -8,22 +8,22 @@ mod global_settings; mod list; mod parser_with_context; -pub type RefContext<'b, 'g, 'r, 's> = &'b Context<'g, 'r, 's>; -pub trait ContextMatcher = for<'b, 'g, 'r, 's> Fn( + type RefContext<'b, 'g, 'r, 's> = &'b Context<'g, 'r, 's>; + 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>>; + type DynContextMatcher<'c> = dyn ContextMatcher + 'c; + trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res, OrgSource<'s>>; #[allow(dead_code)] -pub type DynMatcher<'c> = dyn Matcher + 'c; + type DynMatcher<'c> = dyn Matcher + 'c; -pub use context::Context; -pub use context::ContextElement; -pub use context::ExitMatcherNode; -pub use exiting::ExitClass; -pub use file_access_interface::FileAccessInterface; -pub use file_access_interface::LocalFileAccessInterface; -pub use global_settings::GlobalSettings; -pub use list::List; -pub(crate) use parser_with_context::parser_with_context; + use context::Context; + use context::ContextElement; + use context::ExitMatcherNode; + use exiting::ExitClass; + use file_access_interface::FileAccessInterface; + use file_access_interface::LocalFileAccessInterface; + use global_settings::GlobalSettings; + use list::List; +(crate) use parser_with_context::parser_with_context; diff --git a/src/context/parser_with_context.rs b/src/context/parser_with_context.rs index 6705d47..75e3370 100644 --- a/src/context/parser_with_context.rs +++ b/src/context/parser_with_context.rs @@ -3,4 +3,4 @@ macro_rules! parser_with_context { move |context| move |i| $target(context, i) }; } -pub(crate) use parser_with_context; +(crate) use parser_with_context; diff --git a/src/error/error.rs b/src/error/error.rs index 5a620f0..fcad643 100644 --- a/src/error/error.rs +++ b/src/error/error.rs @@ -2,18 +2,18 @@ use nom::error::ErrorKind; use nom::error::ParseError; use nom::IResult; -pub type Res = IResult>; + type Res = IResult>; // TODO: MyError probably shouldn't be based on the same type as the input type since it's used exclusively with static strings right now. #[derive(Debug)] -pub enum CustomError { + enum CustomError { MyError(MyError), Nom(I, ErrorKind), IO(std::io::Error), } #[derive(Debug)] -pub struct MyError(pub I); + struct MyError( I); impl ParseError for CustomError { fn from_error_kind(input: I, kind: ErrorKind) -> Self { diff --git a/src/error/mod.rs b/src/error/mod.rs index d6e822d..7cd9a46 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -1,4 +1,4 @@ mod error; -pub use error::CustomError; -pub use error::MyError; -pub use error::Res; + use error::CustomError; + use error::MyError; + use error::Res; diff --git a/src/init_tracing.rs b/src/init_tracing.rs index 9b72926..a9dc80c 100644 --- a/src/init_tracing.rs +++ b/src/init_tracing.rs @@ -10,7 +10,7 @@ const SERVICE_NAME: &'static str = "organic"; // Despite the obvious verbosity that fully-qualifying everything causes, in these functions I am fully-qualifying everything relating to tracing. This is because the tracing feature involves multiple libraries working together and so I think it is beneficial to see which libraries contribute which bits. #[cfg(feature = "tracing")] -pub fn init_telemetry() -> Result<(), Box> { + fn init_telemetry() -> Result<(), Box> { // by default it will hit http://localhost:4317 with a gRPC payload // TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned. let exporter = opentelemetry_otlp::new_exporter() @@ -55,17 +55,17 @@ pub fn init_telemetry() -> Result<(), Box> { } #[cfg(feature = "tracing")] -pub fn shutdown_telemetry() -> Result<(), Box> { + fn shutdown_telemetry() -> Result<(), Box> { opentelemetry::global::shutdown_tracer_provider(); Ok(()) } #[cfg(not(feature = "tracing"))] -pub fn init_telemetry() -> Result<(), Box> { + fn init_telemetry() -> Result<(), Box> { Ok(()) } #[cfg(not(feature = "tracing"))] -pub fn shutdown_telemetry() -> Result<(), Box> { + fn shutdown_telemetry() -> Result<(), Box> { Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index afe5aa1..7cba5b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,20 +6,20 @@ #[cfg(feature = "compare")] mod compare; #[cfg(feature = "compare")] -pub use compare::compare_document; + use compare::compare_document; #[cfg(feature = "compare")] -pub use compare::emacs_parse_anonymous_org_document; + use compare::emacs_parse_anonymous_org_document; #[cfg(feature = "compare")] -pub use compare::emacs_parse_file_org_document; + use compare::emacs_parse_file_org_document; #[cfg(feature = "compare")] -pub use compare::get_emacs_version; + use compare::get_emacs_version; #[cfg(feature = "compare")] -pub use compare::get_org_mode_version; + use compare::get_org_mode_version; mod context; mod error; -pub mod parser; -pub mod types; + mod parser; + mod types; -pub use context::GlobalSettings; -pub use context::LocalFileAccessInterface; + use context::GlobalSettings; + use context::LocalFileAccessInterface; diff --git a/src/parser/angle_link.rs b/src/parser/angle_link.rs index f769209..1537ee0 100644 --- a/src/parser/angle_link.rs +++ b/src/parser/angle_link.rs @@ -18,7 +18,7 @@ use crate::parser::util::get_consumed; use crate::types::AngleLink; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn angle_link<'b, 'g, 'r, 's>( + fn angle_link<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, AngleLink<'s>> { diff --git a/src/parser/citation.rs b/src/parser/citation.rs index d1ebdb2..2f00b74 100644 --- a/src/parser/citation.rs +++ b/src/parser/citation.rs @@ -31,7 +31,7 @@ use crate::types::Citation; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn citation<'b, 'g, 'r, 's>( + fn citation<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Citation<'s>> { diff --git a/src/parser/citation_reference.rs b/src/parser/citation_reference.rs index 50697e2..488229d 100644 --- a/src/parser/citation_reference.rs +++ b/src/parser/citation_reference.rs @@ -29,7 +29,7 @@ use crate::types::CitationReference; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn citation_reference<'b, 'g, 'r, 's>( + fn citation_reference<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, CitationReference<'s>> { @@ -49,7 +49,7 @@ pub fn citation_reference<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn citation_reference_key<'b, 'g, 'r, 's>( + fn citation_reference_key<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -161,7 +161,7 @@ fn _key_suffix_end<'b, 'g, 'r, 's>( tag(";")(input) } -pub fn must_balance_bracket<'s, F, O>( + fn must_balance_bracket<'s, F, O>( mut inner: F, ) -> impl FnMut(OrgSource<'s>) -> Res, O> where diff --git a/src/parser/clock.rs b/src/parser/clock.rs index 7f13d25..4570358 100644 --- a/src/parser/clock.rs +++ b/src/parser/clock.rs @@ -20,7 +20,7 @@ use crate::parser::util::start_of_line; use crate::types::Clock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn clock<'b, 'g, 'r, 's>( + fn clock<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Clock<'s>> { diff --git a/src/parser/comment.rs b/src/parser/comment.rs index 5ea95d3..046c07e 100644 --- a/src/parser/comment.rs +++ b/src/parser/comment.rs @@ -25,7 +25,7 @@ use crate::parser::util::start_of_line; use crate::types::Comment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn comment<'b, 'g, 'r, 's>( + fn comment<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Comment<'s>> { @@ -68,7 +68,7 @@ fn comment_line<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_comment<'s>(input: OrgSource<'s>) -> Res, ()> { + fn detect_comment<'s>(input: OrgSource<'s>) -> Res, ()> { tuple(( start_of_line, space0, diff --git a/src/parser/diary_sexp.rs b/src/parser/diary_sexp.rs index 8d58344..bae57fc 100644 --- a/src/parser/diary_sexp.rs +++ b/src/parser/diary_sexp.rs @@ -13,7 +13,7 @@ use crate::parser::util::start_of_line; use crate::types::DiarySexp; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn diary_sexp<'b, 'g, 'r, 's>( + fn diary_sexp<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, DiarySexp<'s>> { @@ -32,7 +32,7 @@ pub fn diary_sexp<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_diary_sexp<'s>(input: OrgSource<'s>) -> Res, ()> { + fn detect_diary_sexp<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, tag("%%(")))(input)?; Ok((input, ())) } diff --git a/src/parser/document.rs b/src/parser/document.rs index 027ba70..d8158ae 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -28,7 +28,7 @@ use crate::types::Object; /// /// This is the main entry point for Organic. It will parse the full contents of the input string as an org-mode document. #[allow(dead_code)] -pub fn parse<'s>(input: &'s str) -> Result, String> { + fn parse<'s>(input: &'s str) -> Result, String> { parse_with_settings(input, &GlobalSettings::default()) } @@ -38,7 +38,7 @@ pub fn parse<'s>(input: &'s str) -> Result, String> { /// /// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO". #[allow(dead_code)] -pub fn parse_with_settings<'g, 's>( + fn parse_with_settings<'g, 's>( input: &'s str, global_settings: &'g GlobalSettings<'g, 's>, ) -> Result, String> { @@ -58,7 +58,7 @@ pub fn parse_with_settings<'g, 's>( /// /// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO". #[allow(dead_code)] -pub fn document<'b, 'g, 'r, 's>( + fn document<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: &'s str, ) -> Res<&'s str, Document<'s>> { @@ -157,7 +157,7 @@ fn _document<'b, 'g, 'r, 's>( } impl<'s> Document<'s> { - pub fn iter_tokens<'r>(&'r self) -> impl Iterator> { + fn iter_tokens<'r>(&'r self) -> impl Iterator> { AllTokensIterator::new(Token::Document(self)) } } diff --git a/src/parser/drawer.rs b/src/parser/drawer.rs index 1cdabe2..f30813f 100644 --- a/src/parser/drawer.rs +++ b/src/parser/drawer.rs @@ -32,7 +32,7 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn drawer<'b, 'g, 'r, 's>( + fn drawer<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Drawer<'s>> { diff --git a/src/parser/dynamic_block.rs b/src/parser/dynamic_block.rs index 083b26c..738ab76 100644 --- a/src/parser/dynamic_block.rs +++ b/src/parser/dynamic_block.rs @@ -32,7 +32,7 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn dynamic_block<'b, 'g, 'r, 's>( + fn dynamic_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, DynamicBlock<'s>> { diff --git a/src/parser/element_parser.rs b/src/parser/element_parser.rs index 2f6b22a..7cfa078 100644 --- a/src/parser/element_parser.rs +++ b/src/parser/element_parser.rs @@ -40,7 +40,7 @@ use crate::parser::table::org_mode_table; use crate::types::Element; use crate::types::SetSource; -pub const fn element( + const fn element( can_be_paragraph: bool, ) -> impl for<'b, 'g, 'r, 's> Fn( RefContext<'b, 'g, 'r, 's>, @@ -127,7 +127,7 @@ fn _element<'b, 'g, 'r, 's>( Ok((remaining, element)) } -pub const fn detect_element( + const fn detect_element( can_be_paragraph: bool, ) -> impl for<'b, 'g, 'r, 's> Fn(RefContext<'b, 'g, 'r, 's>, OrgSource<'s>) -> Res, ()> { diff --git a/src/parser/entity.rs b/src/parser/entity.rs index ca8403a..1fddc23 100644 --- a/src/parser/entity.rs +++ b/src/parser/entity.rs @@ -433,7 +433,7 @@ const ORG_ENTITIES: [&'static str; 413] = [ ]; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn entity<'b, 'g, 'r, 's>( + fn entity<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Entity<'s>> { diff --git a/src/parser/export_snippet.rs b/src/parser/export_snippet.rs index 2b40619..e46e6db 100644 --- a/src/parser/export_snippet.rs +++ b/src/parser/export_snippet.rs @@ -20,7 +20,7 @@ use crate::parser::util::get_consumed; use crate::types::ExportSnippet; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn export_snippet<'b, 'g, 'r, 's>( + fn export_snippet<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExportSnippet<'s>> { diff --git a/src/parser/fixed_width_area.rs b/src/parser/fixed_width_area.rs index d3a0962..bec9ba5 100644 --- a/src/parser/fixed_width_area.rs +++ b/src/parser/fixed_width_area.rs @@ -21,7 +21,7 @@ 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<'b, 'g, 'r, 's>( + fn fixed_width_area<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FixedWidthArea<'s>> { @@ -57,7 +57,7 @@ fn fixed_width_area_line<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_fixed_width_area<'s>(input: OrgSource<'s>) -> Res, ()> { + fn detect_fixed_width_area<'s>(input: OrgSource<'s>) -> Res, ()> { tuple(( start_of_line, space0, diff --git a/src/parser/footnote_definition.rs b/src/parser/footnote_definition.rs index a4053f1..64fe292 100644 --- a/src/parser/footnote_definition.rs +++ b/src/parser/footnote_definition.rs @@ -33,7 +33,7 @@ use crate::parser::util::start_of_line; use crate::types::FootnoteDefinition; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn footnote_definition<'b, 'g, 'r, 's>( + fn footnote_definition<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteDefinition<'s>> { @@ -93,7 +93,7 @@ pub fn footnote_definition<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn label<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { + fn label<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { alt(( digit1, take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c)), @@ -122,7 +122,7 @@ fn footnote_definition_end<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_footnote_definition<'s>(input: OrgSource<'s>) -> Res, ()> { + fn detect_footnote_definition<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, tag_no_case("[fn:"), label, tag("]")))(input)?; Ok((input, ())) } diff --git a/src/parser/footnote_reference.rs b/src/parser/footnote_reference.rs index 28f8b52..18d1092 100644 --- a/src/parser/footnote_reference.rs +++ b/src/parser/footnote_reference.rs @@ -23,7 +23,7 @@ use crate::parser::util::get_consumed; use crate::types::FootnoteReference; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn footnote_reference<'b, 'g, 'r, 's>( + fn footnote_reference<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteReference<'s>> { diff --git a/src/parser/greater_block.rs b/src/parser/greater_block.rs index 8e973de..4c9f74b 100644 --- a/src/parser/greater_block.rs +++ b/src/parser/greater_block.rs @@ -33,7 +33,7 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn greater_block<'b, 'g, 'r, 's>( + fn greater_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, GreaterBlock<'s>> { diff --git a/src/parser/headline.rs b/src/parser/headline.rs index 6be9159..6e6bd79 100644 --- a/src/parser/headline.rs +++ b/src/parser/headline.rs @@ -36,7 +36,7 @@ use crate::types::Object; use crate::types::PriorityCookie; use crate::types::TodoKeywordType; -pub const fn heading( + const fn heading( parent_stars: usize, ) -> impl for<'b, 'g, 'r, 's> Fn( RefContext<'b, 'g, 'r, 's>, @@ -95,7 +95,7 @@ fn _heading<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_headline<'s>(input: OrgSource<'s>) -> Res, ()> { + fn detect_headline<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, many1(tag("*")), space1))(input)?; Ok((input, ())) } diff --git a/src/parser/horizontal_rule.rs b/src/parser/horizontal_rule.rs index c4c054a..f598cd8 100644 --- a/src/parser/horizontal_rule.rs +++ b/src/parser/horizontal_rule.rs @@ -15,7 +15,7 @@ use crate::parser::util::start_of_line; use crate::types::HorizontalRule; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn horizontal_rule<'b, 'g, 'r, 's>( + fn horizontal_rule<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, HorizontalRule<'s>> { diff --git a/src/parser/in_buffer_settings.rs b/src/parser/in_buffer_settings.rs index 59f1143..1cdb90e 100644 --- a/src/parser/in_buffer_settings.rs +++ b/src/parser/in_buffer_settings.rs @@ -13,7 +13,7 @@ use crate::types::Keyword; use crate::GlobalSettings; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn scan_for_in_buffer_settings<'s>( + fn scan_for_in_buffer_settings<'s>( input: OrgSource<'s>, ) -> Res, Vec>> { // TODO: Optimization idea: since this is slicing the OrgSource at each character, it might be more efficient to do a parser that uses a search function like take_until, and wrap it in a function similar to consumed but returning the input along with the normal output, then pass all of that into a verify that confirms we were at the start of a line using the input we just returned. @@ -44,7 +44,7 @@ fn in_buffer_settings_key<'s>(input: OrgSource<'s>) -> Res, OrgSou ))(input) } -pub fn apply_in_buffer_settings<'g, 's, 'sf>( + fn apply_in_buffer_settings<'g, 's, 'sf>( keywords: Vec>, original_settings: &'g GlobalSettings<'g, 's>, ) -> Result, String> { diff --git a/src/parser/inline_babel_call.rs b/src/parser/inline_babel_call.rs index 78cc953..951d8fd 100644 --- a/src/parser/inline_babel_call.rs +++ b/src/parser/inline_babel_call.rs @@ -26,7 +26,7 @@ use crate::parser::util::get_consumed; use crate::types::InlineBabelCall; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn inline_babel_call<'b, 'g, 'r, 's>( + fn inline_babel_call<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, InlineBabelCall<'s>> { diff --git a/src/parser/inline_source_block.rs b/src/parser/inline_source_block.rs index 4589124..4216cfd 100644 --- a/src/parser/inline_source_block.rs +++ b/src/parser/inline_source_block.rs @@ -28,7 +28,7 @@ use crate::parser::util::get_consumed; use crate::types::InlineSourceBlock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn inline_source_block<'b, 'g, 'r, 's>( + fn inline_source_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, InlineSourceBlock<'s>> { diff --git a/src/parser/keyword.rs b/src/parser/keyword.rs index c5cc476..77bec7a 100644 --- a/src/parser/keyword.rs +++ b/src/parser/keyword.rs @@ -31,7 +31,7 @@ const ORG_ELEMENT_AFFILIATED_KEYWORDS: [&'static str; 13] = [ ]; const ORG_ELEMENT_DUAL_KEYWORDS: [&'static str; 2] = ["caption", "results"]; -pub fn filtered_keyword( + fn filtered_keyword( key_parser: F, ) -> impl for<'s> Fn(OrgSource<'s>) -> Res, Keyword<'s>> { move |input| _filtered_keyword(&key_parser, input) @@ -83,7 +83,7 @@ fn _filtered_keyword<'s, F: Matcher>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn keyword<'b, 'g, 'r, 's>( + fn keyword<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { @@ -91,7 +91,7 @@ pub fn keyword<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn affiliated_keyword<'b, 'g, 'r, 's>( + fn affiliated_keyword<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { @@ -99,7 +99,7 @@ pub fn affiliated_keyword<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn babel_call_keyword<'b, 'g, 'r, 's>( + fn babel_call_keyword<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { @@ -112,7 +112,7 @@ fn babel_call_key<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn table_formula_keyword<'b, 'g, 'r, 's>( + fn table_formula_keyword<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { diff --git a/src/parser/keyword_todo.rs b/src/parser/keyword_todo.rs index 821aa8e..4ec11b9 100644 --- a/src/parser/keyword_todo.rs +++ b/src/parser/keyword_todo.rs @@ -19,7 +19,7 @@ use crate::error::Res; /// Parses the text in the value of a #+TODO keyword. /// /// Example input: "foo bar baz | lorem ipsum" -pub fn todo_keywords<'s>(input: &'s str) -> Res<&'s str, (Vec<&'s str>, Vec<&'s str>)> { + fn todo_keywords<'s>(input: &'s str) -> Res<&'s str, (Vec<&'s str>, Vec<&'s str>)> { let (remaining, mut before_pipe_words) = separated_list0(space1, todo_keyword_word)(input)?; let (remaining, after_pipe_words) = opt(tuple(( tuple((space0, tag("|"), space0)), diff --git a/src/parser/latex_environment.rs b/src/parser/latex_environment.rs index a5d379a..16b99ec 100644 --- a/src/parser/latex_environment.rs +++ b/src/parser/latex_environment.rs @@ -25,7 +25,7 @@ use crate::parser::util::start_of_line; use crate::types::LatexEnvironment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn latex_environment<'b, 'g, 'r, 's>( + fn latex_environment<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LatexEnvironment<'s>> { diff --git a/src/parser/latex_fragment.rs b/src/parser/latex_fragment.rs index 7a142d2..5616e22 100644 --- a/src/parser/latex_fragment.rs +++ b/src/parser/latex_fragment.rs @@ -24,7 +24,7 @@ use crate::parser::util::get_consumed; use crate::types::LatexFragment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn latex_fragment<'b, 'g, 'r, 's>( + fn latex_fragment<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LatexFragment<'s>> { @@ -174,7 +174,7 @@ fn dollar_char_fragment<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn pre<'b, 'g, 'r, 's>( + fn pre<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -188,7 +188,7 @@ pub fn pre<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn post<'b, 'g, 'r, 's>( + fn post<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -226,7 +226,7 @@ fn bordered_dollar_fragment<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn open_border<'b, 'g, 'r, 's>( + fn open_border<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -234,7 +234,7 @@ pub fn open_border<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn close_border<'b, 'g, 'r, 's>( + fn close_border<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { diff --git a/src/parser/lesser_block.rs b/src/parser/lesser_block.rs index 4f323d9..abba68c 100644 --- a/src/parser/lesser_block.rs +++ b/src/parser/lesser_block.rs @@ -35,7 +35,7 @@ use crate::types::SrcBlock; use crate::types::VerseBlock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn verse_block<'b, 'g, 'r, 's>( + fn verse_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, VerseBlock<'s>> { @@ -90,7 +90,7 @@ pub fn verse_block<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn comment_block<'b, 'g, 'r, 's>( + fn comment_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, CommentBlock<'s>> { @@ -130,7 +130,7 @@ pub fn comment_block<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn example_block<'b, 'g, 'r, 's>( + fn example_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExampleBlock<'s>> { @@ -170,7 +170,7 @@ pub fn example_block<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn export_block<'b, 'g, 'r, 's>( + fn export_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExportBlock<'s>> { @@ -211,7 +211,7 @@ pub fn export_block<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn src_block<'b, 'g, 'r, 's>( + fn src_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, SrcBlock<'s>> { diff --git a/src/parser/line_break.rs b/src/parser/line_break.rs index a0c721a..dbbefb1 100644 --- a/src/parser/line_break.rs +++ b/src/parser/line_break.rs @@ -13,7 +13,7 @@ use crate::parser::util::get_consumed; use crate::types::LineBreak; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn line_break<'b, 'g, 'r, 's>( + fn line_break<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LineBreak<'s>> { diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 30b685a..22e0e38 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -37,7 +37,7 @@ mod property_drawer; mod radio_link; mod regular_link; mod section; -pub mod sexp; + mod sexp; mod statistics_cookie; mod subscript_and_superscript; mod table; @@ -46,7 +46,7 @@ mod text_markup; mod timestamp; mod token; mod util; -pub use document::document; -pub use document::parse; -pub use document::parse_with_settings; -pub use org_source::OrgSource; + use document::document; + use document::parse; + use document::parse_with_settings; + use org_source::OrgSource; diff --git a/src/parser/object_parser.rs b/src/parser/object_parser.rs index 5542618..07e430e 100644 --- a/src/parser/object_parser.rs +++ b/src/parser/object_parser.rs @@ -32,7 +32,7 @@ use crate::parser::timestamp::timestamp; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn standard_set_object<'b, 'g, 'r, 's>( + fn standard_set_object<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -47,7 +47,7 @@ pub fn standard_set_object<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn minimal_set_object<'b, 'g, 'r, 's>( + fn minimal_set_object<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -140,7 +140,7 @@ fn minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( + fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -174,7 +174,7 @@ fn detect_minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn regular_link_description_set_object<'b, 'g, 'r, 's>( + fn regular_link_description_set_object<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -221,7 +221,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( + fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -238,7 +238,7 @@ pub fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn table_cell_set_object<'b, 'g, 'r, 's>( + fn table_cell_set_object<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -253,7 +253,7 @@ pub fn table_cell_set_object<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( + fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -287,7 +287,7 @@ pub fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( + fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { diff --git a/src/parser/org_macro.rs b/src/parser/org_macro.rs index cf89c3b..4c2a993 100644 --- a/src/parser/org_macro.rs +++ b/src/parser/org_macro.rs @@ -18,7 +18,7 @@ use crate::parser::util::get_consumed; use crate::types::OrgMacro; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_macro<'b, 'g, 'r, 's>( + fn org_macro<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgMacro<'s>> { diff --git a/src/parser/org_source.rs b/src/parser/org_source.rs index 820c01c..1fae341 100644 --- a/src/parser/org_source.rs +++ b/src/parser/org_source.rs @@ -11,10 +11,10 @@ use nom::Slice; use crate::error::CustomError; use crate::error::MyError; -pub type BracketDepth = i16; + type BracketDepth = i16; #[derive(Copy, Clone)] -pub struct OrgSource<'s> { + struct OrgSource<'s> { full_source: &'s str, start: usize, end: usize, // exclusive @@ -37,7 +37,7 @@ impl<'s> OrgSource<'s> { /// Returns a wrapped string that keeps track of values we need for parsing org-mode. /// /// Only call this on the full original string. Calling this on a substring can result in invalid values. - pub fn new(input: &'s str) -> Self { + fn new(input: &'s str) -> Self { OrgSource { full_source: input, start: 0, @@ -51,37 +51,37 @@ impl<'s> OrgSource<'s> { } /// Get the text since the line break preceding the start of this WrappedInput. - pub fn text_since_line_break(&self) -> &'s str { + fn text_since_line_break(&self) -> &'s str { &self.full_source[self.start_of_line..self.start] } - pub fn len(&self) -> usize { + fn len(&self) -> usize { self.end - self.start } - pub fn get_preceding_character(&self) -> Option { + fn get_preceding_character(&self) -> Option { self.preceding_character } - pub fn is_at_start_of_line(&self) -> bool { + fn is_at_start_of_line(&self) -> bool { self.start == self.start_of_line } - pub fn get_until(&self, other: OrgSource<'s>) -> OrgSource<'s> { + fn get_until(&self, other: OrgSource<'s>) -> OrgSource<'s> { assert!(other.start >= self.start); assert!(other.end <= self.end); self.slice(..(other.start - self.start)) } - pub fn get_bracket_depth(&self) -> BracketDepth { + fn get_bracket_depth(&self) -> BracketDepth { self.bracket_depth } - pub fn get_brace_depth(&self) -> BracketDepth { + fn get_brace_depth(&self) -> BracketDepth { self.brace_depth } - pub fn get_parenthesis_depth(&self) -> BracketDepth { + fn get_parenthesis_depth(&self) -> BracketDepth { self.parenthesis_depth } } @@ -306,7 +306,7 @@ impl<'s> InputTakeAtPosition for OrgSource<'s> { } } -pub fn convert_error<'a, I: Into>>( + fn convert_error<'a, I: Into>>( err: nom::Err, ) -> nom::Err> { match err { diff --git a/src/parser/paragraph.rs b/src/parser/paragraph.rs index 2f7345a..7771f64 100644 --- a/src/parser/paragraph.rs +++ b/src/parser/paragraph.rs @@ -22,7 +22,7 @@ use crate::parser::util::start_of_line; use crate::types::Paragraph; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn paragraph<'b, 'g, 'r, 's>( + fn paragraph<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Paragraph<'s>> { diff --git a/src/parser/plain_link.rs b/src/parser/plain_link.rs index c4dc464..ceccc2e 100644 --- a/src/parser/plain_link.rs +++ b/src/parser/plain_link.rs @@ -53,7 +53,7 @@ const ORG_LINK_PARAMETERS: [&'static str; 23] = [ ]; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn plain_link<'b, 'g, 'r, 's>( + fn plain_link<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainLink<'s>> { @@ -105,7 +105,7 @@ fn post<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn protocol<'b, 'g, 'r, 's>( + fn protocol<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 288088b..ed6c716 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -41,7 +41,7 @@ use crate::types::PlainList; use crate::types::PlainListItem; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_plain_list<'s>(input: OrgSource<'s>) -> Res, ()> { + fn detect_plain_list<'s>(input: OrgSource<'s>) -> Res, ()> { if verify( tuple(( start_of_line, @@ -63,7 +63,7 @@ pub fn detect_plain_list<'s>(input: OrgSource<'s>) -> Res, ()> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn plain_list<'b, 'g, 'r, 's>( + fn plain_list<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainList<'s>> { @@ -137,7 +137,7 @@ pub fn plain_list<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn plain_list_item<'b, 'g, 'r, 's>( + fn plain_list_item<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainListItem<'s>> { diff --git a/src/parser/plain_text.rs b/src/parser/plain_text.rs index b50bd13..dffa97f 100644 --- a/src/parser/plain_text.rs +++ b/src/parser/plain_text.rs @@ -16,7 +16,7 @@ use crate::error::Res; use crate::types::Object; use crate::types::PlainText; -pub fn plain_text( + fn plain_text( end_condition: F, ) -> impl for<'b, 'g, 'r, 's> Fn( RefContext<'b, 'g, 'r, 's>, diff --git a/src/parser/planning.rs b/src/parser/planning.rs index 10864ab..6730d3b 100644 --- a/src/parser/planning.rs +++ b/src/parser/planning.rs @@ -18,7 +18,7 @@ use crate::parser::util::start_of_line; use crate::types::Planning; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn planning<'b, 'g, 'r, 's>( + fn planning<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Planning<'s>> { diff --git a/src/parser/property_drawer.rs b/src/parser/property_drawer.rs index f560130..221e2fd 100644 --- a/src/parser/property_drawer.rs +++ b/src/parser/property_drawer.rs @@ -31,7 +31,7 @@ use crate::types::NodeProperty; use crate::types::PropertyDrawer; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn property_drawer<'b, 'g, 'r, 's>( + fn property_drawer<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PropertyDrawer<'s>> { diff --git a/src/parser/radio_link.rs b/src/parser/radio_link.rs index f47a4d2..55f0581 100644 --- a/src/parser/radio_link.rs +++ b/src/parser/radio_link.rs @@ -23,7 +23,7 @@ use crate::types::RadioLink; use crate::types::RadioTarget; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn radio_link<'b, 'g, 'r, 's>( + fn radio_link<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RadioLink<'s>> { @@ -47,7 +47,7 @@ pub fn radio_link<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn rematch_target<'x, 'b, 'g, 'r, 's>( + fn rematch_target<'x, 'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, target: &'x Vec>, input: OrgSource<'s>, @@ -78,7 +78,7 @@ pub fn rematch_target<'x, 'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn radio_target<'b, 'g, 'r, 's>( + fn radio_target<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RadioTarget<'s>> { @@ -118,7 +118,7 @@ fn radio_target_end<'b, 'g, 'r, 's>( alt((tag("<"), tag(">"), line_ending))(input) } -pub trait RematchObject<'x> { + trait RematchObject<'x> { fn rematch_object<'b, 'g, 'r, 's>( &'x self, context: RefContext<'b, 'g, 'r, 's>, diff --git a/src/parser/regular_link.rs b/src/parser/regular_link.rs index e959a28..75416d1 100644 --- a/src/parser/regular_link.rs +++ b/src/parser/regular_link.rs @@ -21,7 +21,7 @@ use crate::types::Object; use crate::types::RegularLink; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn regular_link<'b, 'g, 'r, 's>( + fn regular_link<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { @@ -32,7 +32,7 @@ pub fn regular_link<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn regular_link_without_description<'b, 'g, 'r, 's>( + fn regular_link_without_description<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { @@ -51,7 +51,7 @@ pub fn regular_link_without_description<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn regular_link_with_description<'b, 'g, 'r, 's>( + fn regular_link_with_description<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { @@ -72,7 +72,7 @@ pub fn regular_link_with_description<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn pathreg<'b, 'g, 'r, 's>( + fn pathreg<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -88,7 +88,7 @@ pub fn pathreg<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn description<'b, 'g, 'r, 's>( + fn description<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { diff --git a/src/parser/section.rs b/src/parser/section.rs index bcc4f36..7b82fbb 100644 --- a/src/parser/section.rs +++ b/src/parser/section.rs @@ -25,7 +25,7 @@ use crate::types::Element; use crate::types::Section; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn zeroth_section<'b, 'g, 'r, 's>( + fn zeroth_section<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Section<'s>> { @@ -83,7 +83,7 @@ pub fn zeroth_section<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn section<'b, 'g, 'r, 's>( + fn section<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, mut input: OrgSource<'s>, ) -> Res, Section<'s>> { diff --git a/src/parser/sexp.rs b/src/parser/sexp.rs index 9c98ef7..3eaeb92 100644 --- a/src/parser/sexp.rs +++ b/src/parser/sexp.rs @@ -22,7 +22,7 @@ use super::util::get_consumed; use crate::error::Res; #[derive(Debug)] -pub enum Token<'s> { + enum Token<'s> { Atom(&'s str), List(Vec>), TextWithProperties(TextWithProperties<'s>), @@ -30,9 +30,9 @@ pub enum Token<'s> { } #[derive(Debug)] -pub struct TextWithProperties<'s> { - pub text: &'s str, - pub properties: Vec>, + struct TextWithProperties<'s> { + text: &'s str, + properties: Vec>, } enum ParseState { @@ -41,35 +41,35 @@ enum ParseState { } impl<'s> Token<'s> { - pub fn as_vector<'p>(&'p self) -> Result<&'p Vec>, Box> { + fn as_vector<'p>(&'p self) -> Result<&'p Vec>, Box> { Ok(match self { Token::Vector(children) => Ok(children), _ => Err(format!("wrong token type, expected vector: {:?}", self)), }?) } - pub fn as_list<'p>(&'p self) -> Result<&'p Vec>, Box> { + fn as_list<'p>(&'p self) -> Result<&'p Vec>, Box> { Ok(match self { Token::List(children) => Ok(children), _ => Err(format!("wrong token type, expected list: {:?}", self)), }?) } - pub fn as_atom<'p>(&'p self) -> Result<&'s str, Box> { + fn as_atom<'p>(&'p self) -> Result<&'s str, Box> { Ok(match self { Token::Atom(body) => Ok(*body), _ => Err(format!("wrong token type, expected atom: {:?}", self)), }?) } - pub fn as_text<'p>(&'p self) -> Result<&'p TextWithProperties<'s>, Box> { + fn as_text<'p>(&'p self) -> Result<&'p TextWithProperties<'s>, Box> { Ok(match self { Token::TextWithProperties(body) => Ok(body), _ => Err(format!("wrong token type, expected text: {:?}", self)), }?) } - pub fn as_map<'p>( + fn as_map<'p>( &'p self, ) -> Result>, Box> { let mut hashmap = HashMap::new(); @@ -95,7 +95,7 @@ impl<'s> Token<'s> { } } -pub fn unquote(text: &str) -> Result> { + fn unquote(text: &str) -> Result> { let mut out = String::with_capacity(text.len()); if !text.starts_with(r#"""#) { return Err("Quoted text does not start with quote.".into()); @@ -132,7 +132,7 @@ pub fn unquote(text: &str) -> Result> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { + fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = multispace0(input)?; let remaining = OrgSource::new(remaining); let (remaining, tkn) = token(remaining) @@ -143,7 +143,7 @@ pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn sexp<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { + fn sexp<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { let (remaining, tkn) = token(input)?; Ok((remaining, tkn)) } diff --git a/src/parser/statistics_cookie.rs b/src/parser/statistics_cookie.rs index d83d0ea..5ffe4b7 100644 --- a/src/parser/statistics_cookie.rs +++ b/src/parser/statistics_cookie.rs @@ -13,7 +13,7 @@ use crate::error::Res; use crate::types::StatisticsCookie; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn statistics_cookie<'b, 'g, 'r, 's>( + fn statistics_cookie<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { @@ -24,7 +24,7 @@ pub fn statistics_cookie<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn percent_statistics_cookie<'b, 'g, 'r, 's>( + fn percent_statistics_cookie<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { @@ -45,7 +45,7 @@ pub fn percent_statistics_cookie<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn fraction_statistics_cookie<'b, 'g, 'r, 's>( + fn fraction_statistics_cookie<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { diff --git a/src/parser/subscript_and_superscript.rs b/src/parser/subscript_and_superscript.rs index c026c6a..3114f17 100644 --- a/src/parser/subscript_and_superscript.rs +++ b/src/parser/subscript_and_superscript.rs @@ -33,7 +33,7 @@ use crate::types::Subscript; use crate::types::Superscript; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res, ()> { + fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res, ()> { // This does not have to detect all valid subscript/superscript but all that it detects must be valid. let (remaining, _) = one_of("_^")(input)?; pre(input)?; @@ -46,7 +46,7 @@ pub fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res( + fn subscript<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Subscript<'s>> { @@ -66,7 +66,7 @@ pub fn subscript<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn superscript<'b, 'g, 'r, 's>( + fn superscript<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Superscript<'s>> { diff --git a/src/parser/table.rs b/src/parser/table.rs index e836cdf..19e8436 100644 --- a/src/parser/table.rs +++ b/src/parser/table.rs @@ -33,7 +33,7 @@ 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<'b, 'g, 'r, 's>( + fn org_mode_table<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Table<'s>> { @@ -74,7 +74,7 @@ pub fn org_mode_table<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn detect_table<'s>(input: OrgSource<'s>) -> Res, ()> { + fn detect_table<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, space0, tag("|")))(input)?; Ok((input, ())) } @@ -89,7 +89,7 @@ fn table_end<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table_row<'b, 'g, 'r, 's>( + fn org_mode_table_row<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { @@ -100,7 +100,7 @@ pub fn org_mode_table_row<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table_row_rule<'b, 'g, 'r, 's>( + fn org_mode_table_row_rule<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { @@ -117,7 +117,7 @@ pub fn org_mode_table_row_rule<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table_row_regular<'b, 'g, 'r, 's>( + fn org_mode_table_row_regular<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { @@ -137,7 +137,7 @@ pub fn org_mode_table_row_regular<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn org_mode_table_cell<'b, 'g, 'r, 's>( + fn org_mode_table_cell<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableCell<'s>> { diff --git a/src/parser/target.rs b/src/parser/target.rs index b978966..730c40b 100644 --- a/src/parser/target.rs +++ b/src/parser/target.rs @@ -21,7 +21,7 @@ use crate::parser::util::get_consumed; use crate::types::Target; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn target<'b, 'g, 'r, 's>( + fn target<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Target<'s>> { diff --git a/src/parser/text_markup.rs b/src/parser/text_markup.rs index e36d179..37d6ff1 100644 --- a/src/parser/text_markup.rs +++ b/src/parser/text_markup.rs @@ -42,7 +42,7 @@ use crate::types::Underline; use crate::types::Verbatim; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn text_markup<'b, 'g, 'r, 's>( + fn text_markup<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -60,7 +60,7 @@ pub fn text_markup<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn bold<'b, 'g, 'r, 's>( + fn bold<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Bold<'s>> { @@ -77,7 +77,7 @@ pub fn bold<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn italic<'b, 'g, 'r, 's>( + fn italic<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Italic<'s>> { @@ -94,7 +94,7 @@ pub fn italic<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn underline<'b, 'g, 'r, 's>( + fn underline<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Underline<'s>> { @@ -111,7 +111,7 @@ pub fn underline<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn strike_through<'b, 'g, 'r, 's>( + fn strike_through<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StrikeThrough<'s>> { @@ -128,7 +128,7 @@ pub fn strike_through<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn verbatim<'b, 'g, 'r, 's>( + fn verbatim<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Verbatim<'s>> { @@ -145,7 +145,7 @@ pub fn verbatim<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn code<'b, 'g, 'r, 's>( + fn code<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Code<'s>> { @@ -288,7 +288,7 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn pre<'b, 'g, 'r, 's>( + fn pre<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -307,7 +307,7 @@ pub fn pre<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn post<'b, 'g, 'r, 's>( + fn post<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { diff --git a/src/parser/timestamp.rs b/src/parser/timestamp.rs index a1fff17..ab88e93 100644 --- a/src/parser/timestamp.rs +++ b/src/parser/timestamp.rs @@ -23,7 +23,7 @@ use crate::parser::util::get_consumed; use crate::types::Timestamp; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn timestamp<'b, 'g, 'r, 's>( + fn timestamp<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { diff --git a/src/parser/token.rs b/src/parser/token.rs index 2edcd8c..3fb1fd4 100644 --- a/src/parser/token.rs +++ b/src/parser/token.rs @@ -11,7 +11,7 @@ use crate::types::Section; use crate::types::TableCell; use crate::types::TableRow; -pub enum Token<'r, 's> { + enum Token<'r, 's> { Document(&'r Document<'s>), Heading(&'r Heading<'s>), Section(&'r Section<'s>), @@ -24,7 +24,7 @@ pub enum Token<'r, 's> { } impl<'r, 's> Token<'r, 's> { - pub fn iter_tokens(&self) -> Box> + '_> { + fn iter_tokens(&self) -> Box> + '_> { match self { Token::Document(document) => Box::new( document @@ -109,12 +109,12 @@ impl<'r, 's> Token<'r, 's> { } } -pub struct AllTokensIterator<'r, 's> { + struct AllTokensIterator<'r, 's> { queued_tokens: VecDeque>, } impl<'r, 's> AllTokensIterator<'r, 's> { - pub fn new(tkn: Token<'r, 's>) -> Self { + fn new(tkn: Token<'r, 's>) -> Self { let mut queued_tokens = VecDeque::new(); queued_tokens.push_back(tkn); AllTokensIterator { queued_tokens } diff --git a/src/parser/util.rs b/src/parser/util.rs index 53deb7c..cbda279 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -21,11 +21,11 @@ use crate::error::CustomError; use crate::error::MyError; use crate::error::Res; -pub const WORD_CONSTITUENT_CHARACTERS: &str = + const WORD_CONSTITUENT_CHARACTERS: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; /// Check if we are below a section of the given section type regardless of depth -pub fn in_section<'b, 'g, 'r, 's, 'x>( + fn in_section<'b, 'g, 'r, 's, 'x>( context: RefContext<'b, 'g, 'r, 's>, section_name: &'x str, ) -> bool { @@ -39,7 +39,7 @@ pub fn in_section<'b, 'g, 'r, 's, 'x>( } /// Checks if we are currently an immediate child of the given section type -pub fn immediate_in_section<'b, 'g, 'r, 's, 'x>( + fn immediate_in_section<'b, 'g, 'r, 's, 'x>( context: RefContext<'b, 'g, 'r, 's>, section_name: &'x str, ) -> bool { @@ -54,7 +54,7 @@ pub fn immediate_in_section<'b, 'g, 'r, 's, 'x>( } /// Check if we are below a section of the given section type regardless of depth -pub fn in_object_section<'b, 'g, 'r, 's, 'x>( + fn in_object_section<'b, 'g, 'r, 's, 'x>( context: RefContext<'b, 'g, 'r, 's>, section_name: &'x str, ) -> bool { @@ -68,7 +68,7 @@ pub fn in_object_section<'b, 'g, 'r, 's, 'x>( } /// Get a slice of the string that was consumed in a parser using the original input to the parser and the remaining input after the parser. -pub fn get_consumed<'s>(input: OrgSource<'s>, remaining: OrgSource<'s>) -> OrgSource<'s> { + fn get_consumed<'s>(input: OrgSource<'s>, remaining: OrgSource<'s>) -> OrgSource<'s> { input.get_until(remaining) } @@ -76,19 +76,19 @@ pub fn get_consumed<'s>(input: OrgSource<'s>, remaining: OrgSource<'s>) -> OrgSo /// /// It is up to the caller to ensure this is called at the start of a line. #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn blank_line(input: OrgSource<'_>) -> Res, OrgSource<'_>> { + fn blank_line(input: OrgSource<'_>) -> Res, OrgSource<'_>> { not(eof)(input)?; recognize(tuple((space0, alt((line_ending, eof)))))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { + fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { start_of_line(input)?; alt((eof, recognize(many0(blank_line))))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( + fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { @@ -104,7 +104,7 @@ pub fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( + fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { @@ -117,7 +117,7 @@ pub fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>( + fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { @@ -130,7 +130,7 @@ pub fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>( /// Check that we are at the start of a line #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn start_of_line<'s>(input: OrgSource<'s>) -> Res, ()> { + fn start_of_line<'s>(input: OrgSource<'s>) -> Res, ()> { if input.is_at_start_of_line() { Ok((input, ())) } else { @@ -140,7 +140,7 @@ pub fn start_of_line<'s>(input: OrgSource<'s>) -> Res, ()> { } } -pub fn preceded_by_whitespace( + fn preceded_by_whitespace( allow_start_of_file: bool, ) -> impl for<'s> Fn(OrgSource<'s>) -> Res, ()> { move |input| _preceded_by_whitespace(allow_start_of_file, input) @@ -168,13 +168,13 @@ fn _preceded_by_whitespace<'s>( /// /// This function only operates on spaces, tabs, carriage returns, and line feeds. It does not handle fancy unicode whitespace. #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn non_whitespace_character(input: OrgSource<'_>) -> Res, char> { + fn non_whitespace_character(input: OrgSource<'_>) -> Res, char> { none_of(" \t\r\n")(input) } /// Check that we are at the start of a line #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn exit_matcher_parser<'b, 'g, 'r, 's>( + fn exit_matcher_parser<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -182,7 +182,7 @@ pub fn exit_matcher_parser<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn text_until_exit<'b, 'g, 'r, 's>( + fn text_until_exit<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -193,7 +193,7 @@ pub fn text_until_exit<'b, 'g, 'r, 's>( } #[allow(dead_code)] -pub fn not_yet_implemented() -> Res, ()> { + fn not_yet_implemented() -> Res, ()> { return Err(nom::Err::Error(CustomError::MyError(MyError( "Not implemented yet.".into(), )))); @@ -204,7 +204,7 @@ pub fn not_yet_implemented() -> Res, ()> { /// Text from the current point until the next line break or end of file /// /// Useful for debugging. -pub fn text_until_eol<'r, 's>( + fn text_until_eol<'r, 's>( input: OrgSource<'s>, ) -> Result<&'s str, nom::Err>>> { let line = recognize(many_till(anychar, alt((line_ending, eof))))(input) @@ -212,7 +212,7 @@ pub fn text_until_eol<'r, 's>( Ok(line.trim()) } -pub fn include_input<'s, F, O>( + fn include_input<'s, F, O>( mut inner: F, ) -> impl FnMut(OrgSource<'s>) -> Res, (OrgSource<'s>, O)> where diff --git a/src/types/document.rs b/src/types/document.rs index 142762d..18c9f21 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -2,42 +2,42 @@ use super::Element; use super::Object; use super::Source; -pub type PriorityCookie = u8; + type PriorityCookie = u8; #[derive(Debug)] -pub struct Document<'s> { - pub source: &'s str, - pub zeroth_section: Option>, - pub children: Vec>, + struct Document<'s> { + source: &'s str, + zeroth_section: Option>, + children: Vec>, } #[derive(Debug)] -pub struct Heading<'s> { - pub source: &'s str, - pub stars: usize, - pub todo_keyword: Option<(TodoKeywordType, &'s str)>, - pub priority_cookie: Option, - pub title: Vec>, - pub tags: Vec<&'s str>, - pub children: Vec>, - pub is_comment: bool, - pub is_archived: bool, + struct Heading<'s> { + source: &'s str, + stars: usize, + todo_keyword: Option<(TodoKeywordType, &'s str)>, + priority_cookie: Option, + title: Vec>, + tags: Vec<&'s str>, + children: Vec>, + is_comment: bool, + is_archived: bool, } #[derive(Debug)] -pub struct Section<'s> { - pub source: &'s str, - pub children: Vec>, + struct Section<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug)] -pub enum DocumentElement<'s> { + enum DocumentElement<'s> { Heading(Heading<'s>), Section(Section<'s>), } #[derive(Debug)] -pub enum TodoKeywordType { + enum TodoKeywordType { Todo, Done, } diff --git a/src/types/element.rs b/src/types/element.rs index f29dee1..de5b582 100644 --- a/src/types/element.rs +++ b/src/types/element.rs @@ -23,7 +23,7 @@ use super::SetSource; use super::Source; #[derive(Debug)] -pub enum Element<'s> { + enum Element<'s> { Paragraph(Paragraph<'s>), PlainList(PlainList<'s>), GreaterBlock(GreaterBlock<'s>), diff --git a/src/types/greater_element.rs b/src/types/greater_element.rs index e897945..c5bcab6 100644 --- a/src/types/greater_element.rs +++ b/src/types/greater_element.rs @@ -5,73 +5,73 @@ use super::Object; use super::Source; #[derive(Debug)] -pub struct PlainList<'s> { - pub source: &'s str, - pub children: Vec>, + struct PlainList<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug)] -pub struct PlainListItem<'s> { - pub source: &'s str, - pub indentation: usize, - pub bullet: &'s str, - pub tag: Vec>, - pub children: Vec>, + struct PlainListItem<'s> { + source: &'s str, + indentation: usize, + bullet: &'s str, + tag: Vec>, + children: Vec>, } #[derive(Debug)] -pub struct GreaterBlock<'s> { - pub source: &'s str, - pub name: &'s str, - pub parameters: Option<&'s str>, - pub children: Vec>, + struct GreaterBlock<'s> { + source: &'s str, + name: &'s str, + parameters: Option<&'s str>, + children: Vec>, } #[derive(Debug)] -pub struct DynamicBlock<'s> { - pub source: &'s str, - pub name: &'s str, - pub parameters: Option<&'s str>, - pub children: Vec>, + struct DynamicBlock<'s> { + source: &'s str, + name: &'s str, + parameters: Option<&'s str>, + children: Vec>, } #[derive(Debug)] -pub struct FootnoteDefinition<'s> { - pub source: &'s str, - pub label: &'s str, - pub children: Vec>, + struct FootnoteDefinition<'s> { + source: &'s str, + label: &'s str, + children: Vec>, } #[derive(Debug)] -pub struct Drawer<'s> { - pub source: &'s str, - pub name: &'s str, - pub children: Vec>, + struct Drawer<'s> { + source: &'s str, + name: &'s str, + children: Vec>, } #[derive(Debug)] -pub struct PropertyDrawer<'s> { - pub source: &'s str, - pub children: Vec>, + struct PropertyDrawer<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug)] -pub struct NodeProperty<'s> { - pub source: &'s str, - pub value: Option<&'s str>, + struct NodeProperty<'s> { + source: &'s str, + value: Option<&'s str>, } #[derive(Debug)] -pub struct Table<'s> { - pub source: &'s str, - pub formulas: Vec>, - pub children: Vec>, + struct Table<'s> { + source: &'s str, + formulas: Vec>, + children: Vec>, } #[derive(Debug)] -pub struct TableRow<'s> { - pub source: &'s str, - pub children: Vec>, + struct TableRow<'s> { + source: &'s str, + children: Vec>, } impl<'s> Source<'s> for PlainList<'s> { diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index 06ae33b..bf911f3 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -3,101 +3,101 @@ use super::PlainText; use super::Source; #[derive(Debug)] -pub struct Paragraph<'s> { - pub source: &'s str, - pub children: Vec>, + struct Paragraph<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug)] -pub struct Comment<'s> { - pub source: &'s str, + struct Comment<'s> { + source: &'s str, } #[derive(Debug)] -pub struct TableCell<'s> { - pub source: &'s str, - pub children: Vec>, + struct TableCell<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug)] -pub struct VerseBlock<'s> { - pub source: &'s str, - pub name: &'s str, - pub data: Option<&'s str>, - pub children: Vec>, + struct VerseBlock<'s> { + source: &'s str, + name: &'s str, + data: Option<&'s str>, + children: Vec>, } #[derive(Debug)] -pub struct CommentBlock<'s> { - pub source: &'s str, - pub name: &'s str, - pub data: Option<&'s str>, - pub contents: &'s str, + struct CommentBlock<'s> { + source: &'s str, + name: &'s str, + data: Option<&'s str>, + contents: &'s str, } #[derive(Debug)] -pub struct ExampleBlock<'s> { - pub source: &'s str, - pub name: &'s str, - pub data: Option<&'s str>, - pub contents: &'s str, + struct ExampleBlock<'s> { + source: &'s str, + name: &'s str, + data: Option<&'s str>, + contents: &'s str, } #[derive(Debug)] -pub struct ExportBlock<'s> { - pub source: &'s str, - pub name: &'s str, - pub data: Option<&'s str>, - pub contents: &'s str, + struct ExportBlock<'s> { + source: &'s str, + name: &'s str, + data: Option<&'s str>, + contents: &'s str, } #[derive(Debug)] -pub struct SrcBlock<'s> { - pub source: &'s str, - pub name: &'s str, - pub data: Option<&'s str>, - pub contents: &'s str, + struct SrcBlock<'s> { + source: &'s str, + name: &'s str, + data: Option<&'s str>, + contents: &'s str, } #[derive(Debug)] -pub struct Clock<'s> { - pub source: &'s str, + struct Clock<'s> { + source: &'s str, } #[derive(Debug)] -pub struct DiarySexp<'s> { - pub source: &'s str, + struct DiarySexp<'s> { + source: &'s str, } #[derive(Debug)] -pub struct Planning<'s> { - pub source: &'s str, + struct Planning<'s> { + source: &'s str, } #[derive(Debug)] -pub struct FixedWidthArea<'s> { - pub source: &'s str, + struct FixedWidthArea<'s> { + source: &'s str, } #[derive(Debug)] -pub struct HorizontalRule<'s> { - pub source: &'s str, + struct HorizontalRule<'s> { + source: &'s str, } #[derive(Debug)] -pub struct Keyword<'s> { - pub source: &'s str, - pub key: &'s str, - pub value: &'s str, + struct Keyword<'s> { + source: &'s str, + key: &'s str, + value: &'s str, } #[derive(Debug)] -pub struct LatexEnvironment<'s> { - pub source: &'s str, + struct LatexEnvironment<'s> { + source: &'s str, } impl<'s> Paragraph<'s> { - pub fn of_text(input: &'s str) -> Self { + fn of_text(input: &'s str) -> Self { let mut objects = Vec::with_capacity(1); objects.push(Object::PlainText(PlainText { source: input })); Paragraph { diff --git a/src/types/mod.rs b/src/types/mod.rs index 9cf5b59..f64d7da 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -4,65 +4,65 @@ mod greater_element; mod lesser_element; mod object; mod source; -pub use document::Document; -pub use document::DocumentElement; -pub use document::Heading; -pub use document::PriorityCookie; -pub use document::Section; -pub use document::TodoKeywordType; -pub use element::Element; -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::TableRow; -pub use lesser_element::Clock; -pub use lesser_element::Comment; -pub use lesser_element::CommentBlock; -pub use lesser_element::DiarySexp; -pub use lesser_element::ExampleBlock; -pub use lesser_element::ExportBlock; -pub use lesser_element::FixedWidthArea; -pub use lesser_element::HorizontalRule; -pub use lesser_element::Keyword; -pub use lesser_element::LatexEnvironment; -pub use lesser_element::Paragraph; -pub use lesser_element::Planning; -pub use lesser_element::SrcBlock; -pub use lesser_element::TableCell; -pub use lesser_element::VerseBlock; -pub use object::AngleLink; -pub use object::Bold; -pub use object::Citation; -pub use object::CitationReference; -pub use object::Code; -pub use object::Entity; -pub use object::ExportSnippet; -pub use object::FootnoteReference; -pub use object::InlineBabelCall; -pub use object::InlineSourceBlock; -pub use object::Italic; -pub use object::LatexFragment; -pub use object::LineBreak; -pub use object::Object; -pub use object::OrgMacro; -pub use object::PlainLink; -pub use object::PlainText; -pub use object::RadioLink; -pub use object::RadioTarget; -pub use object::RegularLink; -pub use object::StatisticsCookie; -pub use object::StrikeThrough; -pub use object::Subscript; -pub use object::Superscript; -pub use object::Target; -pub use object::Timestamp; -pub use object::Underline; -pub use object::Verbatim; -pub use source::SetSource; -pub use source::Source; + use document::Document; + use document::DocumentElement; + use document::Heading; + use document::PriorityCookie; + use document::Section; + use document::TodoKeywordType; + use element::Element; + use greater_element::Drawer; + use greater_element::DynamicBlock; + use greater_element::FootnoteDefinition; + use greater_element::GreaterBlock; + use greater_element::NodeProperty; + use greater_element::PlainList; + use greater_element::PlainListItem; + use greater_element::PropertyDrawer; + use greater_element::Table; + use greater_element::TableRow; + use lesser_element::Clock; + use lesser_element::Comment; + use lesser_element::CommentBlock; + use lesser_element::DiarySexp; + use lesser_element::ExampleBlock; + use lesser_element::ExportBlock; + use lesser_element::FixedWidthArea; + use lesser_element::HorizontalRule; + use lesser_element::Keyword; + use lesser_element::LatexEnvironment; + use lesser_element::Paragraph; + use lesser_element::Planning; + use lesser_element::SrcBlock; + use lesser_element::TableCell; + use lesser_element::VerseBlock; + use object::AngleLink; + use object::Bold; + use object::Citation; + use object::CitationReference; + use object::Code; + use object::Entity; + use object::ExportSnippet; + use object::FootnoteReference; + use object::InlineBabelCall; + use object::InlineSourceBlock; + use object::Italic; + use object::LatexFragment; + use object::LineBreak; + use object::Object; + use object::OrgMacro; + use object::PlainLink; + use object::PlainText; + use object::RadioLink; + use object::RadioTarget; + use object::RegularLink; + use object::StatisticsCookie; + use object::StrikeThrough; + use object::Subscript; + use object::Superscript; + use object::Target; + use object::Timestamp; + use object::Underline; + use object::Verbatim; + use source::SetSource; + use source::Source; diff --git a/src/types/object.rs b/src/types/object.rs index 7e5da11..f3569c2 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -1,7 +1,7 @@ use super::Source; #[derive(Debug, PartialEq)] -pub enum Object<'s> { + enum Object<'s> { Bold(Bold<'s>), Italic(Italic<'s>), Underline(Underline<'s>), @@ -32,157 +32,157 @@ pub enum Object<'s> { } #[derive(Debug, PartialEq)] -pub struct Bold<'s> { - pub source: &'s str, - pub children: Vec>, + struct Bold<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug, PartialEq)] -pub struct Italic<'s> { - pub source: &'s str, - pub children: Vec>, + struct Italic<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug, PartialEq)] -pub struct Underline<'s> { - pub source: &'s str, - pub children: Vec>, + struct Underline<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug, PartialEq)] -pub struct StrikeThrough<'s> { - pub source: &'s str, - pub children: Vec>, + struct StrikeThrough<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug, PartialEq)] -pub struct Code<'s> { - pub source: &'s str, - pub contents: &'s str, + struct Code<'s> { + source: &'s str, + contents: &'s str, } #[derive(Debug, PartialEq)] -pub struct Verbatim<'s> { - pub source: &'s str, - pub contents: &'s str, + struct Verbatim<'s> { + source: &'s str, + contents: &'s str, } #[derive(Debug, PartialEq)] -pub struct PlainText<'s> { - pub source: &'s str, + struct PlainText<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct RegularLink<'s> { - pub source: &'s str, + struct RegularLink<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct RadioTarget<'s> { - pub source: &'s str, - pub children: Vec>, + struct RadioTarget<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug, PartialEq)] -pub struct RadioLink<'s> { - pub source: &'s str, - pub children: Vec>, + struct RadioLink<'s> { + source: &'s str, + children: Vec>, } #[derive(Debug, PartialEq)] -pub struct PlainLink<'s> { - pub source: &'s str, - pub link_type: &'s str, - pub path: &'s str, + struct PlainLink<'s> { + source: &'s str, + link_type: &'s str, + path: &'s str, } #[derive(Debug, PartialEq)] -pub struct AngleLink<'s> { - pub source: &'s str, - pub link_type: &'s str, - pub path: &'s str, + struct AngleLink<'s> { + source: &'s str, + link_type: &'s str, + path: &'s str, } #[derive(Debug, PartialEq)] -pub struct OrgMacro<'s> { - pub source: &'s str, - pub macro_name: &'s str, - pub macro_args: Vec<&'s str>, + struct OrgMacro<'s> { + source: &'s str, + macro_name: &'s str, + macro_args: Vec<&'s str>, } #[derive(Debug, PartialEq)] -pub struct Entity<'s> { - pub source: &'s str, - pub entity_name: &'s str, + struct Entity<'s> { + source: &'s str, + entity_name: &'s str, } #[derive(Debug, PartialEq)] -pub struct LatexFragment<'s> { - pub source: &'s str, + struct LatexFragment<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct ExportSnippet<'s> { - pub source: &'s str, - pub backend: &'s str, - pub contents: Option<&'s str>, + struct ExportSnippet<'s> { + source: &'s str, + backend: &'s str, + contents: Option<&'s str>, } #[derive(Debug, PartialEq)] -pub struct FootnoteReference<'s> { - pub source: &'s str, - pub label: Option<&'s str>, - pub definition: Vec>, + struct FootnoteReference<'s> { + source: &'s str, + label: Option<&'s str>, + definition: Vec>, } #[derive(Debug, PartialEq)] -pub struct Citation<'s> { - pub source: &'s str, + struct Citation<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct CitationReference<'s> { - pub source: &'s str, + struct CitationReference<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct InlineBabelCall<'s> { - pub source: &'s str, + struct InlineBabelCall<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct InlineSourceBlock<'s> { - pub source: &'s str, + struct InlineSourceBlock<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct LineBreak<'s> { - pub source: &'s str, + struct LineBreak<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct Target<'s> { - pub source: &'s str, + struct Target<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct StatisticsCookie<'s> { - pub source: &'s str, + struct StatisticsCookie<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct Subscript<'s> { - pub source: &'s str, + struct Subscript<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct Superscript<'s> { - pub source: &'s str, + struct Superscript<'s> { + source: &'s str, } #[derive(Debug, PartialEq)] -pub struct Timestamp<'s> { - pub source: &'s str, + struct Timestamp<'s> { + source: &'s str, } impl<'s> Source<'s> for Object<'s> { diff --git a/src/types/source.rs b/src/types/source.rs index 5e0b8c4..6c90422 100644 --- a/src/types/source.rs +++ b/src/types/source.rs @@ -1,6 +1,6 @@ -pub trait Source<'s> { + trait Source<'s> { fn get_source(&'s self) -> &'s str; } -pub trait SetSource<'s> { + trait SetSource<'s> { fn set_source(&mut self, source: &'s str); } From 84953c16696e01c95e42734f1be8d7e79ea42072 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 11 Sep 2023 13:13:28 -0400 Subject: [PATCH 2/5] Put back in needed pubs. --- src/compare/diff.rs | 14 +-- src/compare/mod.rs | 10 +- src/compare/parse.rs | 8 +- src/compare/util.rs | 9 +- src/context/context.rs | 34 +++--- src/context/exiting.rs | 2 +- src/context/file_access_interface.rs | 6 +- src/context/global_settings.rs | 12 +- src/context/list.rs | 18 +-- src/context/mod.rs | 28 ++--- src/context/parser_with_context.rs | 2 +- src/error/error.rs | 6 +- src/error/mod.rs | 6 +- src/init_tracing.rs | 8 +- src/lib.rs | 19 +-- src/parser/angle_link.rs | 2 +- src/parser/citation.rs | 2 +- src/parser/citation_reference.rs | 6 +- src/parser/clock.rs | 2 +- src/parser/comment.rs | 4 +- src/parser/diary_sexp.rs | 4 +- src/parser/document.rs | 8 +- src/parser/drawer.rs | 2 +- src/parser/dynamic_block.rs | 2 +- src/parser/element_parser.rs | 4 +- src/parser/entity.rs | 2 +- src/parser/export_snippet.rs | 2 +- src/parser/fixed_width_area.rs | 4 +- src/parser/footnote_definition.rs | 6 +- src/parser/footnote_reference.rs | 2 +- src/parser/greater_block.rs | 2 +- src/parser/headline.rs | 4 +- src/parser/horizontal_rule.rs | 2 +- src/parser/in_buffer_settings.rs | 4 +- src/parser/inline_babel_call.rs | 2 +- src/parser/inline_source_block.rs | 2 +- src/parser/keyword.rs | 10 +- src/parser/keyword_todo.rs | 2 +- src/parser/latex_environment.rs | 2 +- src/parser/latex_fragment.rs | 10 +- src/parser/lesser_block.rs | 10 +- src/parser/line_break.rs | 2 +- src/parser/mod.rs | 9 +- src/parser/object_parser.rs | 16 +-- src/parser/org_macro.rs | 2 +- src/parser/org_source.rs | 24 ++-- src/parser/paragraph.rs | 2 +- src/parser/plain_link.rs | 4 +- src/parser/plain_list.rs | 6 +- src/parser/plain_text.rs | 2 +- src/parser/planning.rs | 2 +- src/parser/property_drawer.rs | 2 +- src/parser/radio_link.rs | 8 +- src/parser/regular_link.rs | 10 +- src/parser/section.rs | 4 +- src/parser/sexp.rs | 28 +++-- src/parser/statistics_cookie.rs | 6 +- src/parser/subscript_and_superscript.rs | 6 +- src/parser/table.rs | 12 +- src/parser/target.rs | 2 +- src/parser/text_markup.rs | 18 +-- src/parser/timestamp.rs | 2 +- src/parser/token.rs | 8 +- src/parser/util.rs | 36 +++--- src/types/document.rs | 40 +++---- src/types/element.rs | 46 ++++---- src/types/greater_element.rs | 80 ++++++------- src/types/lesser_element.rs | 100 ++++++++-------- src/types/mod.rs | 124 ++++++++++---------- src/types/object.rs | 148 ++++++++++++------------ src/types/source.rs | 4 +- 71 files changed, 522 insertions(+), 515 deletions(-) diff --git a/src/compare/diff.rs b/src/compare/diff.rs index aa9610a..1f26220 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -69,13 +69,13 @@ use crate::types::Verbatim; use crate::types::VerseBlock; #[derive(Debug)] - enum DiffEntry<'s> { +pub enum DiffEntry<'s> { DiffResult(DiffResult<'s>), DiffLayer(DiffLayer<'s>), } #[derive(Debug)] - struct DiffResult<'s> { +pub struct DiffResult<'s> { status: DiffStatus, name: String, message: Option, @@ -86,13 +86,13 @@ use crate::types::VerseBlock; } #[derive(Debug, PartialEq)] - enum DiffStatus { +enum DiffStatus { Good, Bad, } #[derive(Debug)] - struct DiffLayer<'s> { +pub struct DiffLayer<'s> { name: String, children: Vec>, } @@ -126,11 +126,11 @@ impl<'s> DiffEntry<'s> { } } - fn is_bad(&self) -> bool { + pub fn is_bad(&self) -> bool { self.is_immediately_bad() || self.has_bad_children() } - fn print(&self, original_document: &str) -> Result<(), Box> { + pub fn print(&self, original_document: &str) -> Result<(), Box> { self.print_indented(0, original_document) } @@ -374,7 +374,7 @@ fn compare_object<'s>( } } - fn compare_document<'s>( +pub fn compare_document<'s>( emacs: &'s Token<'s>, rust: &'s Document<'s>, ) -> Result, Box> { diff --git a/src/compare/mod.rs b/src/compare/mod.rs index 8f3ebf0..094dda5 100644 --- a/src/compare/mod.rs +++ b/src/compare/mod.rs @@ -1,8 +1,8 @@ mod diff; mod parse; mod util; - use diff::compare_document; - use parse::emacs_parse_anonymous_org_document; - use parse::emacs_parse_file_org_document; - use parse::get_emacs_version; - use parse::get_org_mode_version; +pub use diff::compare_document; +pub use parse::emacs_parse_anonymous_org_document; +pub use parse::emacs_parse_file_org_document; +pub use parse::get_emacs_version; +pub use parse::get_org_mode_version; diff --git a/src/compare/parse.rs b/src/compare/parse.rs index e8a5f5e..700b5b1 100644 --- a/src/compare/parse.rs +++ b/src/compare/parse.rs @@ -1,7 +1,7 @@ use std::path::Path; use std::process::Command; - fn emacs_parse_anonymous_org_document( +pub fn emacs_parse_anonymous_org_document( file_contents: C, ) -> Result> where @@ -31,7 +31,7 @@ where Ok(String::from_utf8(org_sexp)?) } - fn emacs_parse_file_org_document

(file_path: P) -> Result> +pub fn emacs_parse_file_org_document

(file_path: P) -> Result> where P: AsRef, { @@ -85,7 +85,7 @@ where output } - fn get_emacs_version() -> Result> { +pub fn get_emacs_version() -> Result> { let elisp_script = r#"(progn (message "%s" (version)) )"#; @@ -103,7 +103,7 @@ where Ok(String::from_utf8(out.stderr)?) } - fn get_org_mode_version() -> Result> { +pub fn get_org_mode_version() -> Result> { let elisp_script = r#"(progn (org-mode) (message "%s" (org-version nil t nil)) diff --git a/src/compare/util.rs b/src/compare/util.rs index f9a75f9..c14a794 100644 --- a/src/compare/util.rs +++ b/src/compare/util.rs @@ -21,7 +21,10 @@ fn get_offsets<'s, S: Source<'s>>(source: &'s str, rust_object: &'s S) -> (usize (offset, end) } - fn assert_name<'s>(emacs: &'s Token<'s>, name: &str) -> Result<(), Box> { +pub(crate) fn assert_name<'s>( + emacs: &'s Token<'s>, + name: &str, +) -> Result<(), Box> { let children = emacs.as_list()?; let first_child = children .first() @@ -37,7 +40,7 @@ fn get_offsets<'s, S: Source<'s>>(source: &'s str, rust_object: &'s S) -> (usize Ok(()) } - fn assert_bounds<'s, S: Source<'s>>( +pub(crate) fn assert_bounds<'s, S: Source<'s>>( source: &'s str, emacs: &'s Token<'s>, rust: &'s S, @@ -146,7 +149,7 @@ fn maybe_token_to_usize( /// Returns Ok(None) if value is nil. /// /// Returns error if the attribute is not specified on the token at all. - fn get_property<'s, 'x>( +pub(crate) fn get_property<'s, 'x>( emacs: &'s Token<'s>, key: &'x str, ) -> Result>, Box> { diff --git a/src/context/context.rs b/src/context/context.rs index 75a9e9f..d57b5fd 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -14,7 +14,7 @@ use crate::error::Res; use crate::parser::OrgSource; #[derive(Debug)] - enum ContextElement<'r, 's> { +pub(crate) enum ContextElement<'r, 's> { /// Stores a parser that indicates that children should exit upon matching an exit matcher. ExitMatcherNode(ExitMatcherNode<'r>), @@ -31,10 +31,10 @@ use crate::parser::OrgSource; Placeholder(PhantomData<&'s str>), } - struct ExitMatcherNode<'r> { +pub(crate) struct ExitMatcherNode<'r> { // TODO: Should this be "&'r DynContextMatcher<'c>" ? - exit_matcher: &'r DynContextMatcher<'r>, - class: ExitClass, + pub(crate) exit_matcher: &'r DynContextMatcher<'r>, + pub(crate) class: ExitClass, } impl<'r> std::fmt::Debug for ExitMatcherNode<'r> { @@ -46,13 +46,13 @@ impl<'r> std::fmt::Debug for ExitMatcherNode<'r> { } #[derive(Debug)] - struct Context<'g, 'r, 's> { +pub(crate) struct Context<'g, 'r, 's> { global_settings: &'g GlobalSettings<'g, 's>, tree: List<'r, &'r ContextElement<'r, 's>>, } impl<'g, 'r, 's> Context<'g, 'r, 's> { - fn new( + pub(crate) fn new( global_settings: &'g GlobalSettings<'g, 's>, tree: List<'r, &'r ContextElement<'r, 's>>, ) -> Self { @@ -62,38 +62,38 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { } } - fn with_additional_node(&'r self, new_element: &'r ContextElement<'r, 's>) -> Self { + pub(crate) fn with_additional_node(&'r self, new_element: &'r ContextElement<'r, 's>) -> Self { let new_tree = self.tree.push(new_element); Self::new(self.global_settings, new_tree) } - fn iter(&'r self) -> super::list::Iter<'r, &'r ContextElement<'r, 's>> { + pub(crate) fn iter(&'r self) -> super::list::Iter<'r, &'r ContextElement<'r, 's>> { self.tree.iter() } - fn iter_context(&'r self) -> Iter<'g, 'r, 's> { + fn iter_context(&'r self) -> Iter<'g, 'r, 's> { Iter { next: self.tree.iter_list(), global_settings: self.global_settings, } } - fn get_parent(&'r self) -> Option { + pub(crate) fn get_parent(&'r self) -> Option { self.tree.get_parent().map(|parent_tree| Self { global_settings: self.global_settings, tree: parent_tree.clone(), }) } - fn get_data(&self) -> &ContextElement<'r, 's> { + fn get_data(&self) -> &ContextElement<'r, 's> { self.tree.get_data() } - fn get_global_settings(&self) -> &'g GlobalSettings<'g, 's> { + pub(crate) fn get_global_settings(&self) -> &'g GlobalSettings<'g, 's> { self.global_settings } - fn with_global_settings<'gg>( + pub(crate) fn with_global_settings<'gg>( &self, new_settings: &'gg GlobalSettings<'gg, 's>, ) -> Context<'gg, 'r, 's> { @@ -104,7 +104,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn check_exit_matcher( + pub(crate) fn check_exit_matcher( &'r self, i: OrgSource<'s>, ) -> IResult, OrgSource<'s>, CustomError>> { @@ -133,7 +133,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { /// Indicates if elements should consume the whitespace after them. /// /// Defaults to true. - fn should_consume_trailing_whitespace(&self) -> bool { + pub(crate) fn should_consume_trailing_whitespace(&self) -> bool { self._should_consume_trailing_whitespace().unwrap_or(true) } @@ -158,7 +158,7 @@ fn document_end<'b, 'g, 'r, 's>( eof(input) } - struct Iter<'g, 'r, 's> { +struct Iter<'g, 'r, 's> { global_settings: &'g GlobalSettings<'g, 's>, next: super::list::IterList<'r, &'r ContextElement<'r, 's>>, } @@ -175,7 +175,7 @@ impl<'g, 'r, 's> Iterator for Iter<'g, 'r, 's> { } impl<'r, 's> ContextElement<'r, 's> { - fn document_context() -> Self { + pub(crate) fn document_context() -> Self { Self::ExitMatcherNode(ExitMatcherNode { exit_matcher: &document_end, class: ExitClass::Document, diff --git a/src/context/exiting.rs b/src/context/exiting.rs index f1b37a0..d8ed86f 100644 --- a/src/context/exiting.rs +++ b/src/context/exiting.rs @@ -1,5 +1,5 @@ #[derive(Debug, Copy, Clone)] - enum ExitClass { +pub(crate) enum ExitClass { Document = 1, Alpha = 2, Beta = 3, diff --git a/src/context/file_access_interface.rs b/src/context/file_access_interface.rs index 85e7d51..d54c7cf 100644 --- a/src/context/file_access_interface.rs +++ b/src/context/file_access_interface.rs @@ -1,13 +1,13 @@ use std::fmt::Debug; use std::path::PathBuf; - trait FileAccessInterface: Debug { +pub trait FileAccessInterface: Debug { fn read_file(&self, path: &str) -> Result; } #[derive(Debug, Clone)] - struct LocalFileAccessInterface { - working_directory: Option, +pub struct LocalFileAccessInterface { + pub working_directory: Option, } impl FileAccessInterface for LocalFileAccessInterface { diff --git a/src/context/global_settings.rs b/src/context/global_settings.rs index 76acd58..b0c9305 100644 --- a/src/context/global_settings.rs +++ b/src/context/global_settings.rs @@ -7,15 +7,15 @@ use crate::types::Object; // TODO: Ultimately, I think we'll need most of this: https://orgmode.org/manual/In_002dbuffer-Settings.html #[derive(Debug, Clone)] - struct GlobalSettings<'g, 's> { - radio_targets: Vec<&'g Vec>>, - file_access: &'g dyn FileAccessInterface, - in_progress_todo_keywords: BTreeSet, - complete_todo_keywords: BTreeSet, +pub struct GlobalSettings<'g, 's> { + pub radio_targets: Vec<&'g Vec>>, + pub file_access: &'g dyn FileAccessInterface, + pub in_progress_todo_keywords: BTreeSet, + pub complete_todo_keywords: BTreeSet, } impl<'g, 's> GlobalSettings<'g, 's> { - fn new() -> GlobalSettings<'g, 's> { + fn new() -> GlobalSettings<'g, 's> { GlobalSettings { radio_targets: Vec::new(), file_access: &LocalFileAccessInterface { diff --git a/src/context/list.rs b/src/context/list.rs index 0033883..e23104d 100644 --- a/src/context/list.rs +++ b/src/context/list.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; #[derive(Debug, Clone)] - struct List<'parent, T> { +pub(crate) struct List<'parent, T> { data: T, parent: Link<'parent, T>, } @@ -9,30 +9,30 @@ use std::fmt::Debug; type Link<'parent, T> = Option<&'parent List<'parent, T>>; impl<'parent, T> List<'parent, T> { - fn new(first_item: T) -> Self { + pub(crate) fn new(first_item: T) -> Self { Self { data: first_item, parent: None, } } - fn get_data(&self) -> &T { + pub(crate) fn get_data(&self) -> &T { &self.data } - fn get_parent(&'parent self) -> Link<'parent, T> { + pub(crate) fn get_parent(&'parent self) -> Link<'parent, T> { self.parent } - fn iter(&self) -> Iter<'_, T> { + pub(crate) fn iter(&self) -> Iter<'_, T> { Iter { next: Some(self) } } - fn iter_list(&self) -> IterList<'_, T> { + pub(crate) fn iter_list(&self) -> IterList<'_, T> { IterList { next: Some(self) } } - fn push(&'parent self, item: T) -> Self { + pub(crate) fn push(&'parent self, item: T) -> Self { Self { data: item, parent: Some(self), @@ -40,7 +40,7 @@ impl<'parent, T> List<'parent, T> { } } - struct Iter<'a, T> { +pub(crate) struct Iter<'a, T> { next: Link<'a, T>, } @@ -54,7 +54,7 @@ impl<'a, T> Iterator for Iter<'a, T> { } } - struct IterList<'a, T> { +pub(crate) struct IterList<'a, T> { next: Link<'a, T>, } diff --git a/src/context/mod.rs b/src/context/mod.rs index bc1368a..a396cd3 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -8,22 +8,22 @@ mod global_settings; mod list; mod parser_with_context; - type RefContext<'b, 'g, 'r, 's> = &'b Context<'g, 'r, 's>; - trait ContextMatcher = for<'b, 'g, 'r, 's> Fn( +pub(crate) type RefContext<'b, 'g, 'r, 's> = &'b Context<'g, 'r, 's>; +pub(crate) trait ContextMatcher = for<'b, 'g, 'r, 's> Fn( RefContext<'b, 'g, 'r, 's>, OrgSource<'s>, ) -> Res, OrgSource<'s>>; - type DynContextMatcher<'c> = dyn ContextMatcher + 'c; - trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res, OrgSource<'s>>; +type DynContextMatcher<'c> = dyn ContextMatcher + 'c; +pub(crate) trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res, OrgSource<'s>>; #[allow(dead_code)] - type DynMatcher<'c> = dyn Matcher + 'c; +type DynMatcher<'c> = dyn Matcher + 'c; - use context::Context; - use context::ContextElement; - use context::ExitMatcherNode; - use exiting::ExitClass; - use file_access_interface::FileAccessInterface; - use file_access_interface::LocalFileAccessInterface; - use global_settings::GlobalSettings; - use list::List; -(crate) use parser_with_context::parser_with_context; +pub(crate) use context::Context; +pub(crate) use context::ContextElement; +pub(crate) use context::ExitMatcherNode; +pub(crate) use exiting::ExitClass; +pub use file_access_interface::FileAccessInterface; +pub use file_access_interface::LocalFileAccessInterface; +pub use global_settings::GlobalSettings; +pub(crate) use list::List; +pub(crate) use parser_with_context::parser_with_context; diff --git a/src/context/parser_with_context.rs b/src/context/parser_with_context.rs index 75e3370..6705d47 100644 --- a/src/context/parser_with_context.rs +++ b/src/context/parser_with_context.rs @@ -3,4 +3,4 @@ macro_rules! parser_with_context { move |context| move |i| $target(context, i) }; } -(crate) use parser_with_context; +pub(crate) use parser_with_context; diff --git a/src/error/error.rs b/src/error/error.rs index fcad643..d6a882c 100644 --- a/src/error/error.rs +++ b/src/error/error.rs @@ -2,18 +2,18 @@ use nom::error::ErrorKind; use nom::error::ParseError; use nom::IResult; - type Res = IResult>; +pub(crate) type Res = IResult>; // TODO: MyError probably shouldn't be based on the same type as the input type since it's used exclusively with static strings right now. #[derive(Debug)] - enum CustomError { +pub enum CustomError { MyError(MyError), Nom(I, ErrorKind), IO(std::io::Error), } #[derive(Debug)] - struct MyError( I); +pub struct MyError(pub(crate) I); impl ParseError for CustomError { fn from_error_kind(input: I, kind: ErrorKind) -> Self { diff --git a/src/error/mod.rs b/src/error/mod.rs index 7cd9a46..25109b4 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -1,4 +1,4 @@ mod error; - use error::CustomError; - use error::MyError; - use error::Res; +pub(crate) use error::CustomError; +pub(crate) use error::MyError; +pub(crate) use error::Res; diff --git a/src/init_tracing.rs b/src/init_tracing.rs index a9dc80c..84e2bf7 100644 --- a/src/init_tracing.rs +++ b/src/init_tracing.rs @@ -10,7 +10,7 @@ const SERVICE_NAME: &'static str = "organic"; // Despite the obvious verbosity that fully-qualifying everything causes, in these functions I am fully-qualifying everything relating to tracing. This is because the tracing feature involves multiple libraries working together and so I think it is beneficial to see which libraries contribute which bits. #[cfg(feature = "tracing")] - fn init_telemetry() -> Result<(), Box> { +pub(crate) fn init_telemetry() -> Result<(), Box> { // by default it will hit http://localhost:4317 with a gRPC payload // TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned. let exporter = opentelemetry_otlp::new_exporter() @@ -55,17 +55,17 @@ const SERVICE_NAME: &'static str = "organic"; } #[cfg(feature = "tracing")] - fn shutdown_telemetry() -> Result<(), Box> { +pub(crate) fn shutdown_telemetry() -> Result<(), Box> { opentelemetry::global::shutdown_tracer_provider(); Ok(()) } #[cfg(not(feature = "tracing"))] - fn init_telemetry() -> Result<(), Box> { +pub(crate) fn init_telemetry() -> Result<(), Box> { Ok(()) } #[cfg(not(feature = "tracing"))] - fn shutdown_telemetry() -> Result<(), Box> { +pub(crate) fn shutdown_telemetry() -> Result<(), Box> { Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index 7cba5b3..afc3796 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,20 +6,21 @@ #[cfg(feature = "compare")] mod compare; #[cfg(feature = "compare")] - use compare::compare_document; +pub use compare::compare_document; #[cfg(feature = "compare")] - use compare::emacs_parse_anonymous_org_document; +pub use compare::emacs_parse_anonymous_org_document; #[cfg(feature = "compare")] - use compare::emacs_parse_file_org_document; +pub use compare::emacs_parse_file_org_document; #[cfg(feature = "compare")] - use compare::get_emacs_version; +pub use compare::get_emacs_version; #[cfg(feature = "compare")] - use compare::get_org_mode_version; +pub use compare::get_org_mode_version; mod context; mod error; - mod parser; - mod types; +pub mod parser; +pub mod types; - use context::GlobalSettings; - use context::LocalFileAccessInterface; +pub use context::FileAccessInterface; +pub use context::GlobalSettings; +pub use context::LocalFileAccessInterface; diff --git a/src/parser/angle_link.rs b/src/parser/angle_link.rs index 1537ee0..113b622 100644 --- a/src/parser/angle_link.rs +++ b/src/parser/angle_link.rs @@ -18,7 +18,7 @@ use crate::parser::util::get_consumed; use crate::types::AngleLink; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn angle_link<'b, 'g, 'r, 's>( +pub(crate) fn angle_link<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, AngleLink<'s>> { diff --git a/src/parser/citation.rs b/src/parser/citation.rs index 2f00b74..0da4407 100644 --- a/src/parser/citation.rs +++ b/src/parser/citation.rs @@ -31,7 +31,7 @@ use crate::types::Citation; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn citation<'b, 'g, 'r, 's>( +pub(crate) fn citation<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Citation<'s>> { diff --git a/src/parser/citation_reference.rs b/src/parser/citation_reference.rs index 488229d..696d9a4 100644 --- a/src/parser/citation_reference.rs +++ b/src/parser/citation_reference.rs @@ -29,7 +29,7 @@ use crate::types::CitationReference; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn citation_reference<'b, 'g, 'r, 's>( +pub(crate) fn citation_reference<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, CitationReference<'s>> { @@ -49,7 +49,7 @@ use crate::types::Object; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn citation_reference_key<'b, 'g, 'r, 's>( +pub(crate) fn citation_reference_key<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -161,7 +161,7 @@ fn _key_suffix_end<'b, 'g, 'r, 's>( tag(";")(input) } - fn must_balance_bracket<'s, F, O>( +pub(crate) fn must_balance_bracket<'s, F, O>( mut inner: F, ) -> impl FnMut(OrgSource<'s>) -> Res, O> where diff --git a/src/parser/clock.rs b/src/parser/clock.rs index 4570358..8605444 100644 --- a/src/parser/clock.rs +++ b/src/parser/clock.rs @@ -20,7 +20,7 @@ use crate::parser::util::start_of_line; use crate::types::Clock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn clock<'b, 'g, 'r, 's>( +pub(crate) fn clock<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Clock<'s>> { diff --git a/src/parser/comment.rs b/src/parser/comment.rs index 046c07e..c2f761d 100644 --- a/src/parser/comment.rs +++ b/src/parser/comment.rs @@ -25,7 +25,7 @@ use crate::parser::util::start_of_line; use crate::types::Comment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn comment<'b, 'g, 'r, 's>( +pub(crate) fn comment<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Comment<'s>> { @@ -68,7 +68,7 @@ fn comment_line<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_comment<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn detect_comment<'s>(input: OrgSource<'s>) -> Res, ()> { tuple(( start_of_line, space0, diff --git a/src/parser/diary_sexp.rs b/src/parser/diary_sexp.rs index bae57fc..ac1957b 100644 --- a/src/parser/diary_sexp.rs +++ b/src/parser/diary_sexp.rs @@ -13,7 +13,7 @@ use crate::parser::util::start_of_line; use crate::types::DiarySexp; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn diary_sexp<'b, 'g, 'r, 's>( +pub(crate) fn diary_sexp<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, DiarySexp<'s>> { @@ -32,7 +32,7 @@ use crate::types::DiarySexp; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_diary_sexp<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn detect_diary_sexp<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, tag("%%(")))(input)?; Ok((input, ())) } diff --git a/src/parser/document.rs b/src/parser/document.rs index d8158ae..e176a1c 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -28,7 +28,7 @@ use crate::types::Object; /// /// This is the main entry point for Organic. It will parse the full contents of the input string as an org-mode document. #[allow(dead_code)] - fn parse<'s>(input: &'s str) -> Result, String> { +pub fn parse<'s>(input: &'s str) -> Result, String> { parse_with_settings(input, &GlobalSettings::default()) } @@ -38,7 +38,7 @@ use crate::types::Object; /// /// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO". #[allow(dead_code)] - fn parse_with_settings<'g, 's>( +pub fn parse_with_settings<'g, 's>( input: &'s str, global_settings: &'g GlobalSettings<'g, 's>, ) -> Result, String> { @@ -58,7 +58,7 @@ use crate::types::Object; /// /// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO". #[allow(dead_code)] - fn document<'b, 'g, 'r, 's>( +fn document<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: &'s str, ) -> Res<&'s str, Document<'s>> { @@ -157,7 +157,7 @@ fn _document<'b, 'g, 'r, 's>( } impl<'s> Document<'s> { - fn iter_tokens<'r>(&'r self) -> impl Iterator> { + fn iter_tokens<'r>(&'r self) -> impl Iterator> { AllTokensIterator::new(Token::Document(self)) } } diff --git a/src/parser/drawer.rs b/src/parser/drawer.rs index f30813f..0d28e45 100644 --- a/src/parser/drawer.rs +++ b/src/parser/drawer.rs @@ -32,7 +32,7 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn drawer<'b, 'g, 'r, 's>( +pub(crate) fn drawer<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Drawer<'s>> { diff --git a/src/parser/dynamic_block.rs b/src/parser/dynamic_block.rs index 738ab76..d368385 100644 --- a/src/parser/dynamic_block.rs +++ b/src/parser/dynamic_block.rs @@ -32,7 +32,7 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn dynamic_block<'b, 'g, 'r, 's>( +pub(crate) fn dynamic_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, DynamicBlock<'s>> { diff --git a/src/parser/element_parser.rs b/src/parser/element_parser.rs index 7cfa078..e210384 100644 --- a/src/parser/element_parser.rs +++ b/src/parser/element_parser.rs @@ -40,7 +40,7 @@ use crate::parser::table::org_mode_table; use crate::types::Element; use crate::types::SetSource; - const fn element( +pub(crate) const fn element( can_be_paragraph: bool, ) -> impl for<'b, 'g, 'r, 's> Fn( RefContext<'b, 'g, 'r, 's>, @@ -127,7 +127,7 @@ fn _element<'b, 'g, 'r, 's>( Ok((remaining, element)) } - const fn detect_element( +pub(crate) const fn detect_element( can_be_paragraph: bool, ) -> impl for<'b, 'g, 'r, 's> Fn(RefContext<'b, 'g, 'r, 's>, OrgSource<'s>) -> Res, ()> { diff --git a/src/parser/entity.rs b/src/parser/entity.rs index 1fddc23..4fcb8cf 100644 --- a/src/parser/entity.rs +++ b/src/parser/entity.rs @@ -433,7 +433,7 @@ const ORG_ENTITIES: [&'static str; 413] = [ ]; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn entity<'b, 'g, 'r, 's>( +pub(crate) fn entity<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Entity<'s>> { diff --git a/src/parser/export_snippet.rs b/src/parser/export_snippet.rs index e46e6db..5b99f39 100644 --- a/src/parser/export_snippet.rs +++ b/src/parser/export_snippet.rs @@ -20,7 +20,7 @@ use crate::parser::util::get_consumed; use crate::types::ExportSnippet; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn export_snippet<'b, 'g, 'r, 's>( +pub(crate) fn export_snippet<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExportSnippet<'s>> { diff --git a/src/parser/fixed_width_area.rs b/src/parser/fixed_width_area.rs index bec9ba5..449774f 100644 --- a/src/parser/fixed_width_area.rs +++ b/src/parser/fixed_width_area.rs @@ -21,7 +21,7 @@ use crate::parser::util::start_of_line; use crate::types::FixedWidthArea; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn fixed_width_area<'b, 'g, 'r, 's>( +pub(crate) fn fixed_width_area<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FixedWidthArea<'s>> { @@ -57,7 +57,7 @@ fn fixed_width_area_line<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_fixed_width_area<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn detect_fixed_width_area<'s>(input: OrgSource<'s>) -> Res, ()> { tuple(( start_of_line, space0, diff --git a/src/parser/footnote_definition.rs b/src/parser/footnote_definition.rs index 64fe292..a344697 100644 --- a/src/parser/footnote_definition.rs +++ b/src/parser/footnote_definition.rs @@ -33,7 +33,7 @@ use crate::parser::util::start_of_line; use crate::types::FootnoteDefinition; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn footnote_definition<'b, 'g, 'r, 's>( +pub(crate) fn footnote_definition<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteDefinition<'s>> { @@ -93,7 +93,7 @@ use crate::types::FootnoteDefinition; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn label<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { +pub(crate) fn label<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { alt(( digit1, take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c)), @@ -122,7 +122,7 @@ fn footnote_definition_end<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_footnote_definition<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn detect_footnote_definition<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, tag_no_case("[fn:"), label, tag("]")))(input)?; Ok((input, ())) } diff --git a/src/parser/footnote_reference.rs b/src/parser/footnote_reference.rs index 18d1092..1247a70 100644 --- a/src/parser/footnote_reference.rs +++ b/src/parser/footnote_reference.rs @@ -23,7 +23,7 @@ use crate::parser::util::get_consumed; use crate::types::FootnoteReference; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn footnote_reference<'b, 'g, 'r, 's>( +pub(crate) fn footnote_reference<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, FootnoteReference<'s>> { diff --git a/src/parser/greater_block.rs b/src/parser/greater_block.rs index 4c9f74b..1721163 100644 --- a/src/parser/greater_block.rs +++ b/src/parser/greater_block.rs @@ -33,7 +33,7 @@ use crate::types::Paragraph; use crate::types::SetSource; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn greater_block<'b, 'g, 'r, 's>( +pub(crate) fn greater_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, GreaterBlock<'s>> { diff --git a/src/parser/headline.rs b/src/parser/headline.rs index 6e6bd79..3b472de 100644 --- a/src/parser/headline.rs +++ b/src/parser/headline.rs @@ -36,7 +36,7 @@ use crate::types::Object; use crate::types::PriorityCookie; use crate::types::TodoKeywordType; - const fn heading( +pub(crate) const fn heading( parent_stars: usize, ) -> impl for<'b, 'g, 'r, 's> Fn( RefContext<'b, 'g, 'r, 's>, @@ -95,7 +95,7 @@ fn _heading<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_headline<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn detect_headline<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, many1(tag("*")), space1))(input)?; Ok((input, ())) } diff --git a/src/parser/horizontal_rule.rs b/src/parser/horizontal_rule.rs index f598cd8..9a7413a 100644 --- a/src/parser/horizontal_rule.rs +++ b/src/parser/horizontal_rule.rs @@ -15,7 +15,7 @@ use crate::parser::util::start_of_line; use crate::types::HorizontalRule; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn horizontal_rule<'b, 'g, 'r, 's>( +pub(crate) fn horizontal_rule<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, HorizontalRule<'s>> { diff --git a/src/parser/in_buffer_settings.rs b/src/parser/in_buffer_settings.rs index 1cdb90e..da93d08 100644 --- a/src/parser/in_buffer_settings.rs +++ b/src/parser/in_buffer_settings.rs @@ -13,7 +13,7 @@ use crate::types::Keyword; use crate::GlobalSettings; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn scan_for_in_buffer_settings<'s>( +pub(crate) fn scan_for_in_buffer_settings<'s>( input: OrgSource<'s>, ) -> Res, Vec>> { // TODO: Optimization idea: since this is slicing the OrgSource at each character, it might be more efficient to do a parser that uses a search function like take_until, and wrap it in a function similar to consumed but returning the input along with the normal output, then pass all of that into a verify that confirms we were at the start of a line using the input we just returned. @@ -44,7 +44,7 @@ fn in_buffer_settings_key<'s>(input: OrgSource<'s>) -> Res, OrgSou ))(input) } - fn apply_in_buffer_settings<'g, 's, 'sf>( +pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>( keywords: Vec>, original_settings: &'g GlobalSettings<'g, 's>, ) -> Result, String> { diff --git a/src/parser/inline_babel_call.rs b/src/parser/inline_babel_call.rs index 951d8fd..ce5c97c 100644 --- a/src/parser/inline_babel_call.rs +++ b/src/parser/inline_babel_call.rs @@ -26,7 +26,7 @@ use crate::parser::util::get_consumed; use crate::types::InlineBabelCall; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn inline_babel_call<'b, 'g, 'r, 's>( +pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, InlineBabelCall<'s>> { diff --git a/src/parser/inline_source_block.rs b/src/parser/inline_source_block.rs index 4216cfd..6e5cd5f 100644 --- a/src/parser/inline_source_block.rs +++ b/src/parser/inline_source_block.rs @@ -28,7 +28,7 @@ use crate::parser::util::get_consumed; use crate::types::InlineSourceBlock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn inline_source_block<'b, 'g, 'r, 's>( +pub(crate) fn inline_source_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, InlineSourceBlock<'s>> { diff --git a/src/parser/keyword.rs b/src/parser/keyword.rs index 77bec7a..4a71976 100644 --- a/src/parser/keyword.rs +++ b/src/parser/keyword.rs @@ -31,7 +31,7 @@ const ORG_ELEMENT_AFFILIATED_KEYWORDS: [&'static str; 13] = [ ]; const ORG_ELEMENT_DUAL_KEYWORDS: [&'static str; 2] = ["caption", "results"]; - fn filtered_keyword( +pub(crate) fn filtered_keyword( key_parser: F, ) -> impl for<'s> Fn(OrgSource<'s>) -> Res, Keyword<'s>> { move |input| _filtered_keyword(&key_parser, input) @@ -83,7 +83,7 @@ fn _filtered_keyword<'s, F: Matcher>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn keyword<'b, 'g, 'r, 's>( +pub(crate) fn keyword<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { @@ -91,7 +91,7 @@ fn _filtered_keyword<'s, F: Matcher>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn affiliated_keyword<'b, 'g, 'r, 's>( +pub(crate) fn affiliated_keyword<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { @@ -99,7 +99,7 @@ fn _filtered_keyword<'s, F: Matcher>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn babel_call_keyword<'b, 'g, 'r, 's>( +pub(crate) fn babel_call_keyword<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { @@ -112,7 +112,7 @@ fn babel_call_key<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn table_formula_keyword<'b, 'g, 'r, 's>( +pub(crate) fn table_formula_keyword<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Keyword<'s>> { diff --git a/src/parser/keyword_todo.rs b/src/parser/keyword_todo.rs index 4ec11b9..5a009ea 100644 --- a/src/parser/keyword_todo.rs +++ b/src/parser/keyword_todo.rs @@ -19,7 +19,7 @@ use crate::error::Res; /// Parses the text in the value of a #+TODO keyword. /// /// Example input: "foo bar baz | lorem ipsum" - fn todo_keywords<'s>(input: &'s str) -> Res<&'s str, (Vec<&'s str>, Vec<&'s str>)> { +pub(crate) fn todo_keywords<'s>(input: &'s str) -> Res<&'s str, (Vec<&'s str>, Vec<&'s str>)> { let (remaining, mut before_pipe_words) = separated_list0(space1, todo_keyword_word)(input)?; let (remaining, after_pipe_words) = opt(tuple(( tuple((space0, tag("|"), space0)), diff --git a/src/parser/latex_environment.rs b/src/parser/latex_environment.rs index 16b99ec..9635ad8 100644 --- a/src/parser/latex_environment.rs +++ b/src/parser/latex_environment.rs @@ -25,7 +25,7 @@ use crate::parser::util::start_of_line; use crate::types::LatexEnvironment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn latex_environment<'b, 'g, 'r, 's>( +pub(crate) fn latex_environment<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LatexEnvironment<'s>> { diff --git a/src/parser/latex_fragment.rs b/src/parser/latex_fragment.rs index 5616e22..f7355bc 100644 --- a/src/parser/latex_fragment.rs +++ b/src/parser/latex_fragment.rs @@ -24,7 +24,7 @@ use crate::parser::util::get_consumed; use crate::types::LatexFragment; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn latex_fragment<'b, 'g, 'r, 's>( +pub(crate) fn latex_fragment<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LatexFragment<'s>> { @@ -174,7 +174,7 @@ fn dollar_char_fragment<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn pre<'b, 'g, 'r, 's>( +fn pre<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -188,7 +188,7 @@ fn dollar_char_fragment<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn post<'b, 'g, 'r, 's>( +fn post<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -226,7 +226,7 @@ fn bordered_dollar_fragment<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn open_border<'b, 'g, 'r, 's>( +fn open_border<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -234,7 +234,7 @@ fn bordered_dollar_fragment<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn close_border<'b, 'g, 'r, 's>( +fn close_border<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { diff --git a/src/parser/lesser_block.rs b/src/parser/lesser_block.rs index abba68c..f899c91 100644 --- a/src/parser/lesser_block.rs +++ b/src/parser/lesser_block.rs @@ -35,7 +35,7 @@ use crate::types::SrcBlock; use crate::types::VerseBlock; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn verse_block<'b, 'g, 'r, 's>( +pub(crate) fn verse_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, VerseBlock<'s>> { @@ -90,7 +90,7 @@ use crate::types::VerseBlock; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn comment_block<'b, 'g, 'r, 's>( +pub(crate) fn comment_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, CommentBlock<'s>> { @@ -130,7 +130,7 @@ use crate::types::VerseBlock; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn example_block<'b, 'g, 'r, 's>( +pub(crate) fn example_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExampleBlock<'s>> { @@ -170,7 +170,7 @@ use crate::types::VerseBlock; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn export_block<'b, 'g, 'r, 's>( +pub(crate) fn export_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ExportBlock<'s>> { @@ -211,7 +211,7 @@ use crate::types::VerseBlock; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn src_block<'b, 'g, 'r, 's>( +pub(crate) fn src_block<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, SrcBlock<'s>> { diff --git a/src/parser/line_break.rs b/src/parser/line_break.rs index dbbefb1..30c8eca 100644 --- a/src/parser/line_break.rs +++ b/src/parser/line_break.rs @@ -13,7 +13,7 @@ use crate::parser::util::get_consumed; use crate::types::LineBreak; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn line_break<'b, 'g, 'r, 's>( +pub(crate) fn line_break<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, LineBreak<'s>> { diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 22e0e38..fefe908 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -37,7 +37,7 @@ mod property_drawer; mod radio_link; mod regular_link; mod section; - mod sexp; +pub mod sexp; mod statistics_cookie; mod subscript_and_superscript; mod table; @@ -46,7 +46,6 @@ mod text_markup; mod timestamp; mod token; mod util; - use document::document; - use document::parse; - use document::parse_with_settings; - use org_source::OrgSource; +pub use document::parse; +pub use document::parse_with_settings; +pub(crate) use org_source::OrgSource; diff --git a/src/parser/object_parser.rs b/src/parser/object_parser.rs index 07e430e..f672855 100644 --- a/src/parser/object_parser.rs +++ b/src/parser/object_parser.rs @@ -32,7 +32,7 @@ use crate::parser::timestamp::timestamp; use crate::types::Object; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn standard_set_object<'b, 'g, 'r, 's>( +pub(crate) fn standard_set_object<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -47,7 +47,7 @@ use crate::types::Object; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn minimal_set_object<'b, 'g, 'r, 's>( +pub(crate) fn minimal_set_object<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -140,7 +140,7 @@ fn minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( +pub(crate) fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -174,7 +174,7 @@ fn detect_minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn regular_link_description_set_object<'b, 'g, 'r, 's>( +pub(crate) fn regular_link_description_set_object<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -221,7 +221,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( +fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -238,7 +238,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn table_cell_set_object<'b, 'g, 'r, 's>( +pub(crate) fn table_cell_set_object<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -253,7 +253,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( +fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -287,7 +287,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( +fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { diff --git a/src/parser/org_macro.rs b/src/parser/org_macro.rs index 4c2a993..093dc31 100644 --- a/src/parser/org_macro.rs +++ b/src/parser/org_macro.rs @@ -18,7 +18,7 @@ use crate::parser::util::get_consumed; use crate::types::OrgMacro; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn org_macro<'b, 'g, 'r, 's>( +pub(crate) fn org_macro<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgMacro<'s>> { diff --git a/src/parser/org_source.rs b/src/parser/org_source.rs index 1fae341..4134812 100644 --- a/src/parser/org_source.rs +++ b/src/parser/org_source.rs @@ -11,10 +11,10 @@ use nom::Slice; use crate::error::CustomError; use crate::error::MyError; - type BracketDepth = i16; +pub(crate) type BracketDepth = i16; #[derive(Copy, Clone)] - struct OrgSource<'s> { +pub(crate) struct OrgSource<'s> { full_source: &'s str, start: usize, end: usize, // exclusive @@ -37,7 +37,7 @@ impl<'s> OrgSource<'s> { /// Returns a wrapped string that keeps track of values we need for parsing org-mode. /// /// Only call this on the full original string. Calling this on a substring can result in invalid values. - fn new(input: &'s str) -> Self { + pub(crate) fn new(input: &'s str) -> Self { OrgSource { full_source: input, start: 0, @@ -51,37 +51,37 @@ impl<'s> OrgSource<'s> { } /// Get the text since the line break preceding the start of this WrappedInput. - fn text_since_line_break(&self) -> &'s str { + pub(crate) fn text_since_line_break(&self) -> &'s str { &self.full_source[self.start_of_line..self.start] } - fn len(&self) -> usize { + pub(crate) fn len(&self) -> usize { self.end - self.start } - fn get_preceding_character(&self) -> Option { + pub(crate) fn get_preceding_character(&self) -> Option { self.preceding_character } - fn is_at_start_of_line(&self) -> bool { + pub(crate) fn is_at_start_of_line(&self) -> bool { self.start == self.start_of_line } - fn get_until(&self, other: OrgSource<'s>) -> OrgSource<'s> { + pub(crate) fn get_until(&self, other: OrgSource<'s>) -> OrgSource<'s> { assert!(other.start >= self.start); assert!(other.end <= self.end); self.slice(..(other.start - self.start)) } - fn get_bracket_depth(&self) -> BracketDepth { + pub(crate) fn get_bracket_depth(&self) -> BracketDepth { self.bracket_depth } - fn get_brace_depth(&self) -> BracketDepth { + pub(crate) fn get_brace_depth(&self) -> BracketDepth { self.brace_depth } - fn get_parenthesis_depth(&self) -> BracketDepth { + pub(crate) fn get_parenthesis_depth(&self) -> BracketDepth { self.parenthesis_depth } } @@ -306,7 +306,7 @@ impl<'s> InputTakeAtPosition for OrgSource<'s> { } } - fn convert_error<'a, I: Into>>( +pub(crate) fn convert_error<'a, I: Into>>( err: nom::Err, ) -> nom::Err> { match err { diff --git a/src/parser/paragraph.rs b/src/parser/paragraph.rs index 7771f64..39ed070 100644 --- a/src/parser/paragraph.rs +++ b/src/parser/paragraph.rs @@ -22,7 +22,7 @@ use crate::parser::util::start_of_line; use crate::types::Paragraph; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn paragraph<'b, 'g, 'r, 's>( +pub(crate) fn paragraph<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Paragraph<'s>> { diff --git a/src/parser/plain_link.rs b/src/parser/plain_link.rs index ceccc2e..1827fc3 100644 --- a/src/parser/plain_link.rs +++ b/src/parser/plain_link.rs @@ -53,7 +53,7 @@ const ORG_LINK_PARAMETERS: [&'static str; 23] = [ ]; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn plain_link<'b, 'g, 'r, 's>( +pub(crate) fn plain_link<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainLink<'s>> { @@ -105,7 +105,7 @@ fn post<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn protocol<'b, 'g, 'r, 's>( +pub(crate) fn protocol<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index ed6c716..389c504 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -41,7 +41,7 @@ use crate::types::PlainList; use crate::types::PlainListItem; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_plain_list<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn detect_plain_list<'s>(input: OrgSource<'s>) -> Res, ()> { if verify( tuple(( start_of_line, @@ -63,7 +63,7 @@ use crate::types::PlainListItem; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn plain_list<'b, 'g, 'r, 's>( +pub(crate) fn plain_list<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainList<'s>> { @@ -137,7 +137,7 @@ use crate::types::PlainListItem; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn plain_list_item<'b, 'g, 'r, 's>( +fn plain_list_item<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PlainListItem<'s>> { diff --git a/src/parser/plain_text.rs b/src/parser/plain_text.rs index dffa97f..3b1e3c0 100644 --- a/src/parser/plain_text.rs +++ b/src/parser/plain_text.rs @@ -16,7 +16,7 @@ use crate::error::Res; use crate::types::Object; use crate::types::PlainText; - fn plain_text( +pub(crate) fn plain_text( end_condition: F, ) -> impl for<'b, 'g, 'r, 's> Fn( RefContext<'b, 'g, 'r, 's>, diff --git a/src/parser/planning.rs b/src/parser/planning.rs index 6730d3b..15312bb 100644 --- a/src/parser/planning.rs +++ b/src/parser/planning.rs @@ -18,7 +18,7 @@ use crate::parser::util::start_of_line; use crate::types::Planning; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn planning<'b, 'g, 'r, 's>( +pub(crate) fn planning<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Planning<'s>> { diff --git a/src/parser/property_drawer.rs b/src/parser/property_drawer.rs index 221e2fd..67d86f5 100644 --- a/src/parser/property_drawer.rs +++ b/src/parser/property_drawer.rs @@ -31,7 +31,7 @@ use crate::types::NodeProperty; use crate::types::PropertyDrawer; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn property_drawer<'b, 'g, 'r, 's>( +pub(crate) fn property_drawer<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, PropertyDrawer<'s>> { diff --git a/src/parser/radio_link.rs b/src/parser/radio_link.rs index 55f0581..2276231 100644 --- a/src/parser/radio_link.rs +++ b/src/parser/radio_link.rs @@ -23,7 +23,7 @@ use crate::types::RadioLink; use crate::types::RadioTarget; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn radio_link<'b, 'g, 'r, 's>( +pub(crate) fn radio_link<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RadioLink<'s>> { @@ -47,7 +47,7 @@ use crate::types::RadioTarget; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn rematch_target<'x, 'b, 'g, 'r, 's>( +pub(crate) fn rematch_target<'x, 'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, target: &'x Vec>, input: OrgSource<'s>, @@ -78,7 +78,7 @@ use crate::types::RadioTarget; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn radio_target<'b, 'g, 'r, 's>( +pub(crate) fn radio_target<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RadioTarget<'s>> { @@ -118,7 +118,7 @@ fn radio_target_end<'b, 'g, 'r, 's>( alt((tag("<"), tag(">"), line_ending))(input) } - trait RematchObject<'x> { +pub(crate) trait RematchObject<'x> { fn rematch_object<'b, 'g, 'r, 's>( &'x self, context: RefContext<'b, 'g, 'r, 's>, diff --git a/src/parser/regular_link.rs b/src/parser/regular_link.rs index 75416d1..847b915 100644 --- a/src/parser/regular_link.rs +++ b/src/parser/regular_link.rs @@ -21,7 +21,7 @@ use crate::types::Object; use crate::types::RegularLink; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn regular_link<'b, 'g, 'r, 's>( +pub(crate) fn regular_link<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { @@ -32,7 +32,7 @@ use crate::types::RegularLink; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn regular_link_without_description<'b, 'g, 'r, 's>( +fn regular_link_without_description<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { @@ -51,7 +51,7 @@ use crate::types::RegularLink; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn regular_link_with_description<'b, 'g, 'r, 's>( +fn regular_link_with_description<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, RegularLink<'s>> { @@ -72,7 +72,7 @@ use crate::types::RegularLink; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn pathreg<'b, 'g, 'r, 's>( +fn pathreg<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -88,7 +88,7 @@ use crate::types::RegularLink; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn description<'b, 'g, 'r, 's>( +fn description<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Vec>> { diff --git a/src/parser/section.rs b/src/parser/section.rs index 7b82fbb..d85633f 100644 --- a/src/parser/section.rs +++ b/src/parser/section.rs @@ -25,7 +25,7 @@ use crate::types::Element; use crate::types::Section; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn zeroth_section<'b, 'g, 'r, 's>( +pub(crate) fn zeroth_section<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Section<'s>> { @@ -83,7 +83,7 @@ use crate::types::Section; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn section<'b, 'g, 'r, 's>( +pub(crate) fn section<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, mut input: OrgSource<'s>, ) -> Res, Section<'s>> { diff --git a/src/parser/sexp.rs b/src/parser/sexp.rs index 3eaeb92..1e1a3ea 100644 --- a/src/parser/sexp.rs +++ b/src/parser/sexp.rs @@ -22,7 +22,7 @@ use super::util::get_consumed; use crate::error::Res; #[derive(Debug)] - enum Token<'s> { +pub enum Token<'s> { Atom(&'s str), List(Vec>), TextWithProperties(TextWithProperties<'s>), @@ -30,9 +30,9 @@ use crate::error::Res; } #[derive(Debug)] - struct TextWithProperties<'s> { - text: &'s str, - properties: Vec>, +pub struct TextWithProperties<'s> { + pub(crate) text: &'s str, + pub(crate) properties: Vec>, } enum ParseState { @@ -41,35 +41,39 @@ enum ParseState { } impl<'s> Token<'s> { - fn as_vector<'p>(&'p self) -> Result<&'p Vec>, Box> { + pub(crate) fn as_vector<'p>( + &'p self, + ) -> Result<&'p Vec>, Box> { Ok(match self { Token::Vector(children) => Ok(children), _ => Err(format!("wrong token type, expected vector: {:?}", self)), }?) } - fn as_list<'p>(&'p self) -> Result<&'p Vec>, Box> { + pub(crate) fn as_list<'p>(&'p self) -> Result<&'p Vec>, Box> { Ok(match self { Token::List(children) => Ok(children), _ => Err(format!("wrong token type, expected list: {:?}", self)), }?) } - fn as_atom<'p>(&'p self) -> Result<&'s str, Box> { + pub(crate) fn as_atom<'p>(&'p self) -> Result<&'s str, Box> { Ok(match self { Token::Atom(body) => Ok(*body), _ => Err(format!("wrong token type, expected atom: {:?}", self)), }?) } - fn as_text<'p>(&'p self) -> Result<&'p TextWithProperties<'s>, Box> { + pub(crate) fn as_text<'p>( + &'p self, + ) -> Result<&'p TextWithProperties<'s>, Box> { Ok(match self { Token::TextWithProperties(body) => Ok(body), _ => Err(format!("wrong token type, expected text: {:?}", self)), }?) } - fn as_map<'p>( + pub(crate) fn as_map<'p>( &'p self, ) -> Result>, Box> { let mut hashmap = HashMap::new(); @@ -95,7 +99,7 @@ impl<'s> Token<'s> { } } - fn unquote(text: &str) -> Result> { +pub(crate) fn unquote(text: &str) -> Result> { let mut out = String::with_capacity(text.len()); if !text.starts_with(r#"""#) { return Err("Quoted text does not start with quote.".into()); @@ -132,7 +136,7 @@ impl<'s> Token<'s> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { +pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = multispace0(input)?; let remaining = OrgSource::new(remaining); let (remaining, tkn) = token(remaining) @@ -143,7 +147,7 @@ impl<'s> Token<'s> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn sexp<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn sexp<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { let (remaining, tkn) = token(input)?; Ok((remaining, tkn)) } diff --git a/src/parser/statistics_cookie.rs b/src/parser/statistics_cookie.rs index 5ffe4b7..c2dd44e 100644 --- a/src/parser/statistics_cookie.rs +++ b/src/parser/statistics_cookie.rs @@ -13,7 +13,7 @@ use crate::error::Res; use crate::types::StatisticsCookie; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn statistics_cookie<'b, 'g, 'r, 's>( +pub(crate) fn statistics_cookie<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { @@ -24,7 +24,7 @@ use crate::types::StatisticsCookie; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn percent_statistics_cookie<'b, 'g, 'r, 's>( +fn percent_statistics_cookie<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { @@ -45,7 +45,7 @@ use crate::types::StatisticsCookie; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn fraction_statistics_cookie<'b, 'g, 'r, 's>( +fn fraction_statistics_cookie<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StatisticsCookie<'s>> { diff --git a/src/parser/subscript_and_superscript.rs b/src/parser/subscript_and_superscript.rs index 3114f17..f0eb6ba 100644 --- a/src/parser/subscript_and_superscript.rs +++ b/src/parser/subscript_and_superscript.rs @@ -33,7 +33,7 @@ use crate::types::Subscript; use crate::types::Superscript; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res, ()> { // This does not have to detect all valid subscript/superscript but all that it detects must be valid. let (remaining, _) = one_of("_^")(input)?; pre(input)?; @@ -46,7 +46,7 @@ use crate::types::Superscript; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn subscript<'b, 'g, 'r, 's>( +pub(crate) fn subscript<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Subscript<'s>> { @@ -66,7 +66,7 @@ use crate::types::Superscript; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn superscript<'b, 'g, 'r, 's>( +pub(crate) fn superscript<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Superscript<'s>> { diff --git a/src/parser/table.rs b/src/parser/table.rs index 19e8436..e9ad98f 100644 --- a/src/parser/table.rs +++ b/src/parser/table.rs @@ -33,7 +33,7 @@ use crate::types::TableRow; /// /// This is not the table.el style. #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn org_mode_table<'b, 'g, 'r, 's>( +pub(crate) fn org_mode_table<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Table<'s>> { @@ -74,7 +74,7 @@ use crate::types::TableRow; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn detect_table<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn detect_table<'s>(input: OrgSource<'s>) -> Res, ()> { tuple((start_of_line, space0, tag("|")))(input)?; Ok((input, ())) } @@ -89,7 +89,7 @@ fn table_end<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn org_mode_table_row<'b, 'g, 'r, 's>( +fn org_mode_table_row<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { @@ -100,7 +100,7 @@ fn table_end<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn org_mode_table_row_rule<'b, 'g, 'r, 's>( +fn org_mode_table_row_rule<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { @@ -117,7 +117,7 @@ fn table_end<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn org_mode_table_row_regular<'b, 'g, 'r, 's>( +fn org_mode_table_row_regular<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableRow<'s>> { @@ -137,7 +137,7 @@ fn table_end<'b, 'g, 'r, 's>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn org_mode_table_cell<'b, 'g, 'r, 's>( +fn org_mode_table_cell<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, TableCell<'s>> { diff --git a/src/parser/target.rs b/src/parser/target.rs index 730c40b..29006c5 100644 --- a/src/parser/target.rs +++ b/src/parser/target.rs @@ -21,7 +21,7 @@ use crate::parser::util::get_consumed; use crate::types::Target; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn target<'b, 'g, 'r, 's>( +pub(crate) fn target<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Target<'s>> { diff --git a/src/parser/text_markup.rs b/src/parser/text_markup.rs index 37d6ff1..bd74215 100644 --- a/src/parser/text_markup.rs +++ b/src/parser/text_markup.rs @@ -42,7 +42,7 @@ use crate::types::Underline; use crate::types::Verbatim; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn text_markup<'b, 'g, 'r, 's>( +pub(crate) fn text_markup<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Object<'s>> { @@ -60,7 +60,7 @@ use crate::types::Verbatim; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn bold<'b, 'g, 'r, 's>( +fn bold<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Bold<'s>> { @@ -77,7 +77,7 @@ use crate::types::Verbatim; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn italic<'b, 'g, 'r, 's>( +fn italic<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Italic<'s>> { @@ -94,7 +94,7 @@ use crate::types::Verbatim; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn underline<'b, 'g, 'r, 's>( +fn underline<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Underline<'s>> { @@ -111,7 +111,7 @@ use crate::types::Verbatim; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn strike_through<'b, 'g, 'r, 's>( +fn strike_through<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, StrikeThrough<'s>> { @@ -128,7 +128,7 @@ use crate::types::Verbatim; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn verbatim<'b, 'g, 'r, 's>( +fn verbatim<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Verbatim<'s>> { @@ -145,7 +145,7 @@ use crate::types::Verbatim; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn code<'b, 'g, 'r, 's>( +fn code<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Code<'s>> { @@ -288,7 +288,7 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn pre<'b, 'g, 'r, 's>( +fn pre<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { @@ -307,7 +307,7 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn post<'b, 'g, 'r, 's>( +fn post<'b, 'g, 'r, 's>( _context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, ()> { diff --git a/src/parser/timestamp.rs b/src/parser/timestamp.rs index ab88e93..c1fb5e2 100644 --- a/src/parser/timestamp.rs +++ b/src/parser/timestamp.rs @@ -23,7 +23,7 @@ use crate::parser::util::get_consumed; use crate::types::Timestamp; #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn timestamp<'b, 'g, 'r, 's>( +pub(crate) fn timestamp<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Timestamp<'s>> { diff --git a/src/parser/token.rs b/src/parser/token.rs index 3fb1fd4..8479273 100644 --- a/src/parser/token.rs +++ b/src/parser/token.rs @@ -11,7 +11,7 @@ use crate::types::Section; use crate::types::TableCell; use crate::types::TableRow; - enum Token<'r, 's> { +pub(crate) enum Token<'r, 's> { Document(&'r Document<'s>), Heading(&'r Heading<'s>), Section(&'r Section<'s>), @@ -24,7 +24,7 @@ use crate::types::TableRow; } impl<'r, 's> Token<'r, 's> { - fn iter_tokens(&self) -> Box> + '_> { + fn iter_tokens(&self) -> Box> + '_> { match self { Token::Document(document) => Box::new( document @@ -109,12 +109,12 @@ impl<'r, 's> Token<'r, 's> { } } - struct AllTokensIterator<'r, 's> { +pub(crate) struct AllTokensIterator<'r, 's> { queued_tokens: VecDeque>, } impl<'r, 's> AllTokensIterator<'r, 's> { - fn new(tkn: Token<'r, 's>) -> Self { + pub(crate) fn new(tkn: Token<'r, 's>) -> Self { let mut queued_tokens = VecDeque::new(); queued_tokens.push_back(tkn); AllTokensIterator { queued_tokens } diff --git a/src/parser/util.rs b/src/parser/util.rs index cbda279..f7bfc10 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -21,11 +21,11 @@ use crate::error::CustomError; use crate::error::MyError; use crate::error::Res; - const WORD_CONSTITUENT_CHARACTERS: &str = +pub(crate) const WORD_CONSTITUENT_CHARACTERS: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; /// Check if we are below a section of the given section type regardless of depth - fn in_section<'b, 'g, 'r, 's, 'x>( +pub(crate) fn in_section<'b, 'g, 'r, 's, 'x>( context: RefContext<'b, 'g, 'r, 's>, section_name: &'x str, ) -> bool { @@ -39,7 +39,7 @@ use crate::error::Res; } /// Checks if we are currently an immediate child of the given section type - fn immediate_in_section<'b, 'g, 'r, 's, 'x>( +pub(crate) fn immediate_in_section<'b, 'g, 'r, 's, 'x>( context: RefContext<'b, 'g, 'r, 's>, section_name: &'x str, ) -> bool { @@ -54,7 +54,7 @@ use crate::error::Res; } /// Check if we are below a section of the given section type regardless of depth - fn in_object_section<'b, 'g, 'r, 's, 'x>( +pub(crate) fn in_object_section<'b, 'g, 'r, 's, 'x>( context: RefContext<'b, 'g, 'r, 's>, section_name: &'x str, ) -> bool { @@ -68,7 +68,7 @@ use crate::error::Res; } /// Get a slice of the string that was consumed in a parser using the original input to the parser and the remaining input after the parser. - fn get_consumed<'s>(input: OrgSource<'s>, remaining: OrgSource<'s>) -> OrgSource<'s> { +pub(crate) fn get_consumed<'s>(input: OrgSource<'s>, remaining: OrgSource<'s>) -> OrgSource<'s> { input.get_until(remaining) } @@ -76,19 +76,19 @@ use crate::error::Res; /// /// It is up to the caller to ensure this is called at the start of a line. #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn blank_line(input: OrgSource<'_>) -> Res, OrgSource<'_>> { +pub(crate) fn blank_line(input: OrgSource<'_>) -> Res, OrgSource<'_>> { not(eof)(input)?; recognize(tuple((space0, alt((line_ending, eof)))))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { +fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { start_of_line(input)?; alt((eof, recognize(many0(blank_line))))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( +pub(crate) fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { @@ -104,7 +104,7 @@ use crate::error::Res; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( +pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { @@ -117,7 +117,7 @@ use crate::error::Res; } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>( +pub(crate) fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, Option>> { @@ -130,7 +130,7 @@ use crate::error::Res; /// Check that we are at the start of a line #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn start_of_line<'s>(input: OrgSource<'s>) -> Res, ()> { +pub(crate) fn start_of_line<'s>(input: OrgSource<'s>) -> Res, ()> { if input.is_at_start_of_line() { Ok((input, ())) } else { @@ -140,7 +140,7 @@ use crate::error::Res; } } - fn preceded_by_whitespace( +pub(crate) fn preceded_by_whitespace( allow_start_of_file: bool, ) -> impl for<'s> Fn(OrgSource<'s>) -> Res, ()> { move |input| _preceded_by_whitespace(allow_start_of_file, input) @@ -168,13 +168,13 @@ fn _preceded_by_whitespace<'s>( /// /// This function only operates on spaces, tabs, carriage returns, and line feeds. It does not handle fancy unicode whitespace. #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn non_whitespace_character(input: OrgSource<'_>) -> Res, char> { +pub(crate) fn non_whitespace_character(input: OrgSource<'_>) -> Res, char> { none_of(" \t\r\n")(input) } /// Check that we are at the start of a line #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn exit_matcher_parser<'b, 'g, 'r, 's>( +pub(crate) fn exit_matcher_parser<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -182,7 +182,7 @@ fn _preceded_by_whitespace<'s>( } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] - fn text_until_exit<'b, 'g, 'r, 's>( +pub(crate) fn text_until_exit<'b, 'g, 'r, 's>( context: RefContext<'b, 'g, 'r, 's>, input: OrgSource<'s>, ) -> Res, OrgSource<'s>> { @@ -193,7 +193,7 @@ fn _preceded_by_whitespace<'s>( } #[allow(dead_code)] - fn not_yet_implemented() -> Res, ()> { +fn not_yet_implemented() -> Res, ()> { return Err(nom::Err::Error(CustomError::MyError(MyError( "Not implemented yet.".into(), )))); @@ -204,7 +204,7 @@ fn _preceded_by_whitespace<'s>( /// Text from the current point until the next line break or end of file /// /// Useful for debugging. - fn text_until_eol<'r, 's>( +fn text_until_eol<'r, 's>( input: OrgSource<'s>, ) -> Result<&'s str, nom::Err>>> { let line = recognize(many_till(anychar, alt((line_ending, eof))))(input) @@ -212,7 +212,7 @@ fn _preceded_by_whitespace<'s>( Ok(line.trim()) } - fn include_input<'s, F, O>( +pub(crate) fn include_input<'s, F, O>( mut inner: F, ) -> impl FnMut(OrgSource<'s>) -> Res, (OrgSource<'s>, O)> where diff --git a/src/types/document.rs b/src/types/document.rs index 18c9f21..142762d 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -2,42 +2,42 @@ use super::Element; use super::Object; use super::Source; - type PriorityCookie = u8; +pub type PriorityCookie = u8; #[derive(Debug)] - struct Document<'s> { - source: &'s str, - zeroth_section: Option>, - children: Vec>, +pub struct Document<'s> { + pub source: &'s str, + pub zeroth_section: Option>, + pub children: Vec>, } #[derive(Debug)] - struct Heading<'s> { - source: &'s str, - stars: usize, - todo_keyword: Option<(TodoKeywordType, &'s str)>, - priority_cookie: Option, - title: Vec>, - tags: Vec<&'s str>, - children: Vec>, - is_comment: bool, - is_archived: bool, +pub struct Heading<'s> { + pub source: &'s str, + pub stars: usize, + pub todo_keyword: Option<(TodoKeywordType, &'s str)>, + pub priority_cookie: Option, + pub title: Vec>, + pub tags: Vec<&'s str>, + pub children: Vec>, + pub is_comment: bool, + pub is_archived: bool, } #[derive(Debug)] - struct Section<'s> { - source: &'s str, - children: Vec>, +pub struct Section<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug)] - enum DocumentElement<'s> { +pub enum DocumentElement<'s> { Heading(Heading<'s>), Section(Section<'s>), } #[derive(Debug)] - enum TodoKeywordType { +pub enum TodoKeywordType { Todo, Done, } diff --git a/src/types/element.rs b/src/types/element.rs index de5b582..10c0081 100644 --- a/src/types/element.rs +++ b/src/types/element.rs @@ -23,7 +23,7 @@ use super::SetSource; use super::Source; #[derive(Debug)] - enum Element<'s> { +pub enum Element<'s> { Paragraph(Paragraph<'s>), PlainList(PlainList<'s>), GreaterBlock(GreaterBlock<'s>), @@ -51,28 +51,28 @@ use super::Source; impl<'s> Source<'s> for Element<'s> { fn get_source(&'s self) -> &'s str { match self { - Element::Paragraph(obj) => obj.source, - Element::PlainList(obj) => obj.source, - Element::GreaterBlock(obj) => obj.source, - Element::DynamicBlock(obj) => obj.source, - Element::FootnoteDefinition(obj) => obj.source, - Element::Comment(obj) => obj.source, - Element::Drawer(obj) => obj.source, - Element::PropertyDrawer(obj) => obj.source, - Element::Table(obj) => obj.source, - Element::VerseBlock(obj) => obj.source, - Element::CommentBlock(obj) => obj.source, - Element::ExampleBlock(obj) => obj.source, - Element::ExportBlock(obj) => obj.source, - Element::SrcBlock(obj) => obj.source, - Element::Clock(obj) => obj.source, - Element::DiarySexp(obj) => obj.source, - Element::Planning(obj) => obj.source, - Element::FixedWidthArea(obj) => obj.source, - Element::HorizontalRule(obj) => obj.source, - Element::Keyword(obj) => obj.source, - Element::BabelCall(obj) => obj.source, - Element::LatexEnvironment(obj) => obj.source, + Element::Paragraph(obj) => obj.get_source(), + Element::PlainList(obj) => obj.get_source(), + Element::GreaterBlock(obj) => obj.get_source(), + Element::DynamicBlock(obj) => obj.get_source(), + Element::FootnoteDefinition(obj) => obj.get_source(), + Element::Comment(obj) => obj.get_source(), + Element::Drawer(obj) => obj.get_source(), + Element::PropertyDrawer(obj) => obj.get_source(), + Element::Table(obj) => obj.get_source(), + Element::VerseBlock(obj) => obj.get_source(), + Element::CommentBlock(obj) => obj.get_source(), + Element::ExampleBlock(obj) => obj.get_source(), + Element::ExportBlock(obj) => obj.get_source(), + Element::SrcBlock(obj) => obj.get_source(), + Element::Clock(obj) => obj.get_source(), + Element::DiarySexp(obj) => obj.get_source(), + Element::Planning(obj) => obj.get_source(), + Element::FixedWidthArea(obj) => obj.get_source(), + Element::HorizontalRule(obj) => obj.get_source(), + Element::Keyword(obj) => obj.get_source(), + Element::BabelCall(obj) => obj.get_source(), + Element::LatexEnvironment(obj) => obj.get_source(), } } } diff --git a/src/types/greater_element.rs b/src/types/greater_element.rs index c5bcab6..e897945 100644 --- a/src/types/greater_element.rs +++ b/src/types/greater_element.rs @@ -5,73 +5,73 @@ use super::Object; use super::Source; #[derive(Debug)] - struct PlainList<'s> { - source: &'s str, - children: Vec>, +pub struct PlainList<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug)] - struct PlainListItem<'s> { - source: &'s str, - indentation: usize, - bullet: &'s str, - tag: Vec>, - children: Vec>, +pub struct PlainListItem<'s> { + pub source: &'s str, + pub indentation: usize, + pub bullet: &'s str, + pub tag: Vec>, + pub children: Vec>, } #[derive(Debug)] - struct GreaterBlock<'s> { - source: &'s str, - name: &'s str, - parameters: Option<&'s str>, - children: Vec>, +pub struct GreaterBlock<'s> { + pub source: &'s str, + pub name: &'s str, + pub parameters: Option<&'s str>, + pub children: Vec>, } #[derive(Debug)] - struct DynamicBlock<'s> { - source: &'s str, - name: &'s str, - parameters: Option<&'s str>, - children: Vec>, +pub struct DynamicBlock<'s> { + pub source: &'s str, + pub name: &'s str, + pub parameters: Option<&'s str>, + pub children: Vec>, } #[derive(Debug)] - struct FootnoteDefinition<'s> { - source: &'s str, - label: &'s str, - children: Vec>, +pub struct FootnoteDefinition<'s> { + pub source: &'s str, + pub label: &'s str, + pub children: Vec>, } #[derive(Debug)] - struct Drawer<'s> { - source: &'s str, - name: &'s str, - children: Vec>, +pub struct Drawer<'s> { + pub source: &'s str, + pub name: &'s str, + pub children: Vec>, } #[derive(Debug)] - struct PropertyDrawer<'s> { - source: &'s str, - children: Vec>, +pub struct PropertyDrawer<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug)] - struct NodeProperty<'s> { - source: &'s str, - value: Option<&'s str>, +pub struct NodeProperty<'s> { + pub source: &'s str, + pub value: Option<&'s str>, } #[derive(Debug)] - struct Table<'s> { - source: &'s str, - formulas: Vec>, - children: Vec>, +pub struct Table<'s> { + pub source: &'s str, + pub formulas: Vec>, + pub children: Vec>, } #[derive(Debug)] - struct TableRow<'s> { - source: &'s str, - children: Vec>, +pub struct TableRow<'s> { + pub source: &'s str, + pub children: Vec>, } impl<'s> Source<'s> for PlainList<'s> { diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index bf911f3..e627a8c 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -3,101 +3,101 @@ use super::PlainText; use super::Source; #[derive(Debug)] - struct Paragraph<'s> { - source: &'s str, - children: Vec>, +pub struct Paragraph<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug)] - struct Comment<'s> { - source: &'s str, +pub struct Comment<'s> { + pub source: &'s str, } #[derive(Debug)] - struct TableCell<'s> { - source: &'s str, - children: Vec>, +pub struct TableCell<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug)] - struct VerseBlock<'s> { - source: &'s str, - name: &'s str, - data: Option<&'s str>, - children: Vec>, +pub struct VerseBlock<'s> { + pub source: &'s str, + pub name: &'s str, + pub data: Option<&'s str>, + pub children: Vec>, } #[derive(Debug)] - struct CommentBlock<'s> { - source: &'s str, - name: &'s str, - data: Option<&'s str>, - contents: &'s str, +pub struct CommentBlock<'s> { + pub source: &'s str, + pub name: &'s str, + pub data: Option<&'s str>, + pub contents: &'s str, } #[derive(Debug)] - struct ExampleBlock<'s> { - source: &'s str, - name: &'s str, - data: Option<&'s str>, - contents: &'s str, +pub struct ExampleBlock<'s> { + pub source: &'s str, + pub name: &'s str, + pub data: Option<&'s str>, + pub contents: &'s str, } #[derive(Debug)] - struct ExportBlock<'s> { - source: &'s str, - name: &'s str, - data: Option<&'s str>, - contents: &'s str, +pub struct ExportBlock<'s> { + pub source: &'s str, + pub name: &'s str, + pub data: Option<&'s str>, + pub contents: &'s str, } #[derive(Debug)] - struct SrcBlock<'s> { - source: &'s str, - name: &'s str, - data: Option<&'s str>, - contents: &'s str, +pub struct SrcBlock<'s> { + pub source: &'s str, + pub name: &'s str, + pub data: Option<&'s str>, + pub contents: &'s str, } #[derive(Debug)] - struct Clock<'s> { - source: &'s str, +pub struct Clock<'s> { + pub source: &'s str, } #[derive(Debug)] - struct DiarySexp<'s> { - source: &'s str, +pub struct DiarySexp<'s> { + pub source: &'s str, } #[derive(Debug)] - struct Planning<'s> { - source: &'s str, +pub struct Planning<'s> { + pub source: &'s str, } #[derive(Debug)] - struct FixedWidthArea<'s> { - source: &'s str, +pub struct FixedWidthArea<'s> { + pub source: &'s str, } #[derive(Debug)] - struct HorizontalRule<'s> { - source: &'s str, +pub struct HorizontalRule<'s> { + pub source: &'s str, } #[derive(Debug)] - struct Keyword<'s> { - source: &'s str, - key: &'s str, - value: &'s str, +pub struct Keyword<'s> { + pub source: &'s str, + pub key: &'s str, + pub value: &'s str, } #[derive(Debug)] - struct LatexEnvironment<'s> { - source: &'s str, +pub struct LatexEnvironment<'s> { + pub source: &'s str, } impl<'s> Paragraph<'s> { - fn of_text(input: &'s str) -> Self { + pub(crate) fn of_text(input: &'s str) -> Self { let mut objects = Vec::with_capacity(1); objects.push(Object::PlainText(PlainText { source: input })); Paragraph { diff --git a/src/types/mod.rs b/src/types/mod.rs index f64d7da..9cf5b59 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -4,65 +4,65 @@ mod greater_element; mod lesser_element; mod object; mod source; - use document::Document; - use document::DocumentElement; - use document::Heading; - use document::PriorityCookie; - use document::Section; - use document::TodoKeywordType; - use element::Element; - use greater_element::Drawer; - use greater_element::DynamicBlock; - use greater_element::FootnoteDefinition; - use greater_element::GreaterBlock; - use greater_element::NodeProperty; - use greater_element::PlainList; - use greater_element::PlainListItem; - use greater_element::PropertyDrawer; - use greater_element::Table; - use greater_element::TableRow; - use lesser_element::Clock; - use lesser_element::Comment; - use lesser_element::CommentBlock; - use lesser_element::DiarySexp; - use lesser_element::ExampleBlock; - use lesser_element::ExportBlock; - use lesser_element::FixedWidthArea; - use lesser_element::HorizontalRule; - use lesser_element::Keyword; - use lesser_element::LatexEnvironment; - use lesser_element::Paragraph; - use lesser_element::Planning; - use lesser_element::SrcBlock; - use lesser_element::TableCell; - use lesser_element::VerseBlock; - use object::AngleLink; - use object::Bold; - use object::Citation; - use object::CitationReference; - use object::Code; - use object::Entity; - use object::ExportSnippet; - use object::FootnoteReference; - use object::InlineBabelCall; - use object::InlineSourceBlock; - use object::Italic; - use object::LatexFragment; - use object::LineBreak; - use object::Object; - use object::OrgMacro; - use object::PlainLink; - use object::PlainText; - use object::RadioLink; - use object::RadioTarget; - use object::RegularLink; - use object::StatisticsCookie; - use object::StrikeThrough; - use object::Subscript; - use object::Superscript; - use object::Target; - use object::Timestamp; - use object::Underline; - use object::Verbatim; - use source::SetSource; - use source::Source; +pub use document::Document; +pub use document::DocumentElement; +pub use document::Heading; +pub use document::PriorityCookie; +pub use document::Section; +pub use document::TodoKeywordType; +pub use element::Element; +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::TableRow; +pub use lesser_element::Clock; +pub use lesser_element::Comment; +pub use lesser_element::CommentBlock; +pub use lesser_element::DiarySexp; +pub use lesser_element::ExampleBlock; +pub use lesser_element::ExportBlock; +pub use lesser_element::FixedWidthArea; +pub use lesser_element::HorizontalRule; +pub use lesser_element::Keyword; +pub use lesser_element::LatexEnvironment; +pub use lesser_element::Paragraph; +pub use lesser_element::Planning; +pub use lesser_element::SrcBlock; +pub use lesser_element::TableCell; +pub use lesser_element::VerseBlock; +pub use object::AngleLink; +pub use object::Bold; +pub use object::Citation; +pub use object::CitationReference; +pub use object::Code; +pub use object::Entity; +pub use object::ExportSnippet; +pub use object::FootnoteReference; +pub use object::InlineBabelCall; +pub use object::InlineSourceBlock; +pub use object::Italic; +pub use object::LatexFragment; +pub use object::LineBreak; +pub use object::Object; +pub use object::OrgMacro; +pub use object::PlainLink; +pub use object::PlainText; +pub use object::RadioLink; +pub use object::RadioTarget; +pub use object::RegularLink; +pub use object::StatisticsCookie; +pub use object::StrikeThrough; +pub use object::Subscript; +pub use object::Superscript; +pub use object::Target; +pub use object::Timestamp; +pub use object::Underline; +pub use object::Verbatim; +pub use source::SetSource; +pub use source::Source; diff --git a/src/types/object.rs b/src/types/object.rs index f3569c2..7e5da11 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -1,7 +1,7 @@ use super::Source; #[derive(Debug, PartialEq)] - enum Object<'s> { +pub enum Object<'s> { Bold(Bold<'s>), Italic(Italic<'s>), Underline(Underline<'s>), @@ -32,157 +32,157 @@ use super::Source; } #[derive(Debug, PartialEq)] - struct Bold<'s> { - source: &'s str, - children: Vec>, +pub struct Bold<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug, PartialEq)] - struct Italic<'s> { - source: &'s str, - children: Vec>, +pub struct Italic<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug, PartialEq)] - struct Underline<'s> { - source: &'s str, - children: Vec>, +pub struct Underline<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug, PartialEq)] - struct StrikeThrough<'s> { - source: &'s str, - children: Vec>, +pub struct StrikeThrough<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug, PartialEq)] - struct Code<'s> { - source: &'s str, - contents: &'s str, +pub struct Code<'s> { + pub source: &'s str, + pub contents: &'s str, } #[derive(Debug, PartialEq)] - struct Verbatim<'s> { - source: &'s str, - contents: &'s str, +pub struct Verbatim<'s> { + pub source: &'s str, + pub contents: &'s str, } #[derive(Debug, PartialEq)] - struct PlainText<'s> { - source: &'s str, +pub struct PlainText<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct RegularLink<'s> { - source: &'s str, +pub struct RegularLink<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct RadioTarget<'s> { - source: &'s str, - children: Vec>, +pub struct RadioTarget<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug, PartialEq)] - struct RadioLink<'s> { - source: &'s str, - children: Vec>, +pub struct RadioLink<'s> { + pub source: &'s str, + pub children: Vec>, } #[derive(Debug, PartialEq)] - struct PlainLink<'s> { - source: &'s str, - link_type: &'s str, - path: &'s str, +pub struct PlainLink<'s> { + pub source: &'s str, + pub link_type: &'s str, + pub path: &'s str, } #[derive(Debug, PartialEq)] - struct AngleLink<'s> { - source: &'s str, - link_type: &'s str, - path: &'s str, +pub struct AngleLink<'s> { + pub source: &'s str, + pub link_type: &'s str, + pub path: &'s str, } #[derive(Debug, PartialEq)] - struct OrgMacro<'s> { - source: &'s str, - macro_name: &'s str, - macro_args: Vec<&'s str>, +pub struct OrgMacro<'s> { + pub source: &'s str, + pub macro_name: &'s str, + pub macro_args: Vec<&'s str>, } #[derive(Debug, PartialEq)] - struct Entity<'s> { - source: &'s str, - entity_name: &'s str, +pub struct Entity<'s> { + pub source: &'s str, + pub entity_name: &'s str, } #[derive(Debug, PartialEq)] - struct LatexFragment<'s> { - source: &'s str, +pub struct LatexFragment<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct ExportSnippet<'s> { - source: &'s str, - backend: &'s str, - contents: Option<&'s str>, +pub struct ExportSnippet<'s> { + pub source: &'s str, + pub backend: &'s str, + pub contents: Option<&'s str>, } #[derive(Debug, PartialEq)] - struct FootnoteReference<'s> { - source: &'s str, - label: Option<&'s str>, - definition: Vec>, +pub struct FootnoteReference<'s> { + pub source: &'s str, + pub label: Option<&'s str>, + pub definition: Vec>, } #[derive(Debug, PartialEq)] - struct Citation<'s> { - source: &'s str, +pub struct Citation<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct CitationReference<'s> { - source: &'s str, +pub struct CitationReference<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct InlineBabelCall<'s> { - source: &'s str, +pub struct InlineBabelCall<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct InlineSourceBlock<'s> { - source: &'s str, +pub struct InlineSourceBlock<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct LineBreak<'s> { - source: &'s str, +pub struct LineBreak<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct Target<'s> { - source: &'s str, +pub struct Target<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct StatisticsCookie<'s> { - source: &'s str, +pub struct StatisticsCookie<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct Subscript<'s> { - source: &'s str, +pub struct Subscript<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct Superscript<'s> { - source: &'s str, +pub struct Superscript<'s> { + pub source: &'s str, } #[derive(Debug, PartialEq)] - struct Timestamp<'s> { - source: &'s str, +pub struct Timestamp<'s> { + pub source: &'s str, } impl<'s> Source<'s> for Object<'s> { diff --git a/src/types/source.rs b/src/types/source.rs index 6c90422..5e0b8c4 100644 --- a/src/types/source.rs +++ b/src/types/source.rs @@ -1,6 +1,6 @@ - trait Source<'s> { +pub trait Source<'s> { fn get_source(&'s self) -> &'s str; } - trait SetSource<'s> { +pub trait SetSource<'s> { fn set_source(&mut self, source: &'s str); } From cf383fa3940f51274d2f77eded11126c35a5a313 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 11 Sep 2023 14:59:07 -0400 Subject: [PATCH 3/5] Only include sexp module if compare feature is enabled. --- src/context/context.rs | 1 + src/parser/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/context/context.rs b/src/context/context.rs index d57b5fd..22c4798 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -28,6 +28,7 @@ pub(crate) enum ContextElement<'r, 's> { ConsumeTrailingWhitespace(bool), /// This is just here to use the 's lifetime until I'm sure we can eliminate it from ContextElement. + #[allow(dead_code)] Placeholder(PhantomData<&'s str>), } diff --git a/src/parser/mod.rs b/src/parser/mod.rs index fefe908..6b5b44b 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -37,6 +37,7 @@ mod property_drawer; mod radio_link; mod regular_link; mod section; +#[cfg(feature = "compare")] pub mod sexp; mod statistics_cookie; mod subscript_and_superscript; From 98de5e4ec582e8bf1f30929e9f6ff4b8d128667a Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 11 Sep 2023 15:05:18 -0400 Subject: [PATCH 4/5] Remove unused sexp parser entry point. --- build.rs | 2 +- src/bin_compare.rs | 6 +++--- src/parser/sexp.rs | 16 +++++----------- tests/test_template | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/build.rs b/build.rs index 31e474f..058a8ee 100644 --- a/build.rs +++ b/build.rs @@ -74,7 +74,7 @@ fn write_header(test_file: &mut File) { use organic::compare_document; use organic::parser::parse; use organic::emacs_parse_anonymous_org_document; -use organic::parser::sexp::sexp_with_padding; +use organic::parser::sexp::sexp; "# ) diff --git a/src/bin_compare.rs b/src/bin_compare.rs index 3c65ebc..da41af8 100644 --- a/src/bin_compare.rs +++ b/src/bin_compare.rs @@ -10,7 +10,7 @@ use organic::emacs_parse_file_org_document; use organic::get_emacs_version; use organic::get_org_mode_version; use organic::parser::parse_with_settings; -use organic::parser::sexp::sexp_with_padding; +use organic::parser::sexp::sexp; use organic::GlobalSettings; use organic::LocalFileAccessInterface; @@ -67,7 +67,7 @@ fn run_anonymous_parse>(org_contents: P) -> Result<(), Box>(org_path: P) -> Result<(), Box Result> } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { +pub fn sexp<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = multispace0(input)?; let remaining = OrgSource::new(remaining); let (remaining, tkn) = token(remaining) @@ -146,12 +146,6 @@ pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { Ok((remaining, tkn)) } -#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn sexp<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { - let (remaining, tkn) = token(input)?; - Ok((remaining, tkn)) -} - #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] fn token<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { alt((list, vector, atom))(input) @@ -259,7 +253,7 @@ mod tests { #[test] fn simple() { let input = " (foo bar baz ) "; - let (remaining, parsed) = sexp_with_padding(input).expect("Parse the input"); + let (remaining, parsed) = sexp(input).expect("Parse the input"); assert_eq!(remaining, ""); assert!(match parsed { Token::Atom(_) => false, @@ -272,7 +266,7 @@ mod tests { #[test] fn quoted() { let input = r#" ("foo" bar baz ) "#; - let (remaining, parsed) = sexp_with_padding(input).expect("Parse the input"); + let (remaining, parsed) = sexp(input).expect("Parse the input"); assert_eq!(remaining, ""); assert!(match parsed { Token::Atom(_) => false, @@ -296,7 +290,7 @@ mod tests { #[test] fn quoted_containing_paren() { let input = r#" (foo "b(a)r" baz ) "#; - let (remaining, parsed) = sexp_with_padding(input).expect("Parse the input"); + let (remaining, parsed) = sexp(input).expect("Parse the input"); assert_eq!(remaining, ""); assert!(match parsed { Token::List(_) => true, @@ -332,7 +326,7 @@ mod tests { #[test] fn string_containing_escaped_characters() { let input = r#" (foo "\\( x=2 \\)" bar) "#; - let (remaining, parsed) = sexp_with_padding(input).expect("Parse the input"); + let (remaining, parsed) = sexp(input).expect("Parse the input"); assert_eq!(remaining, ""); assert!(match parsed { Token::Atom(_) => false, diff --git a/tests/test_template b/tests/test_template index 776ebbe..31af35e 100644 --- a/tests/test_template +++ b/tests/test_template @@ -5,7 +5,7 @@ fn {name}() {{ println!("{{}}", org_contents); 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, parsed_sexp) = sexp(org_sexp.as_str()).expect("Sexp Parse failure"); let rust_parsed = parse(org_contents.as_str()).expect("Org Parse failure"); println!("{{:#?}}", rust_parsed); let diff_result = From a651b79e7709d649bede136d4157dbacfa4382d1 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 11 Sep 2023 15:31:48 -0400 Subject: [PATCH 5/5] Move sexp into compare. --- build.rs | 2 +- src/bin_compare.rs | 8 +++--- src/compare/diff.rs | 4 +-- src/compare/mod.rs | 2 ++ src/{parser => compare}/sexp.rs | 43 +++++++++++++++++++++------------ src/compare/util.rs | 2 +- src/lib.rs | 2 ++ src/parser/mod.rs | 2 -- 8 files changed, 39 insertions(+), 26 deletions(-) rename src/{parser => compare}/sexp.rs (87%) diff --git a/build.rs b/build.rs index 058a8ee..5d6f10e 100644 --- a/build.rs +++ b/build.rs @@ -74,7 +74,7 @@ fn write_header(test_file: &mut File) { use organic::compare_document; use organic::parser::parse; use organic::emacs_parse_anonymous_org_document; -use organic::parser::sexp::sexp; +use organic::sexp; "# ) diff --git a/src/bin_compare.rs b/src/bin_compare.rs index da41af8..8f91501 100644 --- a/src/bin_compare.rs +++ b/src/bin_compare.rs @@ -10,7 +10,7 @@ use organic::emacs_parse_file_org_document; use organic::get_emacs_version; use organic::get_org_mode_version; use organic::parser::parse_with_settings; -use organic::parser::sexp::sexp; +use organic::sexp; use organic::GlobalSettings; use organic::LocalFileAccessInterface; @@ -66,8 +66,7 @@ fn run_anonymous_parse>(org_contents: P) -> Result<(), Box>(org_path: P) -> Result<(), Box Token<'s> { } } +/// Check if the child string slice is a slice of the parent string slice. +fn is_slice_of(parent: &str, child: &str) -> bool { + let parent_start = parent.as_ptr() as usize; + let parent_end = parent_start + parent.len(); + let child_start = child.as_ptr() as usize; + let child_end = child_start + child.len(); + child_start >= parent_start && child_end <= parent_end +} + +/// Get a slice of the string that was consumed in a parser using the original input to the parser and the remaining input after the parser. +pub fn get_consumed<'s>(input: &'s str, remaining: &'s str) -> &'s str { + assert!(is_slice_of(input, remaining)); + let source = { + let offset = remaining.as_ptr() as usize - input.as_ptr() as usize; + &input[..offset] + }; + source.into() +} + pub(crate) fn unquote(text: &str) -> Result> { let mut out = String::with_capacity(text.len()); if !text.starts_with(r#"""#) { @@ -138,21 +154,18 @@ pub(crate) fn unquote(text: &str) -> Result> #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] pub fn sexp<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = multispace0(input)?; - let remaining = OrgSource::new(remaining); - let (remaining, tkn) = token(remaining) - .map(|(rem, out)| (Into::<&str>::into(rem), out)) - .map_err(convert_error)?; + let (remaining, tkn) = token(remaining).map(|(rem, out)| (Into::<&str>::into(rem), out))?; let (remaining, _) = multispace0(remaining)?; Ok((remaining, tkn)) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn token<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn token<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { alt((list, vector, atom))(input) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn list<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn list<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = tag("(")(input)?; let (remaining, children) = delimited( multispace0, @@ -164,7 +177,7 @@ fn list<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn vector<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn vector<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = tag("[")(input)?; let (remaining, children) = delimited( multispace0, @@ -176,7 +189,7 @@ fn vector<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn atom<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { not(peek(one_of(")]")))(input)?; alt(( text_with_properties, @@ -187,7 +200,7 @@ fn atom<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn unquoted_atom<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn unquoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, body) = take_till1(|c| match c { ' ' | '\t' | '\r' | '\n' | ')' | ']' => true, _ => false, @@ -196,7 +209,7 @@ fn unquoted_atom<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn quoted_atom<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn quoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = tag(r#"""#)(input)?; let (remaining, _) = escaped( take_till1(|c| match c { @@ -212,7 +225,7 @@ fn quoted_atom<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] -fn hash_notation<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn hash_notation<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = tag("#<")(input)?; let (remaining, _body) = take_till1(|c| match c { '>' => true, @@ -223,7 +236,7 @@ fn hash_notation<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { Ok((remaining, Token::Atom(source.into()))) } -fn text_with_properties<'s>(input: OrgSource<'s>) -> Res, Token<'s>> { +fn text_with_properties<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { let (remaining, _) = tag("#(")(input)?; let (remaining, (text, props)) = delimited( multispace0, diff --git a/src/compare/util.rs b/src/compare/util.rs index c14a794..4e8668b 100644 --- a/src/compare/util.rs +++ b/src/compare/util.rs @@ -1,4 +1,4 @@ -use crate::parser::sexp::Token; +use super::sexp::Token; use crate::types::Source; /// Check if the child string slice is a slice of the parent string slice. diff --git a/src/lib.rs b/src/lib.rs index afc3796..bbd1944 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,6 +15,8 @@ pub use compare::emacs_parse_file_org_document; pub use compare::get_emacs_version; #[cfg(feature = "compare")] pub use compare::get_org_mode_version; +#[cfg(feature = "compare")] +pub use compare::sexp; mod context; mod error; diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 6b5b44b..b19f9ca 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -37,8 +37,6 @@ mod property_drawer; mod radio_link; mod regular_link; mod section; -#[cfg(feature = "compare")] -pub mod sexp; mod statistics_cookie; mod subscript_and_superscript; mod table;