Pygments lexer¶
The Pygments lexer for .qvr source, registered under the qvr alias
through the pygments.lexers entry point.
pygments_lexer
¶
Pygments lexer for the QVR domain-specific language.
The lexer drives on the in-tree tree-sitter parser (compiled via
quivers.dsl._grammar_build) so it always reflects
the authoritative grammar; there is no regex approximation. When the
shared library cannot be loaded, lexer construction raises with a
typed diagnostic so the failure is visible at the rendering site
rather than silently producing a degraded highlight.
Registers the qvr language alias so that code blocks tagged
qvr in MkDocs, Sphinx, or any Pygments-based renderer get
proper syntax highlighting.
Registration via the [project.entry-points] table in
pyproject.toml::
[project.entry-points."pygments.lexers"]
qvr = "quivers.dsl.pygments_lexer:QvrLexer"
QvrLexer
¶
Bases: Lexer
Pygments lexer for .qvr (quivers DSL) files.
The lexer is a thin walker over the in-tree tree-sitter parse; the grammar is the single source of truth. There is no regex approximation: when the shared library can't be loaded, the lexer raises a typed exception so the failure is visible at the rendering site rather than silently emitting a degraded highlight.
get_tokens_unprocessed
¶
Yield (index, token_type, text) tuples for text.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
tuple[int, _TokenType, str]
|
The character offset, Pygments token type, and text of each leaf of the parse and of the whitespace between leaves. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the in-tree tree-sitter parser library cannot be loaded. |