organic/src/parser/nom_context.rs

36 lines
767 B
Rust
Raw Normal View History

2022-10-15 00:01:37 -04:00
use std::cell::RefCell;
use std::rc::Rc;
2022-07-16 17:27:08 -04:00
use nom::branch::alt;
use nom::combinator::not;
2022-07-15 23:26:49 -04:00
use nom::error::VerboseError;
use nom::IResult;
2022-10-15 00:01:37 -04:00
use nom::Parser;
type ContextReference<'r, T> = Option<&'r ContextLayer<'r, T>>;
type MatcherRef = dyn for<'s> FnMut(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>;
2022-10-30 05:48:43 -04:00
pub struct ContextLayer<'r, T> {
data: T,
parent: ContextReference<'r, T>,
}
pub struct TestContext<'r, T> {
head: ContextReference<'r, T>,
}
2022-10-30 05:53:18 -04:00
pub struct ContextData<'r> {
fail_matcher: ChainBehavior<'r>,
}
impl<'r> TestContext<'r, ContextData<'r>> {
pub fn new() -> Self {
TestContext { head: None }
}
}
2022-10-30 05:53:18 -04:00
enum ChainBehavior<'r> {
AndParent(Option<&'r MatcherRef>),
IgnoreParent(Option<&'r MatcherRef>),
2022-07-15 23:26:49 -04:00
}