MCPcopy Index your code
hub / github.com/BloombergGraphics/whatiscode / parseBreakStatement

Function parseBreakStatement

scripts/libs/esprima.js:3582–3622  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

3580 // 12.8 The break statement
3581
3582 function parseBreakStatement(node) {
3583 var label = null, key;
3584
3585 expectKeyword('break');
3586
3587 // Catch the very common case first: immediately a semicolon (U+003B).
3588 if (source.charCodeAt(lastIndex) === 0x3B) {
3589 lex();
3590
3591 if (!(state.inIteration || state.inSwitch)) {
3592 throwError(Messages.IllegalBreak);
3593 }
3594
3595 return node.finishBreakStatement(null);
3596 }
3597
3598 if (hasLineTerminator) {
3599 if (!(state.inIteration || state.inSwitch)) {
3600 throwError(Messages.IllegalBreak);
3601 }
3602
3603 return node.finishBreakStatement(null);
3604 }
3605
3606 if (lookahead.type === Token.Identifier) {
3607 label = parseVariableIdentifier();
3608
3609 key = '$' + label.name;
3610 if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
3611 throwError(Messages.UnknownLabel, label.name);
3612 }
3613 }
3614
3615 consumeSemicolon();
3616
3617 if (label === null && !(state.inIteration || state.inSwitch)) {
3618 throwError(Messages.IllegalBreak);
3619 }
3620
3621 return node.finishBreakStatement(label);
3622 }
3623
3624 // 12.9 The return statement
3625

Callers 1

parseStatementFunction · 0.85

Calls 5

expectKeywordFunction · 0.85
lexFunction · 0.85
throwErrorFunction · 0.85
parseVariableIdentifierFunction · 0.85
consumeSemicolonFunction · 0.85

Tested by

no test coverage detected