netqasm.lang.parsing
netqasm.lang.parsing.binary
- class netqasm.lang.parsing.binary.Deserializer(flavour)
Bases:
objectDeserializes raw bytes into a Subroutine, given a Flavour.
NetQASMInstructionsare immediately created from the binary encoding.(This is in contrast with the parsing.text module, which first converts the input to a
ProtoSubroutine, consisting ofICmds, before transforming it into aSubroutinecontainingNetQASMInstructions.)- 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_protosubroutine(text)
Convert a text representation of a subroutine into a ProtoSubroutine 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 ProtoSubroutine 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 ProtoSubroutine into a Subroutine, given a Flavour (default: vanilla).
- Parameters:
pre_subroutine (
ProtoSubroutine)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]