Constructing a context.

This commit is contained in:
Tom Alexander 2022-11-24 15:14:53 -05:00
parent 1b8dada135
commit a792acf4b0
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 10 additions and 3 deletions

View File

@ -36,11 +36,11 @@ impl<'r, T> ContextTree<'r, T> {
}
}
struct ContextElement<'r> {
fail_matcher: ChainBehavior<'r>,
pub struct ContextElement<'r> {
pub fail_matcher: ChainBehavior<'r>,
}
enum ChainBehavior<'r> {
pub enum ChainBehavior<'r> {
AndParent(Option<&'r Matcher>),
IgnoreParent(Option<&'r Matcher>),
}

View File

@ -26,6 +26,9 @@ use nom::multi::many_till;
use nom::sequence::tuple;
use nom::IResult;
use super::nom_context::ChainBehavior;
use super::nom_context::ContextElement;
use super::nom_context::ContextTree;
use super::parser_with_context::parser_with_context;
use super::text_element_parser::paragraph;
@ -136,6 +139,10 @@ pub fn paragraph_end(input: &str) -> Res<&str, &str> {
}
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
let initial_context = ContextTree::new();
let paragraph_context = initial_context.with_additional_node(ContextElement {
fail_matcher: ChainBehavior::AndParent(Some(&paragraph_end)),
});
// let initial_context = TestContext::new();
// let paragraph_context = initial_context;
// let paragraph_context =