Search in sources :

Example 11 with BinaryOperatorTree

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

the class Parser method parseBitwiseXOR.

// 11.10 Bitwise XOR
private ParseTree parseBitwiseXOR(Expression expressionIn) {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseBitwiseAND(expressionIn);
    while (peek(TokenType.CARET)) {
        Token operator = eat(TokenType.CARET);
        ParseTree right = parseBitwiseAND(expressionIn);
        left = new BinaryOperatorTree(getTreeLocation(start), left, operator, right);
    }
    return left;
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) BinaryOperatorTree(com.google.javascript.jscomp.parsing.parser.trees.BinaryOperatorTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Example 12 with BinaryOperatorTree

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

the class Parser method parseExponentiationExpression.

private ParseTree parseExponentiationExpression() {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseUnaryExpression();
    if (peek(TokenType.STAR_STAR)) {
        // -x**y is a syntax error
        if (left.type == ParseTreeType.UNARY_EXPRESSION) {
            reportError("Unary operator '%s' requires parentheses before '**'", left.asUnaryExpression().operator);
        }
        Token operator = nextToken();
        ParseTree right = parseExponentiationExpression();
        return new BinaryOperatorTree(getTreeLocation(start), left, operator, right);
    } else {
        return left;
    }
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) BinaryOperatorTree(com.google.javascript.jscomp.parsing.parser.trees.BinaryOperatorTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

BinaryOperatorTree (com.google.javascript.jscomp.parsing.parser.trees.BinaryOperatorTree)12 ParseTree (com.google.javascript.jscomp.parsing.parser.trees.ParseTree)12 SourcePosition (com.google.javascript.jscomp.parsing.parser.util.SourcePosition)12