Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create symbols for gates in standard library #185

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

jlapeyre
Copy link
Collaborator

This commit implements the following. Upon encountering include "stdgates.qasm" symbols are created for gates in the standard library according to the spec. No corresponding file need exist. None is actually read or included. If there is such a file in the include path, it is ignored.

Symbols carry a name and a type. The type Gate is parameterized by number of qubits and number of classical parameters. So the symbols created contain all the information that a declaration (but not definition) of the gate would carry. At the level of this parser/analyzer, this allows the gates to be used (called) after the include statement and allows type-checking to ensure that they are called with valid parameters (The latter is only partly implemented at the time of this commit.)

If a name in the standard library is already bound, then a semantic error is recorded. Since no real file is actually included, the location associated with the error is that of the include statement.

This commit implements the following.  Upon encountering `include "stdgates.qasm"` symbols
are created for gates in the standard library according to the spec. No corresponding file
need exist. None is actually read or included. If there is such a file in the include
path, it is ignored.

Symbols carry a name and a type. The type `Gate` is parameterized by number of qubits and
number of classical parameters. So the symbols created contain all the information that a
declaration (but not definition) of the gate would carry. At the level of this
parser/analyzer, this allows the gates to be used (called) after the include statement and
allows type-checking to ensure that they are called with valid parameters (The latter is
only partly implemented at the time of this commit.)

If a name in the standard library is already bound, then a semantic error is recorded.
Since no real file is actually included, the location associated with the error is that of
the `include` statement.
@jlapeyre jlapeyre merged commit 5200b3b into Qiskit:main Mar 22, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant