YREA-SLS/SLS_Python/sls/lexer.py

26 lines
552 B
Python

"""Lexer module placeholder for SLS.
Provide a Lexer class that will later be expanded to match the C implementation.
"""
from dataclasses import dataclass
from typing import Iterator, NamedTuple
class Token(NamedTuple):
type: str
value: str
lineno: int
col: int
@dataclass
class Lexer:
source: str
def tokenize(self) -> Iterator[Token]:
"""Yield tokens from `source`. Currently yields a single EOF token.
Replace with full logic when porting the C lexer.
"""
yield Token("EOF", "", 1, 0)