Swap in the new TestContext everywhere.

This commit is contained in:
Tom Alexander
2022-10-30 05:06:06 -04:00
parent ec2d09b72a
commit 8695d32f40
3 changed files with 16 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ use nom::sequence::tuple;
use nom::IResult;
use super::nom_context::NomContext;
use super::nom_context::TestContext;
use super::parser_with_context::parser_with_context;
use super::text_element_parser::paragraph;
@@ -137,7 +138,10 @@ pub fn paragraph_end(input: &str) -> Res<&str, &str> {
}
pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
let initial_context = NomContext::new(Rc::new(RefCell::new(paragraph_end)));
let ret = many1(parser_with_context!(paragraph)(&initial_context))(input);
let initial_context = TestContext::new();
let paragraph_context =
initial_context.with_additional_fail_matcher(Rc::new(RefCell::new(paragraph_end)));
// let initial_context = NomContext::new(Rc::new(RefCell::new(paragraph_end)));
let ret = many1(parser_with_context!(paragraph)(&paragraph_context))(input);
ret
}