def _get_re(self, patt, mtype=EXACT, callback=None): try: return self._patt_cache[patt] except KeyError: if mtype == EXACT: self._patt_cache[patt] = p = (compile_exact(patt), callback) return p elif mtype == GLOB: self._patt_cache[patt] = p = (re.compile(glob_translate(patt)), callback) return p elif mtype == REGEX: self._patt_cache[patt] = p = (re.compile(patt), callback) return p
def add_exact(self, symbol, state, action, next_state): cre = compile_exact(symbol) self._exact_transitions[(symbol, state)] = (cre, action, next_state)