From 795f1d4b7b60da7d207ec54ba657827489eb7493 Mon Sep 17 00:00:00 2001 From: Thierry Martinez Date: Tue, 14 Oct 2025 15:42:59 +0200 Subject: [PATCH] Support for `id` gate This commit adds support for the [id](https://openqasm.com/language/standard_library.html#id) gate, which corresponds to Graphix `I` instruction. --- README.md | 1 + graphix_qasm_parser/parser.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0256444..e5fd030 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ circuit = parser.parse_file("my_circuit.qasm") | [x](https://openqasm.com/language/standard_library.html#x) | X | | [y](https://openqasm.com/language/standard_library.html#y) | Y | | [z](https://openqasm.com/language/standard_library.html#z) | Z | +| [id](https://openqasm.com/language/standard_library.html#id) | I | | [rx](https://openqasm.com/language/standard_library.html#rx) | RX | | [ry](https://openqasm.com/language/standard_library.html#ry) | RY | | [rz](https://openqasm.com/language/standard_library.html#rz) | RZ | diff --git a/graphix_qasm_parser/parser.py b/graphix_qasm_parser/parser.py index 8abe05f..9f6738b 100644 --- a/graphix_qasm_parser/parser.py +++ b/graphix_qasm_parser/parser.py @@ -13,7 +13,7 @@ ParserRuleContext, ) from graphix import Circuit -from graphix.instruction import CCX, CNOT, RX, RY, RZ, RZZ, SWAP, H, S, X, Y, Z +from graphix.instruction import CCX, CNOT, RX, RY, RZ, RZZ, SWAP, H, I, S, X, Y, Z from openqasm_parser import qasm3Lexer, qasm3Parser, qasm3ParserVisitor # override introduced in Python 3.12 @@ -317,6 +317,9 @@ def visitGateCallStatement(self, ctx: qasm3Parser.GateCallStatementContext) -> N elif gate == "z": # https://openqasm.com/language/standard_library.html#z instruction = Z(target=operands[0]) + elif gate == "id": + # https://openqasm.com/language/standard_library.html#id + instruction = I(target=operands[0]) elif gate == "rx": # https://openqasm.com/language/standard_library.html#rx instruction = RX(target=operands[0], angle=exprs[0])