def _span ( typw ): """ count chars available for wildcard match arguments: typw - wildcard returns: non-negative count if any match possible, otherwise -1 """ k = minMatch(patn[mp:]) # calculate min char count to match rest of pattern # print "exclude=",k,"@",offs # calculate maximum chars a wildcard can match mx = ellyChar.findBreak(text,offs) - k # max span reduced by exclusion if mx < 0: return -1 # cannot match if max span < 0 tfn = Matching[typw] # char type matching a wildcard # print "text at",offs,"maximum wildcard match=",mx nm = 0 for i in range(mx): c = text[offs+i] # next char in text from offset if not tfn(c): break # stop when it fails to match nm += 1 # print "maximum wildcard span=",nm return nm
def findBreak ( self ): """ look for next token break in buffer arguments: self returns: remaining char count in buffer if no break is found otherwise, count of chars to next break if nonzero, but 1 if zero, """ if len(self.buffer) == 0: return 0 if self.buffer[0] == APO: return 1 k = ellyChar.findBreak(self.buffer) # print 'findBreak k=' , k if k > 2 and self.buffer[k-1] in [ APO , APX ]: k -= 1 if k > 2 and self.buffer[k-1] in [ APO , APX , COM , DOT ]: k -= 1 self.index = k return k
def findBreak ( self ): """ look for next token break in buffer arguments: self returns: remaining char count in buffer if no break is found otherwise, count of chars to next break if nonzero, but 1 if zero, """ k = ellyChar.findBreak(self.buffer) self.index = k return k