1
0
infernal-interpreter/infernal_interpreter/Junk.py

33 lines
642 B
Python
Raw Normal View History

import dataclasses
2024-07-09 23:15:47 +00:00
class JunkComparisonException(BaseException):
2024-07-09 23:15:47 +00:00
def __str__(self):
return 'Attempting to perform calculations involving junk values.'
@dataclasses.dataclass
class Junk:
represents: str | None = None
2024-07-09 23:15:47 +00:00
def __str__(self):
return '[{}]'.format(self.represents or 'junk')
2024-07-09 23:15:47 +00:00
def __repr__(self):
2018-02-06 19:56:33 +00:00
return self.__str__()
2024-07-09 23:15:47 +00:00
def __format__(self, format):
return self.__str__()
2024-07-09 23:15:47 +00:00
def __add__(self, other):
2018-02-06 19:56:33 +00:00
return self
2024-07-09 23:15:47 +00:00
def __radd__(self, other):
2018-02-06 19:56:33 +00:00
return self
2024-07-09 23:15:47 +00:00
def __sub__(self, other):
2018-02-06 19:56:33 +00:00
return self
2024-07-09 23:15:47 +00:00
def __rsub__(self, other):
2018-02-06 19:56:33 +00:00
return self