| 387 | } |
| 388 | |
| 389 | private parseLiteralString(multiline: boolean): string { |
| 390 | this.expect("'") |
| 391 | if (multiline) { |
| 392 | this.expect("'") |
| 393 | this.expect("'") |
| 394 | this.advance(this.input.startsWith("\r\n", this.index) ? 2 : this.peek() === "\n" ? 1 : 0) |
| 395 | } |
| 396 | const start = this.index |
| 397 | while (!this.done) { |
| 398 | if (multiline && this.input.startsWith("'''", this.index)) { |
| 399 | const output = this.input.slice(start, this.index) |
| 400 | this.advance(3) |
| 401 | return output + this.closingQuotes("'") |
| 402 | } |
| 403 | if (!multiline && this.peek() === "'") { |
| 404 | const output = this.input.slice(start, this.index) |
| 405 | this.advance() |
| 406 | return output |
| 407 | } |
| 408 | if (!multiline && (this.peek() === "\n" || this.peek() === "\r")) { |
| 409 | this.fail("Literal strings cannot contain newlines") |
| 410 | } |
| 411 | this.advance() |
| 412 | } |
| 413 | this.fail("Unterminated literal string") |
| 414 | } |
| 415 | |
| 416 | private closingQuotes(quote: string): string { |
| 417 | let quotes = "" |