the lexer and token structures were adapted from another project (see docstring on the Lexer class)
14 lines
307 B
Python
14 lines
307 B
Python
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Position:
|
|
"""A simple structure to store the position of a token"""
|
|
file: Optional[str]
|
|
line: int
|
|
column: int
|
|
|
|
def __repr__(self):
|
|
return f"{self.file or ''}L{self.line}:{self.column}"
|