Parse Expr::Suffixed

This commit is contained in:
Richard Feldman 2024-01-17 17:37:18 -05:00 committed by Luke Boswell
parent 88042c2578
commit 9bc0ab79af
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
2 changed files with 15 additions and 0 deletions

View file

@ -267,6 +267,9 @@ pub enum Expr<'a> {
// Collection Literals
List(Collection<'a, &'a Loc<Expr<'a>>>),
/// An expression followed by `!``
Suffixed(&'a Expr<'a>),
RecordUpdate {
update: &'a Loc<Expr<'a>>,
fields: Collection<'a, Loc<AssignedField<'a, Expr<'a>>>>,

View file

@ -1817,6 +1817,18 @@ fn parse_expr_end<'a>(
}
}
}
.map(|(progress, expr, state)| {
// If the next thing after the expression is a `!`, then it's Suffixed
if state.bytes().starts_with(b"!") {
(
progress,
Expr::Suffixed(arena.alloc(expr)),
state.advance(1),
)
} else {
(progress, expr, state)
}
})
}
pub fn loc_expr<'a>(accept_multi_backpassing: bool) -> impl Parser<'a, Loc<Expr<'a>>, EExpr<'a>> {