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

Method parseGroupExpression

src/parser.ts:1019–1142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1017 }
1018
1019 parseGroupExpression(): ArrowParameterPlaceHolderNode | Node.Expression {
1020 let expr;
1021
1022 this.expect('(');
1023 if (this.match(')')) {
1024 this.nextToken();
1025 if (!this.match('=>')) {
1026 this.expect('=>');
1027 }
1028 expr = {
1029 type: ArrowParameterPlaceHolder,
1030 params: [],
1031 async: false
1032 };
1033 } else {
1034 const startToken = this.lookahead;
1035 const params = [];
1036 if (this.match('...')) {
1037 expr = this.parseRestElement(params);
1038 this.expect(')');
1039 if (!this.match('=>')) {
1040 this.expect('=>');
1041 }
1042 expr = {
1043 type: ArrowParameterPlaceHolder,
1044 params: [expr],
1045 async: false
1046 };
1047 } else {
1048 let arrow = false;
1049 this.context.isBindingElement = true;
1050 expr = this.inheritCoverGrammar(this.parseAssignmentExpression);
1051
1052 if (this.match(',')) {
1053 const expressions: Node.Expression[] = [];
1054
1055 this.context.isAssignmentTarget = false;
1056 expressions.push(expr);
1057 while (this.lookahead.type !== Token.EOF) {
1058 if (!this.match(',')) {
1059 break;
1060 }
1061 this.nextToken();
1062 if (this.match(')')) {
1063 this.nextToken();
1064 for (let i = 0; i < expressions.length; i++) {
1065 this.reinterpretExpressionAsPattern(expressions[i]);
1066 }
1067 arrow = true;
1068 expr = {
1069 type: ArrowParameterPlaceHolder,
1070 params: expressions,
1071 async: false
1072 };
1073 } else if (this.match('...')) {
1074 if (!this.context.isBindingElement) {
1075 this.throwUnexpectedToken(this.lookahead);
1076 }

Callers

nothing calls this directly

Calls 10

expectMethod · 0.95
matchMethod · 0.95
nextTokenMethod · 0.95
parseRestElementMethod · 0.95
inheritCoverGrammarMethod · 0.95
throwUnexpectedTokenMethod · 0.95
finalizeMethod · 0.95
startNodeMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected