| 275 | |
| 276 | |
| 277 | class Counter: |
| 278 | def __init__(self, n: int = 0) -> None: |
| 279 | self.n = 0 |
| 280 | |
| 281 | def increment(self, vid: object, ser: object) -> None: |
| 282 | self.n += 1 |
| 283 | |
| 284 | def decrement(self, vid: object, ser: object) -> None: |
| 285 | self.n -= 1 |
| 286 | |
| 287 | def set_to(self, n: int) -> Action: |
| 288 | def set_to_impl(vid: object, ser: object) -> None: |
| 289 | self.n = n |
| 290 | return set_to_impl |
| 291 | |
| 292 | def equals(self, n: int) -> Matcher: |
| 293 | def equals_impl(frame: object) -> bool: |
| 294 | return self.n == n |
| 295 | return equals_impl |
| 296 | |
| 297 | @property |
| 298 | def zero(self) -> Matcher: |
| 299 | return self.equals(0) |
| 300 | |
| 301 | |
| 302 | States = Mapping[str, tuple[tuple[Matcher, Action, str], ...]] |