(parts: string[], end?: CharacterCursor)
| 518 | } |
| 519 | |
| 520 | private _endToken(parts: string[], end?: CharacterCursor): Token { |
| 521 | if (this._currentTokenStart === null) { |
| 522 | throw new ParseError( |
| 523 | this._cursor.getSpan(end), |
| 524 | 'Programming error - attempted to end a token when there was no start to the token', |
| 525 | ); |
| 526 | } |
| 527 | if (this._currentTokenType === null) { |
| 528 | throw new ParseError( |
| 529 | this._cursor.getSpan(this._currentTokenStart), |
| 530 | 'Programming error - attempted to end a token which has no token type', |
| 531 | ); |
| 532 | } |
| 533 | const token = { |
| 534 | type: this._currentTokenType, |
| 535 | parts, |
| 536 | sourceSpan: (end ?? this._cursor).getSpan( |
| 537 | this._currentTokenStart, |
| 538 | this._leadingTriviaCodePoints, |
| 539 | ), |
| 540 | } as Token; |
| 541 | this.tokens.push(token); |
| 542 | this._currentTokenStart = null; |
| 543 | this._currentTokenType = null; |
| 544 | return token; |
| 545 | } |
| 546 | |
| 547 | private _createError(msg: string, span: ParseSourceSpan): ParseError { |
| 548 | if (this._isInExpansionForm()) { |
no test coverage detected