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

Method parseReturnStatement

src/parser.ts:2401–2418  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2399 // https://tc39.github.io/ecma262/#sec-return-statement
2400
2401 parseReturnStatement(): Node.ReturnStatement {
2402 if (!this.context.inFunctionBody) {
2403 this.tolerateError(Messages.IllegalReturn);
2404 }
2405
2406 const node = this.createNode();
2407 this.expectKeyword('return');
2408
2409 const hasArgument = (!this.match(';') && !this.match('}') &&
2410 !this.hasLineTerminator && this.lookahead.type !== Token.EOF) ||
2411 this.lookahead.type === Token.StringLiteral ||
2412 this.lookahead.type === Token.Template;
2413
2414 const argument = hasArgument ? this.parseExpression() : null;
2415 this.consumeSemicolon();
2416
2417 return this.finalize(node, new Node.ReturnStatement(argument));
2418 }
2419
2420 // https://tc39.github.io/ecma262/#sec-with-statement
2421

Callers 1

parseStatementMethod · 0.95

Calls 7

tolerateErrorMethod · 0.95
createNodeMethod · 0.95
expectKeywordMethod · 0.95
matchMethod · 0.95
parseExpressionMethod · 0.95
consumeSemicolonMethod · 0.95
finalizeMethod · 0.95

Tested by

no test coverage detected