You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The statement if ( bool ) <true-body> branches to program if the Boolean evaluates to true
and may optionally be followed by else <false-body>. Both true-body and false-body can
be a single statement terminated by a semicolon, or a program block of several statements { stmt1; stmt2; }.
grammar: ifStatement: IF LPAREN expression RPAREN if_body=statementOrScope (ELSE else_body=statementOrScope)?;
if-then example:
include"stdgates.inc";
qubit q;
if (0 == 1) z q;
output:
Error: [ x QASM3 Parse Error: expected a block
,-[test:4:20]
3 | qubit q;
4 |if (0 == 1) z q;: ^
5 |`----]
if-then-else example:
include"stdgates.inc";
qubit q;
if (0 == 1) z q; else x q;
output:
Error: [ x QASM3 Parse Error: expected a block
,-[test:4:20]
3 | qubit q;
4 |if (0 == 1) z q;else x q;: ^
5 |`----, x QASM3 Parse Error: stmt: expected expression, type declaration, or let| statement ,-[test:4:26] 3 | qubit q; 4 |if (0 == 1) z q;else x q;: ^ 5 |`----]
The text was updated successfully, but these errors were encountered:
Just to warn you because you're opening a lot of issues: this parser is/was experimental, and is not this second under active development. We reprioritised our efforts earlier in the year, and this parser is one of the things that got temporarily deprioritised, before we'd finished making it production ready.
We do intend to pick up development on it again, probably in the new year, but right now, there's nobody from the Qiskit team actively working on it.
From the spec:
grammar:
ifStatement: IF LPAREN expression RPAREN if_body=statementOrScope (ELSE else_body=statementOrScope)?;
if-then example:
output:
if-then-else example:
output:
The text was updated successfully, but these errors were encountered: