Module semantic_analysis

Source
Expand description

The code which performs semantic analyzis on an AST according to the openqasm 2.0 specification.

Structs§

Cbit
A classical bit defined in an openqasm program. Contains the name of the register containing the bit, as well as the index of the bit in the register.
Condition
A condition that determines whether to perform an Operation or not. The first parameter is the name to a classical register. The second parameter is a value to compare the register to when interpreting the register as a binary number with index 0 as the least significan bit. When the register is equal to the second parameter the operation should be applied.
Gate
Describes a custom gate defined in openqasm
OpenQASMProgram
The type returned after performing semantic analysis on an AST.
Qubit
A qubit defined in an openqasm program. Contains the name of the register containing the qubit, as well as the index of the qubit in the register.

Enums§

GateOperation
Operations which can be used inside of a gate declaration in openqasm. This is a subset of Operation. Unlike Operation, however, they contain Expressions instead of f32 (for reasons described in the Expression documentation) and usize instead of Qubit. The usize arguments specify which qubit to use from the gates argument list, starting from the first one at index zero.
Operation
An operation to run when running an openqasm program.
SemanticError
The different errors that can occur when running semantic analysis on an AST.

Type Aliases§

Expression
When defining a gate they can take parameter variables. These variables can then be used in the gate definition to create an expression which can be evaluated into a number. However when defining the gate the parameter variables do not have a specified value so GateOperations can not simply store f32 as parameters, they need to contain functions which along with some values for the parameter variables produce a f32.