From 089165901da2c3c8435d19b85797cdd16e82640f Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Wed, 31 Jan 2024 20:17:34 +0000 Subject: [PATCH] Make AST node more descriptive --- qiskit/qasm3/ast.py | 5 +++-- qiskit/qasm3/exporter.py | 2 +- qiskit/qasm3/printer.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qiskit/qasm3/ast.py b/qiskit/qasm3/ast.py index 97d285df6e68..9b8271ce7fb7 100644 --- a/qiskit/qasm3/ast.py +++ b/qiskit/qasm3/ast.py @@ -596,8 +596,9 @@ class DefaultCase(Expression): """An object representing the `default` special label in switch statements.""" -class SwitchStatementV1(Statement): - """AST node for the proposed 'switch-case' extension to OpenQASM 3. +class SwitchStatementPreview(Statement): + """AST node for the proposed 'switch-case' extension to OpenQASM 3, before the syntax was + stabilized. This corresponds to the :attr:`.ExperimentalFeatures.SWITCH_CASE_V1` logic. The stabilized form of the syntax instead uses :class:`.SwitchStatement`.""" diff --git a/qiskit/qasm3/exporter.py b/qiskit/qasm3/exporter.py index 9ab35a97a8d5..7ae0c321551f 100644 --- a/qiskit/qasm3/exporter.py +++ b/qiskit/qasm3/exporter.py @@ -857,7 +857,7 @@ def case(values, case_block): return [ ast.AssignmentStatement(target, real_target), - ast.SwitchStatementV1( + ast.SwitchStatementPreview( target, ( case(values, block) diff --git a/qiskit/qasm3/printer.py b/qiskit/qasm3/printer.py index bdf1915f1c1a..94d12a7ecff6 100644 --- a/qiskit/qasm3/printer.py +++ b/qiskit/qasm3/printer.py @@ -528,7 +528,7 @@ def _visit_SwitchStatement(self, node: ast.SwitchStatement) -> None: self.stream.write("}") self._end_line() - def _visit_SwitchStatementV1(self, node: ast.SwitchStatementV1) -> None: + def _visit_SwitchStatementPreview(self, node: ast.SwitchStatementPreview) -> None: # This is the pre-release syntax, which had lots of extra `break` statements in it. self._start_line() self.stream.write("switch (")