Under The Hood

Here's the non-backtracking implementation of the "and" pattern:

class AndP (Pattern):
   def Match (self, subject):
      for pat in self.pats:
         if not pat.Match (subject):
            return False
      return True
   def __init__ (self, *pats):
      self.pats = pats
New Models for Processing Text and XML with Python Sam Wilmott
Slide 18 of 51        www.wilmott.ca