more flexible statement parsing

This commit is contained in:
Luke Boswell 2024-04-11 14:23:47 +10:00
parent 68c00a1493
commit b13adf6898
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
2 changed files with 94 additions and 23 deletions

View file

@ -197,12 +197,17 @@ where
)
}
pub fn check_indent<'a, E>(indent_problem: fn(Position) -> E) -> impl Parser<'a, (), E>
pub fn check_indent<'a, E>(
indent_problem: fn(Position) -> E,
inside_suffixed_statement: bool,
) -> impl Parser<'a, (), E>
where
E: 'a,
{
let extra_spaces = if inside_suffixed_statement { 4 } else { 0 };
move |_, state: State<'a>, min_indent: u32| {
if state.column() >= min_indent {
if state.column() >= (min_indent + extra_spaces) {
Ok((NoProgress, (), state))
} else {
Err((NoProgress, indent_problem(state.pos())))