pygsti.circuits.circuitparser.CircuitParser#

class CircuitParser(lexer_object=None, lookup=None)#

Bases: object

Parser for text-format operation sequences

Methods

__init__([lexer_object, lookup])

p_error(p)

p_expable(p)

expable : slcref

p_expable_empty_layer(p)

expable : OPENBR CLOSEBR

p_expable_layer(p)

expable : OPENBR layer CLOSEBR

p_expable_paren(p)

expable : LPAREN string RPAREN

p_expable_single(p)

expable : GATE | INSTRMT | NOP

p_expdstr(p)

expdstr : expable

p_expdstr_expop(p)

expdstr : expable EXPOP INTEGER

p_layer(p)

layer : layer MULTOP layerable

p_layer_layerable(p)

layer : layerable

p_layer_str(p)

layer : layer layerable

p_layerable(p)

layerable : GATE | INSTRMT

p_layerable_subcircuit(p)

layerable : subcircuit

p_layerable_subcircuit_expop(p)

layerable : subcircuit EXPOP INTEGER

p_ppstring(p)

ppstring : pstring

p_ppstring_povm(p)

ppstring : pstring POVM

p_pstring(p)

pstring : string

p_pstring_prep(p)

pstring : PREP string

p_slcref(p)

slcref : strref

p_slcref_slice(p)

slcref : strref OPENBR INTEGER COLON INTEGER CLOSEBR

p_string(p)

string : string MULTOP expdstr

p_string_expdstr(p)

string : expdstr

p_string_str(p)

string : string expdstr

p_strref(p)

strref : STRINGIND REFLBL

p_subcircuit_singlelayer(p)

subcircuit : OPENBR layer CLOSEBR

p_subcircuit_string(p)

subcircuit : LPAREN layer RPAREN

ply_parse(code[, create_subcircuits])

Perform lexing and parsing of code.

Attributes

lookup

The lookup dictionary for expanding references

mode

tokens

static p_expable(p)#

expable : slcref

static p_expable_empty_layer(p)#

expable : OPENBR CLOSEBR

static p_expable_layer(p)#

expable : OPENBR layer CLOSEBR

static p_expable_paren(p)#

expable : LPAREN string RPAREN

static p_expable_single(p)#

expable : GATE | INSTRMT | NOP

static p_expdstr(p)#

expdstr : expable

static p_expdstr_expop(p)#

expdstr : expable EXPOP INTEGER

static p_layer(p)#

layer : layer MULTOP layerable

static p_layer_layerable(p)#

layer : layerable

static p_layer_str(p)#

layer : layer layerable

static p_layerable(p)#

layerable : GATE | INSTRMT

static p_layerable_subcircuit(p)#

layerable : subcircuit

static p_layerable_subcircuit_expop(p)#

layerable : subcircuit EXPOP INTEGER

static p_ppstring(p)#

ppstring : pstring

static p_ppstring_povm(p)#

ppstring : pstring POVM

static p_pstring(p)#

pstring : string

static p_pstring_prep(p)#

pstring : PREP string

static p_slcref(p)#

slcref : strref

static p_slcref_slice(p)#

slcref : strref OPENBR INTEGER COLON INTEGER CLOSEBR

static p_string(p)#

string : string MULTOP expdstr

static p_string_expdstr(p)#

string : expdstr

static p_string_str(p)#

string : string expdstr

p_strref(p)#

strref : STRINGIND REFLBL

static p_subcircuit_singlelayer(p)#

subcircuit : OPENBR layer CLOSEBR

static p_subcircuit_string(p)#

subcircuit : LPAREN layer RPAREN

ply_parse(code, create_subcircuits=True)#

Perform lexing and parsing of code.

Parameters:

code (str) – A circuit encoded as a single-line string

Returns:

  • layer_labels (tuple) – A tuple of the layer-labels of the circuit

  • line_labels (tuple) – A tuple of the line labels of the circuit.

property lookup#

The lookup dictionary for expanding references