MCPcopy
hub / github.com/jquery/esprima / parseBreakStatement

Method parseBreakStatement

src/parser.ts:2376–2397  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2374 // https://tc39.github.io/ecma262/#sec-break-statement
2375
2376 parseBreakStatement(): Node.BreakStatement {
2377 const node = this.createNode();
2378 this.expectKeyword('break');
2379
2380 let label: Node.Identifier | null = null;
2381 if (this.lookahead.type === Token.Identifier && !this.hasLineTerminator) {
2382 const id = this.parseVariableIdentifier();
2383
2384 const key = '$' + id.name;
2385 if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
2386 this.throwError(Messages.UnknownLabel, id.name);
2387 }
2388 label = id;
2389 }
2390
2391 this.consumeSemicolon();
2392 if (label === null && !this.context.inIteration && !this.context.inSwitch) {
2393 this.throwError(Messages.IllegalBreak);
2394 }
2395
2396 return this.finalize(node, new Node.BreakStatement(label));
2397 }
2398
2399 // https://tc39.github.io/ecma262/#sec-return-statement
2400

Callers 1

parseStatementMethod · 0.95

Calls 6

createNodeMethod · 0.95
expectKeywordMethod · 0.95
throwErrorMethod · 0.95
consumeSemicolonMethod · 0.95
finalizeMethod · 0.95

Tested by

no test coverage detected