Starting to move the org-mode specific context tree stuff over.
This commit is contained in:
parent
89148a623c
commit
bdf3c98f34
@ -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>),
|
||||
}
|
||||
|
@ -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>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user