semi-colons working after function invocations
This commit is contained in:
@@ -128,7 +128,13 @@ impl Parser {
|
|||||||
/// Parses the input from the tokenizer buffer and returns the resulting expression
|
/// Parses the input from the tokenizer buffer and returns the resulting expression
|
||||||
pub fn parse(&mut self) -> Result<Option<tree_node::Expression>, ParseError> {
|
pub fn parse(&mut self) -> Result<Option<tree_node::Expression>, ParseError> {
|
||||||
self.assign_next()?;
|
self.assign_next()?;
|
||||||
self.expression()
|
let expr = self.expression()?;
|
||||||
|
|
||||||
|
if self_matches_peek!(self, TokenType::Symbol(Symbol::Semicolon)) {
|
||||||
|
self.assign_next()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Assigns the next token in the tokenizer buffer to the current token
|
/// Assigns the next token in the tokenizer buffer to the current token
|
||||||
@@ -426,7 +432,8 @@ impl Parser {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let expression = self.parse()?.ok_or(ParseError::UnexpectedEOF)?;
|
self.assign_next()?;
|
||||||
|
let expression = self.expression()?.ok_or(ParseError::UnexpectedEOF)?;
|
||||||
|
|
||||||
let current_token = token_from_option!(self.get_next()?);
|
let current_token = token_from_option!(self.get_next()?);
|
||||||
if !token_matches!(current_token, TokenType::Symbol(Symbol::RParen)) {
|
if !token_matches!(current_token, TokenType::Symbol(Symbol::RParen)) {
|
||||||
@@ -511,14 +518,13 @@ impl Parser {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
while !token_matches!(
|
while !self_matches_peek!(self, TokenType::Symbol(Symbol::RBrace)) {
|
||||||
token_from_option!(self.get_next()?),
|
let expression = self.parse()?.ok_or(ParseError::UnexpectedEOF)?;
|
||||||
TokenType::Symbol(Symbol::RBrace)
|
|
||||||
) {
|
|
||||||
let expression = self.expression()?.ok_or(ParseError::UnexpectedEOF)?;
|
|
||||||
expressions.push(expression);
|
expressions.push(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.assign_next()?;
|
||||||
|
|
||||||
Ok(BlockExpression(expressions))
|
Ok(BlockExpression(expressions))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +551,8 @@ impl Parser {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let assignment_expression = self.parse()?.ok_or(ParseError::UnexpectedEOF)?;
|
self.assign_next()?;
|
||||||
|
let assignment_expression = self.expression()?.ok_or(ParseError::UnexpectedEOF)?;
|
||||||
|
|
||||||
// make sure the next token is a semi-colon
|
// make sure the next token is a semi-colon
|
||||||
let current_token = token_from_option!(self.get_next()?);
|
let current_token = token_from_option!(self.get_next()?);
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ fn doThings(x, y, z) {
|
|||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
doThings(1, 2, 3)
|
doThings(1, 2, 3);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user