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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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