Compare commits

..

No commits in common. "76ca2b9762f465e4d04ec8d010eb9eb37b5b1566" and "de7ad182b3e2a5102ecec26812ea056285c7a9fa" have entirely different histories.

4 changed files with 25 additions and 22 deletions

View File

@ -1,2 +1 @@
- =foo :: bar= :: baz - =foo :: bar= :: baz
- lorem :: ipsum :: dolar

View File

@ -108,7 +108,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
&'r self, &'r self,
i: OrgSource<'s>, i: OrgSource<'s>,
) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError<OrgSource<'s>>> { ) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError<OrgSource<'s>>> {
let mut current_class_filter = ExitClass::Gamma; let mut current_class_filter = ExitClass::Delta;
for current_node in self.iter_context() { for current_node in self.iter_context() {
let context_element = current_node.get_data(); let context_element = current_node.get_data();
match context_element { match context_element {

View File

@ -4,6 +4,7 @@ pub enum ExitClass {
Alpha = 2, Alpha = 2,
Beta = 3, Beta = 3,
Gamma = 4, Gamma = 4,
Delta = 5,
} }
impl std::fmt::Display for ExitClass { impl std::fmt::Display for ExitClass {

View File

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