cl-ast: Change loop expression to take any expression as its argument, for later desugaring.
This commit is contained in:
parent
00d72b823a
commit
02b775259e
@ -666,6 +666,7 @@ mod convert {
|
||||
Block => ExprKind::Block,
|
||||
Group => ExprKind::Group,
|
||||
Tuple => ExprKind::Tuple,
|
||||
Loop => ExprKind::Loop,
|
||||
While => ExprKind::While,
|
||||
If => ExprKind::If,
|
||||
For => ExprKind::For,
|
||||
|
@ -497,7 +497,7 @@ pub struct Tuple {
|
||||
/// A [Loop] expression: `loop` [`Block`]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Loop {
|
||||
pub body: Block,
|
||||
pub body: Box<Expr>,
|
||||
}
|
||||
|
||||
/// A [While] expression: `while` [`Expr`] [`Block`] [`Else`]?
|
||||
|
@ -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)?;
|
||||
|
Loading…
Reference in New Issue
Block a user