jaqalpaq.parser package¶
- exception jaqalpaq.parser.JaqalParseError(source, line, column, msg)¶
An error thrown by the parser or lexer.
- jaqalpaq.parser.parse_jaqal_file(filename, override_dict=None, expand_macro=False, expand_let=False, expand_let_map=False, return_usepulses=False, inject_pulses=None, autoload_pulses=True)¶
Parse a file written in Jaqal into core types.
- Parameters
filename (str) – The name of the Jaqal file.
override_dict (dict[str, float]) – An optional dictionary that overrides let statements in the Jaqal code. Note: all keys in this dictionary must exist as let statements or an error will be raised.
expand_macro (bool) – Replace macro invocations by their body while parsing.
expand_let (bool) – Replace let constants by their value while parsing.
expand_let_map (bool) – Replace let constants and mapped qubits while parsing. expand_let is ignored if this is True.
return_usepulses (bool) – Whether to both add a second return value and populate it with the usepulses statement.
inject_pulses – If given, use these pulses specifically.
autoload_pulses (bool) – Whether to employ the usepulses statement for parsing. Requires appropriate gate definitions.
- Returns
The circuit representation of the file and usepulses if requested. usepulses is stored in a dict under the key ‘usepulses’. It is itself a dict mapping
Identifier
bjects to what the import, which may be the special symbol all.
- jaqalpaq.parser.parse_jaqal_string(jaqal, override_dict=None, expand_macro=False, expand_let=False, expand_let_map=False, return_usepulses=False, inject_pulses=None, autoload_pulses=True)¶
Parse a string written in Jaqal into core types.
- Parameters
jaqal (str) – The Jaqal code.
override_dict (dict[str, float]) – An optional dictionary that overrides let statements in the Jaqal code. Note: all keys in this dictionary must exist as let statements or an error will be raised.
expand_macro (bool) – Replace macro invocations by their body while parsing.
expand_let (bool) – Replace let constants by their value while parsing.
expand_let_map (bool) – Replace let constants and mapped qubits while parsing. expand_let is ignored if this is True.
return_usepulses (bool) – Whether to both add a second return value and populate it with the usepulses statement.
inject_pulses – If given, use these pulses specifically.
autoload_pulses (bool) – Whether to employ the usepulses statement for parsing. Requires appropriate gate definitions.
- Returns
The circuit representation of the file and usepulses if requested. usepulses is stored in a dict under the key ‘usepulses’. It is itself a dict mapping
Identifier
objects to what the import, which may be the special symbol all.