Search in sources :

Example 1 with TryStatementTree

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

the class Parser method parseTryStatement.

// 12.14 Try Statement
private ParseTree parseTryStatement() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.TRY);
    ParseTree body = parseBlock();
    ParseTree catchBlock = null;
    if (peek(TokenType.CATCH)) {
        catchBlock = parseCatch();
    }
    ParseTree finallyBlock = null;
    if (peek(TokenType.FINALLY)) {
        finallyBlock = parseFinallyBlock();
    }
    if (catchBlock == null && finallyBlock == null) {
        reportError("'catch' or 'finally' expected.");
    }
    return new TryStatementTree(getTreeLocation(start), body, catchBlock, finallyBlock);
}
Also used : TryStatementTree(com.google.javascript.jscomp.parsing.parser.trees.TryStatementTree) SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)1 TryStatementTree (com.google.javascript.jscomp.parsing.parser.trees.TryStatementTree)1 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)1