mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Get basic def working
This commit is contained in:
parent
f6ecc88d9c
commit
fda3d3056a
8 changed files with 323 additions and 152 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue