parseObjectLiteral method

Expression parseObjectLiteral()

Implementation

Expression parseObjectLiteral() {
  int start = token?.startOffset??0;
  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 new ObjectExpression(properties)
    ..start = start??0
    ..end = endOffset
    ..line = open?.line??0;
}