(src: str, pos: Pos, *, literal: bool)
| 603 | |
| 604 | |
| 605 | def parse_multiline_str(src: str, pos: Pos, *, literal: bool) -> tuple[Pos, str]: |
| 606 | pos += 3 |
| 607 | if src.startswith("\n", pos): |
| 608 | pos += 1 |
| 609 | |
| 610 | if literal: |
| 611 | delim = "'" |
| 612 | end_pos = skip_until( |
| 613 | src, |
| 614 | pos, |
| 615 | "'''", |
| 616 | error_on=ILLEGAL_MULTILINE_LITERAL_STR_CHARS, |
| 617 | error_on_eof=True, |
| 618 | ) |
| 619 | result = src[pos:end_pos] |
| 620 | pos = end_pos + 3 |
| 621 | else: |
| 622 | delim = '"' |
| 623 | pos, result = parse_basic_str(src, pos, multiline=True) |
| 624 | |
| 625 | # Add at maximum two extra apostrophes/quotes if the end sequence |
| 626 | # is 4 or 5 chars long instead of just 3. |
| 627 | if not src.startswith(delim, pos): |
| 628 | return pos, result |
| 629 | pos += 1 |
| 630 | if not src.startswith(delim, pos): |
| 631 | return pos, result + delim |
| 632 | pos += 1 |
| 633 | return pos, result + (delim * 2) |
| 634 | |
| 635 | |
| 636 | def parse_basic_str(src: str, pos: Pos, *, multiline: bool) -> tuple[Pos, str]: |
no test coverage detected
searching dependent graphs…