Search in sources :

Example 1 with ContinueStatement

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

the class RhinoJavaScriptBuilder method continueStatement.

/**
 * {@inheritDoc}
 */
@Override
public AstNode continueStatement(AstNode label) {
    ContinueStatement c = new ContinueStatement();
    c.setLabel(cast(label, Name.class));
    return c;
}
Also used : ContinueStatement(org.mozilla.javascript.ast.ContinueStatement) Name(org.mozilla.javascript.ast.Name)

Example 2 with ContinueStatement

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

the class Parser method continueStatement.

private ContinueStatement continueStatement() throws IOException {
    if (currentToken != Token.CONTINUE)
        codeBug();
    consumeToken();
    int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd;
    Name label = null;
    if (peekTokenOrEOL() == Token.NAME) {
        label = createNameNode();
        end = getNodeEnd(label);
    }
    // matchJumpLabelName only matches if there is one
    LabeledStatement labels = matchJumpLabelName();
    Loop target = null;
    if (labels == null && label == null) {
        if (loopSet == null || loopSet.size() == 0) {
            reportError("msg.continue.outside");
        } else {
            target = loopSet.get(loopSet.size() - 1);
        }
    } else {
        if (labels == null || !(labels.getStatement() instanceof Loop)) {
            reportError("msg.continue.nonloop", pos, end - pos);
        }
        target = labels == null ? null : (Loop) labels.getStatement();
    }
    ContinueStatement pn = new ContinueStatement(pos, end - pos);
    if (// can be null in error-recovery mode
    target != null)
        pn.setTarget(target);
    pn.setLabel(label);
    pn.setLineno(lineno);
    return pn;
}
Also used : WhileLoop(org.mozilla.javascript.ast.WhileLoop) ForLoop(org.mozilla.javascript.ast.ForLoop) GeneratorExpressionLoop(org.mozilla.javascript.ast.GeneratorExpressionLoop) ArrayComprehensionLoop(org.mozilla.javascript.ast.ArrayComprehensionLoop) Loop(org.mozilla.javascript.ast.Loop) ForInLoop(org.mozilla.javascript.ast.ForInLoop) DoLoop(org.mozilla.javascript.ast.DoLoop) LabeledStatement(org.mozilla.javascript.ast.LabeledStatement) ContinueStatement(org.mozilla.javascript.ast.ContinueStatement) Name(org.mozilla.javascript.ast.Name)

Aggregations

ContinueStatement (org.mozilla.javascript.ast.ContinueStatement)2 Name (org.mozilla.javascript.ast.Name)2 ArrayComprehensionLoop (org.mozilla.javascript.ast.ArrayComprehensionLoop)1 DoLoop (org.mozilla.javascript.ast.DoLoop)1 ForInLoop (org.mozilla.javascript.ast.ForInLoop)1 ForLoop (org.mozilla.javascript.ast.ForLoop)1 GeneratorExpressionLoop (org.mozilla.javascript.ast.GeneratorExpressionLoop)1 LabeledStatement (org.mozilla.javascript.ast.LabeledStatement)1 Loop (org.mozilla.javascript.ast.Loop)1 WhileLoop (org.mozilla.javascript.ast.WhileLoop)1