()
| 6172 | } |
| 6173 | |
| 6174 | func (p *Parser) isStartOfExpression() bool { |
| 6175 | if p.isStartOfLeftHandSideExpression() { |
| 6176 | return true |
| 6177 | } |
| 6178 | switch p.token { |
| 6179 | case ast.KindPlusToken, ast.KindMinusToken, ast.KindTildeToken, ast.KindExclamationToken, ast.KindDeleteKeyword, |
| 6180 | ast.KindTypeOfKeyword, ast.KindVoidKeyword, ast.KindPlusPlusToken, ast.KindMinusMinusToken, ast.KindLessThanToken, |
| 6181 | ast.KindAwaitKeyword, ast.KindYieldKeyword, ast.KindPrivateIdentifier, ast.KindAtToken: |
| 6182 | // Yield/await always starts an expression. Either it is an identifier (in which case |
| 6183 | // it is definitely an expression). Or it's a keyword (either because we're in |
| 6184 | // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. |
| 6185 | return true |
| 6186 | } |
| 6187 | // Error tolerance. If we see the start of some binary operator, we consider |
| 6188 | // that the start of an expression. That way we'll parse out a missing identifier, |
| 6189 | // give a good message about an identifier being missing, and then consume the |
| 6190 | // rest of the binary expression. |
| 6191 | if p.isBinaryOperator() { |
| 6192 | return true |
| 6193 | } |
| 6194 | return p.isIdentifier() |
| 6195 | } |
| 6196 | |
| 6197 | func (p *Parser) isStartOfLeftHandSideExpression() bool { |
| 6198 | switch p.token { |
no test coverage detected