def parse_complex(text: str) -> complex:
    """Attempts to parse a complex number in exactly the same way as Quirk."""
    try:
        return complex(_parse_formula_using_token_map(text, PARSE_COMPLEX_TOKEN_MAP_DEG))
    except Exception as ex:
        raise ValueError(f'Failed to parse complex from {text!r}') from ex
Attempts to parse a complex number in exactly the same way as Quirk.
cirq-core/cirq/interop/quirk/cells/parse.py