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::instrument;
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
fn context_many_till<'r, C, I, O, E, F, M, T>(
|
fn context_many_till<'r, I, O, E, F, M, T>(
|
||||||
context: &'r ContextTree<'r, C>,
|
context: &'r ContextTree<'r>,
|
||||||
mut many_matcher: M,
|
mut many_matcher: M,
|
||||||
mut till_matcher: T,
|
mut till_matcher: T,
|
||||||
) -> impl FnMut(I) -> IResult<I, (Vec<O>, F), E>
|
) -> impl FnMut(I) -> IResult<I, (Vec<O>, F), E>
|
||||||
where
|
where
|
||||||
C: ContextElement,
|
|
||||||
I: Clone + InputLength,
|
I: Clone + InputLength,
|
||||||
M: Parser<I, O, E>,
|
M: Parser<I, O, E>,
|
||||||
T: Parser<I, F, E>,
|
T: Parser<I, F, E>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user