Search in sources :

Example 1 with Assignment

use of org.mozilla.javascript.ast.Assignment in project st-js by st-js.

the class RhinoJavaScriptBuilder method assignment.

/**
 * {@inheritDoc}
 */
@Override
public AstNode assignment(AssignOperator operator, AstNode left, AstNode right) {
    Assignment a = new Assignment();
    a.setOperator(operator.getJavaScript());
    a.setLeft(left);
    a.setRight(right);
    return a;
}
Also used : Assignment(org.mozilla.javascript.ast.Assignment)

Example 2 with Assignment

use of org.mozilla.javascript.ast.Assignment in project HL4A by HL4A.

the class Parser method assignExpr.

private AstNode assignExpr() throws IOException {
    int tt = peekToken();
    if (tt == Token.YIELD) {
        return returnOrYield(tt, true);
    }
    AstNode pn = condExpr();
    boolean hasEOL = false;
    tt = peekTokenOrEOL();
    if (tt == Token.EOL) {
        hasEOL = true;
        tt = peekToken();
    }
    if (Token.FIRST_ASSIGN <= tt && tt <= Token.LAST_ASSIGN) {
        consumeToken();
        // Pull out JSDoc info and reset it before recursing.
        Comment jsdocNode = getAndResetJsDoc();
        markDestructuring(pn);
        int opPos = ts.tokenBeg;
        pn = new Assignment(tt, pn, assignExpr(), opPos);
        if (jsdocNode != null) {
            pn.setJsDocNode(jsdocNode);
        }
    } else if (tt == Token.SEMI) {
        // For example: /** @type Number */ C.prototype.x;
        if (currentJsDocComment != null) {
            pn.setJsDocNode(getAndResetJsDoc());
        }
    } else if (!hasEOL && tt == Token.ARROW) {
        consumeToken();
        pn = arrowFunction(pn);
    }
    return pn;
}
Also used : Assignment(org.mozilla.javascript.ast.Assignment) Comment(org.mozilla.javascript.ast.Comment) AstNode(org.mozilla.javascript.ast.AstNode)

Aggregations

Assignment (org.mozilla.javascript.ast.Assignment)2 AstNode (org.mozilla.javascript.ast.AstNode)1 Comment (org.mozilla.javascript.ast.Comment)1