mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-01-07 05:59:03 +01:00
Completed the parsing of multi-parameter functions. It now works!
This commit is contained in:
parent
6d67797565
commit
32cd3a4e9e
@ -184,7 +184,7 @@ impl Parser {
|
||||
TokenKind::OpenParenthesis => self.parse_group(),
|
||||
TokenKind::Pipe => self.parse_abs(),
|
||||
TokenKind::Identifier => self.parse_identifier(),
|
||||
_ => Expr::Literal(self.consume(TokenKind::Literal).value.clone()),
|
||||
_ => Expr::Literal(self.advance().value.clone()),
|
||||
};
|
||||
|
||||
if !self.is_at_end() && self.peek().kind.is_unit() {
|
||||
@ -215,10 +215,18 @@ impl Parser {
|
||||
|
||||
if self.match_token(TokenKind::OpenParenthesis) {
|
||||
self.advance();
|
||||
let parameter = self.parse_expr();
|
||||
|
||||
let mut parameters = Vec::new();
|
||||
parameters.push(self.parse_expr());
|
||||
|
||||
while self.match_token(TokenKind::Comma) {
|
||||
self.advance();
|
||||
parameters.push(self.parse_expr());
|
||||
}
|
||||
|
||||
self.consume(TokenKind::ClosedParenthesis);
|
||||
|
||||
Expr::FnCall(identifier.value, vec![parameter])
|
||||
Expr::FnCall(identifier.value, parameters)
|
||||
} else {
|
||||
Expr::Var(identifier.value)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user