# \[ANN\] Quasar.jl - Pure Julia OpenQASM 3 Lexing and Parsing

**URL:** <https://discourse.julialang.org/t/ann-quasar-jl-pure-julia-openqasm-3-lexing-and-parsing/121513>\
**Category:** Package Announcements\
**Tags:** package, announcement, quantum, parsing\
**Created:** [October 20, 2024, 6:07pm UTC](https://discourse.julialang.org/t/ann-quasar-jl-pure-julia-openqasm-3-lexing-and-parsing/121513 "2024-10-20T18:07:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kslimes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kslimes/32/44413_2.png) [@kslimes](https://discourse.julialang.org/u/kslimes)\
**Post date:** [October 20, 2024, 6:07pm UTC](https://discourse.julialang.org/t/ann-quasar-jl-pure-julia-openqasm-3-lexing-and-parsing/121513/1 "2024-10-20T18:07:46Z")

</div>

# [Quasar.jl](https://juliahub.com/ui/Packages/General/Quasar) - Pure Julia OpenQASM3 lexing and parsing

Links: [GitHub](https://github.com/kshyatt-aws/Quasar.jl)

`Quasar.jl` is a pure Julia package for lexing and parsing [OpenQASM](https://openqasm.com/), a popular intermediate representation for quantum programs. Quasar supports:

- Subroutines
- Custom gate definitions
- Gate modifiers
- Control flow
- Inputs
- Type casting
- Supplying your own `pragma` definitions

What’s not yet supported:

- Output variables (coming soon!)
- OpenPulse
- `angle` types and their logic (coming soon!)

You can parse an OpenQASM program, `str`, in string form like so:

```julia
parsed = Quasar.parse_qasm(str)
visitor = Quasar.QasmProgramVisitor(inputs)
visitor(parsed)

```

The process occurs in two steps: first an AST is generated then visited with any `inputs` (a `Dict{String, <:Any}`), so that you can re-use the AST with various sets of inputs.

Then you can query `instructions(visitor)` to get a list of `CircuitInstructions`, which you can turn into your own program’s gates and other instructions using a package like [`StructTypes.jl`.](https://juliapackages.com/p/structtypes).

`Quasar.jl` is built on top of [`Automa.jl`](https://github.com/BioJulia/Automa.jl), and many thanks to the developers and maintainers of that package for creating it and answering my many questions.

Future plans are to add proper support for `angle`s and outputs, and improve documentation for `pragma`s and generating your idiomatic gate dialects.

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [October 31, 2024, 3:25pm UTC](https://discourse.julialang.org/t/ann-quasar-jl-pure-julia-openqasm-3-lexing-and-parsing/121513/2 "2024-10-31T15:25:15Z")

</div>

@kslimes If you have a publicly accessible presentation programmed, please advise us here.

Or maybe you could do an ad hoc presentation.

In fact, the OpenQASM Technical Steering Committee would _love_ to hear a presentation on Quasar.jl at their meeting. Please contact me or Erik Davis (or anyone else with connections to the TSC) if you are interested.

---

<div class="post-metadata">

**Author:** ![kslimes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kslimes/32/44413_2.png) [@kslimes](https://discourse.julialang.org/u/kslimes)\
**Post date:** [October 31, 2024, 6:23pm UTC](https://discourse.julialang.org/t/ann-quasar-jl-pure-julia-openqasm-3-lexing-and-parsing/121513/3 "2024-10-31T18:23:44Z")

</div>

Heya @jlapeyre, thanks very much for the invite! I’m basically fully booked until mid-December, but perhaps in the new year? I’ll email you (can you DM me an appropriate address?).
