function list(tokeniser, { parser, allowDangler, listName = "list" }) {
  const first = parser(tokeniser);
  if (!first) {
    return [];
  }
  first.tokens.separator = tokeniser.consume(",");
  const items = [first];
  while (first.tokens.separator) {
    const item = parser(tokeniser);
    if (!item) {
      if (!allowDangler) {
        tokeniser.error(`Trailing comma in ${listName}`);
      }
      break;
    }
    item.tokens.separator = tokeniser.consume(",");
    items.push(item);
    if (!item.tokens.separator) break;
  }
  return items;
}
Parses comma-separated list
@param {import("../tokeniser.js").Tokeniser} tokeniser
@param {object} args
@param {Function} args.parser parser function for each item
@param {boolean} [args.allowDangler] whether to allow dangling comma
@param {string} [args.listName] the name to be shown on error messages