mqt.ionshuttler.multi_shuttler.circuit_parsing¶
Module Contents¶
- is_qasm_file(file_path: Path) bool[source]¶
Return whether the file appears to contain an OpenQASM program.
- extract_qubits_from_gate(gate_line: str) list[int][source]¶
Extract canonicalized qubit indices from a gate operation line.
- normalize_qasm_registers(qasm_str: str, *, qreg_name: str = 'q', creg_name: str = 'c') str[source]¶
Rewrite all quantum registers into a single canonical register order.
- parse_qasm_circuit(filename: Path, *, normalize_registers: bool = True) ParsedCircuit[source]¶
Parse a QASM file into stable gate IDs and per-gate metadata.
- Parameters:
filename – Path to the OpenQASM input file.
normalize_registers – Whether to canonicalize all registers before parsing.
- Returns:
The ordered gate IDs and corresponding metadata.
- Raises:
AssertionError – If the file does not contain an OpenQASM header.
ValueError – If qubits cannot be extracted from a gate line.
QASM2ParseError – If register normalization encounters invalid OpenQASM 2.