var/opt/nydus/ops/pycparser/ply/__pycache__/yacc.cpython-38.pyc000064400000147474147206007400020515 0ustar00U afk @sddlZddlZddlZddlZddlZddlZddlZdZdZ dZ dZ dZ dZ dZdZd ZdZejddkrteZneZejZGd d d eZGd d d eZGdddeZddZddZdada da!dZ"ddZ#ddZ$ddZ%ddZ&GdddZ'Gdd d Z(Gd!d"d"Z)e*d#Z+Gd$d%d%eZ,Gd&d'd'eZ-Gd(d)d)eZ.d*d+Z/Gd,d-d-eZ0Gd.d/d/eZ1Gd0d1d1eZ2Gd2d3d3eZ3d4d5Z4d6d7Z5Gd8d9d9eZ6Gd:d;d;e3Z7dd?Z9Gd@dAdAeZ:de de dddde ddddf dBdCZ;dS)DNz3.10Tz parser.outparsetabLALRF(c@s4eZdZddZddZeZddZddZeZd S) PlyLoggercCs ||_dSN)f)selfrr C/opt/nydus/tmp/pip-target-53d1vnqk/lib/python/pycparser/ply/yacc.py__init__nszPlyLogger.__init__cOs|j||ddS)N rwriter msgargskwargsr r r debugqszPlyLogger.debugcOs|jd||ddS)Nz WARNING: r rrr r r warningvszPlyLogger.warningcOs|jd||ddS)NzERROR: r rrr r r erroryszPlyLogger.errorN) __name__ __module__ __qualname__r rinforrcriticalr r r r rms rc@seZdZddZddZdS) NullLoggercCs|Srr )r namer r r __getattribute__szNullLogger.__getattribute__cOs|Srr )r rrr r r __call__szNullLogger.__call__N)rrrrrr r r r rsrc@s eZdZdS) YaccErrorNrrrr r r r r sr cCsPt|}d|krt|}t|tkr4|dtd}dt|jt||f}|S)Nr z ...z<%s @ 0x%x> (%s))reprlen resultlimittyperid)rrepr_strresultr r r format_results r*cCsBt|}d|krt|}t|dkr(|Sdt|jt|fSdS)Nr z <%s @ 0x%x>)r"r#r%rr&)r'r(r r r format_stack_entrys  r,aPLY: Don't use global functions errok(), token(), and restart() in p_error(). Instead, invoke the methods on the associated parser instance: def p_error(p): ... # Use parser.errok(), parser.token(), parser.restart() ... parser = yacc.yacc() cCstttSr)warningswarn_warnmsg_errokr r r r erroks r1cCstttSr)r-r.r/_restartr r r r restarts r3cCstttSr)r-r.r/_tokenr r r r tokens r5cCs>|ja|ja|ja||}z bbbWntk r8YnX|Sr)r1r0r5r4r3r2 NameError) errorfuncr5parserr'r r r call_errorfuncs r9c@seZdZddZddZdS) YaccSymbolcCs|jSrr%r r r r __str__szYaccSymbol.__str__cCst|Srstrr<r r r __repr__szYaccSymbol.__repr__N)rrrr=r@r r r r r:sr:c@sfeZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ dS)YaccProductionNcCs||_||_d|_d|_dSr)slicestacklexerr8)r srCr r r r szYaccProduction.__init__cCsBt|trdd|j|DS|dkr2|j|jS|j|jSdS)NcSsg|] }|jqSr value.0rEr r r sz.YaccProduction.__getitem__..r) isinstancerBrGrCr nr r r __getitem__s   zYaccProduction.__getitem__cCs||j|_dSr)rBrG)r rMvr r r __setitem__szYaccProduction.__setitem__cCsdd|j||DS)NcSsg|] }|jqSr rFrHr r r rJsz/YaccProduction.__getslice__..)rB)r ijr r r __getslice__szYaccProduction.__getslice__cCs t|jSr)r#rBr<r r r __len__szYaccProduction.__len__cCst|j|ddS)NlinenorgetattrrBrLr r r rUszYaccProduction.linenocCs||j|_dSr)rBrU)r rMrUr r r set_linenoszYaccProduction.set_linenocCs,t|j|dd}t|j|d|}||fS)NrUr endlinenorV)r rM startlineendliner r r linespanszYaccProduction.linespancCst|j|ddS)NlexposrrVrLr r r r] szYaccProduction.lexposcCs,t|j|dd}t|j|d|}||fS)Nr]r endlexposrV)r rMstartposendposr r r lexspanszYaccProduction.lexspancCstdSr) SyntaxErrorr<r r r rszYaccProduction.error)N)rrrr rNrPrSrTrUrXr\r]rarr r r r rAs rAc@s\eZdZddZddZddZddZd d Zdd dZdddZ dddZ dddZ d S)LRParsercCs0|j|_|j|_|j|_||_|d|_dSNT) lr_productions productions lr_actionactionlr_gotogotor7set_defaulted_stateserrorok)r ZlrtabZerrorfr r r r s zLRParser.__init__cCs d|_dSrd)rlr<r r r r1&szLRParser.errokcCs@|jdd=|jdd=t}d|_|j||jddS)N$endr) statestacksymstackr:r%append)r symr r r r3)s    zLRParser.restartcCsPi|_|jD]:\}}t|}t|dkr|ddkr|d|j|<qdSNr)defaulted_statesrhitemslistvaluesr#)r stateactionsrulesr r r rk9s  zLRParser.set_defaulted_statescCs i|_dSr)rtr<r r r disable_defaulted_states@sz!LRParser.disable_defaulted_statesNFcCsZ|str.t|trttj}||||||S|rD||||||S||||||SdSr) yaccdevelrKintrsysstderr parsedebugparseoptparseopt_notrack)r inputrDrtracking tokenfuncr r r parseCs  zLRParser.parsec Csd}g}|j}|j} |j} |j} td} d} |d|sLddlm}|j}|| _|| _ |dk rj| ||dkrz|j }n|}||_ g}||_ g}||_ || _d}|dt}d|_||d}|d|d||| kr(|s|s|}n|}|st}d|_|j}|||}n| |}|d|| |d d d d d |Dddt|f|dk r|dkr|||}|d|||d}| r| d8} q|dkrH| | }|j}|j}t}||_d|_|r<|d|jdddd || dDd| |d||n|d|jg| |d||r|| dd}||d<|r|d}|j|_|j|_|d}t|d|j|_t|d|j|_|| _ zd|| d=||_!|"| || d=|dt#| d||| |d|}||Wqt$k r|||%|dd||d}d|_d|_|}t&} d|_'YqXqn|r|j|_|j|_|g}|| _ zL||_!|"| |dt#| d||| |d|}||Wqt$k rD||||d}d|_d|_|}t&} d|_'YqXq|dkr|d}t|dd}|dt#||d|S|dkr|(dd d dd |Dddt|f| dks|j'rt&} d|_'|}|jdkrd}|j)r:|rt*|ds||_||_!t+|j)||}|j'r|}d}qn`|rt*|d rT|j}nd}|rvt,j-.d!||jfnt,j-.d"|jnt,j-.d#dSnt&} t|dkr|jdkrd}d}d}|dd=q|jdkrdS|jdkr|d}|jdkr.|r(t|d |j|_t|d$|j|_d}qt}d|_t*|d rT|j|_|_t*|d$rn|j|_|_||_|||}q|}|r|j|_|j|_||d}qt/d%qdS)&NrzPLY: PARSE DEBUG STARTrslexrmz State : %sz#Defaulted state %s: Reduce using %dz Stack : %sz%s . %s cSsg|] }|jqSr r;rIZxxr r r rJsz'LRParser.parsedebug..z Action : Shift and goto state %sz3Action : Reduce rule [%s] with %s and goto state %d[,cSsg|]}t|jqSr )r,rG)rIZ_vr r r rJs]rYr^z Result : %srFrGzDone : Returning %szPLY: PARSE DEBUG ENDz Error : %scSsg|] }|jqSr r;rr r r rJBsrDrU(yacc: Syntax error at line %d, token=%s yacc: Syntax error, token=%s yacc: Parse error in input. EOF r]yacc: internal parser error!!! )0rhrjrfrtrArrrrDr8rr5rnrorCrpr:r%rpopgetjoinr?lstriprr#rGrUr]rWrYr^rBrxcallabler*rbextend error_countrlrr7hasattrr9r~rr RuntimeError r rrDrrr lookaheadlookaheadstackryrjprodrtpslice errorcountr get_tokenrnroerrtokenrqrxltypetppnameplentargt1rMr)tokrUr r r r\s        *        $               *          zLRParser.parsedebugc Csnd}g}|j}|j} |j} |j} td} d} |sBddlm}|j}|| _|| _|dk r`| ||dkrp|j }n|}||_ g}||_ g}||_ || _ d}|dt}d|_||d}|| kr|s|s|}n|}|st}d|_|j}|||}n| |}|dk rd|dkrJ|||}||d}| r| d8} q|dkrB| | }|j}|j}t}||_d|_|r|| dd}||d<|r|d}|j|_|j|_|d}t|d|j|_t|d|j|_|| _zP|| d=||_|| || d=||| |d|}||Wqtk r||||dd||d}d|_d|_|}t } d |_!YqXqn|r|j|_|j|_|g}|| _z8||_|| ||| |d|}||Wqtk r>||||d}d|_d|_|}t } d |_!YqXq|dkrd|d}t|d d}|S|dkr`| dks|j!rHt } d |_!|}|jdkrd}|j"r|rt#|d s||_||_t$|j"||}|j!rF|}d}qn`|r6t#|d r|j}nd}|r"t%j&'d ||jfnt%j&'d|jnt%j&'ddSnt } t|dkr~|jdkr~d}d}d}|dd=q|jdkrdS|jdkr0|d}|jdkr|rt|d |j|_t|d|j|_d}qt}d|_t#|d r|j|_|_t#|dr|j|_|_||_|||}q|}|rN|j|_|j|_||d}qt(dqdS)NrrsrrmrrYr^rFrGrDrUrrrr]r))rhrjrfrtrArrrDr8rr5rnrorCrpr:r%rrrr#rGrUr]rWrYr^rBrxrrbrrrlr7rr9r~rrrrr r r rsV                                  zLRParser.parseoptcCsd}g}|j}|j} |j} |j} td} d} |sBddlm}|j}|| _|| _|dk r`| ||dkrp|j }n|}||_ g}||_ g}||_ || _ d}|dt}d|_||d}|| kr|s|s|}n|}|st}d|_|j}|||}n| |}|dk r|dkrJ|||}||d}| r| d8} q|dkr| | }|j}|j}t}||_d|_|rT|| dd}||d<|| _zP|| d=||_|| || d=||| |d|}||Wqtk rN||||dd||d}d|_d|_|}t} d|_YqXqn|g}|| _z8||_|| ||| |d|}||Wqtk r||||d}d|_d|_|}t} d|_YqXq|dkr|d}t|dd}|S|dkr| dks$|jrt} d|_|}|jdkrBd}|jr|rbt|d sb||_||_t |j||}|jr|}d}qn`|rt|d r|j!}nd}|rt"j#$d ||jfnt"j#$d |jnt"j#$d dSnt} t|dkr"|jdkr"d}d}d}|dd=q|jdkr2dS|jdkr|d}|jdkrXd}qt}d|_t|d r~|j!|_!|_%t|dr|j&|_&|_'||_|||}q|}||d}qt(dqdS)NrrsrrmrrFrGrDrUrrrr]r))rhrjrfrtrArrrDr8rr5rnrorCrpr:r%rrrr#rGrBrxrrbrrrlrWr7rr9rUr~rrrYr]r^r)r rrDrrrrrryrjrrtrrrrrnrorrqrxrrrrrrrMr)rrUr r r rs6                                  zLRParser.parseopt_notrack)NNFFN)NNFFN)NNFFN)NNFFN) rrrr r1r3rkr{rrrrr r r r rcs  ] 4rcz^[a-zA-Z0-9_-]+$c@sReZdZdZdddZddZd d Zd d Zd dZddZ ddZ ddZ dS) ProductionrrightrNrc Cs||_t||_||_||_d|_||_||_||_t |j|_ g|_ |jD]}||j krL|j |qLg|_ d|_ |jrd|jd|jf|_n d|j|_dSN%s -> %srz %s -> )rtuplernumberfuncrfilelineprecr#usymsrplr_itemslr_nextrr?) r rrr precedencerrrrEr r r r s$    zProduction.__init__cCs|jSrr>r<r r r r==szProduction.__str__cCsdt|dS)Nz Production()r>r<r r r r@@szProduction.__repr__cCs t|jSr)r#rr<r r r rTCszProduction.__len__cCsdSNrsr r<r r r __nonzero__FszProduction.__nonzero__cCs |j|Sr)rr indexr r r rNIszProduction.__getitem__c Cs|t|jkrdSt||}zt|j|d|_Wnttfk rRg|_YnXz|j|d|_Wntk rd|_YnX|Sr)r#rLRItem Prodnameslr_after IndexErrorKeyError lr_before)r rMrr r r lr_itemMs   zProduction.lr_itemcCs|jr||j|_dSrrrr pdictr r r bind]szProduction.bind)rNrr) rrrreducedr r=r@rTrrNrrr r r r rs rc@s,eZdZddZddZddZddZd S) MiniProductioncCs.||_||_||_d|_||_||_||_dSr)rr#rrrrr?)r r?rr#rrrr r r r fszMiniProduction.__init__cCs|jSrr>r<r r r r=oszMiniProduction.__str__cCs d|jS)NzMiniProduction(%s)r>r<r r r r@rszMiniProduction.__repr__cCs|jr||j|_dSrrrr r r rvszMiniProduction.bindN)rrrr r=r@rr r r r res rc@s$eZdZddZddZddZdS)rcCsZ|j|_t|j|_|j|_||_i|_|j|dt|j|_t|j|_|j |_ dS)N.) rrvrrlr_index lookaheadsinsertrr#r)r rrMr r r r s   zLRItem.__init__cCs,|jrd|jd|jf}n d|j}|Sr)rrr)r rEr r r r=s zLRItem.__str__cCsdt|dS)NzLRItem(rr>r<r r r r@szLRItem.__repr__N)rrrr r=r@r r r r rs rcCs6t|d}|dkr2|||kr(||S|d8}q dSrr)r#)symbols terminalsrQr r r rightmost_terminals    rc@s eZdZdS) GrammarErrorNr!r r r r rsrc@seZdZddZddZddZddZd$d d Zd%ddZddZ ddZ ddZ ddZ ddZ ddZddZddZd&d d!Zd"d#Zd S)'GrammarcCsbdg|_i|_i|_i|_|D]}g|j|<qg|jd<i|_i|_i|_i|_t|_ d|_ dSNr) ProductionsrProdmap Terminals NonterminalsFirstFollow PrecedencesetUsedPrecedenceStart)r rtermr r r r s  zGrammar.__init__cCs t|jSr)r#rr<r r r rTszGrammar.__len__cCs |j|Sr)rrr r r rNszGrammar.__getitem__cCsL|jdgkstd||jkr*td||dkr:td||f|j|<dS)Nz2Must call set_precedence() before add_production()z,Precedence already specified for terminal %r)leftrnonassocz:Associativity must be one of 'left','right', or 'nonassoc')rAssertionErrorrr)r rassoclevelr r r set_precedences   zGrammar.set_precedenceNrrc Cs||jkrtd|||f|dkr6td|||ft|sRtd|||ft|D]\}}|ddkrzLt|}t|dkrtd||||f||jkrg|j|<|||<WqZWntk rYnXt|sZ|d krZtd ||||fqZd |kr|d d kr td ||f|d d kr>td||f|d } |j | } | sltd||| fn |j | |d d=nt ||j} |j | d} d||f} | |j kr|j | } td||| fd| j| jft|j} ||jkrg|j|<|D]J}||jkr(|j|| n&||jkr>g|j|<|j|| qt| ||| |||}|j|||j | <z|j||Wn"tk r|g|j|<YnXdS)Nz7%s:%d: Illegal rule name %r. Already defined as a tokenrz5%s:%d: Illegal rule name %r. error is a reserved wordz%s:%d: Illegal rule name %rrz'"rszA%s:%d: Literal token %s in rule %r may only be a single characterz%precz!%s:%d: Illegal name %r in rule %rrz+%s:%d: Syntax error. Nothing follows %%preczH%s:%d: Syntax error. %%prec can only appear at the end of a grammar rulez/%s:%d: Nothing known about the precedence of %rrrz%s:%d: Duplicate rule %s. zPrevious definition at %s:%d)rr_is_identifiermatch enumerateevalr#rbrrraddrrrrrrrprrr)r prodnamesymsrrrrMrEcZprecnameZprodprecmapmZpnumberrrr r r add_production sv                       zGrammar.add_productioncCsT|s|jdj}||jkr&td|tdd|g|jd<|j|d||_dS)Nrszstart symbol %s undefinedrS')rrrrrrpr)r startr r r set_startas   zGrammar.set_startcs>fddtjdjdfddjDS)NcsB|kr dS|j|gD]}|jD] }|q.q$dSr)rrrr)rErr'mark_reachable_from reachabler r r rts   z5Grammar.find_unreachable..mark_reachable_fromrcsg|]}|kr|qSr r rH)rr r rJ~sz,Grammar.find_unreachable..)rrrrr<r rr find_unreachableqszGrammar.find_unreachablec Csi}|jD] }d||<q d|d<|jD] }d||<q&d}|jD]N\}}|D]@}|jD]}||sXd}qrqXd}|rN||sd||<d}qBqNqB|s4qq4g} |D]4\}} | s||jkr||jkr|dkrq| |q| S)NTrmFr)rrrrurrp) r Z terminatesrrM some_changeplrrEZ p_terminatesinfiniterr r r infinite_cycless8      zGrammar.infinite_cyclescCsPg}|jD]@}|sq |jD].}||jkr||jkr|dkr|||fqq |Sr)rrrrrp)r r)rrEr r r undefined_symbolss  zGrammar.undefined_symbolscCs2g}|jD]\}}|dkr|s||q|Sr)rrurp)r Z unused_tokrErOr r r unused_terminalss   zGrammar.unused_terminalscCs8g}|jD]$\}}|s|j|d}||q|SNr)rrurrp)r Z unused_prodrErOrr r r unused_ruless  zGrammar.unused_rulescCs@g}|jD]0}||jks ||jks |||j|dfq |Sr)rrrrp)r ZunusedZtermnamer r r unused_precedences  zGrammar.unused_precedencecCsZg}|D]B}d}|j|D]$}|dkr,d}q||kr||q|rFqqVq|d|S)NFT)rrp)r betar)xZx_produces_emptyrr r r _first s  zGrammar._firstcCs|jr |jS|jD]}|g|j|<qdg|jd<|jD]}g|j|<q6d}|jD]H}|j|D]8}||jD]&}||j|krn|j||d}qnq^qP|sFqqF|jS)NrmFT)rrrrrrrp)r rrMrrrr r r compute_first,s"      zGrammar.compute_firstc Cs<|jr |jS|js||jD]}g|j|<q |s@|jdj}dg|j|<d}|jddD]}t|jD]\}}||jkrl||j|dd}d}|D]:} | dkr| |j|kr|j| | d}| dkrd}q|s|t |jdkrl|j|jD]*} | |j|kr|j| | d}qqlq^|sLq6qL|jS)NrsrmFrT) rrr rrrrrrrpr#) r rkdidaddrrQBZfstZhasemptyrr r r compute_followQs:      zGrammar.compute_followc Cs|jD]}|}d}g}|t|kr(d}ntt||}z|j|j|d|_Wnttfk rjg|_YnXz|j|d|_Wntk rd|_YnX||_ |sq| ||}|d7}q||_ qdSNrrs) rr#rrrrrrrrrpr)r rZlastlrirQrZlrir r r build_lritemss,       zGrammar.build_lritems)Nrr)N)N)rrrr rTrNrrrrrrrrrrr r rr r r r rs $  T @#% ;rc@s eZdZdS) VersionErrorNr!r r r r rsrc@s,eZdZddZddZddZddZd S) LRTablecCsd|_d|_d|_d|_dSr)rgrire lr_methodr<r r r r szLRTable.__init__cCszt|tjr|}ntd|tj|}|jtkr:td|j |_ |j |_ g|_ |jD]}|j t|qV|j|_|jS)N import %s&yacc table file version is out of date)rKtypes ModuleTypeexecr~modulesZ _tabversion__tabversion__rZ _lr_actionrgZ_lr_gotorireZ_lr_productionsrprZ _lr_methodrZ _lr_signature)r modulerrr r r read_tables     zLRTable.read_tablecCsz ddl}Wntk r(ddl}YnXtj|s:tt|d}||}|tkr^t d|||_ ||}|||_ |||_ ||}g|_ |D]}|j t|q||S)Nrrbr)cPickle ImportErrorpickleospathexistsopenloadrrrrgrirerprclose)r filenamerZin_fZ tabversion signaturerfrr r r read_pickles(         zLRTable.read_picklecCs|jD]}||qdSr)rer)r rrr r r bind_callabless zLRTable.bind_callablesN)rrrr rr(r)r r r r rsrc CsLi}|D] }d||<qg}i}|D]$}||dkr"t|||||||q"|Sr)traverse)XRFPNrrCFr r r digraphs  r0c Cs||t|}|||<||||<||}|D]f} || dkrVt| ||||||t|||| ||<|| gD]} | ||krx||| qxq2|||krt||d<||||d<|} | |krt||d<||||d<|} qdS)Nrr)rpr#r*minrMAXINTr) rr.rCr/r+r,r-drelyaelementr r r r*s(       r*c@s eZdZdS) LALRErrorNr!r r r r r8)sr8c@seZdZd$ddZddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZddZddZd%d d!Zd&d"d#ZdS)'LRGeneratedTablerNcCs|dkrtd|||_||_|s*t}||_i|_i|_|j|_i|_ i|_ d|_ d|_ d|_ g|_g|_g|_|j|j|j|dS)N)ZSLRrzUnsupported method %sr)r8grammarrrlogrgrirre lr_goto_cache lr0_cidhash _add_countZ sr_conflictZ rr_conflict conflicts sr_conflicts rr_conflictsrr r lr_parse_table)r r:methodr;r r r r 4s,    zLRGeneratedTable.__init__cCsn|jd7_|dd}d}|rjd}|D]<}|jD]0}t|dd|jkrLq4||j|j|_d}q4q*q|S)NrsTF lr0_addedr)r>rrWrprrD)r IJr rRrr r r lr0_closureYs    zLRGeneratedTable.lr0_closurec Cs|jt||f}|r|S|j|}|s:i}||j|<g}|D]H}|j}|rB|j|krB|t|}|s|i}||t|<|||}qB|d}|s|r||}||d<n||d<||jt||f<|S)Nrm)r<rr&rrrprG) r rErgrEZgsrrMs1r r r lr0_gotoss2       zLRGeneratedTable.lr0_gotoc Cs||jjdjgg}d}|D]}||jt|<|d7}q d}|t|kr||}|d7}i}|D]}|jD] }d||<qnqd|D]@}|||}|rt||jkrqt||jt|<| |qq@|Sr) rGr:rrr=r&r#rrJrp) r CrQrEZasymsiirErrHr r r lr0_itemss(     zLRGeneratedTable.lr0_itemscCsxt}d}|jjddD]@}|jdkr6||jq|jD]}||kr<qq<||jqt||krjqtt|}q |Sr)rr:rr#rrr)r nullableZ num_nullablerrr r r compute_nullable_nonterminalss     z.LRGeneratedTable.compute_nullable_nonterminalscCsjg}t|D]X\}}|D]J}|j|jdkr||j|jdf}|d|jjkr||kr||qq |Sr)rrr#rr:rrp)r rKtransZstatenorxrrr r r find_nonterminal_transitionssz-LRGeneratedTable.find_nonterminal_transitionsc Csi}|\}}g}||||}|D]B} | j| jdkr$| j| jd} | |jjkr$| |kr$|| q$|dkr||jjdjdkr|d|S)Nrsrrm)rJrr#rr:rrpr) r rKrPrNZdr_setrxr.termsrHrr6r r r dr_relations   zLRGeneratedTable.dr_relationc Csrg}|\}}||||}|jt|d}|D]:} | j| jdkr2| j| jd} | |kr2||| fq2|S)Nrrs)rJr=rr&rr#rrp) r rKrPemptyr4rxr.rHrRrr6r r r reads_relation szLRGeneratedTable.reads_relationcCsi}i}i}|D] }d||<q|D]\}} g} g} ||D],} | j| krNq<| j} |}| | jdkr| d} | j| }||f|kr| d}|| jkr| j||jjkrq| j||krq|d}q| ||f||||}|j t |d}qX||D]j}|j| jkrq|j| jkr"qd}||jkrZ|j|| j|dkrNq|d}q&| ||fqq<| D]*}||krg||<|||| fqp| ||| f<q"||fS)Nrsrr) rrr#rr:rrprJr=rr&)r rKrPrNZlookdictZ includedictZdtransrrxr.ZlookbincludesrrrRlirHr'rQr r r compute_lookback_includesC sX          z*LRGeneratedTable.compute_lookback_includescs0fdd}fdd}t|||}|S)Ncs|Sr)rSrrKrNr r r  z4LRGeneratedTable.compute_read_sets..cs|Sr)rUrYrZr r r[ r\r0)r rKntransrNr-r,r/r rZr compute_read_sets s z"LRGeneratedTable.compute_read_setscs(fdd}fdd}t|||}|S)Ncs|Srr rY)readsetsr r r[ r\z6LRGeneratedTable.compute_follow_sets..cs |gSr)rrY)inclsetsr r r[ r\r])r r^r`rar-r,r/r )rar`r compute_follow_sets s   z$LRGeneratedTable.compute_follow_setsc Csl|D]^\}}|D]P\}}||jkr0g|j|<||g}|D]"}||j|kr@|j||q@qqdSr)rurrrp) r Z lookbacksZ followsetrPZlbrxrrr6r r r add_lookaheads s    zLRGeneratedTable.add_lookaheadscCsP|}||}||||}||||\}}||||}|||dSr)rOrQr_rXrbrc)r rKrNrPr`ZlookdZincludedZ followsetsr r r add_lalr_lookaheads s  z$LRGeneratedTable.add_lalr_lookaheadsc$ Cs|jj}|jj}|j}|j}|j}i}|d|j|}|jdkrP| |d}|D]} g} i} i} i} |d|d||d| D]}|d|j |q|d| D]}|j |j dkr|j dkrd| d <|| d <q|jdkr|j|}n|jj|j }|D]}| ||d |j |ff| |}|dk r|dkr*||d \}}||j j\}}||ks||kr|d kr|j | |<|| |<|s|s|d ||j||df||j jd7_nB||kr|dkrd| |<n$|s|d||j||dfn|dkr|| }||j }|j|jkr|j | |<|| |<||}}||j jd7_||j jd8_n ||}}|j|||f|d|| |j | |n td|n(|j | |<|| |<||j jd7_qq|j }|j|d}||jjkr|| |}|jt|d}|dkr| ||d|f| |}|dk r|dkr||krtd|n|dkr||d \}}|| |j j\}}||ks||kr<|dkr<|| |j jd8_|| |<|| |<|s|d||j||dfnH||krZ|dkrZd| |<n*|s|s|d ||j||dfn td|q|| |<|| |<qi}| D]>\}}}|| kr|| |kr|d||d|||f<q|dd}| D]P\}}}|| kr|| |k r||f|kr|d||d}d|||f<q|rb|di} | D]*}!|!jD]}"|"|jjkrtd| |"<qtqj| D]D}#|| |#}|jt|d}|dkr|| |#<|d|#|q| ||<| ||<| ||<|d7}qXdS)NzParsing method: %srrrzstate %dz (%d) %srsrrmzreduce using rule %d (%s)rrz3 ! shift/reduce conflict for %s resolved as reducereducerz2 ! shift/reduce conflict for %s resolved as shiftshiftz= ! reduce/reduce conflict for %s resolved using rule %d (%s)zUnknown conflict in state %drzshift and go to state %dz Shift/shift conflict in state %drz %-15s %sz ! %-15s [ %s ]z" %-30s shift and go to state %d) r:rrrirgr;rrrMrdrr#rrrrrprrr@rrrAr8rrrJr=r&rrr)$r rrrjrhr;ZactionprKstrEZactlistZ st_actionZ st_actionpZst_gotorZlaheadsr6r'ZsprecZslevelZrprecZrlevelZoldpppZchosenpZrejectprQrHrRZ _actprintrZnot_usedZnkeysrLrErMr r r rB s                                               zLRGeneratedTable.lr_parse_tablerc Cst|tjrtd|dd}tj||d}z8t|d}| dtj |t |j |fd}|r`i}|j D]T\} } | D]B\} } || } | sggf} | || <| d| | d| qqz| d |D]f\}} | d || dD]} | d | q| d | dD]} | d | q(| d q| d| dnF| d|j D]&\}} | d|d|d| fqt| d|ri}|jD]Z\} } | D]F\} } || } | sggf} | || <| d| | d| qʐq| d|D]h\}} | d || dD]} | d | qF| d | dD]} | d | qn| d q(| d| dnF| d|jD]&\}} | d|d|d| fq| d| d|jD]Z}|jr:| d|j|j|j|jtj |j|jfn| dt||j|jfq| d|Wn&tk r}zW5d}~XYnXdS)Nz"Won't overwrite existing tabmodulerrz.pywzu # %s # This file is automatically generated. Do not edit. _tabversion = %r _lr_method = %r _lr_signature = %r rsrz _lr_action_items = {z%r:([z%r,z],[z]),z} z _lr_action = {} for _k, _v in _lr_action_items.items(): for _x,_y in zip(_v[0],_v[1]): if not _x in _lr_action: _lr_action[_x] = {} _lr_action[_x][_k] = _y del _lr_action_items z _lr_action = { z (%r,%r):%r,z _lr_goto_items = {z _lr_goto = {} for _k, _v in _lr_goto_items.items(): for _x, _y in zip(_v[0], _v[1]): if not _x in _lr_goto: _lr_goto[_x] = {} _lr_goto[_x][_k] = _y del _lr_goto_items z _lr_goto = { z_lr_productions = [ z (%r,%r,%d,%r,%r,%d), z (%r,%r,%d,None,None,None), z] )rKrrIOErrorsplitr r!rr#rbasenamerrrgrurrprirerr?rr#rrr%)r tabmodule outputdirr'Zbasemodulenamer&rZsmallerrurEndrrOrQr rer r r write_table s                             zLRGeneratedTable.write_tablec Csz ddl}Wntk r(ddl}YnXt|d}|t|t||j|t|||t||j|t||j |tg}|j D]T}|j r| |j |j|j|j tj|j|jfq| t ||j|jdddfq|||tW5QRXdS)Nrwb)rrrr#dumprpickle_protocolrrgrirerrpr?rr#r r!rlrr)r r&r'routfZoutprr r r pickle_table s    , zLRGeneratedTable.pickle_table)rN)rr)r)rrrr rGrJrMrOrQrSrUrXr_rbrcrdrBrqrvr r r r r93s" %#8+PB zr9cCs0t|}|j}|j|jkr,||j|Sr)r~ _getframe f_globalscopyf_localsupdate)levelsrZldictr r r get_caller_module_dictC s     r}c Csg}|}d}|}|D]}|d7}|}|s2qz|ddkrf|sTtd||f|} |dd} n@|d} | }|dd} |d} | dkr| dkrtd||f|||| | fWqtk rYqtk rtd |||fYqXq|S) Nrsr|z%s:%d: Misplaced '|':z::=z!%s:%d: Syntax error. Expected ':'z%s:%d: Syntax error in rule %r) splitlinesrkrbrp Exceptionstrip) docrrr:ZpstringsZlastpZdlineZpsrrrZassignr r r parse_grammarO s6  rc@seZdZd ddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZdS)! ParserReflectNcCsL||_d|_d|_d|_t|_g|_d|_|dkrBtt j |_ n||_ dS)NF) rr error_functokensrrr:rrr~rr;)r rr;r r r r y szParserReflect.__init__cCs,|||||dSr) get_startget_error_func get_tokensget_precedenceget_pfunctionsr<r r r get_all s zParserReflect.get_allcCs6|||||||jSr)validate_startvalidate_error_funcvalidate_tokensvalidate_precedencevalidate_pfunctionsvalidate_modulesrr<r r r validate_all szParserReflect.validate_allc Csg}zr|jr||j|jr:|ddd|jD|jrR|d|j|jD]}|drX||dqXWnttfk rYnXd|S)NrcSsg|]}d|qS)r)r)rIrr r r rJ sz+ParserReflect.signature..rr)rrprrrpfuncs TypeError ValueError)r partsrr r r r' s  zParserReflect.signaturec Cstd}|jD]}zt|\}}Wntk r>YqYnXi}t|D]^\}}|d7}||}|rL|d}| |} | s|||<qLt |} |j d| ||| qLqdS)Nz\s*def\s+(p_[a-zA-Z_0-9]*)\(rsz;%s:%d: Function %s redefined. Previously defined on line %d) recompilerinspectgetsourcelinesrjrrgroupr getsourcefiler;r) r ZfrerlinesZlinenZ counthashrrrprevr&r r r r s,        zParserReflect.validate_modulescCs|jd|_dS)Nr)rrrr<r r r r szParserReflect.get_startcCs&|jdk r"t|jts"|jddS)Nz'start' must be a string)rrK string_typesr;rr<r r r r s  zParserReflect.validate_startcCs|jd|_dS)Np_error)rrrr<r r r r szParserReflect.get_error_funccCs|jrt|jtjrd}n*t|jtjr.d}n|jdd|_dS|jjj}|jjj }t |j}|j ||jjj|}|dkr|jd||d|_dS)Nrrsz2'p_error' defined, but is not a function or methodTz$%s:%d: p_error() requires 1 argument)rrKr FunctionType MethodTyper;r__code__co_firstlineno co_filenamer getmodulerr co_argcount)r ismethodZelineZefilerZargcountr r r r s      z!ParserReflect.validate_error_funccCsn|jd}|s&|jdd|_dSt|ttfsJ|jdd|_dS|sd|jdd|_dS||_dS)NrzNo token list is definedTztokens must be a list or tupleztokens is empty)rrr;rrKrvrr)r rr r r r s    zParserReflect.get_tokenscCsVd|jkr |jdd|_dSt}|jD]$}||krF|jd|||q,dS)Nrz.Illegal token name 'error'. Is a reserved wordTzToken %r multiply defined)rr;rrrr)r rrMr r r r s   zParserReflect.validate_tokenscCs|jd|_dS)Nr)rrrr<r r r r szParserReflect.get_precedencecCsg}|jrt|jttfs2|jdd|_dSt|jD]\}}t|ttfsj|jdd|_dSt|dkr|jd|d|_dS|d}t|ts|jdd|_dS|ddD]<}t|ts|jd d|_dS| |||dfqq<||_ dS) Nz"precedence must be a list or tupleTzBad precedence tablerz?Malformed precedence entry %s. Must be (assoc, term, ..., term)rz)precedence associativity must be a stringrsz precedence items must be strings) rrKrvrr;rrr#rrppreclist)r rrrrrr r r r s6       z!ParserReflect.validate_precedencecCsg}|jD]\\}}|dr|dkr*qt|tjtjfrt|d|jj }t |}| ||||j fq|jddd||_dS)Np_rrcSs |dt|d|d|dfS)Nrrsrrr>)Z p_functionr r r r[D s  z.ParserReflect.get_pfunctions..)key)rru startswithrKrrrrWrrrrrp__doc__sortr)r Z p_functionsritemrrr r r r7 s zParserReflect.get_pfunctionsc CsNg}t|jdkr(|jdd|_dS|jD]\}}}}t|}|j|}t|tj rbd}nd}|j j |kr|jd|||j d|_q.|j j |kr|jd|||j d|_q.|j s|jd|||j q.z(t|||} | D]} ||| fqWn:tk r4} z|jt| d|_W5d} ~ XYnX|j|q.|jD]\} } | d rzt| tjtj frzqN| d rqN| d r| d kr|jd | t| tjr| j j dkst| tj rN| jj j dkrN| j rNz8| j d }|ddkr&|jd| j j| j j| Wntk r>YnXqN||_dS)Nrz+no rules of the form p_rulename are definedTrrsz%%s:%d: Rule %r has too many argumentsz#%s:%d: Rule %r requires an argumentzA%s:%d: No documentation string specified in function %r (ignored)rZt_rz%r not defined as a functionrrz9%s:%d: Possible grammar rule %r defined without p_ prefix)r#rr;rrrrrKrrrrrrrrrprbr?rrrurr__func__rkrrrr:)r r:rrrrrrZreqargsZparsed_grHrprMrOr r r rL sn             z!ParserReflect.validate_pfunctions)N)rrrr rrr'rrrrrrrrrrrr r r r rx s  rc < s0 |dkr t}| rd}| dkr&ttj} rffddtD} t| }d|krntj|dj|d<ntd}| dkrt |t j r|j}nLd|kr|d}n:| d}d |dd}td |ttj|dd }tj|} |d }|rt |trd|kr|d|}|dk r&||d <t|| d }||jrJtd|}zt}| rl|| }n ||}|s||krz&||jt||j }|j!a!|WWSt"k r}z| #d|W5d}~XYnXWnFt$k r}z| #t|W5d}~XYnt%k r&YnX| dkr|rztt&tj | |d} Wn<t'k r}z| #d||ft(} W5d}~XYnXnt(} | )dt*d}|+rtd|j s| #dt,|j-}|j.D]P\}}}z|/|||Wn0t0k r*}z| #d|W5d}~XYnXq|j1D]b\}}|\} }!}"}#z|2|"|#|| |!Wn4t0k r}z| d|d}W5d}~XYnXq6z&|dkr|3|j4n |3|Wn6t0k r}z| t|d}W5d}~XYnX|rtd|5}$|$D]"\}%}&| d|&j6|&j7|%d}q|8}'|'r| )d | )d| )d |'D]}| #d|| )d|qf|r| )d | )d| )d t9|j:D]\}(})| )d|(|)q|;}*|*D]}&| #d|&j6|&j7|&j<qt=|'dkr| #dt=|'dkr.| #d t=|'t=|*dkrF| #d!t=|*dkrd| #d"t=|*|r4| )d | )d#| )d t>|j?}+|+@|+D]*}| )d$|d% d&d|j?|Dq| )d | )d'| )d t>|jA},|,@|,D]*}-| )d$|-d% d(d|jA|-Dq| )d |r~|B}.|.D]}/| #d)|/qF|C}0|0D]}1| d*|1d}qf|D}2|2D]\}}| d+||d}q|rtd|r| Ed,|tF||| }|rFt=|jG}3|3dkr| #d-n|3dkr| #d.|3t=|jH}4|4dkr0| #d/n|4dkrF| #d0|4|rp|jGs\|jHrp| #d | #d1| #d |jGD]\}5}6}7| #d2|6|5|7qtI}8|jHD]x\}5}9}:|5tJ|9tJ|:f|8krАq| #d3|5|9| #d4|:|5| #d3|5|9| #d4|:|5|8K|5tJ|9tJ|:fqg};|jHD]@\}5}9}:|:jLs.|:|;kr.| #d5|:| #d5|:|;M|:q.|rz|N|| |Wn6t'k r}z| #d6||fW5d}~XYnX| rz|O| |Wn6t'k r }z| #d6| |fW5d}~XYnX||jt||j }|j!a!|S)7Nrcsg|]}|t|fqSr )rW)rIr rr r rJ szyacc..__file__rrrrrr __package__r)r;zUnable to build parserz.There was a problem loading the table file: %rrizCouldn't open %r. %sz5Created by PLY version %s (http://www.dabeaz.com/ply)Fz no p_error() function is definedz%sTz;%s:%d: Symbol %r used, but not defined as a token or a rulezUnused terminals:zToken %r defined, but not usedz %srz Rule %-5d %sz$%s:%d: Rule %r defined, but not usedrszThere is 1 unused tokenzThere are %d unused tokenszThere is 1 unused rulezThere are %d unused rulesz'Terminals, with rules where they appearz %-20s : %srcSsg|] }t|qSr r>rHr r r rJG sz*Nonterminals, with rules where they appearcSsg|] }t|qSr r>rHr r r rJO szSymbol %r is unreachablez)Infinite recursion detected for symbol %rz0Precedence rule %r defined for unknown symbol %rzGenerating %s tablesz1 shift/reduce conflictz%d shift/reduce conflictsz1 reduce/reduce conflictz%d reduce/reduce conflictsz Conflicts:z7shift/reduce conflict for %s in state %d resolved as %sz;reduce/reduce conflict in state %d resolved using rule (%s)zrejected rule (%s) in state %dzRule (%s) is never reducedzCouldn't create %r. %s)P tab_modulerr~rdirdictrrr}rKrrrkrrrWr r!dirnamerr?rrrr r'rr(rr)rrcrrrrrrr#rjrr __version__rrrrrrr:rrrrrrrrrrrr#rvrrrrrrrr9r@rArr&rrrprqrv)>s   4m H.rT   )