Transform comments such as '# E: message' or '# E:3: message' in input. The result is lines like 'fnam:line: error: message'.
(input: list[str], output: list[str], fnam: str)
| 537 | |
| 538 | |
| 539 | def expand_errors(input: list[str], output: list[str], fnam: str) -> None: |
| 540 | """Transform comments such as '# E: message' or |
| 541 | '# E:3: message' in input. |
| 542 | |
| 543 | The result is lines like 'fnam:line: error: message'. |
| 544 | """ |
| 545 | |
| 546 | for i in range(len(input)): |
| 547 | # The first in the split things isn't a comment |
| 548 | for possible_err_comment in input[i].split(" # ")[1:]: |
| 549 | m = re.search( |
| 550 | r"^([ENW]):((?P<col>\d+):)? (?P<message>.*)$", possible_err_comment.strip() |
| 551 | ) |
| 552 | if m: |
| 553 | if m.group(1) == "E": |
| 554 | severity = "error" |
| 555 | elif m.group(1) == "N": |
| 556 | severity = "note" |
| 557 | elif m.group(1) == "W": |
| 558 | severity = "warning" |
| 559 | col = m.group("col") |
| 560 | message = m.group("message") |
| 561 | message = message.replace("\\#", "#") # adds back escaped # character |
| 562 | if col is None: |
| 563 | output.append(f"{fnam}:{i + 1}: {severity}: {message}") |
| 564 | else: |
| 565 | output.append(f"{fnam}:{i + 1}:{col}: {severity}: {message}") |
| 566 | |
| 567 | |
| 568 | def fix_win_path(line: str) -> str: |