ast: add continue expression

This commit is contained in:
2025-10-28 22:47:58 -04:00
parent fb8677c937
commit d5e25a15dc
4 changed files with 5 additions and 0 deletions

View File

@@ -120,6 +120,7 @@ fn from_prefix(token: &Token) -> PResult<(Ps, Prec)> {
TKind::While => (Ps::Op(Op::While), Prec::Body),
TKind::Break => (Ps::Op(Op::Break), Prec::Body),
TKind::Return => (Ps::Op(Op::Return), Prec::Body),
TKind::Continue => (Ps::Op(Op::Continue), Prec::Min),
TKind::LCurly => (Ps::Op(Op::Block), Prec::Min),
TKind::RCurly => (Ps::End, Prec::Do),
@@ -266,6 +267,7 @@ impl<'t> Parse<'t> for Expr {
Some(value) => Expr::Op(Op::Group, vec![value]),
None => Expr::Op(Op::Tuple, vec![]),
},
Ps::Op(Op::Continue) => p.consume().then(Expr::Op(Op::Continue, vec![])),
Ps::Op(op @ (Op::If | Op::While)) => {
p.consume();
let exprs = vec![