From 43b2dc9e935d6fe789044705c8c88d4ae1c242e8 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Fri, 5 Jan 2024 23:11:32 +0100 Subject: [PATCH] source: Location: prepare for builtins --- compiler/source.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/source.py b/compiler/source.py index 14ec6f1..b5fd3a9 100644 --- a/compiler/source.py +++ b/compiler/source.py @@ -12,15 +12,23 @@ logger = Logger(__name__) @typecheck @dataclass class Location: - line: int - character: int + line: int = -1 + character: int = -1 file: str = "" + internal: bool = False def __str__(self) -> str: + if self.internal: + return "" return f"{self.file}:{self.line}:{self.character}" @typecheck def __lt__(self, other: Location) -> bool: + if self.internal: + return True + if other.internal: + return False + if self.file != other.file: logger.trace(f"{self} is not in the same file as {other}") return False