netqasm.lang.parsing¶
netqasm.lang.parsing.binary¶
-
class
netqasm.lang.parsing.binary.
Deserializer
(flavour)¶ Bases:
object
Deserializes raw bytes into a Subroutine, given a Flavour.
NetQASMInstructions
are immediately created from the binary encoding.(This is in contrast with the parsing.text module, which first converts the input to a
PreSubroutine
, consisting ofICmd
s, before transforming it into aSubroutine
containingNetQASMInstruction
s.)- Parameters
flavour (
Flavour
) –
-
deserialize_subroutine
(raw)¶ - Parameters
raw (
bytes
) –- Return type
-
deserialize_command
(raw)¶ - Parameters
raw (
bytes
) –- Return type
netqasm.lang.parsing.text¶
-
netqasm.lang.parsing.text.
parse_text_presubroutine
(text)¶ Convert a text representation of a subroutine into a PreSubroutine object.
- Parameters
text (
str
) –- Return type
-
netqasm.lang.parsing.text.
parse_text_subroutine
(subroutine, assign_branch_labels=True, make_args_operands=True, replace_constants=True, flavour=None)¶ Convert a text representation of a subroutine into a Subroutine object.
Internally, first a PreSubroutine object is created, consisting of ICmd`s. This is then converted into a `Subroutine using assemble_subroutine.
- Parameters
subroutine (
str
) –flavour (
Optional
[Flavour
]) –
- Return type
-
netqasm.lang.parsing.text.
assemble_subroutine
(pre_subroutine, assign_branch_labels=True, make_args_operands=True, replace_constants=True, flavour=None)¶ Convert a PreSubroutine into a Subroutine, given a Flavour (default: vanilla).
- Parameters
pre_subroutine (
PreSubroutine
) –flavour (
Optional
[Flavour
]) –
- Return type
-
netqasm.lang.parsing.text.
parse_register
(register)¶ - Parameters
register (
str
) –- Return type
-
netqasm.lang.parsing.text.
parse_address
(address)¶ - Parameters
address (
str
) –- Return type
Union
[Address
,ArraySlice
,ArrayEntry
]
-
netqasm.lang.parsing.text.
get_current_registers
(commands)¶ - Parameters
commands (
List
[Union
[ICmd
,BranchLabel
]]) –- Return type
Set
[str
]