Skip to main content

pygments-pss

A Pygments lexer for the Accellera Portable Test and Stimulus Standard (PSS), packaged as a plugin. Installing it is the entire configuration step:

pip install pygments-pss

After that, pss is a language Pygments knows about everywhere it looks — no conf.py entry, no mkdocs.yml entry, no registration call:

pygmentize -l pss my_test.pss
```pss
component pss_top {
    action entry {
        activity {
            do mem_write;
        }
    }
}
```

Targets PSS 3.1 (Draft 19), including annotations, monitors, behavioral coverage and triple-quoted target templates, and lexes earlier revisions unchanged.

Why

Pygments ships no PSS lexer, so every documentation pipeline that shows PSS either renders it as plain text or hand-rolls a lexer. This is that lexer, once, with tests.

Usage

Sphinx — nothing to configure; the entry point is enough.

.. code-block:: pss

   component pss_top { }

MyST/Markdown fences (```pss) work the same way. Options go through highlight_options:

highlight_options = {"pss": {"builtins": False}}

MkDocs — install the package; pymdownx.highlight picks it up. No mkdocs.yml change is needed beyond whatever highlighting extension you already use.

Command line

pygmentize -l pss -f html -O full,style=friendly -o out.html my_test.pss
pygmentize -S friendly -f html > pygments.css     # stylesheet for fragments
pygmentize -l pss -f terminal256 my_test.pss      # 256-colour terminal

Python

from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_by_name

print(highlight(source, get_lexer_by_name("pss"), HtmlFormatter()))

Options

Option Type Default Effect
docstrings bool True Highlight ///, //!, /** */ and /*! */ as Comment.Special. A psstools convention rather than a PSS one; costs nothing for projects that do not use it.
builtins bool True Highlight core-library names (Annex C: std_pkg, executor_pkg, addr_reg_pkg, sync_pkg) as Name.Builtin.

Two further options — dialect (standard versus pssparser extensions) and target_lexers (lex a exec body C = """…""" body as C/C++/SystemVerilog) — are designed but not implemented in this release.

What gets highlighted

Construct Token
// …, /* … */ Comment.Single, Comment.Multiline
/// …, //! …, /** … */ Comment.Special
compile if / has / assert Comment.Preproc
Type-declaring and qualifier keywords Keyword.Declaration
Built-in types Keyword.Type
true, false, null Keyword.Constant
this, super Name.Builtin.Pseudo
@ann, .field in its parameters Name.Decorator, Name.Attribute
Declared name after a declaration keyword, and its base type Name.Class
package a::b, import a::b::* Name.Namespace
foo( Name.Function
Core-library names Name.Builtin
8'hFF, 0xFF, 0b1010, 0755, 42 Number.Hex / Bin / Oct / Integer, by base
1.5, 2e6 Number.Float
"…" / """…""" String.Double / String.Heredoc
{{expr}} / {% … %} in a template String.Interpol / Comment.Preproc, with PSS tokens inside

Known deviations and false positives

Kept short and honest rather than absent:

  • Whitespace-separated based literals are not supported. The LRM permits 8'h FF; supporting it costs a lookahead and risks mis-lexing 8'h followed by an unrelated identifier. 8'hFF is the supported form.
  • An escaped identifier runs to whitespace, so \net1; includes the semicolon. That is Clause 4.3's rule, not a defect — the terminator is white space and nothing else. Write \net1 ; if you want the semicolon back.
  • A user-defined name that shadows a core-library name is highlighted as a builtin. A RegexLexer has no scope information. Turn it off with builtins=False.
  • numeric is not treated as a keyword. It appears in pssparser's token list and in a damaged cell of the LRM's keyword table, but nowhere in the Annex B grammar. Highlighting a non-keyword is a visible error; missing one is mild.
  • Tool extensions are not keywords: pyimport, pyobj, from, init, option are pssparser reservations, not PSS.
  • Template parameter brackets are not special. < and > stay Operator; distinguishing them from comparison needs a parser. One consequence: a templated declaration's base type (struct s<type T> : base_s) is not highlighted as a class.
  • A typedef's declared name is an ordinary Name, because in typedef bit[3:0] nibble_t; the name comes after an arbitrary type expression.

Requirements

Python 3.9+ and Pygments 2.14+. No other runtime dependency: no parser, no ANTLR, no compiler.

License

Apache-2.0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygments_pss-0.1.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygments_pss-0.1.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file pygments_pss-0.1.0.tar.gz.

File metadata

  • Download URL: pygments_pss-0.1.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.12

File hashes

Hashes for pygments_pss-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60a9687f483c77295dfa45e2605173f663f7a35f3c4c0ca3d730d859a7a27faf
MD5 11f805bcd9ee34f0c67304a30f758568
BLAKE2b-256 533f031915d6e0f6f6a017f02a2c83aea057f7d362d7617dcf93582d86e78cc5

See more details on using hashes here.

File details

Details for the file pygments_pss-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pygments_pss-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.12

File hashes

Hashes for pygments_pss-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02768ec09b62d32048fcd435fdc83ef51f40eb243650f3669ec5b65cdf9bc49f
MD5 cea2b879b86d275fb63b1d2ab573c53e
BLAKE2b-256 a6055573ce40f7b4142fd5563cfc0903935bd1ed97f9034388327b4d5a23d59a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page