:py:mod:`pygsti.circuits.circuitparser` ======================================= .. py:module:: pygsti.circuits.circuitparser .. autoapi-nested-parse:: Implementations of a text parser for reading GST input files. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 slowcircuitparser/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: pygsti.circuits.circuitparser.CircuitLexer pygsti.circuits.circuitparser.CircuitParser Attributes ~~~~~~~~~~ .. autoapisummary:: pygsti.circuits.circuitparser.warn_msg .. py:data:: warn_msg .. py:class:: CircuitLexer Lexer for matching and interpreting text-format operation sequences .. py:attribute:: tokens :value: "('EXPOP', 'MULTOP', 'INTEGER', 'NOP', 'GATE', 'INSTRMT', 'PREP', 'POVM', 'REFLBL', 'OPENBR',..." .. py:attribute:: t_EXPOP :value: "'\\\\^'" .. py:attribute:: t_MULTOP :value: "'\\\\*'" .. py:attribute:: t_OPENBR :value: "'\\\\['" .. py:attribute:: t_CLOSEBR :value: "'\\\\]'" .. py:attribute:: t_LPAREN :value: "'\\\\('" .. py:attribute:: t_RPAREN :value: "'\\\\)'" .. py:attribute:: t_COLON :value: "'\\\\:'" .. py:attribute:: t_SEMICOLON :value: "'\\\\;'" .. py:attribute:: t_EXCLAM :value: "'\\\\!'" .. py:attribute:: t_ignore :value: "' \\t'" .. py:method:: make_label(s) :staticmethod: .. py:method:: t_GATE(t) :staticmethod: ``'G[a-z0-9_]+(;[a-zQ0-9_\./]+)*(:[a-zQ0-9_]+)*(![0-9\.]+)?'`` .. py:method:: t_INSTRMT(t) :staticmethod: ``'I[a-z0-9_]+(![0-9\.]+)?'`` .. py:method:: t_PREP(t) :staticmethod: ``'rho[a-z0-9_]+(![0-9\.]+)?'`` .. py:method:: t_POVM(t) :staticmethod: ``'M[a-z0-9_]+(![0-9\.]+)?'`` .. py:method:: t_STRINGIND(t) :staticmethod: ``'S(?=\s*\<)'`` .. py:method:: t_REFLBL(t) :staticmethod: ``'<\s*[a-zA-Z0-9_]+\s*>'`` .. py:method:: t_NOP(t) :staticmethod: ``'\{\}'`` .. py:method:: t_INTEGER(t) :staticmethod: ``'\d+'`` .. py:method:: t_error(t) :staticmethod: .. py:class:: CircuitParser(lexer_object=None, lookup=None) Bases: :py:obj:`object` Parser for text-format operation sequences .. py:property:: lookup The lookup dictionary for expanding references .. py:attribute:: tokens :value: "('EXPOP', 'MULTOP', 'INTEGER', 'NOP', 'GATE', 'INSTRMT', 'PREP', 'POVM', 'REFLBL', 'OPENBR',..." .. py:attribute:: mode :value: "'simple'" .. py:method:: p_strref(p) strref : STRINGIND REFLBL .. py:method:: p_slcref_slice(p) :staticmethod: slcref : strref OPENBR INTEGER COLON INTEGER CLOSEBR .. py:method:: p_slcref(p) :staticmethod: slcref : strref .. py:method:: p_subcircuit_singlelayer(p) :staticmethod: subcircuit : OPENBR layer CLOSEBR .. py:method:: p_subcircuit_string(p) :staticmethod: subcircuit : LPAREN layer RPAREN .. py:method:: p_layerable(p) :staticmethod: layerable : GATE | INSTRMT .. py:method:: p_layerable_subcircuit(p) :staticmethod: layerable : subcircuit .. py:method:: p_layerable_subcircuit_expop(p) :staticmethod: layerable : subcircuit EXPOP INTEGER .. py:method:: p_layer_layerable(p) :staticmethod: layer : layerable .. py:method:: p_layer_str(p) :staticmethod: layer : layer layerable .. py:method:: p_layer(p) :staticmethod: layer : layer MULTOP layerable .. py:method:: p_expable_paren(p) :staticmethod: expable : LPAREN string RPAREN .. py:method:: p_expable_layer(p) :staticmethod: expable : OPENBR layer CLOSEBR .. py:method:: p_expable_empty_layer(p) :staticmethod: expable : OPENBR CLOSEBR .. py:method:: p_expable_single(p) :staticmethod: expable : GATE | INSTRMT | NOP .. py:method:: p_expable(p) :staticmethod: expable : slcref .. py:method:: p_expdstr_expop(p) :staticmethod: expdstr : expable EXPOP INTEGER .. py:method:: p_expdstr(p) :staticmethod: expdstr : expable .. py:method:: p_string_expdstr(p) :staticmethod: string : expdstr .. py:method:: p_string_str(p) :staticmethod: string : string expdstr .. py:method:: p_string(p) :staticmethod: string : string MULTOP expdstr .. py:method:: p_pstring(p) :staticmethod: pstring : string .. py:method:: p_pstring_prep(p) :staticmethod: pstring : PREP string .. py:method:: p_ppstring(p) :staticmethod: ppstring : pstring .. py:method:: p_ppstring_povm(p) :staticmethod: ppstring : pstring POVM .. py:method:: p_error(p) :staticmethod: .. py:method:: 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.