Qiskit / openqasm3_parser

Parser and semantic analyzer for the OpenQASM3 language
Apache License 2.0
11 stars 12 forks source link

Create symbols for gates in standard library #185

Closed jlapeyre closed 7 months ago

jlapeyre commented 7 months ago

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.