(src: str, pos: Pos, *, multiline: bool)
| 550 | |
| 551 | |
| 552 | def parse_basic_str(src: str, pos: Pos, *, multiline: bool) -> tuple[Pos, str]: |
| 553 | if multiline: |
| 554 | error_on = ILLEGAL_MULTILINE_BASIC_STR_CHARS |
| 555 | parse_escapes = parse_basic_str_escape_multiline |
| 556 | else: |
| 557 | error_on = ILLEGAL_BASIC_STR_CHARS |
| 558 | parse_escapes = parse_basic_str_escape |
| 559 | result = "" |
| 560 | start_pos = pos |
| 561 | while True: |
| 562 | try: |
| 563 | char = src[pos] |
| 564 | except IndexError: |
| 565 | raise suffixed_err(src, pos, "Unterminated string") from None |
| 566 | if char == '"': |
| 567 | if not multiline: |
| 568 | return pos + 1, result + src[start_pos:pos] |
| 569 | if src.startswith('"""', pos): |
| 570 | return pos + 3, result + src[start_pos:pos] |
| 571 | pos += 1 |
| 572 | continue |
| 573 | if char == "\\": |
| 574 | result += src[start_pos:pos] |
| 575 | pos, parsed_escape = parse_escapes(src, pos) |
| 576 | result += parsed_escape |
| 577 | start_pos = pos |
| 578 | continue |
| 579 | if char in error_on: |
| 580 | raise suffixed_err(src, pos, f"Illegal character {char!r}") |
| 581 | pos += 1 |
| 582 | |
| 583 | |
| 584 | def parse_value( # noqa: C901 |
no test coverage detected