Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/shlex.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@sdZddlZddlZddlmZyddlmZWn!ek
reddlmZnXddgZ	ddd��YZ
eed�Z
ed	kreej�d
kr�e
�Zn"ejd
Ze
ee�e�Zx+ej�Zer
dee�GHq�q�dS(
s8A lexical analyzer class for simple shell-like syntaxes.i�N(tdeque(tStringIOtshlextsplitcBszeZdZdded�Zd�Zdd�Zd�Zd�Z	d�Z
d�Zddd�Zd	�Z
d
�ZRS(s8A lexical analyzer class for simple shell-like syntaxes.cCs<t|t�rt|�}n|dk	r?||_||_ntj|_d|_||_|rod|_	n	d|_	d|_
d|_|jr�|jd7_nd|_t
|_d|_d|_d|_d	|_t�|_d
|_d|_d|_t�|_d|_|jr8d|j|jfGHndS(
Ntt#t?abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_s>������������������������� 	
s'"s\t"t iisshlex: reading from %s, line %d(t
isinstancet
basestringRtNonetinstreamtinfiletsyststdintposixteoft
commenterst	wordcharst
whitespacetFalsetwhitespace_splittquotestescapet
escapedquoteststateRtpushbacktlinenotdebugttokent	filestacktsource(tselfRR
R((s/sys/lib/python2.7/shlex.pyt__init__s<																		cCs5|jdkr!dt|�GHn|jj|�dS(s:Push a token onto the stack popped by the get_token methodisshlex: pushing token N(RtreprRt
appendleft(R!ttok((s/sys/lib/python2.7/shlex.pyt
push_token;scCs�t|t�rt|�}n|jj|j|j|jf�||_||_d|_|jr�|dk	r�d|jfGHq�d|jfGHndS(s9Push an input source onto the lexer's input source stack.isshlex: pushing to file %ssshlex: pushing to stream %sN(
R	R
RRR$R
RRRR(R!t	newstreamtnewfile((s/sys/lib/python2.7/shlex.pytpush_sourceAs"				cCs\|jj�|jj�\|_|_|_|jrOd|j|jfGHnd|_dS(sPop the input source stack.sshlex: popping to %s, line %dRN(RtcloseRtpopleftR
RRR(R!((s/sys/lib/python2.7/shlex.pyt
pop_sourceOs
!	cCs/|jr=|jj�}|jdkr9dt|�GHn|S|j�}|jdk	r�x\||jkr�|j|j��}|r�|\}}|j||�n|j	�}q[Wnx9||j
kr�js�|j
S|j�|j	�}q�W|jdkr+||j
kr#dt|�GHq+dGHn|S(sBGet a token from the input stream (or from stack if it's nonempty)isshlex: popping token s
shlex: token=sshlex: token=EOFN(
RR+RR#t
read_tokenR Rt
sourcehookR)t	get_tokenRRR,(R!R%trawtspecR(R'((s/sys/lib/python2.7/shlex.pyR/Xs.		
cCsnt}d}x�r|jjd�}|dkrF|jd|_n|jdkrxdGt|j�GdGt|�GHn|jdkr�d|_	Pq|jdkr�s�d|_Pq||j
kr�jdkr�d	GHn|j	s�jr|rPq�q||jkr-|jj
�|jd|_q|jrW||jkrWd
}||_q||jkr{||_	d
|_q||jkr�|js�||_	n||_q|jr�||_	d
|_q||_	|j	s�jr|rPqqq|j|jkr�t}|s5|jdkr)dGHntd�n||jkrv|jsj|j	||_	d|_Pq�d
|_q|jr�||jkr�|j|jkr�|j}||_q|j	||_	q|j|jkr_|s|jdkr�GHntd�n||jkrC||jkrC||krC|j	|j|_	n|j	||_	||_q|jd
kr|s�d|_Pq||j
kr�|jdkr�dGHnd|_|j	s�|jr|rPq�q||jkr5|jj
�|jd|_|jr�|_|j	s(|jr|rPq2qq�|jrY||jkrY||_q|jr�||jkr�d
}||_q||jks�||jks�|jr�|j	||_	q|jj|�|jdkr�GHnd|_|j	rPqqqqW|j	}d|_	|jr;|r;|dkr;d}n|jdkrj|rbdt|�GHqjdGHn|S(NRis
isshlex: in statesI see character:Ris+shlex: I see whitespace in whitespace statetas shlex: I see EOF in quotes statesNo closing quotations shlex: I see EOF in escape statesNo escaped characters%shlex: I see whitespace in word states&shlex: I see punctuation in word statesshlex: raw token=sshlex: raw token=EOF(RtTrueRtreadRRR#RRRRRRtreadlineRRRRt
ValueErrorRRR$(R!tquotedtescapedstatetnextchartresult((s/sys/lib/python2.7/shlex.pyR-xs�			
										
						
			cCs|ddkr |dd!}nt|jt�rltjj|�rltjjtjj|j�|�}n|t|d�fS(s(Hook called on a filename to be sourced.iRii�tr(	R	R
R
tostpathtisabstjointdirnametopen(R!R(((s/sys/lib/python2.7/shlex.pyR.�s
%'cCs>|dkr|j}n|dkr0|j}nd||fS(s<Emit a C-compiler-like, Emacs-friendly error-message leader.s"%s", line %d: N(RR
R(R!R
R((s/sys/lib/python2.7/shlex.pyterror_leaders
cCs|S(N((R!((s/sys/lib/python2.7/shlex.pyt__iter__	scCs(|j�}||jkr$t�n|S(N(R/Rt
StopIteration(R!R((s/sys/lib/python2.7/shlex.pytnexts	N(t__name__t
__module__t__doc__RRR"R&R)R,R/R-R.RBRCRE(((s/sys/lib/python2.7/shlex.pyRs$				 	�		cCs7t|d|�}t|_|s-d|_nt|�S(NRR(RR3RRtlist(tstcommentsRtlex((s/sys/lib/python2.7/shlex.pyRs
	t__main__isToken: ((RHtos.pathR<RtcollectionsRt	cStringIORtImportErrort__all__RRR3RRFtlentargvtlexertfileRAR/tttR#(((s/sys/lib/python2.7/shlex.pyt<module>s(
�


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].