QASM-rust
An OPENQASM 2.0 parser written in Rust 🌵
Features
- Passes the official OpenQASM conformance test suite
- As described in the OpenQASM specification
- Get tokens for a given source file
- Resolve include statements
- Remove comments
- Build Abstract Syntax Tree of a list of tokens
Usage
The usage of qasm
is fully given in the docs. A brief example is given here:
Here is an example that reads a file test.qasm
, processes it and then prints the AST.
test.qasm
OPENQASM 2.0;
// Clifford gate: Hadamard
gate h a { u2(0,pi) a; }
qreg q[2];
creg c[1];
h q[0];
CX q[0], q[1];
measure q[1] -> c[1];
main.rs
extern crate qasm;
use env;
use File;
use *;
use ;
Output
Ok
License
MIT