source: Location: prepare for builtins
This commit is contained in:
parent
3fa039110b
commit
43b2dc9e93
1 changed files with 10 additions and 2 deletions
|
|
@ -12,15 +12,23 @@ logger = Logger(__name__)
|
||||||
@typecheck
|
@typecheck
|
||||||
@dataclass
|
@dataclass
|
||||||
class Location:
|
class Location:
|
||||||
line: int
|
line: int = -1
|
||||||
character: int
|
character: int = -1
|
||||||
file: str = "<none>"
|
file: str = "<none>"
|
||||||
|
internal: bool = False
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
if self.internal:
|
||||||
|
return "<internal>"
|
||||||
return f"{self.file}:{self.line}:{self.character}"
|
return f"{self.file}:{self.line}:{self.character}"
|
||||||
|
|
||||||
@typecheck
|
@typecheck
|
||||||
def __lt__(self, other: Location) -> bool:
|
def __lt__(self, other: Location) -> bool:
|
||||||
|
if self.internal:
|
||||||
|
return True
|
||||||
|
if other.internal:
|
||||||
|
return False
|
||||||
|
|
||||||
if self.file != other.file:
|
if self.file != other.file:
|
||||||
logger.trace(f"{self} is not in the same file as {other}")
|
logger.trace(f"{self} is not in the same file as {other}")
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue