use comma,space as list separator (was comma only)

This commit is contained in:
Sander Hautvast 2021-03-02 19:21:23 +01:00
parent c63e2dabb6
commit 3d0cd483e6

View file

@ -95,12 +95,16 @@ export const parse = function (tokens) {
function finish_call(callee) {
let arguments_list = [];
if (!check(token_types.RIGHT_PAREN, token_index)) {
let result;
do {
arguments_list.push(expression());
} while (match([token_types.COMMA]));
}
if (!match([token_types.RIGHT_PAREN])) {
throw {message: "Expect ')' after arguments."};
result = expression();
if (result) {
arguments_list.push(result);
} else {
throw {message: "Expect ')' after arguments."};
}
match([token_types.COMMA]);
} while (!match([token_types.RIGHT_PAREN]));
}
return {type: 'call', name: callee, arguments: arguments_list};
@ -154,7 +158,7 @@ export const parse = function (tokens) {
function match(tokens_to_match) {
for (let i = 0; i < tokens_to_match.length; i++) {
if (are_same(tokens_to_match[i], current_token())) {
advance()
advance();
return true;
}
}