parseArrayLiteral method

Expression parseArrayLiteral()

Implementation

Expression parseArrayLiteral() {
  int? start = token!.startOffset;
  Token open = requireNext(Token.LBRACKET);
  List<Expression?> expressions = <Expression?>[];
  while (token!.type != Token.RBRACKET) {
    if (token!.type == Token.COMMA) {
      next();
      expressions.add(null);
    } else {
      expressions.add(parseAssignment());
      if (token!.type != Token.RBRACKET) {
        consume(Token.COMMA);
      }
    }
  }
  consume(Token.RBRACKET);
  return ArrayExpression(expressions)
    ..start = start
    ..end = endOffset
    ..line = open.line;
}