Parser refactoring (#11871)
* refactor: parseMaybeUnary => parseUnary * refactor: extract shouldExitDescending method * refactor: add parseUpdate * refactor: avoid comparing with hardcoded token value * refactor: add ParseNewOrNewTarget * refactor: add parseCoverCallAndAsyncArrowHead * add parseBind * refactor: polish parseTaggedTemplateExpression interface * refactor: add parseMember method * refactor: add parseSuper method * refactor: add parseAsyncArrowUnaryFunction method * fix: disallow line break before async binding arrow * refactor: simplify tt.name logic * refactor: add parseDo method * refactor: misc * refactor: rename parseObjectMember by parsePropertyDefinition * refactor: unify set/get/async keyword parsing in ObjectMethod * refactor: misc * refactor: add parseArrayLike method * refactor: move fsharp epilogure and prologue inside parseObjectLike * fixup * refactor: rename parseFunctionExpression to parseFunctionOrFunctionSent * refactor: remove redundant logic * refactor: rename parseClassPropertyName by parseClassElementName * refactor: avoid unecessary lookahead when parsing tt._export * fix: export-default-from should support escaped async as export binding * address review comments * parseUnary -> parseMaybeUnary
This commit is contained in:
@@ -313,14 +313,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
isGenerator: boolean,
|
||||
isAsync: boolean,
|
||||
isPattern: boolean,
|
||||
containsEsc: boolean,
|
||||
isAccessor: boolean,
|
||||
): ?N.ObjectMethod {
|
||||
const node: N.EstreeProperty = (super.parseObjectMethod(
|
||||
prop,
|
||||
isGenerator,
|
||||
isAsync,
|
||||
isPattern,
|
||||
containsEsc,
|
||||
isAccessor,
|
||||
): any);
|
||||
|
||||
if (node) {
|
||||
|
||||
@@ -2362,8 +2362,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
isGenerator: boolean,
|
||||
isAsync: boolean,
|
||||
isPattern: boolean,
|
||||
isAccessor: boolean,
|
||||
refExpressionErrors: ?ExpressionErrors,
|
||||
containsEsc: boolean,
|
||||
): void {
|
||||
if ((prop: $FlowFixMe).variance) {
|
||||
this.unexpected((prop: $FlowFixMe).variance.start);
|
||||
@@ -2373,7 +2373,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
let typeParameters;
|
||||
|
||||
// method shorthand
|
||||
if (this.isRelational("<")) {
|
||||
if (this.isRelational("<") && !isAccessor) {
|
||||
typeParameters = this.flowParseTypeParameterDeclaration();
|
||||
if (!this.match(tt.parenL)) this.unexpected();
|
||||
}
|
||||
@@ -2385,8 +2385,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
isGenerator,
|
||||
isAsync,
|
||||
isPattern,
|
||||
isAccessor,
|
||||
refExpressionErrors,
|
||||
containsEsc,
|
||||
);
|
||||
|
||||
// add typeParameters if we found them
|
||||
|
||||
@@ -1823,13 +1823,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.typeParameters = typeArguments;
|
||||
return this.finishCallExpression(node, state.optionalChainMember);
|
||||
} else if (this.match(tt.backQuote)) {
|
||||
return this.parseTaggedTemplateExpression(
|
||||
const result = this.parseTaggedTemplateExpression(
|
||||
base,
|
||||
startPos,
|
||||
startLoc,
|
||||
base,
|
||||
state,
|
||||
typeArguments,
|
||||
);
|
||||
result.typeParameters = typeArguments;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user