Module

protocols

Protocols for Patitas.

Defines the contracts for sub-lexers and delegates. Used for zero-copy handoff (ZCLH) to external highlighters.

Classes

LexerDelegate 2
Protocol for sub-lexers that process source ranges. Thread Safety: Implementations must be sta…

Protocol for sub-lexers that process source ranges.

Thread Safety:

Implementations must be stateless or use only local variables.
The source string is read-only shared state.

Methods

tokenize_range 4 Iterator[Any]
Tokenize a specific range of the source string.
def tokenize_range(self, source: str, start: int, end: int, language: str) -> Iterator[Any]
Parameters
Name Type Description
source

The complete source buffer (read-only)

start

Start index (inclusive)

end

End index (exclusive)

language

Language identifier for lexer selection

Returns
Iterator[Any]
supports_language 1 bool
Check if this delegate can handle the given language.
def supports_language(self, language: str) -> bool
Parameters
Name Type Description
language
Returns
bool