with addition node not working.
This commit is contained in:
parent
7346f5e850
commit
b8e3074a0e
@ -9,9 +9,13 @@
|
|||||||
// let child2 = child1.with_additional_node(&child2_context);
|
// let child2 = child1.with_additional_node(&child2_context);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
use nom::combinator::recognize;
|
||||||
use nom::error::VerboseError;
|
use nom::error::VerboseError;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
|
use super::text::bold_end;
|
||||||
|
use super::text::Res;
|
||||||
|
|
||||||
type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>;
|
type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>;
|
||||||
type Link<'p> = Option<&'p dyn NodeType<'p>>;
|
type Link<'p> = Option<&'p dyn NodeType<'p>>;
|
||||||
|
|
||||||
@ -81,34 +85,38 @@ where
|
|||||||
ContextTree { head: None }
|
ContextTree { head: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_additional_node<F: for<'s> ContextElement<'s>>(
|
// pub fn with_additional_node<'s, F: ContextElement<'s>>(
|
||||||
&'r self,
|
// &'r self,
|
||||||
element: F,
|
// element: F,
|
||||||
) -> ContextTree<'r, F> {
|
// ) -> ContextTree<'r, F> {
|
||||||
let new_node = {
|
// let new_node = {
|
||||||
let parent: Option<&dyn NodeType<'_>> = match &self.head {
|
// let parent: Option<&dyn NodeType<'_>> = match &self.head {
|
||||||
Some(node) => Some(node),
|
// Some(node) => Some(node),
|
||||||
None => None,
|
// None => None,
|
||||||
};
|
// };
|
||||||
Node {
|
// Node {
|
||||||
data: element,
|
// data: element,
|
||||||
parent,
|
// parent,
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
ContextTree {
|
// ContextTree {
|
||||||
head: Some(new_node),
|
// head: Some(new_node),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_context() {
|
fn test_context() {
|
||||||
let foo = "foo";
|
let foo = "foo";
|
||||||
let context = ContextTree::new();
|
// let context = ContextTree::new();
|
||||||
let child1_context = PreviousElementNode { dummy: foo };
|
let child1_context = PreviousElementNode { dummy: foo };
|
||||||
let child1 = context.with_additional_node(&child1_context);
|
// let child1 = context.with_additional_node(child1_context);
|
||||||
let child2_context = FailMatcherNode {
|
let child2_context = FailMatcherNode {
|
||||||
fail_matcher: ChainBehavior::AndParent(Some(&recognize_bold_end)),
|
fail_matcher: ChainBehavior::AndParent(Some(&recognize_bold_end)),
|
||||||
};
|
};
|
||||||
let child2 = child1.with_additional_node(&child2_context);
|
// let child2 = child1.with_additional_node(child2_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn recognize_bold_end(input: &str) -> Res<&str, &str> {
|
||||||
|
recognize(bold_end)(input)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user