Skip to main content

unitracker-grammar

The canonical unitracker document as a Lark grammar, with an LALR parser for it and the note table its expressions read as F(k), and the modulator expression language: checked, printed in its one text and compiled to Python.

A document names no player. It holds everything it plays: instruments, programs, expressions, phrases and the tables its expressions index. Its only constants are the note table at its clock and the header defaults (PAL clock, 3 voices, tempo 6). Format 1.22's slots line names, per cell, the modulator slots that fire in order, each with its default binding and the voice events it holds and resets on (slots: {freq: {wave: {mod: note, reset: [row.note]}, tick: {hold: [step-1, row]}}}); its mod records are templates over named parameters and its x records instances (x1: porta {s: 32}); a slot. prefix on a cell's row key, instrument field or command (tick.freq: x3, !tick.freq:x3) names the slot it binds or stops; its order line names the phases of a tick in the order they run (order: [events, ctrl, pulse, filter, freq, pw, cut, read]). Format 1.21's hold line names, per cell, the events its modulators hold on (unitracker-player's semantics).

Install

pip install "unitracker-grammar @ git+https://github.com/anarkiwi/unitracker-grammar"

Use

from unitracker_grammar import parse, CanonicalError, frequency, table
tree = parse(text)        # a lark.Tree, or CanonicalError naming the line and column
frequency(57)             # F(57): A4 at the PAL clock
table(clock_hz=1022727)   # F(k) for every note whose word fits, from C0, at NTSC

parser() is the cached lark.Lark parser and GRAMMAR the grammar file resource.

Expressions

unitracker_grammar.expr owns the modulator expression language. An expression is a stdlib ast node, read from a text by tree or from a parse tree's expr and fexpr rules by the Nodes transformer.

from unitracker_grammar import expr, frequency
expr.canonical("1024 + 16*min(3, φ)")       # '16*min(3, φ) + 1024', its one text
fn = expr.compile_expr("v + W[φ]", {"_F": frequency, "_T": {"W": expr.indexed([1, 2])}})
fn(10, 1, 48)                               # (v, φ, N, n=0) -> 12

v is the cell's value, φ the modulator's tick count, N the sounding note and n the event note; a template's other lowercase names are its parameters, which params lists and bind replaces with integers. source is the Python source of an expression (ExpressionError outside the grammar), printed the one text of a node and written an integer literal as an int. // and % raise ZeroDivisionError on a divisor of 0; with zero=True they are 0.

Grammar

src/unitracker_grammar/canonical.lark; the document format and the meaning of each construct are described in unitracker's docs/format.

Metadata

Release files for unitracker-grammar 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unitracker-grammar 0.8.0
File Size Uploaded Provenance
unitracker_grammar-0.8.0.tar.gz 30.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for unitracker-grammar 0.8.0
File Interpreter ABI Platform
unitracker_grammar-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 51.3 kB

Release files / unitracker_grammar-0.8.0.tar.gz

Download URL unitracker_grammar-0.8.0.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2909865739d91ab080bbaf7b46892c84cfd531055e86233e5ae31fe7593041a4
BLAKE2b-256 checksum
How to use checksums
1ccdb3acee5f30711f940601c464a3a635aa474e81240ea931b535a2cfd53a63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / unitracker_grammar-0.8.0-py3-none-any.whl

Download URL unitracker_grammar-0.8.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5216d4e8efe674dd209e28700f21552af9debd6f2208218f535beeef326351a0
BLAKE2b-256 checksum
How to use checksums
9533120a38f5a0de3eafe86d7cb967977d041d77477cc0f053847169b4cd2750
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for unitracker-grammar 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for unitracker_grammar-0.8.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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