mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
make optional always backtrack on error
This commit is contained in:
parent
872f83680f
commit
851f472167
1 changed files with 10 additions and 4 deletions
|
@ -925,12 +925,11 @@ where
|
|||
|
||||
match parser.parse(arena, state) {
|
||||
Ok((progress, out1, state)) => Ok((progress, Some(out1), state)),
|
||||
Err((MadeProgress, fail, state)) => {
|
||||
Err((_, _, _)) => {
|
||||
// NOTE this will backtrack
|
||||
// Ok((NoProgress, None, original_state))
|
||||
Err((MadeProgress, fail, state))
|
||||
// TODO can we get rid of some of the potential backtracking?
|
||||
Ok((NoProgress, None, original_state))
|
||||
}
|
||||
Err((NoProgress, _, _)) => Ok((NoProgress, None, original_state)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1296,6 +1295,13 @@ macro_rules! one_or_more {
|
|||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
($parser:expr) => {
|
||||
move |arena, state: $crate::parser::State<'a>| dbg!($parser.parse(arena, state))
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! attempt {
|
||||
($attempting:expr, $parser:expr) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue