Skip to main content
zsuite Logo

zsuite

A toolkit for building programming languages in Python: syntax, checks, execution and editor support.

Programming languages, DSLs and data formats, from a grammar to a fast implementation with an editor. Each stage is its own package, usable alone; together they cover the whole way.

GitHub Stars Python Zig License


Package Stage What it does PyPI
zgram Syntax PEG grammars compiled to native parsers with LLVM: parse trees, ASTs, error messages, error recovery zgram-py
zrules Static semantics Rules over zgram's trees: scopes and names, context rules, types (generics, unions, subtyping), control flow, diagnostics zrules-py
zrun Execution Semantics written as Python functions, compiled to native code by partial evaluation; executables of a program zrun-py
zlsp Editors A Language Server for any language defined with zgram and checked with zrules: diagnostics, navigation, completion, hover zlsp-py

Installation

pip install zsuite-py              # the four packages, at versions that work together
pip install "zsuite-py[exe]"       # and what building executables needs

The import names are zgram, zrules, zrun and zlsp (each can also be installed alone as <name>-py). Wheels cover CPython 3.10+ on x86_64 Linux and Windows.

Quick start

zsuite new calc        # a language project: grammar, rules, semantics, language server, tests
cd calc
python calc.py run fib.calc        # run a program, compiled to native code
python calc.py check fib.calc      # its errors and warnings
python calc.py lsp                 # a language server for your editor
python -m pytest test_calc.py      # its tests

The project is the tutorial's language under your name: change the grammar in syntax.py, the rules in checks.py, what each construct does in semantics.py, and the editor's view in server.py.

How they fit

source ──zgram──▶ parse tree ──zrules──▶ checked tree + symbols + types ──zrun──▶ running program
                                   │
                                   └──zlsp──▶ editor (diagnostics, go to definition, hover, ...)
  • zgram turns text into a tree: a grammar in, a parser out (zgram.compile(grammar)), its nodes labelled with what the grammar names them.
  • zrules checks the tree: rules written as selectors over node kinds ("break_stmt" inside a loop, each name defined once in its scope, the types of expressions), reported as diagnostics with source positions.
  • zrun runs it: a semantic per node kind, plain Python taking the node and the runtime; zrun compiles the semantics for the program's tree to native code, so the language runs at a fraction of a hand-written interpreter's speed.
  • zlsp serves it to editors: the grammar and the rules are all it needs.

Versions

Each package is released on its own; these are the current ones, which work together:

zgram zrules zrun zlsp
0.5.2 0.2.0 0.5.0 0.1.3

Documentation

  • Tutorial: building a language through all four stages, from grammar to editor and executable.
  • Best practices: grammars that recover well, rules, semantics that compile fast, testing, shipping.
  • Design: how the suite fits together, its decisions and its roadmap.
  • Each package's README is its reference.

Project Structure

src/zsuite/          # the zsuite package: versions(), `zsuite new`
examples/tiny/       # the tutorial's language: one file per stage, and its tests
                     # (also `zsuite new`'s template)
docs/                # the tutorial, best practices, the design
tests/               # the package's tests

License

MIT

Metadata

Release files for zsuite-py 0.2.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 zsuite-py 0.2.0
File Size Uploaded
zsuite_py-0.2.0.tar.gz 29.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zsuite-py 0.2.0
File Interpreter ABI Platform
zsuite_py-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 42.7 kB

Release files / zsuite_py-0.2.0.tar.gz

Download URL zsuite_py-0.2.0.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
959ca60cccc4cb03234e2d4aa069873cdefb4368e410025d0206cbe213da177e
BLAKE2b-256 checksum
How to use checksums
36e361267e8f5e37d1c293d99b98ce1bed7a2989e01550f0e82b3ac9d463c03b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / zsuite_py-0.2.0-py3-none-any.whl

Download URL zsuite_py-0.2.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0540a191af66b4b91e7f9ba3f1164c8fbca9c890b1c715714568a09355f6a507
BLAKE2b-256 checksum
How to use checksums
cb500e32df33c01bd927277c68a7c4a91aab4ea108194fe59769912e7b83ea16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release 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