<s> '''<STR_LIT>''' <EOL> from ccruft import * <EOL> from error import * <EOL> from struct import * <EOL> from table import * <EOL> from sys import exit <EOL> MAXRHS = <NUM_LIT:1000> <EOL> ( <EOL> INITIALIZE , <EOL> WAITING_FOR_DECL_OR_RULE , <EOL> WAITING_FOR_DECL_KEYWORD , <EOL> WAITING_FOR_DECL_ARG , <EOL> WAITING_FOR_PRECEDENCE_SYMBOL , <EOL> WAITING_FOR_ARROW , <EOL> IN_RHS , <EOL> LHS_ALIAS_1 , <EOL> LHS_ALIAS_2 , <EOL> LHS_ALIAS_3 , <EOL> RHS_ALIAS_1 , <EOL> RHS_ALIAS_2 , <EOL> PRECEDENCE_MARK_1 , <EOL> PRECEDENCE_MARK_2 , <EOL> RESYNC_AFTER_RULE_ERROR , <EOL> RESYNC_AFTER_DECL_ERROR , <EOL> WAITING_FOR_FALLBACK_ID , <EOL> WAITING_FOR_WILDCARD_ID , <EOL> ) = range ( <NUM_LIT> ) <EOL> pstate = struct ( <EOL> '<STR_LIT>' , <EOL> ( <EOL> '<STR_LIT:filename>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:state>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> ) <EOL> def parseonetoken ( psp , x ) : <EOL> '''<STR_LIT>''' <EOL> x = Strsafe ( x ) <EOL> if psp . state == INITIALIZE : <EOL> psp . prevrule = None <EOL> psp . preccounter = <NUM_LIT:0> <EOL> psp . firstrule = psp . lastrule = None <EOL> psp . gp . nrule = <NUM_LIT:0> <EOL> psp . state = WAITING_FOR_DECL_OR_RULE <EOL> if psp . state == WAITING_FOR_DECL_OR_RULE : <EOL> if x [ <NUM_LIT:0> ] == '<STR_LIT:%>' : <EOL> psp . state = WAITING_FOR_DECL_KEYWORD <EOL> elif x [ <NUM_LIT:0> ] . islower ( ) : <EOL> psp . lhs = Symbol_new ( x ) <EOL> psp . nrhs = <NUM_LIT:0> <EOL> psp . lhsalias = None <EOL> psp . state = WAITING_FOR_ARROW <EOL> elif x [ <NUM_LIT:0> ] == '<STR_LIT:{>' : <EOL> if True : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> "<STR_LIT>" ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> elif psp . prevrule is None : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> elif psp . prevrule . code is not None : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> else : <EOL> psp . prevrule . line = psp . tokenlineno <EOL> psp . prevrule . code = x [ <NUM_LIT:1> : ] <EOL> elif x [ <NUM_LIT:0> ] == '<STR_LIT:[>' : <EOL> psp . state = PRECEDENCE_MARK_1 <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> elif psp . state == PRECEDENCE_MARK_1 : <EOL> if not x [ <NUM_LIT:0> ] . isupper ( ) : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> "<STR_LIT>" ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> elif psp . prevrule is None : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> elif psp . prevrule . precsym is not None : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> "<STR_LIT>" ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> else : <EOL> psp . prevrule . precsym = Symbol_new ( x ) <EOL> psp . state = PRECEDENCE_MARK_2 <EOL> elif psp . state == PRECEDENCE_MARK_2 : <EOL> if x [ <NUM_LIT:0> ] != '<STR_LIT:]>' : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = WAITING_FOR_DECL_OR_RULE <EOL> elif psp . state == WAITING_FOR_ARROW : <EOL> if x [ : <NUM_LIT:3> ] == '<STR_LIT>' : <EOL> psp . state = IN_RHS <EOL> elif x [ <NUM_LIT:0> ] == '<STR_LIT:(>' : <EOL> psp . state = LHS_ALIAS_1 <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> psp . lhs . name ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_RULE_ERROR <EOL> elif psp . state == LHS_ALIAS_1 : <EOL> if x [ <NUM_LIT:0> ] . isalpha ( ) : <EOL> psp . lhsalias = x <EOL> psp . state = LHS_ALIAS_2 <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> x , psp . lhs . name ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_RULE_ERROR <EOL> elif psp . state == LHS_ALIAS_2 : <EOL> if x [ <NUM_LIT:0> ] == '<STR_LIT:)>' : <EOL> psp . state = LHS_ALIAS_3 <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> psp . lhsalias ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_RULE_ERROR <EOL> elif psp . state == LHS_ALIAS_3 : <EOL> if x [ : <NUM_LIT:3> ] == '<STR_LIT>' : <EOL> psp . state = IN_RHS <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> psp . lhs . name , psp . lhsalias ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_RULE_ERROR <EOL> elif psp . state == IN_RHS : <EOL> if x [ <NUM_LIT:0> ] == '<STR_LIT:.>' : <EOL> rp = rule ( <EOL> ruleline = psp . tokenlineno , <EOL> rhs = psp . rhs [ : psp . nrhs ] , <EOL> rhsalias = psp . alias [ : psp . nrhs ] , <EOL> lhs = psp . lhs , <EOL> lhsalias = psp . lhsalias , <EOL> nrhs = psp . nrhs , <EOL> code = None , <EOL> precsym = None , <EOL> index = psp . gp . nrule , <EOL> lhsStart = False , <EOL> line = <NUM_LIT:0> , <EOL> canReduce = False , <EOL> nextlhs = None , <EOL> next = None , <EOL> ) <EOL> psp . gp . nrule += <NUM_LIT:1> <EOL> rp . nextlhs = rp . lhs . rule <EOL> rp . lhs . rule = rp <EOL> if psp . firstrule is None : <EOL> psp . firstrule = psp . lastrule = rp <EOL> else : <EOL> psp . lastrule . next = rp <EOL> psp . lastrule = rp <EOL> psp . prevrule = rp <EOL> psp . state = WAITING_FOR_DECL_OR_RULE <EOL> elif x [ <NUM_LIT:0> ] . isalpha ( ) : <EOL> if psp . nrhs >= MAXRHS : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_RULE_ERROR <EOL> else : <EOL> psp . rhs [ psp . nrhs ] = Symbol_new ( x ) <EOL> psp . alias [ psp . nrhs ] = None <EOL> psp . nrhs += <NUM_LIT:1> <EOL> elif x [ <NUM_LIT:0> ] in ( '<STR_LIT:|>' , '<STR_LIT:/>' ) and psp . nrhs > <NUM_LIT:0> : <EOL> msp = psp . rhs [ psp . nrhs - <NUM_LIT:1> ] <EOL> if msp . type != MULTITERMINAL : <EOL> origsp = msp <EOL> msp = symbol ( <EOL> type = MULTITERMINAL , <EOL> nsubsym = <NUM_LIT:1> , <EOL> subsym = [ origsp ] , <EOL> name = origsp . name , <EOL> index = <NUM_LIT:0> , <EOL> rule = None , <EOL> fallback = None , <EOL> prec = <NUM_LIT:0> , <EOL> assoc = <NUM_LIT:0> , <EOL> firstset = None , <EOL> _lambda = False , <EOL> useCnt = <NUM_LIT:0> , <EOL> ) <EOL> psp . rhs [ psp . nrhs - <NUM_LIT:1> ] = msp <EOL> msp . nsubsym += <NUM_LIT:1> <EOL> msp . subsym . append ( Symbol_new ( x [ <NUM_LIT:1> : ] ) ) <EOL> if x [ <NUM_LIT:1> ] . islower ( ) or msp . subsym [ <NUM_LIT:0> ] . name [ <NUM_LIT:0> ] . islower ( ) : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> "<STR_LIT>" ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> elif x [ <NUM_LIT:0> ] == '<STR_LIT:(>' and psp . nrhs > <NUM_LIT:0> : <EOL> psp . state = RHS_ALIAS_1 <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_RULE_ERROR <EOL> elif psp . state == RHS_ALIAS_1 : <EOL> if x [ <NUM_LIT:0> ] . isalpha ( ) : <EOL> psp . alias [ psp . nrhs - <NUM_LIT:1> ] = x <EOL> psp . state = RHS_ALIAS_2 <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> x , psp . rhs [ psp . nrhs - <NUM_LIT:1> ] . name ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_RULE_ERROR <EOL> elif psp . state == RHS_ALIAS_2 : <EOL> if x [ <NUM_LIT:0> ] == '<STR_LIT:)>' : <EOL> psp . state = IN_RHS <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> psp . lhsalias ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_RULE_ERROR <EOL> elif psp . state == WAITING_FOR_DECL_KEYWORD : <EOL> if x [ <NUM_LIT:0> ] . isalpha ( ) : <EOL> psp . declkeyword = x <EOL> psp . declargslot = None <EOL> psp . insertLineMacro = True <EOL> psp . state = WAITING_FOR_DECL_ARG <EOL> if strcmp ( x , "<STR_LIT:name>" ) == <NUM_LIT:0> : <EOL> psp . declargslot = '<STR_LIT:name>' <EOL> psp . insertLineMacro = False <EOL> elif strcmp ( x , "<STR_LIT>" ) == <NUM_LIT:0> : <EOL> psp . declargslot = '<STR_LIT>' <EOL> psp . insertLineMacro = False <EOL> elif strcmp ( x , "<STR_LIT>" ) == <NUM_LIT:0> : <EOL> psp . declargslot = '<STR_LIT:start>' <EOL> psp . insertLineMacro = False <EOL> elif strcmp ( x , "<STR_LIT:left>" ) == <NUM_LIT:0> : <EOL> psp . preccounter += <NUM_LIT:1> <EOL> psp . declassoc = LEFT <EOL> psp . state = WAITING_FOR_PRECEDENCE_SYMBOL <EOL> elif strcmp ( x , "<STR_LIT:right>" ) == <NUM_LIT:0> : <EOL> psp . preccounter += <NUM_LIT:1> <EOL> psp . declassoc = RIGHT <EOL> psp . state = WAITING_FOR_PRECEDENCE_SYMBOL <EOL> elif strcmp ( x , "<STR_LIT>" ) == <NUM_LIT:0> : <EOL> psp . preccounter += <NUM_LIT:1> <EOL> psp . declassoc = NONE <EOL> psp . state = WAITING_FOR_PRECEDENCE_SYMBOL <EOL> elif strcmp ( x , "<STR_LIT>" ) == <NUM_LIT:0> : <EOL> psp . fallback = None <EOL> psp . state = WAITING_FOR_FALLBACK_ID <EOL> elif strcmp ( x , "<STR_LIT>" ) == <NUM_LIT:0> : <EOL> psp . state = WAITING_FOR_WILDCARD_ID <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_DECL_ERROR <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_DECL_ERROR <EOL> elif psp . state == WAITING_FOR_PRECEDENCE_SYMBOL : <EOL> if x [ <NUM_LIT:0> ] == '<STR_LIT:.>' : <EOL> psp . state = WAITING_FOR_DECL_OR_RULE <EOL> elif x [ <NUM_LIT:0> ] . isupper ( ) : <EOL> sp = Symbol_new ( x ) <EOL> if sp . prec >= <NUM_LIT:0> : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , <EOL> x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> else : <EOL> sp . prec = psp . preccounter <EOL> sp . assoc = psp . declassoc <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> """<STR_LIT>""" , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> elif psp . state == WAITING_FOR_DECL_ARG : <EOL> if x [ <NUM_LIT:0> ] in ( '<STR_LIT:{>' , '<STR_LIT:">' ) or x [ <NUM_LIT:0> ] . isalnum ( ) : <EOL> zNew = x <EOL> if zNew [ <NUM_LIT:0> ] in ( '<STR_LIT:">' , '<STR_LIT:{>' ) : <EOL> zNew = zNew [ <NUM_LIT:1> : ] <EOL> zOld = getattr ( psp . gp , psp . declargslot ) <EOL> if not zOld : <EOL> zOld = "<STR_LIT>" <EOL> zBuf = zOld <EOL> if psp . insertLineMacro : <EOL> if zBuf and zBuf [ - <NUM_LIT:1> ] != '<STR_LIT:\n>' : <EOL> zBuf += '<STR_LIT:\n>' <EOL> zBuf += "<STR_LIT>" % psp . tokenlineno <EOL> zBuf += '<STR_LIT:">' <EOL> zBuf += psp . filename . replace ( '<STR_LIT:\\>' , '<STR_LIT>' ) <EOL> zBuf += '<STR_LIT:">' <EOL> zBuf += '<STR_LIT:\n>' <EOL> zBuf += zNew <EOL> setattr ( psp . gp , psp . declargslot , zBuf ) <EOL> psp . state = WAITING_FOR_DECL_OR_RULE <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> "<STR_LIT>" , <EOL> psp . declkeyword , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> psp . state = RESYNC_AFTER_DECL_ERROR <EOL> elif psp . state == WAITING_FOR_FALLBACK_ID : <EOL> if x [ <NUM_LIT:0> ] == '<STR_LIT:.>' : <EOL> psp . state = WAITING_FOR_DECL_OR_RULE <EOL> elif not x [ <NUM_LIT:0> ] . isupper ( ) : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> else : <EOL> sp = Symbol_new ( x ) <EOL> if psp . fallback is None : <EOL> psp . fallback = sp <EOL> elif sp . fallback : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> "<STR_LIT>" , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> else : <EOL> sp . fallback = psp . fallback <EOL> psp . gp . has_fallback = <NUM_LIT:1> <EOL> elif psp . state == WAITING_FOR_WILDCARD_ID : <EOL> if x [ <NUM_LIT:0> ] == '<STR_LIT:.>' : <EOL> psp . state = WAITING_FOR_DECL_OR_RULE <EOL> elif not x [ <NUM_LIT:0> ] . isupper ( ) : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , <EOL> '<STR_LIT>' , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> else : <EOL> sp = Symbol_new ( x ) <EOL> if psp . gp . wildcard is None : <EOL> psp . gp . wildcard = sp <EOL> else : <EOL> ErrorMsg ( psp . filename , psp . tokenlineno , "<STR_LIT>" , x ) <EOL> psp . errorcnt += <NUM_LIT:1> <EOL> elif psp . state in ( RESYNC_AFTER_RULE_ERROR , RESYNC_AFTER_DECL_ERROR ) : <EOL> if x [ <NUM_LIT:0> ] == '<STR_LIT:.>' : <EOL> psp . state = WAITING_FOR_DECL_OR_RULE <EOL> elif x [ <NUM_LIT:0> ] == '<STR_LIT:%>' : <EOL> psp . state = WAITING_FOR_DECL_KEYWORD <EOL> return <EOL> def Parse ( gp ) : <EOL> startline = <NUM_LIT:0> <EOL> ps = pstate ( <EOL> gp = gp , <EOL> filename = gp . filename , <EOL> errorcnt = <NUM_LIT:0> , <EOL> state = INITIALIZE , <EOL> tokenlineno = <NUM_LIT:0> , <EOL> tokenstart = None , <EOL> fallback = None , <EOL> lhs = None , <EOL> lhsalias = None , <EOL> nrhs = <NUM_LIT:0> , <EOL> rhs = [ None ] * MAXRHS , <EOL> alias = [ None ] * MAXRHS , <EOL> prevrule = None , <EOL> declkeyword = None , <EOL> declargslot = None , <EOL> insertLineMacro = False , <EOL> declassoc = <NUM_LIT:0> , <EOL> preccounter = <NUM_LIT:0> , <EOL> firstrule = None , <EOL> lastrule = None , <EOL> ) <EOL> try : <EOL> fp = open ( ps . filename , "<STR_LIT:rb>" ) <EOL> except IOError : <EOL> ErrorMsg ( ps . filename , <NUM_LIT:0> , "<STR_LIT>" ) <EOL> gp . errorcnt += <NUM_LIT:1> <EOL> return <EOL> filebuf = fp . read ( ) <EOL> fp . close ( ) <EOL> lineno = <NUM_LIT:1> <EOL> cp = <NUM_LIT:0> <EOL> while cp < len ( filebuf ) : <EOL> c = filebuf [ cp ] <EOL> if c == '<STR_LIT:\n>' : <EOL> lineno += <NUM_LIT:1> <EOL> if c . isspace ( ) : <EOL> cp += <NUM_LIT:1> <EOL> continue <EOL> if filebuf [ cp : cp + <NUM_LIT:2> ] == "<STR_LIT>" : <EOL> cp += <NUM_LIT:2> <EOL> while cp < len ( filebuf ) : <EOL> if filebuf [ cp ] == '<STR_LIT:\n>' : <EOL> break <EOL> cp += <NUM_LIT:1> <EOL> continue <EOL> if filebuf [ cp : cp + <NUM_LIT:2> ] == "<STR_LIT>" : <EOL> cp += <NUM_LIT:2> <EOL> while cp < len ( filebuf ) : <EOL> if filebuf [ cp ] == '<STR_LIT:\n>' : <EOL> lineno += <NUM_LIT:1> <EOL> if filebuf [ cp - <NUM_LIT:1> : cp + <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> cp += <NUM_LIT:1> <EOL> break <EOL> cp += <NUM_LIT:1> <EOL> continue <EOL> ps . tokenstart = cp <EOL> ps . tokenlineno = lineno <EOL> if c == '<STR_LIT:">' : <EOL> cp += <NUM_LIT:1> <EOL> while cp < len ( filebuf ) : <EOL> c = filebuf [ cp ] <EOL> if c == '<STR_LIT:">' : <EOL> nextcp = cp + <NUM_LIT:1> <EOL> break <EOL> if c == '<STR_LIT:\n>' : <EOL> lineno += <NUM_LIT:1> <EOL> cp += <NUM_LIT:1> <EOL> else : <EOL> ErrorMsg ( ps . filename , startline , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ps . errorcnt += <NUM_LIT:1> <EOL> nextcp = cp <EOL> elif c == '<STR_LIT:{>' : <EOL> cp += <NUM_LIT:1> <EOL> level = <NUM_LIT:1> <EOL> while cp < len ( filebuf ) and ( level > <NUM_LIT:1> or filebuf [ cp ] != '<STR_LIT:}>' ) : <EOL> c = filebuf [ cp ] <EOL> if c == '<STR_LIT:\n>' : <EOL> lineno += <NUM_LIT:1> <EOL> elif c == '<STR_LIT:{>' : <EOL> level += <NUM_LIT:1> <EOL> elif c == '<STR_LIT:}>' : <EOL> level -= <NUM_LIT:1> <EOL> elif filebuf [ cp : cp + <NUM_LIT:2> ] == "<STR_LIT>" : <EOL> cp += <NUM_LIT:2> <EOL> while cp < len ( filebuf ) : <EOL> c = filebuf [ cp ] <EOL> if filebuf [ cp ] == '<STR_LIT:\n>' : <EOL> lineno += <NUM_LIT:1> <EOL> if filebuf [ cp - <NUM_LIT:1> : cp + <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> cp += <NUM_LIT:1> <EOL> break <EOL> cp += <NUM_LIT:1> <EOL> elif filebuf [ cp : cp + <NUM_LIT:2> ] == "<STR_LIT>" : <EOL> cp += <NUM_LIT:2> <EOL> while cp < len ( filebuf ) : <EOL> if filebuf [ cp ] == '<STR_LIT:\n>' : <EOL> lineno += <NUM_LIT:1> <EOL> break <EOL> cp += <NUM_LIT:1> <EOL> elif c == "<STR_LIT:'>" or c == '<STR_LIT:">' : <EOL> startchar = c <EOL> prevc = <NUM_LIT:0> <EOL> cp += <NUM_LIT:1> <EOL> while ( cp < len ( filebuf ) and <EOL> ( filebuf [ cp ] != startchar or prevc == '<STR_LIT:\\>' ) <EOL> ) : <EOL> c = filebuf [ cp ] <EOL> if c == '<STR_LIT:\n>' : <EOL> lineno += <NUM_LIT:1> <EOL> if prevc == '<STR_LIT:\\>' : <EOL> prevc = <NUM_LIT:0> <EOL> else : <EOL> prevc = c <EOL> cp += <NUM_LIT:1> <EOL> cp += <NUM_LIT:1> <EOL> if cp == len ( filebuf ) : <EOL> ErrorMsg ( ps . filename , ps . tokenlineno , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ps . errorcnt += <NUM_LIT:1> <EOL> nextcp = cp <EOL> else : <EOL> nextcp = cp + <NUM_LIT:1> <EOL> elif c . isalnum ( ) : <EOL> while c . isalnum ( ) or c == '<STR_LIT:_>' : <EOL> cp += <NUM_LIT:1> <EOL> if cp > len ( filebuf ) : <EOL> break <EOL> c = filebuf [ cp ] <EOL> nextcp = cp <EOL> elif filebuf [ cp : cp + <NUM_LIT:3> ] == "<STR_LIT>" : <EOL> cp += <NUM_LIT:3> <EOL> nextcp = cp <EOL> elif ( c in ( '<STR_LIT:/>' , '<STR_LIT:|>' ) ) and cp + <NUM_LIT:1> < len ( filebuf ) and filebuf [ cp + <NUM_LIT:1> ] . isalpha ( ) : <EOL> cp += <NUM_LIT:2> <EOL> while cp < len ( filebuf ) : <EOL> c = filebuf [ cp ] <EOL> if not ( c . isalnum ( ) or c == '<STR_LIT:_>' ) : <EOL> break <EOL> cp += <NUM_LIT:1> <EOL> nextcp = cp <EOL> else : <EOL> cp += <NUM_LIT:1> <EOL> nextcp = cp <EOL> token = filebuf [ ps . tokenstart : cp ] <EOL> parseonetoken ( ps , token ) <EOL> cp = nextcp <EOL> gp . rule = ps . firstrule <EOL> gp . errorcnt = ps . errorcnt <EOL> return </s>
