mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Parse if
and args w/ idents, format w/ parens
This commit is contained in:
parent
2ced7ee5d8
commit
ebaed27193
5 changed files with 184 additions and 20 deletions
|
@ -200,6 +200,26 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn not<'a, P, Val>(parser: P) -> impl Parser<'a, ()>
|
||||
where
|
||||
P: Parser<'a, Val>,
|
||||
{
|
||||
move |arena, state: State<'a>| {
|
||||
let original_state = state.clone();
|
||||
|
||||
match parser.parse(arena, state) {
|
||||
Ok((_, _)) => Err((
|
||||
Fail {
|
||||
reason: FailReason::ConditionFailed,
|
||||
attempting: original_state.attempting,
|
||||
},
|
||||
original_state,
|
||||
)),
|
||||
Err((_, _)) => Ok(((), original_state)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lookahead<'a, Peek, P, PeekVal, Val>(peek: Peek, parser: P) -> impl Parser<'a, Val>
|
||||
where
|
||||
Peek: Parser<'a, PeekVal>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue