Skip to content

[FEATURE] Add support for while statements  #7

@TheGupta2012

Description

@TheGupta2012

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)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestqasm3Related to openqasm3qasm3-coverageAdding support for qasm3 constructsunitary-hackIssues for the Unitary Hack

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions