K iddlmZddlmZddlmZej ZejZejZGddeZ y))tree)PythonTokenTypes) BaseParserc@eZdZdZidej dej dejdejdejdejdejd ejd ejd ejd ejd ejdejdejdejdejdejej ej"ej$ej&ej(ej*ej,ej.ej.ej0d Zej4Zej:ej<ej>ej@ejBejDejFejHejJejLejNejPejRejTiZ+dfd Z,fdZ-dZ.dZ/fdZ0dZ1dZ2xZ3S)Parserz 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_stmtclassdeffuncdef file_input import_name import_from break_stmt continue_stmt return_stmt raise_stmt yield_exprdel_stmt pass_stmt global_stmt nonlocal_stmt print_stmt assert_stmt) if_stmt with_stmtfor_stmt while_stmttry_stmt sync_comp_for decoratorlambdeflambdef_nocondnamedexpr_testcTt||||g|_g|_d|_y)N)error_recoveryr)super__init__ syntax_errors_omit_dedent_list_indent_counter)self pgen_grammarr$start_nonterminal __class__s Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/parso/python/parser.pyr&zParser.__init__@s7 '8(6  8 !# c|jr&|jdk7rt|j|}t||S)Nr )_error_recovery_start_nonterminalNotImplementedError_recovery_tokenizer%parse)r*tokensr-s r.r5z Parser.parseHs?   &&,6)),,V4Fw}V$$r/c |j||}|S#t$r'|dk(r |dg|ddz}|j||}Y|SwxYw)a  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_mapKeyError default_node)r* nonterminalchildrennodes r. convert_nodezParser.convert_nodeQsk <-4==-h7D  <g% %QK=8Ab>9$$[(;D  d | _ yy#t$$rY wxYw#t$$rYywxYw) Nr:r   simple_stmtcttt|D]B\}}|jdk(r|S|jdk(s(t |j dk7sA|SS)Nr r8)reversedlist enumerater>lennodes)stack until_index stack_nodes r. current_suitez,Parser.error_recovery..current_suitesv,4D59I4J+K ' Z))\9   ++w6:++,1   r/rUr8stmt) r[rZ get_last_leafr2rKr ENDMARKERDEDENTrLendswithdfa from_rule transitionsNEWLINEnext_dfais_final dfa_pushes _add_tokenr<r1r%r$_stack_removalINDENTr(appendr)rPythonErrorLeafnamer>arcs)r*token tos_nodes last_leafplanr^r\typrLrNrM error_leaftosr-s r.r$zParser.error_recoveryosJJrN(( !" 335II  " "l 2/999JJ&(1I1I$1O"11$7 zz"~!!++}< ::b>--99:J:R:RSD}}--doo.2]] 2*.##7)%0 0 $DJJ/   {Q / OOE ",1 )C 6f}&&--d.B.BC--chhy&QJ JJrN ' ' 3jjn ??g % '',,v. &W `  s$4I* I:* I76I7: JJc$|j|dDcgc]}|jD]}|}}}|r@tj|}|j|dz jj |g|j|dt |Scc}}w)NrU)r[rZrPythonErrorNodernbool)r* start_indexr]r@ all_nodess r.rlzParser._stack_removals,0JJ{|,DbjQ[QaQabTbTb b '' 2D JJ{Q ' - - 4 4T :#% ;< IcsB c#2K|D]}|d}|tk(r\|j}|r8|d|jk(r&|j|xjdzc_W|xjdzc_n|tk(r|xjdz c_|yw)Nrr:rU)rbr(r)poprm)r*r6rrrvos r.r4zParser._recovery_tokenizes E(Cf}**2$"6"66EEG((A-($$)$$$)$K sBB)Tr )4__name__ __module__ __qualname____doc__rExprStmtClassFunctionModule ImportName ImportFromKeywordStatement ReturnStmt YieldExpr GlobalStmt AssertStmtIfStmtWithStmtForStmt WhileStmtTryStmt SyncCompFor DecoratorLambda NamedExprr; PythonNoder=rSTRINGStringNUMBERNumberrgNewlinera EndMarkerFSTRING_STRING FStringString FSTRING_START FStringStart FSTRING_END FStringEndrHr&r5rArOr$rlr4 __classcell__)r-s@r.rr s"T]]DJJ 4== dkk  t  t  d++ .. t d++ dnn D)) T** t .. d++!" t#$;;]]LLnnLL))^^;;++..=H@??L   $,,""DNN''););&&(9(9$$dooI!%(QDLr/rN) parso.pythonrparso.python.tokenr parso.parserrrCrmrbrr/r.rs?/#    CZCr/