|
|
@ -151,14 +151,14 @@ impl Parser { |
|
|
|
let cond = self.parse()?; |
|
|
|
let cond = self.parse()?; |
|
|
|
self.expect_punc(Punctuator::CloseParen, "if block")?; |
|
|
|
self.expect_punc(Punctuator::CloseParen, "if block")?; |
|
|
|
let expr = self.parse()?; |
|
|
|
let expr = self.parse()?; |
|
|
|
let next = self.get_token(self.pos + 1); |
|
|
|
let next = self.get_token(self.pos); |
|
|
|
Ok(mk!( |
|
|
|
Ok(mk!( |
|
|
|
self, |
|
|
|
self, |
|
|
|
ExprDef::IfExpr( |
|
|
|
ExprDef::IfExpr( |
|
|
|
Box::new(cond), |
|
|
|
Box::new(cond), |
|
|
|
Box::new(expr), |
|
|
|
Box::new(expr), |
|
|
|
if next.is_ok() && next.unwrap().data == TokenData::Keyword(Keyword::Else) { |
|
|
|
if next.is_ok() && next.unwrap().data == TokenData::Keyword(Keyword::Else) { |
|
|
|
self.pos += 2; |
|
|
|
self.pos += 1; |
|
|
|
Some(Box::new(self.parse()?)) |
|
|
|
Some(Box::new(self.parse()?)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
None |
|
|
|
None |
|
|
|