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.4 0.2.0 0.6.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.3.2

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.3.2
File Size Uploaded
zsuite_py-0.3.2.tar.gz 29.6 kB Details

Built distribution (wheel)

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

Total release size: 42.7 kB

Release files / zsuite_py-0.3.2.tar.gz

Download URL zsuite_py-0.3.2.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e361db417c7993aa670031ebdc225b603cbe46752645ae197aa3c1fcc2df82f1
BLAKE2b-256 checksum
How to use checksums
560816bfac91aee4b75f67f279c5bf27a7a772fb2531b112f462ad958b454c90
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.3.2-py3-none-any.whl

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

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

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