MCPcopy Index your code
hub / github.com/nodejs/node / parseLeftHandSideExpressionOrHigher

Function parseLeftHandSideExpressionOrHigher

test/fixtures/snapshot/typescript.js:35069–35131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35067 return expression;
35068 }
35069 function parseLeftHandSideExpressionOrHigher() {
35070 // Original Ecma:
35071 // LeftHandSideExpression: See 11.2
35072 // NewExpression
35073 // CallExpression
35074 //
35075 // Our simplification:
35076 //
35077 // LeftHandSideExpression: See 11.2
35078 // MemberExpression
35079 // CallExpression
35080 //
35081 // See comment in parseMemberExpressionOrHigher on how we replaced NewExpression with
35082 // MemberExpression to make our lives easier.
35083 //
35084 // to best understand the below code, it's important to see how CallExpression expands
35085 // out into its own productions:
35086 //
35087 // CallExpression:
35088 // MemberExpression Arguments
35089 // CallExpression Arguments
35090 // CallExpression[Expression]
35091 // CallExpression.IdentifierName
35092 // import (AssignmentExpression)
35093 // super Arguments
35094 // super.IdentifierName
35095 //
35096 // Because of the recursion in these calls, we need to bottom out first. There are three
35097 // bottom out states we can run into: 1) We see 'super' which must start either of
35098 // the last two CallExpression productions. 2) We see 'import' which must start import call.
35099 // 3)we have a MemberExpression which either completes the LeftHandSideExpression,
35100 // or starts the beginning of the first four CallExpression productions.
35101 var pos = getNodePos();
35102 var expression;
35103 if (token() === 100 /* SyntaxKind.ImportKeyword */) {
35104 if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
35105 // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "("
35106 // For example:
35107 // var foo3 = require("subfolder
35108 // import * as foo1 from "module-from-node
35109 // We want this import to be a statement rather than import call expression
35110 sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */;
35111 expression = parseTokenNode();
35112 }
35113 else if (lookAhead(nextTokenIsDot)) {
35114 // This is an 'import.*' metaproperty (i.e. 'import.meta')
35115 nextToken(); // advance past the 'import'
35116 nextToken(); // advance past the dot
35117 expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos);
35118 sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */;
35119 }
35120 else {
35121 expression = parseMemberExpressionOrHigher();
35122 }
35123 }
35124 else {
35125 expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher();
35126 }

Callers 3

parseUpdateExpressionFunction · 0.85
parseDecoratorExpressionFunction · 0.85

Calls 10

getNodePosFunction · 0.85
lookAheadFunction · 0.85
parseTokenNodeFunction · 0.85
nextTokenFunction · 0.85
finishNodeFunction · 0.85
parseIdentifierNameFunction · 0.85
parseSuperExpressionFunction · 0.85
parseCallExpressionRestFunction · 0.85
tokenFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…