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.3 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.1

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

Built distribution (wheel)

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

Total release size: 42.7 kB

Release files / zsuite_py-0.3.1.tar.gz

Download URL zsuite_py-0.3.1.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c8fc605a93ad6f3b137b65b79394f628b5ba313fca5fd1f8dcf4c5e496e61d28
BLAKE2b-256 checksum
How to use checksums
73ac68349cac7bb96c3379ffe91a9e380f570f7a4194406d649e0ac2f0873c6b
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.1-py3-none-any.whl

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

This release

0.3.1 This release

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