(parts: string[], end?: CharacterCursor)
| 500 | } |
| 501 | |
| 502 | private _endToken(parts: string[], end?: CharacterCursor): Token { |
| 503 | if (this._currentTokenStart === null) { |
| 504 | throw new ParseError( |
| 505 | this._cursor.getSpan(end), |
| 506 | 'Programming error - attempted to end a token when there was no start to the token', |
| 507 | ); |
| 508 | } |
| 509 | if (this._currentTokenType === null) { |
| 510 | throw new ParseError( |
| 511 | this._cursor.getSpan(this._currentTokenStart), |
| 512 | 'Programming error - attempted to end a token which has no token type', |
| 513 | ); |
| 514 | } |
| 515 | const token = { |
| 516 | type: this._currentTokenType, |
| 517 | parts, |
| 518 | sourceSpan: (end ?? this._cursor).getSpan( |
| 519 | this._currentTokenStart, |
| 520 | this._leadingTriviaCodePoints, |
| 521 | ), |
| 522 | } as Token; |
| 523 | this.tokens.push(token); |
| 524 | this._currentTokenStart = null; |
| 525 | this._currentTokenType = null; |
| 526 | return token; |
| 527 | } |
| 528 | |
| 529 | private _createError(msg: string, span: ParseSourceSpan): ParseError { |
| 530 | if (this._isInExpansionForm()) { |
no test coverage detected