pygsti.circuits.circuitparser.CircuitParser#
- class CircuitParser(lexer_object=None, lookup=None)#
Bases:
objectParser for text-format operation sequences
Methods
__init__([lexer_object, lookup])p_error(p)p_expable(p)expable : slcref
expable : OPENBR CLOSEBR
expable : OPENBR layer CLOSEBR
expable : LPAREN string RPAREN
expable : GATE | INSTRMT | NOP
p_expdstr(p)expdstr : expable
expdstr : expable EXPOP INTEGER
p_layer(p)layer : layer MULTOP layerable
layer : layerable
p_layer_str(p)layer : layer layerable
p_layerable(p)layerable : GATE | INSTRMT
layerable : subcircuit
layerable : subcircuit EXPOP INTEGER
p_ppstring(p)ppstring : pstring
ppstring : pstring POVM
p_pstring(p)pstring : string
pstring : PREP string
p_slcref(p)slcref : strref
slcref : strref OPENBR INTEGER COLON INTEGER CLOSEBR
p_string(p)string : string MULTOP expdstr
string : expdstr
p_string_str(p)string : string expdstr
p_strref(p)strref : STRINGIND REFLBL
subcircuit : OPENBR layer CLOSEBR
subcircuit : LPAREN layer RPAREN
ply_parse(code[, create_subcircuits])Perform lexing and parsing of code.
Attributes
The lookup dictionary for expanding references
modetokens- 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