Starting to move the org-mode specific context tree stuff over.

This commit is contained in:
Tom Alexander 2022-12-03 20:47:31 -05:00
parent 89148a623c
commit bdf3c98f34
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 36 additions and 3 deletions

View File

@ -1 +1,35 @@
use nom::error::VerboseError;
use nom::IResult;
use super::list::List;
type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>;
pub struct ContextTree<'r> {
tree: List<ContextElement<'r>>,
}
impl<'r> ContextTree<'r> {
pub fn new() -> Self {
ContextTree { tree: List::new() }
}
}
pub enum ContextElement<'r> {
FailMatcherNode(FailMatcherNode<'r>),
PreviousElementNode(PreviousElementNode<'r>),
}
pub struct FailMatcherNode<'r> {
pub fail_matcher: ChainBehavior<'r>,
}
pub struct PreviousElementNode<'r> {
pub dummy: &'r str,
}
#[derive(Clone)]
pub enum ChainBehavior<'r> {
AndParent(Option<&'r Matcher>),
IgnoreParent(Option<&'r Matcher>),
}

View File

@ -34,13 +34,12 @@ use nom::Parser;
use tracing::instrument;
use tracing::trace;
fn context_many_till<'r, C, I, O, E, F, M, T>(
context: &'r ContextTree<'r, C>,
fn context_many_till<'r, I, O, E, F, M, T>(
context: &'r ContextTree<'r>,
mut many_matcher: M,
mut till_matcher: T,
) -> impl FnMut(I) -> IResult<I, (Vec<O>, F), E>
where
C: ContextElement,
I: Clone + InputLength,
M: Parser<I, O, E>,
T: Parser<I, F, E>,