MCPcopy Create free account
hub / github.com/microsoft/typescript-go / isStartOfExpression

Method isStartOfExpression

internal/parser/parser.go:6174–6195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6172}
6173
6174func (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
6197func (p *Parser) isStartOfLeftHandSideExpression() bool {
6198 switch p.token {

Callers 7

isListElementMethod · 0.95
parseTypeParameterMethod · 0.95
parseYieldExpressionMethod · 0.95
isStartOfStatementMethod · 0.95

Calls 3

isBinaryOperatorMethod · 0.95
isIdentifierMethod · 0.95

Tested by

no test coverage detected