Get basic def working

This commit is contained in:
Richard Feldman 2019-09-29 22:32:02 +03:00
parent f6ecc88d9c
commit fda3d3056a
8 changed files with 323 additions and 152 deletions

View file

@ -209,31 +209,6 @@ where
}
}
#[cfg(not(debug_assertions))]
pub fn map_with_arena<'a, P, F, Before, After>(parser: P, transform: F) -> impl Parser<'a, After>
where
P: Parser<'a, Before>,
F: Fn(&'a Bump, Before) -> After,
{
map_with_arena_impl(parser, transform)
}
#[inline(always)]
pub fn map_with_arena_impl<'a, P, F, Before, After>(
parser: P,
transform: F,
) -> impl Parser<'a, After>
where
P: Parser<'a, Before>,
F: Fn(&'a Bump, Before) -> After,
{
move |arena, state| {
parser
.parse(arena, state)
.map(|(output, next_state)| (transform(arena, output), next_state))
}
}
#[cfg(not(debug_assertions))]
pub fn attempt<'a, P, Val>(attempting: Attempting, parser: P) -> impl Parser<'a, Val>
where
@ -1114,6 +1089,28 @@ where
BoxedParser::new(and_impl(p1, p2))
}
#[cfg(not(debug_assertions))]
pub fn map_with_arena<'a, P, F, Before, After>(parser: P, transform: F) -> impl Parser<'a, After>
where
P: Parser<'a, Before>,
F: Fn(&'a Bump, Before) -> After,
{
map_with_arena_impl(parser, transform)
}
#[inline(always)]
fn map_with_arena_impl<'a, P, F, Before, After>(parser: P, transform: F) -> impl Parser<'a, After>
where
P: Parser<'a, Before>,
F: Fn(&'a Bump, Before) -> After,
{
move |arena, state| {
parser
.parse(arena, state)
.map(|(output, next_state)| (transform(arena, output), next_state))
}
}
#[cfg(debug_assertions)]
pub fn map_with_arena<'a, P, F, Before, After>(parser: P, transform: F) -> BoxedParser<'a, After>
where