%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/lib2to3/pgen2/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/lib2to3/pgen2/driver.pyc

ó
Pêáac@sdZdZddgZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZdefd„ƒYZd	„Zd
deedd„Zd„Zd
„Zd„ZedkrejeeƒƒƒndS(sZParser driver.

This provides a high-level interface to parse a file into a syntax tree.

s#Guido van Rossum <guido@python.org>tDrivertload_grammariÿÿÿÿNi(tgrammartparsettokenttokenizetpgencBsVeZddd„Zed„Zed„Zed„Zded„Zed„Z	RS(cCs:||_|dkr$tjƒ}n||_||_dS(N(RtNonetloggingt	getLoggertloggertconvert(tselfRRR
((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pyt__init__ s
		cCs=tj|j|jƒ}|jƒd}d}d	}}}}	}
d}xé|D]Ã}|\}}}}	}
|||fkr
||f|ks¨t||f|fƒ‚|\}
}||
krá|d|
|7}|
}d}n||kr
||
||!7}|}q
n|tjtj	fkr`||7}|	\}}|j
dƒrQ|d7}d}qQqQn|tjkrtj
|}n|r¨|jjdtj|||ƒn|j||||fƒrà|rÜ|jjdƒnPnd}|	\}}|j
dƒrQ|d7}d}qQqQWtjd||||fƒ‚|jS(
s4Parse a series of tokens and return the syntax tree.iius
s%s %r (prefix=%r)sStop.tsincomplete inputN(RtParserRRtsetupRtAssertionErrorRtCOMMENTtNLtendswithRtOPtopmapR
tdebugttok_nametaddtokent
ParseErrortrootnode(RttokensRtptlinenotcolumnttypetvaluetstarttendt	line_texttprefixt	quintuplets_linenots_column((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pytparse_tokens'sT

*	

	

	cCs"tj|jƒ}|j||ƒS(s*Parse a stream and return the syntax tree.(Rtgenerate_tokenstreadlineR)(RtstreamRR((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pytparse_stream_rawWscCs|j||ƒS(s*Parse a stream and return the syntax tree.(R-(RR,R((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pytparse_stream\scCs;tj|d|ƒ}z|j||ƒSWd|jƒXdS(s(Parse a file and return the syntax tree.trN(tcodecstopenR.tclose(RtfilenametencodingRR,((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pyt
parse_file`scCs+tjtj|ƒjƒ}|j||ƒS(s*Parse a string and return the syntax tree.(RR*tStringIOR+R)(RttextRR((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pytparse_stringhsN(
t__name__t
__module__RR
tFalseR)R-R.R5R8(((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pyRs0cCsRtjj|ƒ\}}|dkr-d}n||djtttjƒƒdS(Ns.txtRt.s.pickle(tostpathtsplitexttjointmaptstrtsystversion_info(tgttheadttail((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pyt_generate_pickle_namens	sGrammar.txtcCsÞ|dkrtjƒ}n|dkr3t|ƒn|}|sOt||ƒrÁ|jd|ƒtj|ƒ}|rÚ|jd|ƒy|j|ƒWq¾t	k
rº}|jd|ƒq¾XqÚnt
jƒ}|j|ƒ|S(s'Load the grammar (maybe from a pickle).s!Generating grammar tables from %ssWriting grammar tables to %ssWriting failed: %sN(
RRR	RHt_newertinfoRtgenerate_grammartdumptIOErrorRtGrammartload(REtgptsavetforceR
tgte((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pyRus
cCsNtjj|ƒstStjj|ƒs,tStjj|ƒtjj|ƒkS(s0Inquire whether file a was written since file b.(R=R>texistsR;tTruetgetmtime(tatb((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pyRIŠs
cCsctjj|ƒrt|ƒSttjj|ƒƒ}tj||ƒ}tj	ƒ}|j
|ƒ|S(sÙNormally, loads a pickled grammar by doing
        pkgutil.get_data(package, pickled_grammar)
    where *pickled_grammar* is computed from *grammar_source* by adding the
    Python version and using a ``.pickle`` extension.

    However, if *grammar_source* is an extant file, load_grammar(grammar_source)
    is called instead. This facilitates using a packaged grammar file when needed
    but preserves load_grammar's automatic regeneration behavior when possible.

    (R=R>tisfileRRHtbasenametpkgutiltget_dataRRNtloads(tpackagetgrammar_sourcetpickled_nametdataRS((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pytload_packaged_grammar“s

cGsc|stjd}ntjdtjdtjddƒx$|D]}t|dtdtƒq?WtS(sMain program, when run as a script: produce grammar pickle files.

    Calls load_grammar for each argument, a path to a grammar text file.
    itlevelR,tformats%(message)sRQRR(RCtargvRtbasicConfigtINFOtstdoutRRV(targsRE((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pytmain§s
t__main__(t__doc__t
__author__t__all__R0R=RR\R6RCRRRRRRtobjectRRHRRVR;RRIRcRkR9texittint(((s0/usr/local/lib/python2.7/lib2to3/pgen2/driver.pyt<module>s$(P					


Zerion Mini Shell 1.0