Skip to content

Commit

Permalink
refactor qasm 3 visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGupta2012 committed Aug 15, 2024
1 parent 47184a0 commit d314d80
Show file tree
Hide file tree
Showing 7 changed files with 764 additions and 631 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Types of changes:
### ➕ New Features

### 🌟 Improvements
* Re-factor the `BasicQasmVisitor` and improve modularity ( [#142](https://github.com/qBraid/qbraid-qir/pull/142) )

### 📜 Documentation
* Housekeeping updates for release ( [#135](https://github.com/qBraid/qbraid-qir/pull/135) )
Expand Down
106 changes: 106 additions & 0 deletions qbraid_qir/qasm3/utils/imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright (C) 2024 qBraid
#
# This file is part of the qBraid-SDK
#
# The qBraid-SDK is free software released under the GNU General Public License v3
# or later. You can redistribute and/or modify it under the terms of the GPL v3.
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>.
#
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.

"""
Module defining Qasm3 imports.
"""

from openqasm3.ast import (
AliasStatement,
ArrayLiteral,
ArrayType,
BinaryExpression,
BooleanLiteral,
BoolType,
BranchingStatement,
ClassicalArgument,
ClassicalAssignment,
ClassicalDeclaration,
ConstantDeclaration,
DiscreteSet,
DurationLiteral,
ExpressionStatement,
FloatLiteral,
)
from openqasm3.ast import FloatType as Qasm3FloatType
from openqasm3.ast import (
ForInLoop,
FunctionCall,
GateModifierName,
Identifier,
ImaginaryLiteral,
Include,
IndexedIdentifier,
IndexExpression,
IntegerLiteral,
)
from openqasm3.ast import IntType as Qasm3IntType
from openqasm3.ast import (
IODeclaration,
QuantumBarrier,
QuantumGate,
QuantumGateDefinition,
QuantumGateModifier,
QuantumMeasurementStatement,
QuantumReset,
QubitDeclaration,
RangeDefinition,
ReturnStatement,
Statement,
SubroutineDefinition,
SwitchStatement,
UnaryExpression,
WhileLoop,
)

__all__ = [
"AliasStatement",
"ArrayLiteral",
"ArrayType",
"BinaryExpression",
"BooleanLiteral",
"BoolType",
"BranchingStatement",
"ClassicalArgument",
"ClassicalAssignment",
"ClassicalDeclaration",
"ConstantDeclaration",
"DiscreteSet",
"DurationLiteral",
"ExpressionStatement",
"FloatLiteral",
"Qasm3FloatType",
"ForInLoop",
"FunctionCall",
"GateModifierName",
"Identifier",
"ImaginaryLiteral",
"Include",
"IndexedIdentifier",
"IndexExpression",
"IntegerLiteral",
"Qasm3IntType",
"IODeclaration",
"QuantumBarrier",
"QuantumGate",
"QuantumGateDefinition",
"QuantumGateModifier",
"QuantumMeasurementStatement",
"QuantumReset",
"QubitDeclaration",
"RangeDefinition",
"ReturnStatement",
"Statement",
"SubroutineDefinition",
"SwitchStatement",
"UnaryExpression",
"WhileLoop",
]
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
UintType,
)

from .elements import InversionOp
from .exceptions import Qasm3ConversionError
from .linalg import kak_decomposition_angles
from ..elements import InversionOp
from ..exceptions import Qasm3ConversionError
from ..linalg import kak_decomposition_angles

OPERATOR_MAP = {
"+": lambda x, y: x + y,
Expand Down
Loading

0 comments on commit d314d80

Please sign in to comment.