Search in sources :

Example 6 with BinaryOperatorTree

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

the class Parser method parseAdditiveExpression.

// 11.6 Additive Expression
private ParseTree parseAdditiveExpression() {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseMultiplicativeExpression();
    while (peekAdditiveOperator()) {
        Token operator = nextToken();
        ParseTree right = parseMultiplicativeExpression();
        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 7 with BinaryOperatorTree

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

the class Parser method parseLogicalAND.

// 11.11 Logical AND
private ParseTree parseLogicalAND(Expression expressionIn) {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseBitwiseOR(expressionIn);
    while (peek(TokenType.AND)) {
        Token operator = eat(TokenType.AND);
        ParseTree right = parseBitwiseOR(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 8 with BinaryOperatorTree

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

the class Parser method parseMultiplicativeExpression.

// 11.5 Multiplicative Expression
private ParseTree parseMultiplicativeExpression() {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseExponentiationExpression();
    while (peekMultiplicativeOperator()) {
        Token operator = nextToken();
        ParseTree right = parseExponentiationExpression();
        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 9 with BinaryOperatorTree

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

the class Parser method parseLogicalOR.

// 11.11 Logical OR
private ParseTree parseLogicalOR(Expression expressionIn) {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseLogicalAND(expressionIn);
    while (peek(TokenType.OR)) {
        Token operator = eat(TokenType.OR);
        ParseTree right = parseLogicalAND(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 10 with BinaryOperatorTree

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

the class Parser method parseAssignment.

private ParseTree parseAssignment(Expression expressionIn) {
    if (peek(TokenType.YIELD) && inGeneratorContext()) {
        return parseYield(expressionIn);
    }
    SourcePosition start = getTreeStartLocation();
    // TODO(blickly): Allow TypeScript syntax in arrow function parameters
    ParseTree left = parseConditional(expressionIn);
    if (isStartOfAsyncArrowFunction(left)) {
        // re-evaluate as an async arrow function.
        resetScanner(left);
        return parseAsyncArrowFunction(expressionIn);
    }
    if (peek(TokenType.ARROW)) {
        return completeAssignmentExpressionParseAtArrow(left, expressionIn);
    }
    if (peekAssignmentOperator()) {
        left = transformLeftHandSideExpression(left);
        if (!left.isValidAssignmentTarget()) {
            reportError("invalid assignment target");
        }
        Token operator = nextToken();
        ParseTree right = parseAssignment(expressionIn);
        return 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)

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