diff --git a/src/parser/new_context.rs b/src/parser/new_context.rs index ee025055..24e49fd6 100644 --- a/src/parser/new_context.rs +++ b/src/parser/new_context.rs @@ -8,3 +8,47 @@ // }; // let child2 = child1.with_additional_node(&child2_context); // } + +use nom::error::VerboseError; +use nom::IResult; + +type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>; +type Link<'p> = Option<&'p dyn NodeType<'p>>; + +struct Node<'p, T> { + data: T, + parent: Link<'p>, +} + +pub trait NodeType<'p> { + fn get_data(&self) -> &dyn ContextElement; + fn get_parent(&self) -> Link<'p>; +} + +impl<'p, T> NodeType<'p> for Node<'p, T> +where + T: ContextElement, +{ + fn get_data(&self) -> &dyn ContextElement { + &self.data + } + + fn get_parent(&self) -> Link<'p> { + self.parent + } +} + +pub trait ContextElement {} + +struct FailMatcherNode<'r> { + fail_matcher: ChainBehavior<'r>, +} + +struct PreviousElementNode<'r> { + dummy: &'r str, +} + +enum ChainBehavior<'r> { + AndParent(Option<&'r Matcher>), + IgnoreParent(Option<&'r Matcher>), +}