GAL / Backend /lexer /errors.py
Clarkoer's picture
add comments ehehe
e6b283b
raw
history blame contribute delete
562 Bytes
# AUTO: Defines class `LexicalError`.
class LexicalError:
# AUTO: Defines function `__init__`.
def __init__(self, pos, details):
# AUTO: Sets `self.pos`.
self.pos = pos
# AUTO: Sets `self.details`.
self.details = details
# AUTO: Defines function `as_string`.
def as_string(self):
# AUTO: Sets `self.details`.
self.details = self.details.replace('\n', '\\n')
# AUTO: Returns this result to the caller.
return f"LEXICAL error line {self.pos.ln} col {self.pos.col} {self.details}"