Search in sources :

Example 1 with EmptyStatementTree

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

the class Parser method parseEmptyStatement.

// 12.3 Empty Statement
private EmptyStatementTree parseEmptyStatement() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.SEMI_COLON);
    return new EmptyStatementTree(getTreeLocation(start));
}
Also used : EmptyStatementTree(com.google.javascript.jscomp.parsing.parser.trees.EmptyStatementTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition)

Example 2 with EmptyStatementTree

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

the class Parser method parseCatch.

private CatchTree parseCatch() {
    SourcePosition start = getTreeStartLocation();
    CatchTree catchBlock;
    eat(TokenType.CATCH);
    ParseTree exception = new EmptyStatementTree(new SourceRange(getTreeEndLocation(), getTreeStartLocation()));
    if (peekToken().type == TokenType.OPEN_PAREN) {
        eat(TokenType.OPEN_PAREN);
        if (peekPatternStart()) {
            exception = parsePattern(PatternKind.INITIALIZER);
        } else {
            exception = parseIdentifierExpression();
        }
        eat(TokenType.CLOSE_PAREN);
    } else {
        recordFeatureUsed(Feature.OPTIONAL_CATCH_BINDING);
    }
    BlockTree catchBody = parseBlock();
    catchBlock = new CatchTree(getTreeLocation(start), exception, catchBody);
    return catchBlock;
}
Also used : EmptyStatementTree(com.google.javascript.jscomp.parsing.parser.trees.EmptyStatementTree) CatchTree(com.google.javascript.jscomp.parsing.parser.trees.CatchTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) BlockTree(com.google.javascript.jscomp.parsing.parser.trees.BlockTree) SourceRange(com.google.javascript.jscomp.parsing.parser.util.SourceRange) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

EmptyStatementTree (com.google.javascript.jscomp.parsing.parser.trees.EmptyStatementTree)2 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)2 BlockTree (com.google.javascript.jscomp.parsing.parser.trees.BlockTree)1 CatchTree (com.google.javascript.jscomp.parsing.parser.trees.CatchTree)1 ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)1 SourceRange (com.google.javascript.jscomp.parsing.parser.util.SourceRange)1