Skip to content

Commit

Permalink
recursively parse elseif branches
Browse files Browse the repository at this point in the history
  • Loading branch information
deaddog committed Jul 11, 2022
1 parent 9298a88 commit bca9a29
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/syntax/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,20 @@ where
self.token = Some(token);
Ok(ast::Block::default())
},
Token { kind: TokenKind::Keyword(Keyword::ElseIf), pos, .. } => {
self.step();

let (condition, then, otherwise) = self.parse_condblock()?;

let stmt = ast::Statement::Expr(ast::Expr::If {
condition: condition.into(),
then: then,
otherwise: otherwise,
pos: pos,
});

Ok(ast::Block::Block(Box::new([stmt])))
},
Token { kind: TokenKind::Keyword(Keyword::Else), .. } => {
self.step();
let block = self.parse_block();
Expand Down

0 comments on commit bca9a29

Please sign in to comment.