Skip to main content

Reference OpenQASM AST in Python

Project description

OpenNode: a reference OpenQASM 3.0 AST in Python

This directory contains a reference AST implementation for OpenQASM 3.0 in Python. It consists of:

  • ast.py: The AST nodes.
  • parser/antlr: A parser based on Antlr grammar and reference parser also found in this repo. It walks the ANTLR parse tree to generate the AST tree.
  • ast_visitor: A base AST visitor and an example showing how to implement compiler passes using the visitor.
  • tests: A set of unit tests.

Developer setup

  1. Setup the Antlr tools following the README under grammar. Then from source/grammar directory, run:
antlr4 -o ../openqasm/parser/antlr -Dlanguage=Python3 -visitor qasm3.g4
  1. Change to the current directory and install additional requirements with pip install -r requirements.txt -r requirements-dev.txt.
  2. Format python code: black ..
  3. Check style: bylint ..
  4. Run tests: pytest.

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

openqasm3-0.0.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

openqasm3-0.0.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file openqasm3-0.0.0.tar.gz.

File metadata

  • Download URL: openqasm3-0.0.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for openqasm3-0.0.0.tar.gz
Algorithm Hash digest
SHA256 780eecc3c6797dd0ad0a925b5826c780338af437709113a2afd5ede82323a452
MD5 17ff45b79c505720c5f265daa4c54f45
BLAKE2b-256 b6bf2c607bc7afa9cef03adf891acd791e0f8707d853bd9170b8fff6fc9ad94b

See more details on using hashes here.

File details

Details for the file openqasm3-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: openqasm3-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for openqasm3-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d992b90b30e6a89cfc768f83d50e9a2cb7a95b12db1c01e0175b8262b1557772
MD5 c5993e2e2ba89a7f8b68ac4c7f172408
BLAKE2b-256 04028695b18a024d4a6c0491a15b19010c8418e22d6b66869302595b4e009fe3

See more details on using hashes here.

Supported by

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