
    X-Ph                    <   U d Z ddlmZ ddlZddlmZ d  ed          D             Zded<   ej	        D ]Z
e
e ee
          <   d	D ]=Z
d
e
 Ze                    d                              d          Zee ee          <   >de ed          <   ddZddZdS )a  Encode valid C string literals from Python strings.

If a character is not allowed in C string literals, it is either emitted
as a simple escape sequence (e.g. '\n'), or an octal escape sequence
with exactly three digits ('\oXXX'). Question marks are escaped to
prevent trigraphs in the string literal from being interpreted. Note
that '\?' is an invalid escape sequence in Python.

Consider the string literal "AB\xCDEF". As one would expect, Python
parses it as ['A', 'B', 0xCD, 'E', 'F']. However, the C standard
specifies that all hexadecimal digits immediately following '\x' will
be interpreted as part of the escape sequence. Therefore, it is
unexpectedly parsed as ['A', 'B', 0xCDEF].

Emitting ("AB\xCD" "EF") would avoid this behaviour. However, we opt
for simplicity and use octal escape sequences instead. They do not
suffer from the same issue as they are defined to parse at most three
octal digits.
    )annotationsN)Finalc                    g | ]}d |d	S )\03o .0is     U/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypyc/codegen/cstring.py
<listcomp>r      s     444A<<<<444       r   CHAR_MAP)
'"r   abfnrtvr   asciiunicode_escapez\??r   bytesreturnstrc                D    d                     d | D                       }|S )zIProduce contents of a C string literal for a byte string, without quotes. c                (    g | ]}t           |         S r   )r   r	   s     r   r   z,encode_bytes_as_c_string.<locals>.<listcomp>-   s    ...qx{...r   )join)r   escapeds     r   encode_bytes_as_c_stringr%   +   s'    gg..A...//GNr   valuec                ,    dt          |           z   dz   S )zCreate initializer for a C char[]/ char * variable from a string.

    For example, if value if b'foo', the result would be '"foo"'.
    r   )r%   )r&   s    r   c_string_initializerr(   1   s    
 )%000366r   )r   r   r   r   )r&   r   r   r   )__doc__
__future__r   stringtypingr   ranger   __annotations__	printablecordr$   encodedecodedecodedr%   r(   r   r   r   <module>r5      s*    ( # " " " " "       44s444 4 4 4 4 
	  AHSSVV 
= % %A1hhGnnW%%,,-=>>G$HSS\\ S    7 7 7 7 7 7r   