class_docstr: Base class for implementations of deterministic finite
  automata.
  
  This is abstract to allow for the possibility of states
  being calculated lazily as we traverse the DFA (which
  we make heavy use of in our L* implementation - see
  lstar.py for details).
  
  States can be of any hashable type.
class_docstr_tok: ["Base","class","for","implementations","of","deterministic","finite","automata",".","This","is","abstract","to","allow","for","the","possibility","of","states","being","calculated","lazily","as","we","traverse","the","DFA","(","which","we","make","heavy","use","of","in","our","L","*","implementation","-","see","lstar.py","for","details",")",".","States","can","be","of","any","hashable","type","."]
docstr: Return all pairs ``(u, v)`` such that ``self.matches(string[u:v])``.
docstr_tok: ["Return","all","pairs","``","(","u",",","v",")","``","such","that","``","self.matches","(","string","[","u",":","v","]",")","``","."]
code: def all_matching_regions(self, string):
      """Return all pairs ``(u, v)`` such that ``self.matches(string[u:v])``."""
  
      # Stack format: (k, state, indices). After reading ``k`` characters
      # starting from any i in ``indices`` the DFA would be at ``state``.
      stack = [(0, self.start, range(len(string)))]
  
      results = []
  
      while stack:
          k, state, indices = stack.pop()
  
          # If the state is dead, abort early - no point continuing on
          # from here where there will be no more matches.
          if self.is_dead(state):
              continue
  
          # If the state is accepting, then every one of these indices
          # has a matching region of length ``k`` starting from it.
          if self.is_accepting(state):
              results.extend([(i, i + k) for i in indices])
  
          next_by_state = defaultdict(list)
  
          for i in indices:
              if i + k < len(string):
                  c = string[i + k]
                  next_by_state[self.transition(state, c)].append(i)
          for next_state, next_indices in next_by_state.items():
              stack.append((k + 1, next_state, next_indices))
      return results
  
imports: import threading
  from collections import Counter, defaultdict, deque
  from math import inf
  from hypothesis.internal.reflection import proxies
label_desc: Use image node_id 10 for calling the DFA obj's underlying member method code with example usage: obj.all_matching_regions(string) and returns: results