Browse Source

next is already sitting at correct token, no need to advance. Fixes #38

pull/41/head
Jason Williams 5 years ago
parent
commit
2cc4c6fafb
  1. 4
      src/lib/syntax/parser.rs

4
src/lib/syntax/parser.rs

@ -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

Loading…
Cancel
Save