
    `N`                     R    d Z ddlZddlZddlZddlZ G d de          Zd Zd ZdS )zVerify that the generated code is valid code.

This takes a line of code and "normalizes" it. I.e., it transforms the snippet
into something that has the potential to compile.

    VerifyCode(): the main function exported by this module.
    Nc                       e Zd ZdZdS )InternalErrorz+Internal error in verifying formatted code.N)__name__
__module____qualname____doc__     5lib/python3.11/site-packages/yapf/yapflib/verifier.pyr   r      s        33$r
   r   c                 (   	 t          t          j        |                               d          dd           dS # t          $ r 	 t          j        t          j        |                     d                                                    dd           Y dS # t          $ rn 	 t          |           }t          |                    d          dd           n4# t          $ r' t          t          j                    d                   w xY wY Y dS w xY ww xY w)zVerify that the reformatted code is syntactically correct.

  Arguments:
    code: (unicode) The reformatted code snippet.

  Raises:
    SyntaxError if the code was reformatted incorrectly.
  zUTF-8<string>exec
   N)compiletextwrapdedentencodeSyntaxErrorastparselstrip_NormalizeCoder   sysexc_info)codenormalized_codes     r   
VerifyCoder   !   s)   
/HOD!!((11:vFFFFF	 / / //	iD 1 12299;;ZPPPPPP / / //(..&&w//VDDDD / / /CLNN1-.../ 	EDDD//s@   6: 
DAB
D 3CD1DDDDDc                    t          j        |                     d                                                    } |                     d          }d}t	          |          D ]2\  }}|                                }|r|                    d          s n3d                    ||d                   dz   } t          j	        d|           r| dz  } n't          j	        d|           rn	 d| z   dz   }t          j        t          j        |                    d                                                    d	d
           |} n# t          $ r d| z   } Y nw xY w|                     d          r| dz  } nt          j	        d|           r| dz  } nnt          j	        d|           r	d| z   dz   } nPt          j	        d|           rd| z   } n5t          j	        d|           rd| z   } nt          j	        d|           rd| z   } | dz   S )z.Make sure that the code snippet is compilable.r   r   #Nz+(if|while|for|with|def|class|async|await)\bz	
    passz(elif|else)\bzif True:
    pass
r   r   zif True: pass
@z
def _():
    passztry\bz
    pass
except:
    passz(except|finally)\bztry:
    pass
z(return|yield)\bzdef _():
    z(continue|break)\bzwhile True:
    zprint\bz&from __future__ import print_function
)r   r   r   split	enumeratestrip
startswithjoinrematchr   r   r   )r   linesilinetry_codes        r   r   r   7   s6   	T**	+	+	2	2	4	4$ **T

%!5!!  ga::<<D DOOC(( e	59			$$X<dCC <LDD	x $'' <&'$.=h	i
/(//$//
0
0
7
7
9
9:vO O Odd & & &%ddd& s <""DD	x$ 	<++DD	x%t,, <$|3DD	x#T** <d"DD	x%t,, <%DD	x
D!! <4t;D	s   %AD= =EE)	r   r   r'   r   r   	Exceptionr   r   r   r	   r
   r   <module>r.      s     


 				 



     I   
/ / /,& & & & &r
   