ds_lexer#
Lexer#
DSLexer#
class DSLexer(pygments.lexer.RegexLexer)
The Pygments lexer for DS source.
Attribute |
Value |
|---|---|
|
|
|
|
|
|
|
|
(Source: tools/ds_lexer/ds_lexer.py)
Reserved word tokens#
The words DS reserves are those of [LLEX.9.6], and each class of them takes one token type.
Words |
Token type |
|---|---|
the words that open a file-level declaration, such as |
|
the words that head an action, such as |
|
|
|
|
|
the type names, such as |
|
the builtins and aggregations, and |
|
the reserved kwargs |
|
every other reserved word |
|
A name after . is Name.Attribute, whatever word it spells.
(Source: tools/ds_lexer/ds_lexer.py, Spec: [LLEX.9.6], [LLEX.9.8])
Other tokens#
Source |
Token type |
|---|---|
a |
|
a triple-quoted string |
|
a string |
|
a regex literal after a match operator |
|
a hexadecimal, binary or octal literal |
|
a unit literal |
|
a float literal |
|
a decimal integer literal |
|
any other name |
|
|
|
(Source: tools/ds_lexer/ds_lexer.py, Spec: [LLEX.4.1], [LLEX.11.1], [LLEX.11.2], [LLEX.12], [LLEX.13], [LLEX.16.5], [LREG.5.1])
Pygments registration#
[project.entry-points."pygments.lexers"] ds = "ds_lexer:DSLexer"
Installing ds-lang-lexer registers DSLexer with Pygments under the alias ds, so a ds code fence highlights wherever Pygments runs.
(Source: tools/ds_lexer/pyproject.toml)
Sphinx#
setup#
def setup(app)
Registers a DSLexer as Sphinx’s lexer for ds when ds_lexer is loaded as a Sphinx extension.
It returns {"version": "0.1", "parallel_read_safe": True, "parallel_write_safe": True}. It imports sphinx, which ds-lang-lexer does not depend on.
(Source: tools/ds_lexer/ds_lexer.py)