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