Skip to content

Commit

Permalink
feat: defined a base template to create all handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhritikrishna123 committed Feb 23, 2025
1 parent 13f2506 commit e3261b7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lexer/handler/base.py
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

0 comments on commit e3261b7

Please sign in to comment.