Convert all functions to using the wrapped input type.
Some checks failed
rust-test Build rust-test has failed
rust-build Build rust-build has failed

This commit is contained in:
Tom Alexander
2023-08-23 00:30:26 -04:00
parent b7a5dd48ea
commit dab598e5e7
45 changed files with 1217 additions and 572 deletions

View File

@@ -5,6 +5,7 @@ use nom::IResult;
use super::list::List;
use super::list::Node;
use super::org_source::OrgSource;
use super::Context;
use super::Object;
use crate::error::CustomError;
@@ -12,7 +13,8 @@ use crate::error::MyError;
use crate::error::Res;
use crate::parser::exiting::ExitClass;
type Matcher = dyn for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str>;
type Matcher =
dyn for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>;
#[derive(Debug, Clone)]
pub struct ContextTree<'r, 's> {
@@ -47,8 +49,8 @@ impl<'r, 's> ContextTree<'r, 's> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn check_exit_matcher(
&'r self,
i: &'s str,
) -> IResult<&'s str, &'s str, CustomError<&'s str>> {
i: OrgSource<'s>,
) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError<OrgSource<'s>>> {
// Special check for EOF. We don't just make this a document-level exit matcher since the IgnoreParent ChainBehavior could cause early exit matchers to not run.
let at_end_of_file = eof(i);
if at_end_of_file.is_ok() {
@@ -78,7 +80,9 @@ impl<'r, 's> ContextTree<'r, 's> {
};
}
// TODO: Make this a specific error instead of just a generic MyError
return Err(nom::Err::Error(CustomError::MyError(MyError("NoExit"))));
return Err(nom::Err::Error(CustomError::MyError(MyError(
"NoExit".into(),
))));
}
pub fn get_document_root(&self) -> Option<&'s str> {
@@ -215,31 +219,31 @@ pub struct ExitMatcherNode<'r> {
#[derive(Debug)]
pub struct FootnoteReferenceDefinition<'s> {
pub position: &'s str,
pub position: OrgSource<'s>,
pub depth: usize,
}
#[derive(Debug)]
pub struct CitationBracket<'s> {
pub position: &'s str,
pub position: OrgSource<'s>,
pub depth: usize,
}
#[derive(Debug)]
pub struct BabelHeaderBracket<'s> {
pub position: &'s str,
pub position: OrgSource<'s>,
pub depth: usize,
}
#[derive(Debug)]
pub struct InlineSourceBlockBracket<'s> {
pub position: &'s str,
pub position: OrgSource<'s>,
pub depth: usize,
}
#[derive(Debug)]
pub struct SubscriptSuperscriptBrace<'s> {
pub position: &'s str,
pub position: OrgSource<'s>,
pub depth: usize,
}