()
| 5562 | } |
| 5563 | |
| 5564 | func (p *Parser) parsePrimaryExpression() *ast.Expression { |
| 5565 | switch p.token { |
| 5566 | case ast.KindNoSubstitutionTemplateLiteral: |
| 5567 | if p.scanner.TokenFlags()&ast.TokenFlagsIsInvalid != 0 { |
| 5568 | p.reScanTemplateToken(false /*isTaggedTemplate*/) |
| 5569 | } |
| 5570 | fallthrough |
| 5571 | case ast.KindNumericLiteral, ast.KindBigIntLiteral, ast.KindStringLiteral: |
| 5572 | return p.parseLiteralExpression(false /*intern*/) |
| 5573 | case ast.KindThisKeyword, ast.KindSuperKeyword, ast.KindNullKeyword, ast.KindTrueKeyword, ast.KindFalseKeyword: |
| 5574 | return p.parseKeywordExpression() |
| 5575 | case ast.KindOpenParenToken: |
| 5576 | return p.parseParenthesizedExpression() |
| 5577 | case ast.KindOpenBracketToken: |
| 5578 | return p.parseArrayLiteralExpression() |
| 5579 | case ast.KindOpenBraceToken: |
| 5580 | return p.parseObjectLiteralExpression() |
| 5581 | case ast.KindAsyncKeyword: |
| 5582 | // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. |
| 5583 | // If we encounter `async [no LineTerminator here] function` then this is an async |
| 5584 | // function; otherwise, its an identifier. |
| 5585 | if !p.lookAhead((*Parser).nextTokenIsFunctionKeywordOnSameLine) { |
| 5586 | break |
| 5587 | } |
| 5588 | return p.parseFunctionExpression() |
| 5589 | case ast.KindAtToken: |
| 5590 | return p.parseDecoratedExpression() |
| 5591 | case ast.KindClassKeyword: |
| 5592 | return p.parseClassExpression() |
| 5593 | case ast.KindFunctionKeyword: |
| 5594 | return p.parseFunctionExpression() |
| 5595 | case ast.KindNewKeyword: |
| 5596 | return p.parseNewExpressionOrNewDotTarget() |
| 5597 | case ast.KindSlashToken, ast.KindSlashEqualsToken: |
| 5598 | if p.reScanSlashToken() == ast.KindRegularExpressionLiteral { |
| 5599 | return p.parseLiteralExpression(false /*intern*/) |
| 5600 | } |
| 5601 | case ast.KindTemplateHead: |
| 5602 | return p.parseTemplateExpression(false /*isTaggedTemplate*/) |
| 5603 | case ast.KindPrivateIdentifier: |
| 5604 | return p.parsePrivateIdentifier() |
| 5605 | } |
| 5606 | return p.parseIdentifierWithDiagnostic(diagnostics.Expression_expected, nil) |
| 5607 | } |
| 5608 | |
| 5609 | func (p *Parser) parseParenthesizedExpression() *ast.Expression { |
| 5610 | pos := p.nodePos() |
no test coverage detected