|
|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
|
use nom::branch::alt;
|
|
|
|
|
use nom::bytes::complete::tag;
|
|
|
|
|
use nom::character::complete::anychar;
|
|
|
|
|
use nom::character::complete::digit1;
|
|
|
|
|
use nom::character::complete::line_ending;
|
|
|
|
|
use nom::character::complete::one_of;
|
|
|
|
|
@@ -301,18 +302,11 @@ fn item_tag<'b, 'g, 'r, 's>(
|
|
|
|
|
context: RefContext<'b, 'g, 'r, 's>,
|
|
|
|
|
input: OrgSource<'s>,
|
|
|
|
|
) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
|
|
|
|
|
let contexts = [
|
|
|
|
|
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
|
|
|
|
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
|
|
|
|
class: ExitClass::Gamma,
|
|
|
|
|
exit_matcher: &item_tag_line_ending_end,
|
|
|
|
|
}),
|
|
|
|
|
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
|
|
|
|
class: ExitClass::Delta,
|
|
|
|
|
exit_matcher: &item_tag_end,
|
|
|
|
|
}),
|
|
|
|
|
];
|
|
|
|
|
let parser_context = context.with_additional_node(&contexts[0]);
|
|
|
|
|
let parser_context = parser_context.with_additional_node(&contexts[1]);
|
|
|
|
|
});
|
|
|
|
|
let parser_context = context.with_additional_node(&parser_context);
|
|
|
|
|
let (remaining, (children, _exit_contents)) = verify(
|
|
|
|
|
many_till(
|
|
|
|
|
// TODO: Should this be using a different set like the minimal set?
|
|
|
|
|
@@ -321,7 +315,7 @@ fn item_tag<'b, 'g, 'r, 's>(
|
|
|
|
|
),
|
|
|
|
|
|(children, _exit_contents)| !children.is_empty(),
|
|
|
|
|
)(input)?;
|
|
|
|
|
let (remaining, _) = tuple((one_of(" \t"), tag("::")))(remaining)?;
|
|
|
|
|
let (remaining, _) = item_tag_divider(remaining)?;
|
|
|
|
|
Ok((remaining, children))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -330,19 +324,22 @@ fn item_tag_end<'b, 'g, 'r, 's>(
|
|
|
|
|
_context: RefContext<'b, 'g, 'r, 's>,
|
|
|
|
|
input: OrgSource<'s>,
|
|
|
|
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
|
|
|
|
alt((
|
|
|
|
|
recognize(tuple((
|
|
|
|
|
one_of(" \t"),
|
|
|
|
|
tag("::"),
|
|
|
|
|
alt((recognize(one_of(" \t")), line_ending, eof)),
|
|
|
|
|
)))(input)
|
|
|
|
|
item_tag_divider,
|
|
|
|
|
opt(tuple((
|
|
|
|
|
peek(one_of(" \t")),
|
|
|
|
|
many_till(anychar, peek(alt((item_tag_divider, line_ending, eof)))),
|
|
|
|
|
))),
|
|
|
|
|
alt((line_ending, eof)),
|
|
|
|
|
))),
|
|
|
|
|
line_ending,
|
|
|
|
|
))(input)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
|
|
|
|
fn item_tag_line_ending_end<'b, 'g, 'r, 's>(
|
|
|
|
|
_context: RefContext<'b, 'g, 'r, 's>,
|
|
|
|
|
input: OrgSource<'s>,
|
|
|
|
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
|
|
|
|
line_ending(input)
|
|
|
|
|
fn item_tag_divider<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
|
|
|
|
recognize(tuple((one_of(" \t"), tag("::"))))(input)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
|
|
|
|
|