no more semicolon for now
This commit is contained in:
parent
bbc6c276a8
commit
40bf9bc992
|
@ -45,7 +45,6 @@ kinds!(
|
|||
ParenOpen,
|
||||
ParenClose,
|
||||
Comma,
|
||||
Semicolon,
|
||||
Eol,
|
||||
Func,
|
||||
If,
|
||||
|
@ -285,9 +284,6 @@ where
|
|||
// , comma
|
||||
',' => self.eat_to(Token::Comma),
|
||||
|
||||
// ; semicolon
|
||||
';' => self.eat_to(Token::Semicolon),
|
||||
|
||||
// = equals
|
||||
// or == equal to
|
||||
'=' => match self.eat_peek() {
|
||||
|
|
|
@ -128,8 +128,7 @@ where
|
|||
}
|
||||
// start of a block
|
||||
Token::CurlyOpen => {
|
||||
let exprs =
|
||||
self.parse_delimited_until(TokenKind::Semicolon, Some(TokenKind::CurlyClose))?;
|
||||
let exprs = self.parse_until(Some(TokenKind::CurlyClose))?;
|
||||
// skip curly brace
|
||||
self.eat();
|
||||
Box::new(Expr::Block(Block { exprs }))
|
||||
|
@ -254,6 +253,22 @@ where
|
|||
Ok(lhs)
|
||||
}
|
||||
|
||||
fn parse_until(&mut self, until: Option<TokenKind>) -> Result<Vec<Expr>> {
|
||||
let mut exprs = Vec::new();
|
||||
|
||||
while !self.is_next(until) {
|
||||
// try to parse expr
|
||||
exprs.push(*self.parse_expr(Precedence::Min, false)?);
|
||||
|
||||
// check for end
|
||||
if self.is_next(until) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(exprs)
|
||||
}
|
||||
|
||||
fn parse_delimited_until(
|
||||
&mut self,
|
||||
delim: TokenKind,
|
||||
|
@ -283,7 +298,7 @@ where
|
|||
}
|
||||
|
||||
pub fn parse(&mut self) -> Result<Block> {
|
||||
let exprs = self.parse_delimited_until(TokenKind::Semicolon, None)?;
|
||||
let exprs = self.parse_until(None)?;
|
||||
Ok(Block { exprs })
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue