()
| 505 | } |
| 506 | |
| 507 | private scanString(): Token { |
| 508 | const start = this.index; |
| 509 | const quote = this.peek; |
| 510 | this.advance(); // Skip initial quote. |
| 511 | |
| 512 | let buffer = ''; |
| 513 | let marker = this.index; |
| 514 | const input = this.input; |
| 515 | |
| 516 | while (this.peek != quote) { |
| 517 | if (this.peek == chars.$BACKSLASH) { |
| 518 | const result = this.scanStringBackslash(buffer, marker); |
| 519 | if (typeof result !== 'string') { |
| 520 | return result; // Error |
| 521 | } |
| 522 | buffer = result; |
| 523 | marker = this.index; |
| 524 | } else if (this.peek == chars.$EOF) { |
| 525 | return this.error('Unterminated quote', 0); |
| 526 | } else { |
| 527 | this.advance(); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | const last: string = input.substring(marker, this.index); |
| 532 | this.advance(); // Skip terminating quote. |
| 533 | |
| 534 | return new StringToken(start, this.index, buffer + last, StringTokenKind.Plain); |
| 535 | } |
| 536 | |
| 537 | private scanQuestion(start: number): Token { |
| 538 | this.advance(); |
no test coverage detected