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

Function parseExprAtom

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

Source from the content-addressed store, hash-verified

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

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