Convert all functions to using the wrapped input type.
This commit is contained in:
@@ -12,6 +12,7 @@ use nom::combinator::recognize;
|
||||
use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
|
||||
use super::org_source::OrgSource;
|
||||
use super::Context;
|
||||
use crate::error::CustomError;
|
||||
use crate::error::MyError;
|
||||
@@ -32,11 +33,11 @@ use crate::parser::util::start_of_line;
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn property_drawer<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, PropertyDrawer<'s>> {
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, PropertyDrawer<'s>> {
|
||||
if immediate_in_section(context, "property-drawer") {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"Cannot nest objects of the same element",
|
||||
"Cannot nest objects of the same element".into(),
|
||||
))));
|
||||
}
|
||||
let (
|
||||
@@ -68,11 +69,20 @@ pub fn property_drawer<'r, 's>(
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
|
||||
Ok((remaining, PropertyDrawer { source, children }))
|
||||
Ok((
|
||||
remaining,
|
||||
PropertyDrawer {
|
||||
source: source.into(),
|
||||
children,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn property_drawer_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
fn property_drawer_end<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
recognize(tuple((
|
||||
parser_with_context!(start_of_line)(context),
|
||||
space0,
|
||||
@@ -85,8 +95,8 @@ fn property_drawer_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn node_property<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, NodeProperty<'s>> {
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, NodeProperty<'s>> {
|
||||
let (remaining, (_start_of_line, _leading_whitespace, _open_colon, _name, _close_colon)) =
|
||||
tuple((
|
||||
parser_with_context!(start_of_line)(context),
|
||||
@@ -95,13 +105,17 @@ fn node_property<'r, 's>(
|
||||
parser_with_context!(node_property_name)(context),
|
||||
tag(":"),
|
||||
))(input)?;
|
||||
match tuple((space0::<&str, nom::error::Error<&str>>, line_ending))(remaining) {
|
||||
match tuple((
|
||||
space0::<OrgSource<'_>, nom::error::Error<OrgSource<'_>>>,
|
||||
line_ending,
|
||||
))(remaining)
|
||||
{
|
||||
Ok((remaining, _ws)) => {
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
remaining,
|
||||
NodeProperty {
|
||||
source,
|
||||
source: source.into(),
|
||||
value: None,
|
||||
},
|
||||
))
|
||||
@@ -113,8 +127,8 @@ fn node_property<'r, 's>(
|
||||
Ok((
|
||||
remaining,
|
||||
NodeProperty {
|
||||
source,
|
||||
value: Some(value),
|
||||
source: source.into(),
|
||||
value: Some(value.into()),
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -122,7 +136,10 @@ fn node_property<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn node_property_name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
fn node_property_name<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let parser_context =
|
||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Beta,
|
||||
@@ -141,7 +158,7 @@ fn node_property_name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn node_property_name_end<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, &'s str> {
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
alt((tag("+:"), tag(":")))(input)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user