Skip to main content

A high-level Python package to parse and generate Zig code.

Project description

Zyntex - Zig code parser for Python

Downloads License Python Version Zig

Zyntex is a Python library that allows you to parse and generate Zig code at a high level. Function bodies and other low-level elements are currently returned as raw strings. Currently, it can parse Zig code written in version 0.15.1 - the supported parsing version will be continuously updated in the future.

Internally, it uses bindings to Zig's std AST parser, making it both fast and memory-efficient. Important: currently bindings are only available for windows-x86_64, macos-x86_64, and linux-x86_64. For more information, read the docs.

Be aware that the project is at a very early stage of development and is actively being developed.

Features

  • Parse Zig source from strings or files.
  • Code generation - emitting Zig code from Python objects via premade printers.
  • High-performance, low-memory parsing powered by Zig’s std parser.
  • Easy-to-use, Pythonic API designed for inspection Zig code.
  • Zero-dependency - the project requires no external dependencies on either the Zig side or the Python side.

Installation

pip install zyntex

Minimal example

from typing import cast

from zyntex.code_generation.premade import DefaultCodePrinter
from zyntex.parsing.syntax import VariableDeclaration
from zyntex.parsing import SourceCode

code_printer = DefaultCodePrinter()
src = SourceCode("const result: usize = 15 + 15;")

variable = cast(VariableDeclaration, src.content[0])
variable.is_public = True
print(code_printer.print(src)) # pub const result: usize = 15 + 15;

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zyntex-0.2.3.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zyntex-0.2.3-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file zyntex-0.2.3.tar.gz.

File metadata

  • Download URL: zyntex-0.2.3.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for zyntex-0.2.3.tar.gz
Algorithm Hash digest
SHA256 98c1604541438cfa1457c18c024abf99d8ef73cfe18e0cc826921de238fd18d1
MD5 6bc2d010fe652cc2ec069743c232e4f9
BLAKE2b-256 f9d0443bd28671414613301350d5378d85c651d9f08adc79b45ad1e1c76f53c9

See more details on using hashes here.

File details

Details for the file zyntex-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: zyntex-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for zyntex-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 57eb11aa0bf9a209e8d586cbd228f3ca867557bc141036c024be011f8560f09c
MD5 7f1470d969c1a96d132cf78ef984c92d
BLAKE2b-256 d00e0add387b298153059057d69f18d80e0bc7cf258741507027dd878da68ce3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page