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