Search in sources :

Example 1 with IfStatementTree

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

the class Parser method parseIfStatement.

// 12.5 If Statement
private IfStatementTree parseIfStatement() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.IF);
    eat(TokenType.OPEN_PAREN);
    ParseTree condition = parseExpression();
    eat(TokenType.CLOSE_PAREN);
    ParseTree ifClause = parseStatement();
    ParseTree elseClause = null;
    if (peek(TokenType.ELSE)) {
        eat(TokenType.ELSE);
        elseClause = parseStatement();
    }
    return new IfStatementTree(getTreeLocation(start), condition, ifClause, elseClause);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) IfStatementTree(com.google.javascript.jscomp.parsing.parser.trees.IfStatementTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

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