MCPcopy Create free account
hub / github.com/babel/babel / parseYield

Function parseYield

packages/babel-parser/src/parser/expression.ts:3030–3071  ·  view source on GitHub ↗
(this: Parser, startLoc: Position)

Source from the content-addressed store, hash-verified

3028 // Parses yield expression inside generator.
3029
3030 parseYield(this: Parser, startLoc: Position): N.YieldExpression {
3031 const node = this.startNodeAt<N.YieldExpression>(startLoc);
3032
3033 this.expressionScope.recordParameterInitializerError(
3034 Errors.YieldInParameter,
3035 startLoc.index,
3036 );
3037
3038 let delegating = false;
3039 let argument: N.Expression | null = null;
3040 if (!this.hasPrecedingLineBreak()) {
3041 delegating = this.eat(tt.star);
3042 switch (this.state.type) {
3043 case tt.semi:
3044 case tt.eof:
3045 case tt.braceR:
3046 case tt.parenR:
3047 case tt.bracketR:
3048 case tt.braceBarR:
3049 case tt.colon:
3050 case tt.comma:
3051 // The above is the complete set of tokens that can
3052 // follow an AssignmentExpression, and none of them
3053 // can start an AssignmentExpression
3054 if (!delegating) break;
3055 /* fallthrough */
3056 case tt._in:
3057 // `in` may follow an AssignmentExpression[~In] in an Annex B
3058 // for-in initializer: `for (var x = yield in z)`
3059 if (this.options.annexB && !delegating) break;
3060 /* fallthrough */
3061 default:
3062 argument = this.parseMaybeAssign();
3063 }
3064 }
3065 if (!argument) {
3066 this.state.regExpAllowedAt = this.state.lastTokEndLoc!.index;
3067 }
3068 node.delegate = delegating;
3069 node.argument = argument;
3070 return this.finishNode(node, "YieldExpression");
3071 }
3072
3073 // https://tc39.es/ecma262/#prod-ImportCall
3074 parseImportCall(

Callers

nothing calls this directly

Calls 3

finishNodeMethod · 0.80
parseMaybeAssignMethod · 0.45

Tested by

no test coverage detected