main+errors: use stdout instead of stderr

This commit is contained in:
Antoine Viallon 2024-01-09 17:14:41 +01:00
parent 8b0ec8cbe2
commit 692ee511eb
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -74,14 +74,13 @@ def main():
except CompilationError as e: except CompilationError as e:
e.location.source = data e.location.source = data
print(f"{e}\n{e.location.show_in_source()}", file=sys.stderr) print(f"{e}\n{e.location.show_in_source()}", flush=True)
if e.__cause__ is not None: if e.__cause__ is not None:
if rootLogger.level <= LogLevel.Debug: if rootLogger.level <= LogLevel.Debug:
raise e.__cause__ raise e.__cause__
print(f"Caused by:\n{e.__cause__.__class__.__name__}: {e.__cause__}", file=sys.stderr) print(f"Caused by:\n{e.__cause__.__class__.__name__}: {e.__cause__}", flush=True)
finally: finally:
CompilationWarning.show_warnings(data)
def print_ir(intermediate_representation: list[ir.IRAction]): def print_ir(intermediate_representation: list[ir.IRAction]):
@ -95,6 +94,7 @@ def print_ir(intermediate_representation: list[ir.IRAction]):
messages += [f"{repr(ir_item)}\n"] messages += [f"{repr(ir_item)}\n"]
print("\n".join(messages)) print("\n".join(messages))
CompilationWarning.show_warnings(data, file=sys.stdout)
if __name__ == "__main__": if __name__ == "__main__":