memq_dqc.preprocessing.qasm¶
qasm
¶
OpenQASM 3 preprocessing.
The public surface here is the set of entry points for getting an OpenQASM 3 program in and out of memq_dqc, plus CircuitQubit, the qubit reference those programs are expressed in terms of.
The statement-cleaning helpers and the Cleaned* node types are
implementation details of the circuit builders. They remain importable from
their defining modules (memq_dqc.preprocessing.qasm.analysis, .ast_utils,
.cleaning, .types) but are not part of the supported API and may
change without notice.
CircuitQubit
dataclass
¶
Represents a circuit-level qubit with register name and index.
dump_qasm_program
¶
Serialize an OpenQASM 3 program to source text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
program
|
Program
|
Program to serialize. |
required |
Returns:
| Type | Description |
|---|---|
str
|
OpenQASM 3 source text. |
load_qasm_program
¶
Load an OpenQASM 3 program from a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the OpenQASM 3 file. |
required |
Returns:
| Type | Description |
|---|---|
Program
|
The parsed OpenQASM 3 program. |
Source code in src/memq_dqc/preprocessing/qasm/io.py
parse_qasm_file
¶
Parse an OpenQASM 3 file without additional structural constraints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the OpenQASM 3 file. |
required |
Returns:
| Type | Description |
|---|---|
Program
|
Parsed OpenQASM 3 program. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If |
Source code in src/memq_dqc/preprocessing/qasm/io.py
parse_qasm_source
¶
Parse OpenQASM 3 source text into an AST program.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qasm_source
|
str
|
OpenQASM 3 source text. |
required |
Returns:
| Type | Description |
|---|---|
Program
|
Parsed OpenQASM 3 program. |