Qx.Export.OpenQASM.Lowering (Qx - Quantum Computing Simulator v0.6.0)
View SourceConverts a parsed OpenQASM AST (see Qx.Export.OpenQASM.AST) into a
%Qx.QuantumCircuit{}.
This stage performs:
- Register tracking — accepts a single
qubit/bitregister; rejects multi-register programs with a typed error pointing at the second declaration. - Gate-name resolution — looks up each
gate_callagainst a literal whitelist (@stdgate_table); unknown names raiseQx.QasmUnsupportedError. Per Iron Law 1, never converts caller input to atoms. - Decomposition — for
tdg,sx,u1,u2, expands to one or more Qx instruction tuples.idis dropped. - Parameter evaluation — calls
Qx.Export.OpenQASM.Expr.eval/2to fold numeric expressions to floats. - Validation — qubit references must point at the declared register and stay in bounds; classical bits likewise.
Summary
Functions
Lowers a parsed AST into a %QuantumCircuit{}.
Functions
@spec lower({:program, list()}) :: {:ok, Qx.QuantumCircuit.t()} | {:error, Exception.t()}
Lowers a parsed AST into a %QuantumCircuit{}.
Returns {:ok, circuit} or {:error, exception} where exception is one
of Qx.QasmParseError, Qx.QasmUnsupportedError, Qx.QubitIndexError,
Qx.ClassicalBitError.