add word10 fn

This commit is contained in:
Bryce Miller 2023-05-19 21:13:33 -04:00
parent 57336e3de1
commit 0f289ed712
No known key found for this signature in database
GPG key ID: F1E97BF8DF152350

View file

@ -1608,6 +1608,48 @@ where
}
}
pub fn word10<'a, ToError, E>(
word_1: u8,
word_2: u8,
word_3: u8,
word_4: u8,
word_5: u8,
word_6: u8,
word_7: u8,
word_8: u8,
word_9: u8,
word_10: u8,
to_error: ToError,
) -> impl Parser<'a, (), E>
where
ToError: Fn(Position) -> E,
E: 'a,
{
debug_assert_ne!(word_1, b'\n');
debug_assert_ne!(word_2, b'\n');
debug_assert_ne!(word_3, b'\n');
debug_assert_ne!(word_4, b'\n');
debug_assert_ne!(word_5, b'\n');
debug_assert_ne!(word_6, b'\n');
debug_assert_ne!(word_7, b'\n');
debug_assert_ne!(word_8, b'\n');
debug_assert_ne!(word_9, b'\n');
debug_assert_ne!(word_10, b'\n');
let needle = [
word_1, word_2, word_3, word_4, word_5, word_6, word_7, word_8, word_9, word_10,
];
move |_arena: &'a Bump, state: State<'a>, _min_indent: u32| {
if state.bytes().starts_with(&needle) {
let state = state.advance(10);
Ok((MadeProgress, (), state))
} else {
Err((NoProgress, to_error(state.pos())))
}
}
}
#[macro_export]
macro_rules! word1_check_indent {
($word:expr, $word_problem:expr, $min_indent:expr, $indent_problem:expr) => {