Search in sources :

Example 1 with ConditionalExpressionTree

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

the class Parser method parseConditional.

// 11.12 Conditional Expression
private ParseTree parseConditional(Expression expressionIn) {
    SourcePosition start = getTreeStartLocation();
    ParseTree condition = parseShortCircuit(expressionIn);
    if (peek(TokenType.QUESTION)) {
        eat(TokenType.QUESTION);
        ParseTree left = parseAssignment(expressionIn);
        eat(TokenType.COLON);
        ParseTree right = parseAssignment(expressionIn);
        return new ConditionalExpressionTree(getTreeLocation(start), condition, left, right);
    }
    return condition;
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) ConditionalExpressionTree(com.google.javascript.jscomp.parsing.parser.trees.ConditionalExpressionTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

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