mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Parse closures
This commit is contained in:
parent
5d6057bfc3
commit
2a80702a21
8 changed files with 224 additions and 52 deletions
|
@ -174,6 +174,19 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn then<'a, P1, F, Before, After>(parser: P1, transform: F) -> impl Parser<'a, After>
|
||||
where
|
||||
P1: Parser<'a, Before>,
|
||||
After: 'a,
|
||||
F: Fn(&'a Bump, State<'a>, Before) -> ParseResult<'a, After>,
|
||||
{
|
||||
move |arena, state| {
|
||||
parser
|
||||
.parse(arena, state)
|
||||
.and_then(|(output, next_state)| transform(arena, next_state, output))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub fn map<'a, P, F, Before, After>(parser: P, transform: F) -> impl Parser<'a, After>
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue