MCPcopy Create free account
hub / github.com/babel/babel / parseFor

Function parseFor

packages/babel-parser/src/parser/statement.ts:1338–1357  ·  view source on GitHub ↗
(
    this: Parser,
    node: Undone<N.ForStatement>,
    init?: N.VariableDeclaration | N.Expression | null,
  )

Source from the content-addressed store, hash-verified

1336 // expression.
1337
1338 parseFor(
1339 this: Parser,
1340 node: Undone<N.ForStatement>,
1341 init?: N.VariableDeclaration | N.Expression | null,
1342 ): N.ForStatement {
1343 node.init = init;
1344 this.semicolon(/* allowAsi */ false);
1345 node.test = this.match(tt.semi) ? null : this.parseExpression();
1346 this.semicolon(/* allowAsi */ false);
1347 node.update = this.match(tt.parenR) ? null : this.parseExpression();
1348 this.expect(tt.parenR);
1349
1350 // Parse the loop body.
1351 node.body = this.parseStatement();
1352
1353 this.scope.exit();
1354 this.state.labels.pop();
1355
1356 return this.finishNode(node, "ForStatement");
1357 }
1358
1359 // Parse a `for`/`in` and `for`/`of` loop, which are almost
1360 // same from parser's perspective.

Callers

nothing calls this directly

Calls 4

matchMethod · 0.80
finishNodeMethod · 0.80
semicolonMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected