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

Method parseNewExpression

src/parser.ts:1184–1208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1182 }
1183
1184 parseNewExpression(): Node.MetaProperty | Node.NewExpression {
1185 const node = this.createNode();
1186
1187 const id = this.parseIdentifierName();
1188 assert(id.name === 'new', 'New expression must start with `new`');
1189
1190 let expr;
1191 if (this.match('.')) {
1192 this.nextToken();
1193 if (this.lookahead.type === Token.Identifier && this.context.inFunctionBody && this.lookahead.value === 'target') {
1194 const property = this.parseIdentifierName();
1195 expr = new Node.MetaProperty(id, property);
1196 } else {
1197 this.throwUnexpectedToken(this.lookahead);
1198 }
1199 } else {
1200 const callee = this.isolateCoverGrammar(this.parseLeftHandSideExpression);
1201 const args = this.match('(') ? this.parseArguments() : [];
1202 expr = new Node.NewExpression(callee, args);
1203 this.context.isAssignmentTarget = false;
1204 this.context.isBindingElement = false;
1205 }
1206
1207 return this.finalize(node, expr);
1208 }
1209
1210 parseAsyncArgument() {
1211 const arg = this.parseAssignmentExpression();

Callers

nothing calls this directly

Calls 9

createNodeMethod · 0.95
parseIdentifierNameMethod · 0.95
matchMethod · 0.95
nextTokenMethod · 0.95
throwUnexpectedTokenMethod · 0.95
isolateCoverGrammarMethod · 0.95
parseArgumentsMethod · 0.95
finalizeMethod · 0.95
assertFunction · 0.90

Tested by

no test coverage detected