🤖 AI Summary
This work addresses the challenge of executing Q# quantum programs directly in web environments. Methodologically, we design and implement the first TypeScript-based compiler toolchain that translates Q# to QASM 3.0, featuring a complete lexer and an LL(1) parser supporting a core subset of Q# syntax, along with a lightweight, structured JSON intermediate representation (IR) that preserves semantics across platforms and enables portable code generation. Our key contributions are: (1) the first browser-native Q# compilation capability, substantially improving accessibility for quantum programming; and (2) a modular JSON IR design that enhances extensibility and interoperability across heterogeneous platforms. Experimental evaluation demonstrates correct compilation and semantic fidelity for representative Q# programs, with performance comparable to mainstream Q# compilers.
📝 Abstract
We implement a compile toolchain from Q# to QASM 3.0 including a full-featured lexer and parser implementation, as well as a compiler that supports a subset of Q# features. The lexer, parser and compiler are shown to work with various input Q# programs and the implementation is compared against existing Q# compile tools. Unlike the Microsoft implementation of the official Q# compile toolchain, our implementation is written in TypeScript in order to port functionality to web environments.