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

Method parseLeftHandSideExpressionAllowCall

src/parser.ts:1238–1300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1236 }
1237
1238 parseLeftHandSideExpressionAllowCall(): Node.Expression {
1239 const startToken = this.lookahead;
1240 const maybeAsync = this.matchContextualKeyword('async');
1241
1242 const previousAllowIn = this.context.allowIn;
1243 this.context.allowIn = true;
1244
1245 let expr;
1246 if (this.matchKeyword('super') && this.context.inFunctionBody) {
1247 expr = this.createNode();
1248 this.nextToken();
1249 expr = this.finalize(expr, new Node.Super());
1250 if (!this.match('(') && !this.match('.') && !this.match('[')) {
1251 this.throwUnexpectedToken(this.lookahead);
1252 }
1253 } else {
1254 expr = this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression);
1255 }
1256
1257 while (true) {
1258 if (this.match('.')) {
1259 this.context.isBindingElement = false;
1260 this.context.isAssignmentTarget = true;
1261 this.expect('.');
1262 const property = this.parseIdentifierName();
1263 expr = this.finalize(this.startNode(startToken), new Node.StaticMemberExpression(expr, property));
1264
1265 } else if (this.match('(')) {
1266 const asyncArrow = maybeAsync && (startToken.lineNumber === this.lookahead.lineNumber);
1267 this.context.isBindingElement = false;
1268 this.context.isAssignmentTarget = false;
1269 const args = asyncArrow ? this.parseAsyncArguments() : this.parseArguments();
1270 expr = this.finalize(this.startNode(startToken), new Node.CallExpression(expr, args));
1271 if (asyncArrow && this.match('=>')) {
1272 for (let i = 0; i < args.length; ++i) {
1273 this.reinterpretExpressionAsPattern(args[i]);
1274 }
1275 expr = {
1276 type: ArrowParameterPlaceHolder,
1277 params: args,
1278 async: true
1279 };
1280 }
1281 } else if (this.match('[')) {
1282 this.context.isBindingElement = false;
1283 this.context.isAssignmentTarget = true;
1284 this.expect('[');
1285 const property = this.isolateCoverGrammar(this.parseExpression);
1286 this.expect(']');
1287 expr = this.finalize(this.startNode(startToken), new Node.ComputedMemberExpression(expr, property));
1288
1289 } else if (this.lookahead.type === Token.Template && this.lookahead.head) {
1290 const quasi = this.parseTemplateLiteral();
1291 expr = this.finalize(this.startNode(startToken), new Node.TaggedTemplateExpression(expr, quasi));
1292
1293 } else {
1294 break;
1295 }

Callers

nothing calls this directly

Calls 15

matchKeywordMethod · 0.95
createNodeMethod · 0.95
nextTokenMethod · 0.95
finalizeMethod · 0.95
matchMethod · 0.95
throwUnexpectedTokenMethod · 0.95
inheritCoverGrammarMethod · 0.95
expectMethod · 0.95
parseIdentifierNameMethod · 0.95
startNodeMethod · 0.95
parseAsyncArgumentsMethod · 0.95

Tested by

no test coverage detected