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

Function parseReturnStatement

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

Source from the content-addressed store, hash-verified

3624 // 12.9 The return statement
3625
3626 function parseReturnStatement(node) {
3627 var argument = null;
3628
3629 expectKeyword('return');
3630
3631 if (!state.inFunctionBody) {
3632 tolerateError(Messages.IllegalReturn);
3633 }
3634
3635 // 'return' followed by a space and an identifier is very common.
3636 if (source.charCodeAt(lastIndex) === 0x20) {
3637 if (isIdentifierStart(source.charCodeAt(lastIndex + 1))) {
3638 argument = parseExpression();
3639 consumeSemicolon();
3640 return node.finishReturnStatement(argument);
3641 }
3642 }
3643
3644 if (hasLineTerminator) {
3645 // HACK
3646 return node.finishReturnStatement(null);
3647 }
3648
3649 if (!match(';')) {
3650 if (!match('}') && lookahead.type !== Token.EOF) {
3651 argument = parseExpression();
3652 }
3653 }
3654
3655 consumeSemicolon();
3656
3657 return node.finishReturnStatement(argument);
3658 }
3659
3660 // 12.10 The with statement
3661

Callers 1

parseStatementFunction · 0.85

Calls 6

expectKeywordFunction · 0.85
tolerateErrorFunction · 0.85
isIdentifierStartFunction · 0.85
parseExpressionFunction · 0.85
consumeSemicolonFunction · 0.85
matchFunction · 0.85

Tested by

no test coverage detected