Compiling but I'm not generating a new context.
This commit is contained in:
parent
ee9e6297a6
commit
b4215128fa
@ -1,30 +1,25 @@
|
||||
macro_rules! failable_sequence {
|
||||
($name:ident,$inp:ident,$context:ident,$begin_matcher:expr,$element_matcher:expr,$success_matcher:expr) => {
|
||||
pub fn $name<'b, F>(
|
||||
$context: &'b NomContext<F>,
|
||||
pub fn $name<F>(
|
||||
$context: &NomContext<F>,
|
||||
) -> impl for<'a> FnMut(
|
||||
&'a str,
|
||||
) -> nom::IResult<
|
||||
&'a str,
|
||||
crate::parser::text::Sequence<'a>,
|
||||
VerboseError<&'a str>,
|
||||
> + 'b
|
||||
> + '_
|
||||
where
|
||||
F: for<'a> nom::Parser<&'a str, &'a str, VerboseError<&'a str>>,
|
||||
F: for<'a> FnMut(&'a str) -> nom::IResult<&'a str, &'a str, VerboseError<&'a str>>,
|
||||
{
|
||||
let fail_matcher = $context.fail_matcher.clone();
|
||||
let new_fail_matcher = alt((
|
||||
|i| fail_matcher.borrow_mut().parse(i),
|
||||
recognize($success_matcher),
|
||||
));
|
||||
|
||||
move |$inp: &str| {
|
||||
let new_context = $context.with_no_bold();
|
||||
// let other_new_context = NomContext::with_additional_fail_matcher(
|
||||
// |i: &str| recognize($success_matcher)(i),
|
||||
// $context,
|
||||
// );
|
||||
let other_new_context = super::nom_context::NomContext::new(new_fail_matcher);
|
||||
// let other_new_context =
|
||||
// super::nom_context::NomContext::new($context.fail_matcher.clone());
|
||||
let element_matcher = recognize($element_matcher(&new_context));
|
||||
let local_fail_matcher = $context.fail_matcher.clone();
|
||||
let ret = map(
|
||||
@ -32,11 +27,11 @@ macro_rules! failable_sequence {
|
||||
$begin_matcher,
|
||||
nom::multi::many_till(
|
||||
nom::sequence::preceded(
|
||||
not(|i| local_fail_matcher.borrow_mut().parse(i)),
|
||||
not(|i| local_fail_matcher.borrow_mut()(i)),
|
||||
element_matcher,
|
||||
),
|
||||
nom::sequence::preceded(
|
||||
not(|i| local_fail_matcher.borrow_mut().parse(i)),
|
||||
not(|i| local_fail_matcher.borrow_mut()(i)),
|
||||
$success_matcher,
|
||||
),
|
||||
),
|
||||
|
@ -1,5 +1,5 @@
|
||||
use nom::error::VerboseError;
|
||||
use nom::Parser;
|
||||
use nom::IResult;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
@ -14,7 +14,7 @@ pub struct NomContext<F> {
|
||||
|
||||
impl<F> NomContext<F>
|
||||
where
|
||||
F: for<'a> Parser<&'a str, &'a str, VerboseError<&'a str>>,
|
||||
F: for<'a> FnMut(&'a str) -> IResult<&'a str, &'a str, VerboseError<&'a str>>,
|
||||
{
|
||||
pub fn new(fail_matcher: F) -> Self {
|
||||
NomContext {
|
||||
|
Loading…
Reference in New Issue
Block a user