MCPcopy Create free account
hub / github.com/dchester/jsonpath / parseReturnStatement

Function parseReturnStatement

jsonpath.js:2999–3030  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2997 // 12.9 The return statement
2998
2999 function parseReturnStatement() {
3000 var argument = null;
3001
3002 expectKeyword('return');
3003
3004 if (!state.inFunctionBody) {
3005 throwErrorTolerant({}, Messages.IllegalReturn);
3006 }
3007
3008 // 'return' followed by a space and an identifier is very common.
3009 if (source.charCodeAt(index) === 0x20) {
3010 if (isIdentifierStart(source.charCodeAt(index + 1))) {
3011 argument = parseExpression();
3012 consumeSemicolon();
3013 return delegate.createReturnStatement(argument);
3014 }
3015 }
3016
3017 if (peekLineTerminator()) {
3018 return delegate.createReturnStatement(null);
3019 }
3020
3021 if (!match(';')) {
3022 if (!match('}') && lookahead.type !== Token.EOF) {
3023 argument = parseExpression();
3024 }
3025 }
3026
3027 consumeSemicolon();
3028
3029 return delegate.createReturnStatement(argument);
3030 }
3031
3032 // 12.10 The with statement
3033

Callers 1

parseStatementFunction · 0.85

Calls 7

expectKeywordFunction · 0.85
throwErrorTolerantFunction · 0.85
isIdentifierStartFunction · 0.85
parseExpressionFunction · 0.85
consumeSemicolonFunction · 0.85
peekLineTerminatorFunction · 0.85
matchFunction · 0.85

Tested by

no test coverage detected