finishCall method

Expr finishCall(
  1. Expr callee
)

Implementation

Expr finishCall(Expr callee) {
  List<Expr> arguments = [];
  if (!check(TokenType.RIGHT_PAREN)) {
    do {
      if (check(TokenType.RIGHT_PAREN)) break;
      if (arguments.length >= 255) {
        error(peek(), "Can't have more than 255 arguments.");
      }
      if (peekNext().type == TokenType.COLON) {
        Token name =
            consume(TokenType.IDENTIFIER, "Expect argument name before :.");
        consume(TokenType.COLON, "Expect : after map key.");
        Expr expr = expression();
        arguments.add(NamedArgs({name.lexeme: expr}));
      } else {
        arguments.add(expression());
      }
    } while (match([TokenType.COMMA]));
  }

  Token paren = consume(TokenType.RIGHT_PAREN, "Expect ')' after arguments.");

  return Call(callee, paren, arguments);
}