MCPcopy Create free account
hub / github.com/davidkingzyb/SCAST / parseCompIter

Function parseCompIter

lib/filbert.js:2304–2324  ·  view source on GitHub ↗
(expr, first)

Source from the content-addressed store, hash-verified

2302 // 'expr' is the body to be used after unrolling the ifs and fors
2303
2304 function parseCompIter(expr, first) {
2305 if (first && tokType !== _for) unexpected();
2306 if (eat(_bracketR)) return expr;
2307 var node = startNode();
2308 if (eat(_for)) {
2309 var init = parseExpression(false, true);
2310 var tupleArgs = getTupleArgs(init);
2311 if (!tupleArgs) checkLVal(init);
2312 expect(_in);
2313 var right = parseExpression();
2314 var body = parseCompIter(expr, false);
2315 var block = nc.createNodeSpan(body, body, "BlockStatement", { body: [body] });
2316 finishNode(node, "BlockStatement");
2317 return nc.createFor(node, init, tupleArgs, right, block);
2318 } else if (eat(_if)) {
2319 if (tokType === _parenL) node.test = parseParenExpression();
2320 else node.test = parseExpression();
2321 node.consequent = parseCompIter(expr, false);
2322 return finishNode(node, "IfStatement");
2323 } else unexpected();
2324 }
2325
2326 // Parse class
2327

Callers 1

parseListFunction · 0.85

Calls 9

eatFunction · 0.85
startNodeFunction · 0.85
parseExpressionFunction · 0.85
getTupleArgsFunction · 0.85
checkLValFunction · 0.85
expectFunction · 0.85
finishNodeFunction · 0.85
parseParenExpressionFunction · 0.85
unexpectedFunction · 0.70

Tested by

no test coverage detected