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.1 0.2.0 0.4.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.1.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.1.0
File Size Uploaded
zsuite_py-0.1.0.tar.gz 29.5 kB Details

Built distribution (wheel)

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

Total release size: 42.6 kB

Release files / zsuite_py-0.1.0.tar.gz

Download URL zsuite_py-0.1.0.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6c7cb16932e1cf11cd6973fd43ed385ff025df497ecb89661a096b8621f99ad9
BLAKE2b-256 checksum
How to use checksums
859a6485b4f6d0a1498b296dfce35b57b01649ec96919b5831b2c997e721deb2
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.1.0-py3-none-any.whl

Download URL zsuite_py-0.1.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a391350db1db5fc121d0fec245256854aa285b6ca5cba8f7d9ab291ac8da5471
BLAKE2b-256 checksum
How to use checksums
f7611e673e2d2c272d7170feffc9218b6e2d548fdf9a2d52217c4e309746742b
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

0.2.0

2 release files

This release

0.1.0 This release

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