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

Method parseSwitchCase

src/parser.ts:2447–2469  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2445 // https://tc39.github.io/ecma262/#sec-switch-statement
2446
2447 parseSwitchCase(): Node.SwitchCase {
2448 const node = this.createNode();
2449
2450 let test;
2451 if (this.matchKeyword('default')) {
2452 this.nextToken();
2453 test = null;
2454 } else {
2455 this.expectKeyword('case');
2456 test = this.parseExpression();
2457 }
2458 this.expect(':');
2459
2460 const consequent: Node.StatementListItem[] = [];
2461 while (true) {
2462 if (this.match('}') || this.matchKeyword('default') || this.matchKeyword('case')) {
2463 break;
2464 }
2465 consequent.push(this.parseStatementListItem());
2466 }
2467
2468 return this.finalize(node, new Node.SwitchCase(test, consequent));
2469 }
2470
2471 parseSwitchStatement(): Node.SwitchStatement {
2472 const node = this.createNode();

Callers 1

parseSwitchStatementMethod · 0.95

Calls 10

createNodeMethod · 0.95
matchKeywordMethod · 0.95
nextTokenMethod · 0.95
expectKeywordMethod · 0.95
parseExpressionMethod · 0.95
expectMethod · 0.95
matchMethod · 0.95
finalizeMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected