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

Function parseBlock

packages/babel-parser/src/parser/statement.ts:1228–1253  ·  view source on GitHub ↗
(
    this: Parser,
    allowDirectives: boolean = false,
    createNewLexicalScope: boolean = true,
    afterBlockParse?: (hasStrictModeDirective: boolean) => void,
  )

Source from the content-addressed store, hash-verified

1226 // function bodies).
1227
1228 parseBlock(
1229 this: Parser,
1230 allowDirectives: boolean = false,
1231 createNewLexicalScope: boolean = true,
1232 afterBlockParse?: (hasStrictModeDirective: boolean) => void,
1233 ): N.BlockStatement {
1234 const node = this.startNode<N.BlockStatement>();
1235 if (allowDirectives) {
1236 this.state.strictErrors.clear();
1237 }
1238 this.expect(tt.braceL);
1239 if (createNewLexicalScope) {
1240 this.scope.enter(ScopeFlag.OTHER);
1241 }
1242 this.parseBlockBody(
1243 node,
1244 allowDirectives,
1245 false,
1246 tt.braceR,
1247 afterBlockParse,
1248 );
1249 if (createNewLexicalScope) {
1250 this.scope.exit();
1251 }
1252 return this.finishNode(node, "BlockStatement");
1253 }
1254
1255 isValidDirective(stmt: N.Statement): stmt is N.ExpressionStatement {
1256 return (

Callers

nothing calls this directly

Calls 4

parseBlockBodyMethod · 0.80
finishNodeMethod · 0.80
enterMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected