
    h                         S SK Jr  S SKJr  S SKJr  \R                  r\R                  r\R                  r " S S\5      r	g)    )tree)PythonTokenTypes)
BaseParserc                   P  ^  \ rS rSrSr0 S\R                  _S\R                  _S\R                  _S\R                  _S\R                  _S\R                  _S	\R                  _S
\R                  _S\R                  _S\R                  _S\R                  _S\R                  _S\R                  _S\R                  _S\R                  _S\R                  _S\R                   _\R"                  \R$                  \R&                  \R(                  \R*                  \R,                  \R.                  \R0                  \R0                  \R2                  S.
Er\R6                  r\R<                  \R>                  \R@                  \RB                  \RD                  \RF                  \RH                  \RJ                  \RL                  \RN                  \RP                  \RR                  \RT                  \RV                  0r,SU 4S jjr-U 4S jr.S r/S r0U 4S jr1S r2S r3Sr4U =r5$ )Parser   z
This class is used to parse a Python file, it then divides them into a
class structure of different scopes.

:param pgen_grammar: The grammar object of pgen2. Loaded by load_grammar.
	expr_stmtclassdeffuncdef
file_inputimport_nameimport_from
break_stmtcontinue_stmtreturn_stmt
raise_stmt
yield_exprdel_stmt	pass_stmtglobal_stmtnonlocal_stmt
print_stmtassert_stmt)
if_stmt	with_stmtfor_stmt
while_stmttry_stmtsync_comp_for	decoratorlambdeflambdef_nocondnamedexpr_testc                 L   > [         TU ]  XUS9  / U l        / U l        SU l        g )N)error_recoveryr   )super__init__syntax_errors_omit_dedent_list_indent_counter)selfpgen_grammarr%   start_nonterminal	__class__s       fC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\parso/python/parser.pyr'   Parser.__init__@   s4    (6 	 	8  !#     c                    > U R                   (       a'  U R                  S:w  a  [        eU R                  U5      n[        TU ]  U5      $ )Nr   )_error_recovery_start_nonterminalNotImplementedError_recovery_tokenizer&   parse)r+   tokensr.   s     r/   r7   Parser.parseH   s?    &&,6)),,V4Fw}V$$r1   c                      U R                   U   " U5      nU$ ! [         a'    US:X  a  US   /USS -   nU R                  X5      n U$ f = f)z
Convert raw node information to a PythonBaseNode instance.

This is passed to the parser driver which calls it whenever a reduction of a
grammar rule produces a new complete node, so that the tree is build
strictly bottom-up.
suiter      )node_mapKeyErrordefault_node)r+   nonterminalchildrennodes       r/   convert_nodeParser.convert_nodeQ   sg    		<==-h7D   	<g%
 %QK=8Ab>9$$[;D	<s    -A
	A
c                    U[         :X  aG  X R                  R                  ;   a  [        R                  " X$U5      $ [        R
                  " X$U5      $ U R                  R                  U[        R                  5      " X$U5      $ )N)	NAME_pgen_grammarreserved_syntax_stringsr   KeywordName	_leaf_mapgetOperator)r+   typevalueprefix	start_poss        r/   convert_leafParser.convert_leafe   s_    4<**BBB||Ef==yy6::~~!!$6uPPr1   c                 d  > U R                   S   R                  nU(       a  US   R                  5       nOS nU R                  S:X  Ga*  UR                  [
        R                  :X  dT  UR                  [        :X  a  UR                  R                  S5      (       d  UR                  R                  S5      (       d  U R                   S   R                  R                  S:X  a   U R                   S   R                  R                  [
        R                     nUR                  R                  (       aA  UR                   (       d0  UR                  U R                   S   l
        U R#                  U5        g U R&                  (       d  [(        TU ]U  U5      $ S nU" U R                   5      nU R-                  US-   5      (       a  U R#                  U5        O~Uu  pxpU[.        :X  a%  U R0                  R3                  U R4                  5        [6        R8                  " UR:                  XU
5      nU R                   S   R                  R3                  U5        U R                   S   nUR<                  S:X  a    UR                  R>                  S	   Ul
        g g ! [$         a     GN+f = f! [$         a     g f = f)
Nr=   r   
simple_stmtc                     [        [        [        U 5      5      5       HF  u  pUR                  S:X  a    U$ UR                  S:X  d  M*  [	        UR
                  5      S:w  d  ME    U$    W$ )Nr   r;      )reversedlist	enumeraterA   lennodes)stackuntil_index
stack_nodes      r/   current_suite,Parser.error_recovery.<locals>.current_suite   sp     ,4D59I4J+K'))\9   ++w6 :++,1 ,L r1   rZ   r;   stmt) r`   r_   get_last_leafr4   rO   r   	ENDMARKERDEDENTrP   endswithdfa	from_ruletransitionsNEWLINEnext_dfais_final
dfa_pushes
_add_tokenr?   r3   r&   r%   _stack_removalINDENTr)   appendr*   r   PythonErrorLeafnamerA   arcs)r+   token	tos_nodes	last_leafplanrc   ra   typrP   rR   rQ   
error_leaftosr.   s                r/   r%   Parser.error_recoveryo   s   JJrN((	!"335II""l2/999JJ&(1I1I$1O1O"11$77
 zz"~!!++}<
::b>--99:J:R:RSD }}--doo .2]]

2*.##7)%00	 $DJJ/{Q//OOE",1)C	f} &&--d.B.BC--chh&QJJJrN  ''
3jjn??g%'',,v.	 &W   `  s$   #4J 1J" 
JJ"
J/.J/c                 8   U R                   US   VVs/ s H  o"R                    H  o3PM     M     nnnU(       aA  [        R                  " U5      nU R                   US-
     R                  R	                  U5        / U R                   US & [        U5      $ s  snnf )NrZ   )r`   r_   r   PythonErrorNodert   bool)r+   start_indexrb   rC   	all_nodess        r/   rr   Parser._stack_removal   s    ,0JJ{|,Db,DjQaQaTQaT,D	b''	2DJJ{Q'--44T:#%

;< I cs   Bc              #   H  #    U H  nUS   nU[         :X  ac  U R                  nU(       a:  US   U R                  :X  a'  UR                  5         U =R                  S-  sl        M_  U =R                  S-  sl        OU[        :X  a  U =R                  S-  sl        Uv   M     g 7f)Nr   r=   rZ   )rh   r)   r*   poprs   )r+   r8   rx   r|   os        r/   r6   Parser._recovery_tokenize   s     E(Cf} **2$"6"66EEG((A-($$)$$$)$K s   B B")r*   r)   r(   )Tr   )6__name__
__module____qualname____firstlineno____doc__r   ExprStmtClassFunctionModule
ImportName
ImportFromKeywordStatement
ReturnStmt	YieldExpr
GlobalStmt
AssertStmtIfStmtWithStmtForStmt	WhileStmtTryStmtSyncCompFor	DecoratorLambda	NamedExprr>   
PythonNoder@   r   STRINGStringNUMBERNumberrm   Newlinerg   	EndMarkerFSTRING_STRINGFStringStringFSTRING_STARTFStringStartFSTRING_END
FStringEndrL   r'   r7   rD   rS   r%   rr   r6   __static_attributes____classcell__)r.   s   @r/   r   r      s'   T]]DJJ 	4== 	dkk	
 	t 	t 	d++ 	.. 	t 	d++ 	dnn 	D)) 	T** 	t 	..  	d++!" 	t#$ ;;]]LLnnLL)) ^^;;++..=H@ ??L 	  $,,""DNN''););&&(9(9$$dooI!%(QDL r1   r   N)
parso.pythonr   parso.python.tokenr   parso.parserr   rG   rs   rh   r    r1   r/   <module>r      s?     / # 		 	 		 	 CZ Cr1   