mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-01-23 05:28:34 +01:00
Fixed function declarations not parsing properly.
This commit is contained in:
parent
70d2913cb9
commit
94722ed27e
@ -68,7 +68,7 @@ impl Parser {
|
|||||||
if self.match_token(TokenKind::Identifier) {
|
if self.match_token(TokenKind::Identifier) {
|
||||||
return match self.peek_next().kind {
|
return match self.peek_next().kind {
|
||||||
TokenKind::Equals => self.parse_var_decl_stmt(),
|
TokenKind::Equals => self.parse_var_decl_stmt(),
|
||||||
TokenKind::Identifier => self.parse_identifier_stmt(),
|
TokenKind::OpenParenthesis => self.parse_identifier_stmt(),
|
||||||
_ => Stmt::Expr(Box::new(self.parse_expr())),
|
_ => Stmt::Expr(Box::new(self.parse_expr())),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ impl Parser {
|
|||||||
let primary = self.parse_primary(); // Since function declarations and function calls look the same at first, simply parse a "function call", and re-use the data.
|
let primary = self.parse_primary(); // Since function declarations and function calls look the same at first, simply parse a "function call", and re-use the data.
|
||||||
|
|
||||||
// If `primary` is followed by an equal sign, it is a function declaration.
|
// If `primary` is followed by an equal sign, it is a function declaration.
|
||||||
if self.peek().kind.compare(&TokenKind::Equals) {
|
if let TokenKind::Equals = self.peek().kind {
|
||||||
self.advance();
|
self.advance();
|
||||||
let expr = self.parse_expr();
|
let expr = self.parse_expr();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user