/3>c@stddlZdefdYZdefdYZdd dYZdd d YZd Zd ZdS(iNt SyntaxErrorcBs,eZdZdddZdZeZRS(sBWhen we run into an unexpected token, this is the exception to useis Bad TokencCs#tj|||_||_dS(N(t Exceptiont__init__tpostmsg(tselfRR((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyR s  cCs2|jdkrdSd|j d|jdSdS(Nis#sSyntaxError[@ char s: t](RR(R((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyt__repr__s(t__name__t __module__t__doc__RRt__str__(((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyR s t NoMoreTokenscBseZdZRS(s7Another exception object, for when we run out of tokens(RR R (((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyR stScannercBs/eZdZddZdZdZRS(cCsg|_g|_||_d|_||_|dk r{g|_x6|D]+\}}|jj|tj |fqIWndS(s]Patterns is [(terminal,regex)...] Ignore is [terminal,...]; Input is a stringiN( ttokenst restrictionstinputRtignoretNonetpatternstappendtretcompile(RRRRtktr((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyRs       icCs|t|jkr%|j|n|t|jkr|r}|j|r}x-|D]"}||j|krTdqTqTWn|j|StdS(sGet the i'th token, and if i is one past the end, then scan for another token; restrict is a list of tokens that are allowed, or 0 for any token.s&Unimplemented: restriction set changedN(tlenRtscanRR (RtitrestrictR((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyttoken+s  cCsEd}x8|jdD])}d||d|d|d f}qW|S(s2Print the last 10 tokens that have been scanned intis%s (@%s) %s = %siii(R(Rtoutputtt((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyR9s'c Csxd}d}x|jD]\}}|rL||krL||jkrLqn|j|j|j}|rt|jd|kr|}t|jd}qqW|dkr|dkrd}|rdt|d}nt|j|n||jkr|j|j|||j|j|j|!f}|j||_|j sb||j dkr|j j ||j j |ndS|j||_qdS(ssShould scan another token and add it to the list, self.tokens, and add the restriction to self.restrictionsis(error)is Bad TokensTrying to find one of s, N( RRtmatchRRRtgrouptjoinRRRR( RRt best_matchtbest_pattptregexptmRR((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyR@s0!!(RR RRRR(((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyR s   tParsercBs#eZdZdZdZRS(cCs||_d|_dS(Ni(t_scannert_pos(Rtscanner((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyRks cGs |jj|j|}|dS(s|Returns the token type for lookahead; if there are any args then the list of args is the set of token types to allowi(R*RR+(Rttypesttok((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyt_peekoscCs]|jj|j|g}|d|krEt|dd|nd|j|_|dS(s5Returns the matched text, and moves to the next tokeniisTrying to find ii(R*RR+R(RttypeR.((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyt_scanus (RR RR/R1(((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyR)js  c Cs|j}t|| d}|jd|d dGH|t|dd|d!}|t|dd}t|| d}t|| d}|dks||kr|dkr|}n|dkr||kr||d}||d}nt|d|}t|d|}|dks<||krE|dkrE|}n|dkr^|| }nx:t|dkr|d krd |d }|d }qaWd G|GHd Gd|dGHdG|GHdS(sCThis is a really dumb long function to print error messages nicely.s s on line it:iPis iFi<s...i is> t t^sList of nearby tokens:N(RtcountRtmaxtrfindtfindR(RterrR,R&tlinettextRtj((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyt print_errors0 $ $   ! cCsyt||SWntk r}|jj}yt|||jWqtk rdG|jGdGdt||j dGHqXnt k rdGH|jGHnXdS(Ns Syntax Errorson lineis s0Could not complete parsing; stopped around here:( tgetattrRR*RR=t ImportErrorRR5RR (tparsertruletsR((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pytwrap_error_reporters  / (((RRRR R R)R=RC(((sC/opt/freeware/lib/python2.7/site-packages/_xmlplus/xpath/yappsrt.pyts  R $