var/opt/nydus/ops/pycparser/ply/__pycache__/lex.cpython-38.pyc000064400000051657147206004620020364 0ustar00U af @s<dZdZddlZddlZddlZddlZddlZddlZzejej fZ Wne k rde e fZ YnXedZGdddeZGdddeZGdd d eZGd d d eZGd d d ZddZddZddZddZddZddZGdddeZdddddeejddddf ddZ d$d d!Z!d"d#Z"e"Z#dS)%z3.10Nz^[a-zA-Z0-9_]+$c@seZdZddZdS)LexErrorcCs|f|_||_dSN)argstext)selfmessagesr B/opt/nydus/tmp/pip-target-53d1vnqk/lib/python/pycparser/ply/lex.py__init__:szLexError.__init__N)__name__ __module__ __qualname__r r r r r r9src@seZdZddZddZdS)LexTokencCsd|j|j|j|jfS)NzLexToken(%s,%r,%d,%d))typevaluelinenolexposrr r r __str__AszLexToken.__str__cCst|Sr)strrr r r __repr__DszLexToken.__repr__N)r r rrrr r r r r@src@s4eZdZddZddZddZddZeZeZd S) PlyLoggercCs ||_dSrf)rrr r r r LszPlyLogger.__init__cOs|j||ddS)N rwritermsgrkwargsr r r criticalOszPlyLogger.criticalcOs|jd||ddS)Nz WARNING: rrrr r r warningRszPlyLogger.warningcOs|jd||ddS)NzERROR: rrrr r r errorUszPlyLogger.errorN) r r rr r!r"r#infodebugr r r r rKs rc@seZdZddZddZdS) NullLoggercCs|Srr )rnamer r r __getattribute__^szNullLogger.__getattribute__cOs|Srr )rrr r r r __call__aszNullLogger.__call__N)r r rr(r)r r r r r&]sr&c@s|eZdZddZdddZdddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZddZeZdS)LexercCsd|_d|_i|_i|_i|_d|_g|_d|_i|_i|_ i|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_d|_d|_d|_d|_dS)NINITIALrF)lexre lexretext lexstaterelexstateretextlexstaterenameslexstate lexstatestack lexstateinfolexstateignorelexstateerrorf lexstateeoff lexreflagslexdatarlexlen lexerrorflexeoff lextokens lexignore lexliterals lexmoduler lexoptimizerr r r r ts.zLexer.__init__Nc Cst|}|ri}|jD]t\}}g}|D]L\}}g} |D]:} | rL| dsX| | q<| t|| dj| dfqr9r@r5r0rEzipr1r2rF_funcs_to_namesr6r7r r8)rlextab outputdirZ basetabmodulefilenametfZtabre statenamelretitempatfuncZretextrenamesZtaberrrKZtabeofr r r writetabs6 & zLexer.writetabc CsBt|tjr|}ntd|tj|}t|ddtkr@td|j |_ |j |_ |j |_|j t|jB|_|j|_|j|_i|_i|_|jD]P\}}g}g}|D]&\}} |t||j t| |fq||j|<||j|<qi|_|jD]\}} || |j|<qi|_|j D]\}} || |j|<q|!ddS)N import %sZ _tabversionz0.0zInconsistent PLY versionr+)"rPrQrRexecsysmodulesrGr[ ImportErrorZ _lextokensr>Z _lexreflagsr9Z _lexliteralsr@set lextokens_allZ _lexstateinfor5Z_lexstateignorer6r0r1Z _lexstatererErFrecompile_names_to_funcsr7Z_lexstateerrorfr8Z _lexstateeoffbegin) rZtabfilefdictr`rdrerfZtxtitemrg func_namerKr r r readtabs8       z Lexer.readtabcCs8|dd}t|tstd||_d|_t||_dS)Nr-zExpected a stringr)rP StringTypes ValueErrorr:rlenr;)rrrIr r r inputs   z Lexer.inputcCsd||jkrtd|j||_|j||_|j|d|_|j|d|_ |j |d|_ ||_ dS)NzUndefined stater,) r0rzr.r1r/r6getr?r7r<r8r=r3rstater r r rus   z Lexer.begincCs|j|j||dSr)r4rFr3rur~r r r push_stateszLexer.push_statecCs||jdSr)rur4poprr r r pop_stateszLexer.pop_statecCs|jSr)r3rr r r current_state!szLexer.current_statecCs|j|7_dSr)r)rnr r r skip'sz Lexer.skipc Cs~|j}|j}|j}|j}||kr|||kr8|d7}q|jD]\}}|||}|sXq>t}||_|j |_ ||_|j } || \} |_ | s|j r| |_|S| }q| }||_ ||_||_| |} | s|j}|j}q|js(| j |jkr(td| jj| jj| j| j f||d| S|||jkrtt}|||_|j |_ |j|_ ||_|d|_|S|jrt}|j|d|_|j |_ d|_ ||_ ||_||_||} ||jkrtd||||d|j}| sq| S||_td|||f||dq|jr\t}d|_ d|_|j |_ ||_||_ ||_||} | S|d|_|jdkrztddS) Nr-z4%s:%d: Rule '%s' returned an unknown token type '%s'r#z&Scanning error. Illegal character '%s'z"Illegal character '%s' at index %deofr,z"No input string given with input())rr;r?r:r.matchrgrouprr lastindexrendlexerZlexmatchrBrqr__code__ co_filenameco_firstlinenor r@r<r= RuntimeError) rrr;r?r:r. lexindexfuncmtokirhZnewtokr r r token1s              z Lexer.tokencCs|Srr rr r r __iter__szLexer.__iter__cCs|}|dkrt|Sr)r StopIteration)rtr r r nextsz Lexer.next)N)r,)r r rr rLrjrxr|rurrrrrrr__next__r r r r r*ss  %(   nr*cCst|d|jS)Nregex)rG__doc__)rhr r r _get_regexsrcCs0t|}|j}|j|jkr,||j|Sr)rm _getframe f_globalsrDf_localsupdate)levelsrldictr r r get_caller_module_dicts     rcCsFg}t||D]2\}}|r6|dr6|||dfq||q|SrC)r^rF)Zfunclistnamelistresultrr'r r r r_s   r_cCsDg}|D]6}|r4|dr4|||d|dfq||q|SrC)rF)rrvrrr r r rts   rtcCsf|sgSd|}zt||}dgt|jd}|dd}|jD]z\}} ||d} t| t j t j fkr| ||f|| <||| <qN| dk rN||| <| ddkrd|| <qNd||f|| <qN||fg|g|gfWSt k r`tt|d} | dkrd} t|d| |||\} } }t|| d|||\}}}| || |||fYSXdS)N|r-ignore_r)NN)rWrrrsmax groupindexvaluesrEr}rrQ FunctionType MethodTypefind Exceptionintr{_form_master_re)Zrelistreflagsrtoknamesrr.rZ lexindexnamesrrhandlerllistreZlnamesZrlistZrreZrnamesr r r rs2       rcCsd}|d}t|dddD]\}}||kr |dkr q>q |dkrXt|d|}nd}d|krlt|}d||d}||fS)Nr-_ANY)r+)rT enumerater\rW)rnamesZnonstatepartsrpartstatesZ tokennamer r r _statetokens rc@sfeZdZdddZddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ dS) LexerReflectNrcCsL||_d|_g|_||_ddi|_t|_d|_|dkrBtt j n||_ dS)Nr+ inclusiveF) rZ error_functokensr stateinforprnr#rrmstderrlog)rrrrr r r r /s zLexerReflect.__init__cCs$||||dSr) get_tokens get_literals get_states get_rulesrr r r get_all:szLexerReflect.get_allcCs||||jSr)validate_tokensvalidate_literalsvalidate_rulesr#rr r r validate_allAszLexerReflect.validate_allcCsp|jdd}|s(|jdd|_dSt|ttfsL|jdd|_dS|sf|jdd|_dS||_dS)NrzNo token list is definedTztokens must be a list or tupleztokens is empty)rr}rr#rPlistr\r)rrr r r rHs   zLexerReflect.get_tokenscCsPi}|jD]@}t|s,|jd|d|_||krB|jd|d||<q dS)NzBad token name '%s'TzToken '%s' multiply definedr-)r_is_identifierrrr#r")rZ terminalsrr r r r\s  zLexerReflect.validate_tokenscCs |jdd|_|jsd|_dS)Nliteralsr,)rr}rrr r r rgszLexerReflect.get_literalscCsjz>|jD]2}t|tr"t|dkr|jdt|d|_qWn&tk rd|jdd|_YnXdS)Nr-z.Invalid literal %s. Must be a single characterTzIInvalid literals specification. literals must be a sequence of characters)rrPryr{rr#rZ TypeError)rrIr r r rms   zLexerReflect.validate_literalscCs|jdd|_|jrt|jttfs:|jdd|_n|jD]}t|trZt|dkrt|jdt |d|_q@|\}}t|t s|jdt |d|_q@|dks|dks|jd |d|_q@||j kr|jd |d|_q@||j |<q@dS) Nrz)states must be defined as a tuple or listTrzMInvalid state specifier %s. Must be a tuple (statename,'exclusive|inclusive')zState name %s must be a stringr exclusivez:State type for state %s must be 'inclusive' or 'exclusive'zState '%s' already defined) rr}rrPr\rrr#r{rZryr)rrr'Z statetyper r r rxs0    zLexerReflect.get_statesc Cs,dd|jD}i|_i|_i|_i|_i|_i|_|jD]}g|j|<g|j|<q:t|dkrv|j dd|_ dS|D]d}|j|}t ||j\}}||j|<t |drD|dkr|D]}||j|<qnt|dkr|D]}||j|<qnV|d kr"|j j}|j j}|j d |||jd|_ n |D]}|j|||fq&qzt|tr|d kr|D]}||j|<q^d |kr|j d |n@|dkr|j d |d|_ n |D]}|j|||fqqz|j d|d|_ qz|jD]}|jdddq|jD]}|jddddqdS)NcSs g|]}|dddkr|qS)NrZt_r ).0rr r r sz*LexerReflect.get_rules..rz+No rules of the form t_rulename are definedTr)r#rignorez,%s:%d: Rule '%s' must be defined as a string\z#%s contains a literal backslash '\''Rule '%s' must be defined as a functionz&%s not defined as a function or stringcSs |djjSNr-)rrxr r r z(LexerReflect.get_rules..)rJcSs t|dSr)r{rr r r rr)rJreverse)rrfuncsymstrsymrerrorfeoffrr{rr#rhasattrrrrr rFrPryr"rsort) rZtsymbolsrrrrtoknamelinefiler r r rsb              zLexerReflect.get_rulesc Csz|jD]T}|j|D]l\}}|jj}|jj}t|}|j||j |}t |t j rbd}nd}|jj } | |kr|jd|||jd|_q| |kr|jd|||jd|_qt|s|jd|||jd|_qzDtd|t|f|j} | dr|jd |||jd|_Wqtjk r} zB|jd |||j| d t|krl|jd |||jd|_W5d} ~ XYqXq|j|D]\} } |j | }|d kr|jd| d|_q||jkr|ddkr|jd| |d|_qz:td| | f|j} | dr2|jd| d|_WnTtjk r} z2|jd| | d | krr|jd| d|_W5d} ~ XYnXq|j|s|j|s|jd|d|_|j|d}|r|}|jj}|jj}t|}|j|t |t j r d}nd}|jj } | |kr:|jd|||jd|_| |kr|jd|||jd|_q|jD]}||qddS)Nrr-z'%s:%d: Rule '%s' has too many argumentsTz%%s:%d: Rule '%s' requires an argumentz2%s:%d: No regular expression defined for rule '%s' (?P<%s>%s)r,z<%s:%d: Regular expression for rule '%s' matches empty stringz3%s:%d: Invalid regular expression for rule '%s'. %s#z6%s:%d. Make sure '#' in rule '%s' is escaped with '\#'r#rrrz-Rule '%s' defined for an unspecified token %sz5Regular expression for rule '%s' matches empty stringz,Invalid regular expression for rule '%s'. %sz/Make sure '#' in rule '%s' is escaped with '\#'zNo rules defined for state '%s')rrrrrinspect getmodulernaddrrPrQr co_argcountrr#r rrrrsrrrrrrr}validate_module)rrfnamerrrmodulerZreqargsnargsrIer'rZefuncr r r rs                zLexerReflect.validate_rulesc Cszt|\}}Wntk r(YdSXtd}td}i}|d7}|D]n}||}|sj||}|r|d} || } | s||| <n$t|} |j d| || | d|_ |d7}qNdS)Nz\s*def\s+(t_[a-zA-Z_0-9]*)\(z\s*(t_[a-zA-Z_0-9]*)\s*=r-z7%s:%d: Rule %s redefined. Previously defined on line %dT) rgetsourcelinesrSrrrsrrr} getsourcefilerr#) rrlinesZlinenZfreZsreZ counthashrrr'prevrbr r r r@s*        zLexerReflect.validate_module)Nr)r r rr rrrrrrrrrrr r r r r.s   BgrFr`c % sr|dkr d}d} ddi} t} || _| dkr6ttj} |rL|dkrLttj}|rT|rfddtD} t| } d| krtj| dj| d<nt d} | d }|rt |t rd |kr|d |}t | | |d }||s|rtd |r8|r8z"| || | ja| ja| a| WStk r6YnX|rh|d |j|d|j|d|jt| _|jD]}| j|qvt |jttfrt|jd |j| _!n|j| _!| jt| j!B| _"|j} i}| D]}g}|j#|D]J\}}|j$j%}|j$j&}|'d|t(|f|r|d|t(||q|j)|D]2\}}|'d||f|rH|d|||qH|||<q|r|d|D]h}t*|||| |j+\}}}|| j,|<|| j-|<|| j.|<|rt/|D]\}}|d|||qq| 0D]`\}}|dkr|dkr| j,|1| j,d| j-|1| j-d| j.|1| j.dq| | _2| j,d| _3| j-d| _4|| _5|j6| _7| j7 dd| _8|j9| _:|j9 dd| _;| j;s| |j= dd| _?| 0D]\} }|dkrB| |j9kr | .__file__r r __package__rM)rrzCan't build lexerzlex: tokens = %rzlex: literals = %rzlex: states = %rrrz(lex: Adding rule %s -> '%s' (state '%s')z#lex: ==== MASTER REGEXS FOLLOW ====z"lex: state '%s' : regex[%d] = '%s'r,zNo t_error rule is definedrz1No error rule is defined for exclusive state '%s'z2No ignore rule is defined for exclusive state '%s'rNrkz#Couldn't write lextab module %r. %s)Jr*rBrrmrdirdictrnrrr}rPrrrr SyntaxErrorrxrr|rror$rrrrpr>rrr\rrWr@rqrrrrrFrrrrr0r1r2rrEextendr5r.r/r9rr6r?rr7r<r"rr8r=rQrRrTrlrGrUrVdirnamerjrS)%rrHr%optimizer`rZnowarnraZdebuglogZerrorlogrrZlexobjZ_itemspkgZlinforZregexsrZ regex_listrrrrr'rr.Zre_textZre_namesrrstypersrcfilerpkgnamerr rr lex_s                            $rcCs|sVz&tjd}t|}|}|Wn*tk rTtjdtj}YnX|rb|j }nt }|||rz|j }nt }|}|sqtjd|j |j |j |jfq~dS)Nr-z/Reading from standard input (type EOF to end): z(%s,%r,%d,%d) )rmargvrXreadclose IndexErrorstdoutrstdinr|rrrrr)rdatarbr_input_tokenrr r r runmains(   rcsfdd}|S)Ncs tdrt|_n|_|S)Nr))rrrrrr r set_regexBs  zTOKEN..set_regexr )rrr rr TOKENAs r)NN)$rYr[rrrmrQrDrUrZ StringTypeZ UnicodeTyperyAttributeErrorrbytesrsrrrrHrrr&r*rrr_rtrrrrVERBOSErrrTokenr r r r "sN  F  (3  A "