Search in sources :

Example 1 with GeneratorExpression

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

the class Parser method generatorExpression.

private AstNode generatorExpression(AstNode result, int pos, boolean inFunctionParams) throws IOException {
    List<GeneratorExpressionLoop> loops = new ArrayList<GeneratorExpressionLoop>();
    while (peekToken() == Token.FOR) {
        loops.add(generatorExpressionLoop());
    }
    int ifPos = -1;
    ConditionData data = null;
    if (peekToken() == Token.IF) {
        consumeToken();
        ifPos = ts.tokenBeg - pos;
        data = condition();
    }
    if (!inFunctionParams) {
        mustMatchToken(Token.RP, "msg.no.paren.let");
    }
    GeneratorExpression pn = new GeneratorExpression(pos, ts.tokenEnd - pos);
    pn.setResult(result);
    pn.setLoops(loops);
    if (data != null) {
        pn.setIfPosition(ifPos);
        pn.setFilter(data.condition);
        pn.setFilterLp(data.lp - pos);
        pn.setFilterRp(data.rp - pos);
    }
    return pn;
}
Also used : ArrayList(java.util.ArrayList) GeneratorExpressionLoop(org.mozilla.javascript.ast.GeneratorExpressionLoop) GeneratorExpression(org.mozilla.javascript.ast.GeneratorExpression)

Aggregations

ArrayList (java.util.ArrayList)1 GeneratorExpression (org.mozilla.javascript.ast.GeneratorExpression)1 GeneratorExpressionLoop (org.mozilla.javascript.ast.GeneratorExpressionLoop)1