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

@@ -7,6 +7,7 @@ use nom::character::complete::space0;
use nom::combinator::verify;
use nom::multi::many_till;
use super::org_source::OrgSource;
use super::parser_with_context::parser_with_context;
use super::util::get_consumed;
use super::Context;
@@ -22,8 +23,8 @@ use crate::parser::util::exit_matcher_parser;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn regular_link<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, RegularLink<'s>> {
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RegularLink<'s>> {
alt((
parser_with_context!(regular_link_without_description)(context),
parser_with_context!(regular_link_with_description)(context),
@@ -33,21 +34,26 @@ pub fn regular_link<'r, 's>(
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn regular_link_without_description<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, RegularLink<'s>> {
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RegularLink<'s>> {
let (remaining, _opening_bracket) = tag("[[")(input)?;
let (remaining, _path) = pathreg(context, remaining)?;
let (remaining, _closing_bracket) = tag("]]")(remaining)?;
let (remaining, _trailing_whitespace) = space0(remaining)?;
let source = get_consumed(input, remaining);
Ok((remaining, RegularLink { source }))
Ok((
remaining,
RegularLink {
source: source.into(),
},
))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn regular_link_with_description<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, RegularLink<'s>> {
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RegularLink<'s>> {
let (remaining, _opening_bracket) = tag("[[")(input)?;
let (remaining, _path) = pathreg(context, remaining)?;
let (remaining, _closing_bracket) = tag("][")(remaining)?;
@@ -55,11 +61,19 @@ pub fn regular_link_with_description<'r, 's>(
let (remaining, _closing_bracket) = tag("]]")(remaining)?;
let (remaining, _trailing_whitespace) = space0(remaining)?;
let source = get_consumed(input, remaining);
Ok((remaining, RegularLink { source }))
Ok((
remaining,
RegularLink {
source: source.into(),
},
))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn pathreg<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
pub fn pathreg<'r, 's>(
context: Context<'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let (remaining, path) = escaped(
take_till1(|c| match c {
'\\' | ']' => true,
@@ -74,8 +88,8 @@ pub fn pathreg<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
pub fn description<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, Vec<Object<'s>>> {
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
let parser_context =
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Beta,
@@ -93,6 +107,9 @@ pub fn description<'r, 's>(
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn description_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
fn description_end<'r, 's>(
context: Context<'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
tag("]]")(input)
}