qasmparse

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package qasmparse parses OpenQASM 3.0 with OpenPulse cal {} blocks into pulse.Program objects. It is the inverse of the QASM emission performed by the Braket backend serializer.

The parser handles the subset of OpenQASM used for pulse-level control: port declarations, frame definitions, and all eight pulse instruction types (play, delay, set_phase, shift_phase, set_frequency, shift_frequency, barrier, capture_v0).

Usage:

prog, err := qasmparse.ParseString(qasmSource)
if err != nil {
    log.Fatal(err)
}
// prog is a *pulse.Program

Waveform constructor calls (e.g., gaussian(0.5, 2e-08, 1e-08)) are resolved against built-in waveforms from the waveform package. Custom waveforms can be registered via WithWaveform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(r io.Reader, opts ...Option) (*pulse.Program, error)

Parse reads OpenPulse QASM from r and returns a pulse Program.

func ParseString

func ParseString(source string, opts ...Option) (*pulse.Program, error)

ParseString parses OpenPulse QASM source text into a pulse Program.

Types

type Option

type Option func(*config)

Option configures the parser.

func WithDefaultDt

func WithDefaultDt(dt float64) Option

WithDefaultDt sets the port time resolution (default 1e-9 = 1ns).

func WithWaveform

func WithWaveform(name string, fn WaveformConstructor) Option

WithWaveform registers a custom waveform constructor by name.

type WaveformConstructor

type WaveformConstructor func(args []float64) (pulse.Waveform, error)

WaveformConstructor builds a waveform from numeric arguments.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL