Create symbols for gates in standard library #185
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.