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

Function parseBlock

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

Source from the content-addressed store, hash-verified

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