| 38 | |
| 39 | |
| 40 | class Position: |
| 41 | def __init__(self, chars: int, line: int) -> None: |
| 42 | self.chars = chars |
| 43 | self.line = line |
| 44 | |
| 45 | @classmethod |
| 46 | def start(cls) -> "Position": |
| 47 | return cls(chars=0, line=1) |
| 48 | |
| 49 | def set(self, other: "Position") -> None: |
| 50 | self.chars = other.chars |
| 51 | self.line = other.line |
| 52 | |
| 53 | def advance(self, string: str) -> None: |
| 54 | self.chars += len(string) |
| 55 | self.line += len(re.findall(_newline, string)) |
| 56 | |
| 57 | |
| 58 | class Error(Exception): |
nothing calls this directly
no outgoing calls
no test coverage detected