Search in sources :

Example 1 with YieldExpressionTree

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

the class Parser method parseYield.

// yield [no line terminator] (*)? AssignExpression
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generator-function-definitions-runtime-semantics-evaluation
private ParseTree parseYield(Expression expressionIn) {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.YIELD);
    boolean isYieldAll = false;
    ParseTree expression = null;
    if (!peekImplicitSemiColon()) {
        isYieldAll = eatOpt(TokenType.STAR) != null;
        if (peekAssignmentExpression()) {
            expression = parseAssignment(expressionIn);
        } else if (isYieldAll) {
            reportError("yield* requires an expression");
        }
    }
    return new YieldExpressionTree(getTreeLocation(start), isYieldAll, expression);
}
Also used : SourcePosition(com.google.javascript.jscomp.parsing.parser.util.SourcePosition) YieldExpressionTree(com.google.javascript.jscomp.parsing.parser.trees.YieldExpressionTree) ParseTree(com.google.javascript.jscomp.parsing.parser.trees.ParseTree)

Aggregations

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