Qf)4dZddlZddlZddlZddlmZddlmZgdZGddZ ddZ d Z ejd ejjZd Zd Zed k(rSeej(dk(ree yej(dZee5Zee eedddyy#1swYyxYw)8A lexical analyzer class for simple shell-like syntaxes.N)deque)StringIO)shlexsplitquotejoincfeZdZdZ ddZedZdZddZdZ dZ d Z d Z dd Z d Zd Zy)rrNct|tr t|}|||_||_nt j |_d|_||_|rd|_nd|_d|_ d|_ |jr|xjdz c_ d|_ d|_ d|_ d|_d |_d |_t#|_d |_d |_d|_t#|_d|_|sd}n|d urd}||_|rst#|_|xjdz c_ |jj5t6j9|}|jj;||_ yy)N#?abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_u|ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞz Fz'"\" rTz();<>|&z~-./*?=) isinstancestrrinstreaminfilesysstdinposixeof commenters wordchars whitespacewhitespace_splitquotesescape escapedquotesstaterpushbacklinenodebugtoken filestacksource_punctuation_chars_pushback_chars maketransdictfromkeys translate)selfrrrpunctuation_charsts ,/opt/alt/python312/lib64/python3.12/shlex.py__init__zshlex.__init__sN h $)H  $DM DKIIDMDK DHDHB :: NN ^ _N# %          "  $ & ) "3 #(7D NNi 'N((7H)IJA!^^55a8DN c|jSN)r)r/s r2r0zshlex.punctuation_charsDs&&&r4c|jdk\rtdt|z|jj |y)z:Push a token onto the stack popped by the get_token methodrzshlex: pushing token N)r%printreprr# appendleft)r/toks r2 push_tokenzshlex.push_tokenHs1 ::? )DI5 6   %r4c\t|tr t|}|jj |j |j |jf||_||_d|_|jr4|td|j ytd|j yy)z9Push an input source onto the lexer's input source stack.rNzshlex: pushing to file zshlex: pushing to stream ) rrrr'r;rrr$r%r9)r/ newstreamnewfiles r2 push_sourcezshlex.push_sourceNs i % +I !!4;; t{{"KL !  ::"T[[BCt}}FG r4c|jj|jj\|_|_|_|j r$td|j|j fzd|_y)zPop the input source stack.zshlex: popping to %s, line %drN) rcloser'popleftrr$r%r9r"r7s r2 pop_sourcezshlex.pop_source\s_ 48NN4J4J4L1dmT[ :: 1]]DKK01 2 r4c|jrB|jj}|jdk\rtdt |z|S|j }|j g||j k(rX|j|j }|r|\}}|j|||j}||j k(rX||jk(rH|js |jS|j|j}||jk(rH|jdk\r3||jk7rtdt |z|Std|S)zBGet a token from the input stream (or from stack if it's nonempty)rzshlex: popping token z shlex: token=zshlex: token=EOF) r#rDr%r9r: read_tokenr( sourcehookrA get_tokenrr'rE)r/r<rawspecr@r?s r2rIzshlex.get_tokenes+ ==--'')CzzQ-S 9:Joo ;; "$t'89+/(Wi$$Y8nn& $TXXo>>xx!nn& TXXo ::?dhhoS 12 () r4c d}d} |jr'|jr|jj}n|jj d}|dk(r|xj dz c_|j dk\rtd|jd||j d |_ n<|jdk(r\|s d|_n!||jvr8|j d k\r td |js|jr|rnݐ ||jvr1|jj|xj dz c_n|jr||jvr d }||_nu||jvr||_ d |_nW||jvr||_ d |_n9||j vr|js||_ ||_n|j"r||_ d |_n||_ |js|jr|rnҐ|j|j vrd}|s%|j d k\r tdt%d||jk(r3|js|xj|z c_ d|_nVd |_nK|jr;||jvr-|j|j&vr|j}||_n|xj|z c_ n|j|jvr|s%|j d k\r tdt%d||j vr3||jk7r$||k7r|xj|jz c_ |xj|z c_ ||_nO|jdvr@|s d|_n7||jvr?|j d k\r tdd|_|js|jr|rn||jvra|jj|xj dz c_|jrd|_|js|jr|rn}i|jd k(rW||jvr|xj|z c_ nE||jvr|jj)|d|_n|jr||j vr||_n|jr||jvr d }||_n||jvs(||j vs|j"r$||jvr|xj|z c_ n|jr|jj)|n|j*j-||j d k\r tdd|_|js|jr|rn|j}d |_ |jr |s|d k(rd}|j dkDr&|rtdt/|z|Std|S)NFrTr zshlex: in state z I see character: r z+shlex: I see whitespace in whitespace stateacz shlex: I see EOF in quotes statezNo closing quotationz shlex: I see EOF in escape statezNo escaped character)rPrQz%shlex: I see whitespace in word statez&shlex: I see punctuation in word statezshlex: raw token=zshlex: raw token=EOF)r0r*poprreadr$r%r9r"r&rrrreadliner rrr ValueErrorr!appendr#r;r:)r/quoted escapedstatenextcharresults r2rGzshlex.read_tokens  %%$*>*>//335==--a04 q zzQ$**BJLMzz! s"!%DJ0zzQKLzzdjjV 0MM**,KK1$KZZH $;#&L!)DJ/!)DJ!$DJ!7!77!)DJ!$DJ,::%- !)DJ**!)DJ!$DJ!)DJzzdjjV t{{*zzQ@A$%;<<tzz):: h. %( %( jjX%<++B,#'::L!)DJJJ(*Jt{{*zzQ@A$%;<<!DKK/ DJJ.8|3KJJ$**,J h& ) z)!%DJ0zzQEF!$DJzzdjjV 0MM**,KK1$Kzz%( ::$**!$ZZ3&4#9#99 h. #4??: 0077A%( ZZH $;!)DJZZH $;#&L!)DJ$..0H 4K//"$*@*@@JJ(*J--,,33H= 00:zzQFG!$DJzzdjjV GH ::f2F ::>)DL89 ,- r4c8|ddk(r|dd}t|jtrftjj |sGtjj tjj|j|}|t|dfS)z(Hook called on a filename to be sourced.rrrr) rrrospathisabsr dirnameopen)r/r@s r2rHzshlex.sourcehooksm 1: amG dkk3 ' g0Fggll277??4;;#?IGgs+,,r4cH| |j}| |j}d||fzS)z[[F >[[F"ff%555r4c|Sr6r7s r2__iter__zshlex.__iter__(s r4cP|j}||jk(rt|Sr6)rIr StopIteration)r/r&s r2__next__zshlex.__next__+s%  DHH   r4)NNFFr6)NN)__name__ __module__ __qualname____doc__r3propertyr0r=rArErIrGrHrdrgrjrfr4r2rrsV>9>#(-9^''& H@Pd-6r4rcl| tdt||}d|_|sd|_t |S)z-Split the string *s* using shell-like syntax.zs argument must not be None)rTr )rUrrrlist)scommentsrlexs r2rr1s;y677  CC  9r4c2djd|DS)z3Return a shell-escaped string from *split_command*.rc32K|]}t|ywr6)r).0args r2 zjoin..>s8-3E#J-s)r ) split_commands r2r r <s 888-8 88r4z[^\w@%+=:,./-]cR|syt||Sd|jddzdzS)z1Return a shell-escaped version of the string *s*.z'''z'"'"') _find_unsafereplace)rrs r2rrCs4 A 3 * *S 00r4c~|jx}r+tdt|z|jx}r*yy)NzToken: )rIr9r:)lexertts r2 _print_tokensrOs9! !" ! i$r("#! !" !r4__main__r)FT)rnr^rer collectionsrior__all__rrr compileASCIIsearchr}rrrklenargvfnrbfrfr4r2rs>  -\\|9 rzz+RXX6==  1$ z 388}eg XXa[ "X %2, 'X  Xs B66B?