Search in sources :

Example 1 with ObjectLiteralExpressionTree

use of com.google.javascript.jscomp.parsing.parser.trees.ObjectLiteralExpressionTree in project closure-compiler by google.

the class Parser method parseObjectLiteral.

// 11.1.4 Object Literal Expression
private ParseTree parseObjectLiteral() {
    SourcePosition start = getTreeStartLocation();
    ImmutableList.Builder<ParseTree> result = ImmutableList.builder();
    eat(TokenType.OPEN_CURLY);
    Token commaToken = null;
    while (peek(TokenType.SPREAD) || peekPropertyNameOrComputedProp(0) || peek(TokenType.STAR) || peekAccessibilityModifier()) {
        commaToken = null;
        result.add(parsePropertyAssignment());
        commaToken = eatOpt(TokenType.COMMA);
        if (commaToken == null) {
            break;
        }
    }
    eat(TokenType.CLOSE_CURLY);
    maybeReportTrailingComma(commaToken);
    return new ObjectLiteralExpressionTree(getTreeLocation(start), result.build());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ObjectLiteralExpressionTree(com.google.javascript.jscomp.parsing.parser.trees.ObjectLiteralExpressionTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ObjectLiteralExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.ObjectLiteralExpressionTree)1 ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)1 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)1