(predicate: (char: number, charNext: number, charNextNext: number) => boolean, expectedClose?: string, consumeClose?: number)
| 788 | } |
| 789 | |
| 790 | private scanUntil(predicate: (char: number, charNext: number, charNextNext: number) => boolean, expectedClose?: string, consumeClose?: number) { |
| 791 | const start = this.#offset; |
| 792 | |
| 793 | do { |
| 794 | // advance the position |
| 795 | if (isLineBreak(this.#ch)) { |
| 796 | this.advance(this.#ch === CharacterCodes.carriageReturn && this.#chNext === CharacterCodes.lineFeed ? 2 : 1); |
| 797 | this.#line++; |
| 798 | this.#column = 0; |
| 799 | this.markPosition(); // make sure the map has the new location |
| 800 | } else { |
| 801 | this.#column += this.widthOfCh; |
| 802 | this.advance(); |
| 803 | } |
| 804 | |
| 805 | if (this.eof) { |
| 806 | this.assert(!expectedClose, `Unexpected end of file while searching for '${expectedClose}'`); |
| 807 | break; |
| 808 | } |
| 809 | |
| 810 | } while (!predicate(this.#ch, this.#chNext, this.#chNextNext)); |
| 811 | |
| 812 | if (consumeClose) { |
| 813 | this.advance(consumeClose); |
| 814 | } |
| 815 | |
| 816 | // and after... |
| 817 | this.markPosition(); |
| 818 | |
| 819 | return this.#text.substring(start, this.#offset); |
| 820 | } |
| 821 | |
| 822 | private scanSingleLineComment() { |
| 823 | this.text = this.scanUntil(isLineBreak); |
no test coverage detected