app.processing.pre.utils

Utils used within app.processing.pre.

Module Contents

exception app.processing.pre.utils.PreprocessingException(msg: str, node: app.model.CompileRequest.Node | None = None)

Exception raises during app.processing.pre.

Parameters:
  • msg (str)

  • node (app.model.CompileRequest.Node | None)

app.processing.pre.utils.expr_to_int(expr: openqasm3.ast.Expression | None) int

Get an integer from an expression.

This method does no analysis of the overall AST. If it cannot extract an integer from an expression, it throws.

Parameters:

expr (openqasm3.ast.Expression | None) – Expression to be analyses

Returns:

the resulting integer parsed from the Expression

Return type:

int

app.processing.pre.utils.annotate(statement: TQasmStatement, annotations: list[openqasm3.ast.Annotation]) TQasmStatement

Sets annotations on the specified node.

Parameters:
  • statement (TQasmStatement) – The statement to be annotated

  • annotations (list[openqasm3.ast.Annotation]) – The annotations to be applied

Returns:

The node with annotations applied

Return type:

TQasmStatement

app.processing.pre.utils.parse_io_annotation(annotation: openqasm3.ast.Annotation) int

Parse the command of a @leqo.input or @leqo.output Annotation.

Parameters:

annotation (openqasm3.ast.Annotation) – The annotation to parse

Returns:

The indices

Return type:

int

app.processing.pre.utils.parse_range_definition(range_def: openqasm3.ast.RangeDefinition, length: int) list[int]

Return list of integers expressed by qasm3-range.

The complexity of this function arises because openqasm3 includes the last element and python does not.

Parameters:
Return type:

list[int]

app.processing.pre.utils.parse_qasm_index(index: list[openqasm3.ast.IndexElement], length: int) list[int] | int

Parse list of qasm3 indexes.

This can return either a single index or a subset of them. Multiple indexes are applied iteratively (as qiskit also does it).

Parameters:
  • index (list[openqasm3.ast.IndexElement])

  • length (int)

Return type:

list[int] | int