parseObjectLiteral method

Expression parseObjectLiteral()

Implementation

Expression parseObjectLiteral() {
  int? start = token!.startOffset;
  Token open = requireNext(Token.LBRACE);
  List<Property> properties = <Property>[];
  while (token!.type != Token.RBRACE) {
    if (properties.isNotEmpty) {
      consume(Token.COMMA);
    }
    if (token!.type == Token.RBRACE) break; // may end with extra comma
    properties.add(parseProperty());
  }
  requireNext(Token.RBRACE);
  return ObjectExpression(properties)
    ..start = start
    ..end = endOffset
    ..line = open.line;
}