Feature Description
Add support for the while loops in openqasm. The main motivation behind this feature is to provide complete semantic coverage of the openqasm3 grammar
Current
The following code containing a while loop in openqasm fails during unroll -
import pyqasm
qasm_str = """
OPENQASM 3.0;
include "stdgates.inc";
qubit q;
bit result;
int i = 0;
// Keep applying hadamards and measuring a qubit
// until 10, |1>s are measured
while (i < 10) {
h q;
result = measure q;
if (result) {
i += 1;
}
}"""
module = pyqasm.loads(qasm_str)
module.unroll()
...
ValidationError: Unsupported statement of type <class 'openqasm3.ast.WhileLoop'>
Implementation (Optional)
Feature Description
Add support for the
whileloops in openqasm. The main motivation behind this feature is to provide complete semantic coverage of the openqasm3 grammarCurrent
The following code containing a
whileloop in openqasm fails duringunroll-Implementation (Optional)
Similar to the handling of
forloop statements, we will need to add implementation for the_visit_while_loopmethod in theQasmVisitorclassThis will require analyzing the structure of
openqasm3.ast.WhileLoopclass and figuring out how to evaluate the conditions in different iterations.