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

Function parseFor

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

Source from the content-addressed store, hash-verified

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