Search in sources :

Example 51 with ParseTree

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

the class Parser method parseEnumMembers.

private ImmutableList<ParseTree> parseEnumMembers() {
    SourceRange range = getTreeLocation(getTreeStartLocation());
    IdentifierToken propertyName;
    ParseTree member = null;
    ImmutableList.Builder<ParseTree> result = ImmutableList.builder();
    while (peekId()) {
        propertyName = parseIdentifierExpression().identifierToken;
        member = new PropertyNameAssignmentTree(range, propertyName, null);
        result.add(member);
        if (!peek(TokenType.CLOSE_CURLY)) {
            eat(TokenType.COMMA);
        }
    }
    return result.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) SourceRange(com.google.javascript.jscomp.parsing.parser.util.SourceRange) PropertyNameAssignmentTree(com.google.javascript.jscomp.parsing.parser.trees.PropertyNameAssignmentTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 52 with ParseTree

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

the class Parser method parseAmbientDeclaration.

private ParseTree parseAmbientDeclaration() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.DECLARE);
    ParseTree declare = parseAmbientDeclarationHelper();
    return new AmbientDeclarationTree(getTreeLocation(start), declare);
}
Also used : AmbientDeclarationTree(com.google.javascript.jscomp.parsing.parser.trees.AmbientDeclarationTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 53 with ParseTree

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

the class Parser method parseTypeAlias.

private ParseTree parseTypeAlias() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.TYPE);
    IdentifierToken alias = eatId();
    eat(TokenType.EQUAL);
    ParseTree original = parseType();
    eatPossibleImplicitSemiColon();
    return new TypeAliasTree(getTreeLocation(start), alias, original);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) TypeAliasTree(com.google.javascript.jscomp.parsing.parser.trees.TypeAliasTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 54 with ParseTree

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

the class Parser method parsePatternRest.

private ParseTree parsePatternRest(PatternKind patternKind) {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.SPREAD);
    ParseTree patternAssignmentTarget = parseRestAssignmentTarget(patternKind);
    return new AssignmentRestElementTree(getTreeLocation(start), patternAssignmentTarget);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) AssignmentRestElementTree(com.google.javascript.jscomp.parsing.parser.trees.AssignmentRestElementTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 55 with ParseTree

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

the class Parser method parseRecordTypeExpression.

private ParseTree parseRecordTypeExpression() {
    SourcePosition start = getTreeStartLocation();
    ParseTree typeExpression;
    if (peek(TokenType.OPEN_CURLY)) {
        eat(TokenType.OPEN_CURLY);
        typeExpression = new RecordTypeTree(getTreeLocation(start), parseInterfaceElements());
        eat(TokenType.CLOSE_CURLY);
    } else {
        typeExpression = parseTypeQuery();
    }
    return typeExpression;
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) RecordTypeTree(com.google.javascript.jscomp.parsing.parser.trees.RecordTypeTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)100 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)81 ImmutableList (com.google.common.collect.ImmutableList)15 BinaryOperatorTree (com.google.javascript.jscomp.parsing.parser.trees.BinaryOperatorTree)14 FormalParameterListTree (com.google.javascript.jscomp.parsing.parser.trees.FormalParameterListTree)9 FunctionDeclarationTree (com.google.javascript.jscomp.parsing.parser.trees.FunctionDeclarationTree)6 BlockTree (com.google.javascript.jscomp.parsing.parser.trees.BlockTree)5 DefaultParameterTree (com.google.javascript.jscomp.parsing.parser.trees.DefaultParameterTree)5 SourceRange (com.google.javascript.jscomp.parsing.parser.util.SourceRange)5 ArgumentListTree (com.google.javascript.jscomp.parsing.parser.trees.ArgumentListTree)4 ComputedPropertyMethodTree (com.google.javascript.jscomp.parsing.parser.trees.ComputedPropertyMethodTree)4 OptionalMemberExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.OptionalMemberExpressionTree)4 OptionalMemberLookupExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.OptionalMemberLookupExpressionTree)4 ComputedPropertyMemberVariableTree (com.google.javascript.jscomp.parsing.parser.trees.ComputedPropertyMemberVariableTree)3 GenericTypeListTree (com.google.javascript.jscomp.parsing.parser.trees.GenericTypeListTree)3 IdentifierExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.IdentifierExpressionTree)3 NullTree (com.google.javascript.jscomp.parsing.parser.trees.NullTree)3 OptChainCallExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.OptChainCallExpressionTree)3 CommaExpressionTree (com.google.javascript.jscomp.parsing.parser.trees.CommaExpressionTree)2 DoWhileStatementTree (com.google.javascript.jscomp.parsing.parser.trees.DoWhileStatementTree)2