cl-ast: Change loop expression to take any expression as its argument, for later desugaring.

This commit is contained in:
2024-04-18 01:53:32 -05:00
parent 00d72b823a
commit 02b775259e
3 changed files with 6 additions and 8 deletions

View File

@@ -809,7 +809,10 @@ impl<'t> Parser<'t> {
self.consume_peeked();
Unary { kind, tail: self.exprkind(after)?.into() }.into()
}
TokenKind::Loop => ExprKind::Loop(self.parse_loop()?),
TokenKind::Loop => {
self.consume_peeked();
Loop { body: self.expr()?.into() }.into()
}
TokenKind::While => ExprKind::While(self.parse_while()?),
TokenKind::If => ExprKind::If(self.parse_if()?),
TokenKind::For => ExprKind::For(self.parse_for()?),
@@ -1011,12 +1014,6 @@ impl<'t> Parser<'t> {
}
/// ## Control flow subexpressions
impl<'t> Parser<'t> {
/// [Loop] = `loop` [Block]
pub fn parse_loop(&mut self) -> PResult<Loop> {
self.match_type(TokenKind::Loop, Parsing::Loop)?;
Ok(Loop { body: self.block()? })
}
/// [While] = `while` [Expr] [Block] [Else]?
pub fn parse_while(&mut self) -> PResult<While> {
self.match_type(TokenKind::While, Parsing::While)?;