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

Function parseExprAtom

packages/babel-parser/src/parser/expression.ts:1185–1423  ·  view source on GitHub ↗
(
    this: Parser,
    refExpressionErrors?: ExpressionErrors | null,
  )

Source from the content-addressed store, hash-verified

1183 // AsyncArrowFunction
1184
1185 parseExprAtom(
1186 this: Parser,
1187 refExpressionErrors?: ExpressionErrors | null,
1188 ): N.Expression | N.Super | N.Import {
1189 let node;
1190 let decorators: N.Decorator[] | null = null;
1191
1192 const { type } = this.state;
1193 switch (type) {
1194 case tt._super:
1195 return this.parseSuper();
1196
1197 case tt._import:
1198 node = this.startNode<N.MetaProperty | N.Import | N.ImportExpression>();
1199 this.next();
1200
1201 if (this.match(tt.dot)) {
1202 return this.parseImportMetaPropertyOrPhaseCallOrSyncCall(node);
1203 }
1204
1205 if (this.match(tt.parenL)) {
1206 if (this.optionFlags & OptionFlags.CreateImportExpressions) {
1207 return this.parseImportCall(node as Undone<N.ImportExpression>);
1208 } else {
1209 return this.finishNode(node, "Import");
1210 }
1211 } else {
1212 this.raise(Errors.UnsupportedImport, this.state.lastTokStartLoc!);
1213 return this.finishNode(node, "Import");
1214 }
1215
1216 case tt._this:
1217 node = this.startNode<N.ThisExpression>();
1218 this.next();
1219 return this.finishNode(node, "ThisExpression");
1220
1221 case tt._do: {
1222 return this.parseDo(this.startNode(), false);
1223 }
1224
1225 case tt.slash:
1226 case tt.slashAssign: {
1227 this.readRegexp();
1228 return this.parseRegExpLiteral(this.state.value);
1229 }
1230
1231 case tt.num:
1232 return this.parseNumericLiteral(this.state.value);
1233
1234 case tt.bigint:
1235 return this.parseBigIntLiteral(this.state.value);
1236
1237 case tt.string:
1238 return this.parseStringLiteral(this.state.value);
1239
1240 case tt._null:
1241 return this.parseNullLiteral();
1242

Callers

nothing calls this directly

Calls 15

isIdentifierStartFunction · 0.90
tokenIsIdentifierFunction · 0.90
nextMethod · 0.80
matchMethod · 0.80
finishNodeMethod · 0.80
parseRegExpLiteralMethod · 0.80
parseNumericLiteralMethod · 0.80
parseBigIntLiteralMethod · 0.80
parseStringLiteralMethod · 0.80
parseNullLiteralMethod · 0.80
parseBooleanLiteralMethod · 0.80

Tested by

no test coverage detected