Constructing a context.
This commit is contained in:
parent
1b8dada135
commit
a792acf4b0
@ -36,11 +36,11 @@ impl<'r, T> ContextTree<'r, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ContextElement<'r> {
|
pub struct ContextElement<'r> {
|
||||||
fail_matcher: ChainBehavior<'r>,
|
pub fail_matcher: ChainBehavior<'r>,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ChainBehavior<'r> {
|
pub enum ChainBehavior<'r> {
|
||||||
AndParent(Option<&'r Matcher>),
|
AndParent(Option<&'r Matcher>),
|
||||||
IgnoreParent(Option<&'r Matcher>),
|
IgnoreParent(Option<&'r Matcher>),
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ use nom::multi::many_till;
|
|||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
use nom::IResult;
|
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::parser_with_context::parser_with_context;
|
||||||
use super::text_element_parser::paragraph;
|
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)>> {
|
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(¶graph_end)),
|
||||||
|
});
|
||||||
// let initial_context = TestContext::new();
|
// let initial_context = TestContext::new();
|
||||||
// let paragraph_context = initial_context;
|
// let paragraph_context = initial_context;
|
||||||
// let paragraph_context =
|
// let paragraph_context =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user