Zyntex - Zig parsing and code generation for Python
Parse, inspect, and generate Zig code from Python.

Documentation
· Examples
· Contributing
Zyntex wraps Zig's std AST parser and exposes Python objects for working with
source code. Inspect declarations, edit their properties, and emit Zig code using
the built-in printers.
Zyntex is in early development. Breaking API changes are expected.
Features
- Parse source from strings, files, or directories of Zig files.
- Inspect and edit top-level elements - parsing is currently limited to this level.
- Generate Zig code from Python objects with built-in or custom printers.
- Defer parsing until needed, or parse multiple files concurrently.
- No Python runtime dependencies, with native bindings to Zig's standard parser.
Type annotations and declaration bodies are exposed as Zig source strings.
Installation
pip install zyntex
Requirements:
- Python 3.9+.
- Windows, Linux, or macOS on x86_64. Other CPU architectures are not yet supported.
Quick start
from typing import cast
from zyntex.code_generation.premade import DefaultCodePrinter
from zyntex.parsing import SourceCode
from zyntex.parsing.syntax import VariableDeclaration
printer = DefaultCodePrinter()
source = SourceCode("const count: u32 = 42;")
variable = cast(VariableDeclaration, source.content[0])
variable.is_public = True
variable.type_hint = "u64"
print(printer.print(source))
Output:
pub const count: u64 = 42;
For a larger example, see the Zig code linter.
Development
python/ - Python package, tests, and packaging configuration.
zig/ - Native library, tests, and AST enum generator.
tools/ - Native library and documentation build scripts.
docs/ - Documentation sources.
examples/ - Usage examples.
See the contributing guide for setup, building native libraries, and running tests.