-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: defined a base template to create all handlers
- Loading branch information
1 parent
13f2506
commit e3261b7
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from abc import ABC, abstractmethod | ||
from ..state import LexerState, Position | ||
|
||
class TokenHandler(ABC): | ||
"""Base class for all token handlers.""" | ||
|
||
@abstractmethod | ||
def can_handle(self, state: LexerState) -> bool: | ||
"""Check if the handler can process the current character.""" | ||
pass | ||
|
||
@abstractmethod | ||
def handle(self, state: LexerState, start_pos: Position) -> None: | ||
"""Process the token and update state.""" | ||
pass |