# protocols

URL: /patitas/api/protocols/
Section: api
Description: Protocols for Patitas.

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

---

> For a complete page index, fetch /patitas/llms.txt.

Open LLM text
(/patitas/api/protocols/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fprotocols%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fprotocols%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fprotocols%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Fprotocols%2Findex.txt)

Module

#
`protocols`

Protocols for Patitas.

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

1Class

## Classes

`LexerDelegate`

2

▼

Protocol for sub-lexers that process source ranges.

Thread Safety:
Implementations must be sta…

Bases:

`Protocol`

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`
