()
| 34385 | return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; |
| 34386 | } |
| 34387 | function parseAssignmentExpressionOrHigher() { |
| 34388 | // AssignmentExpression[in,yield]: |
| 34389 | // 1) ConditionalExpression[?in,?yield] |
| 34390 | // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield] |
| 34391 | // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield] |
| 34392 | // 4) ArrowFunctionExpression[?in,?yield] |
| 34393 | // 5) AsyncArrowFunctionExpression[in,yield,await] |
| 34394 | // 6) [+Yield] YieldExpression[?In] |
| 34395 | // |
| 34396 | // Note: for ease of implementation we treat productions '2' and '3' as the same thing. |
| 34397 | // (i.e. they're both BinaryExpressions with an assignment operator in it). |
| 34398 | // First, do the simple check if we have a YieldExpression (production '6'). |
| 34399 | if (isYieldExpression()) { |
| 34400 | return parseYieldExpression(); |
| 34401 | } |
| 34402 | // Then, check if we have an arrow function (production '4' and '5') that starts with a parenthesized |
| 34403 | // parameter list or is an async arrow function. |
| 34404 | // AsyncArrowFunctionExpression: |
| 34405 | // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] |
| 34406 | // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] |
| 34407 | // Production (1) of AsyncArrowFunctionExpression is parsed in "tryParseAsyncSimpleArrowFunctionExpression". |
| 34408 | // And production (2) is parsed in "tryParseParenthesizedArrowFunctionExpression". |
| 34409 | // |
| 34410 | // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is |
| 34411 | // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done |
| 34412 | // with AssignmentExpression if we see one. |
| 34413 | var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression(); |
| 34414 | if (arrowExpression) { |
| 34415 | return arrowExpression; |
| 34416 | } |
| 34417 | // Now try to see if we're in production '1', '2' or '3'. A conditional expression can |
| 34418 | // start with a LogicalOrExpression, while the assignment productions can only start with |
| 34419 | // LeftHandSideExpressions. |
| 34420 | // |
| 34421 | // So, first, we try to just parse out a BinaryExpression. If we get something that is a |
| 34422 | // LeftHandSide or higher, then we can try to parse out the assignment expression part. |
| 34423 | // Otherwise, we try to parse out the conditional expression bit. We want to allow any |
| 34424 | // binary expression here, so we pass in the 'lowest' precedence here so that it matches |
| 34425 | // and consumes anything. |
| 34426 | var pos = getNodePos(); |
| 34427 | var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); |
| 34428 | // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized |
| 34429 | // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single |
| 34430 | // identifier and the current token is an arrow. |
| 34431 | if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { |
| 34432 | return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); |
| 34433 | } |
| 34434 | // Now see if we might be in cases '2' or '3'. |
| 34435 | // If the expression was a LHS expression, and we have an assignment operator, then |
| 34436 | // we're in '2' or '3'. Consume the assignment and return. |
| 34437 | // |
| 34438 | // Note: we call reScanGreaterToken so that we get an appropriately merged token |
| 34439 | // for cases like `> > =` becoming `>>=` |
| 34440 | if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { |
| 34441 | return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos); |
| 34442 | } |
| 34443 | // It wasn't an assignment or a lambda. This is a conditional expression: |
| 34444 | return parseConditionalExpressionRest(expr, pos); |
no test coverage detected
searching dependent graphs…