diff --git a/regexp.py b/regexp.py --- a/regexp.py +++ b/regexp.py @@ -294,9 +294,9 @@ class Regexp: class RegexpDFA: def __init__(self, rules, end_states, alphabet_index): - self.rules = rules + self.rules = rules or [1, 1] self.end_states = end_states - self.alphabet_index = alphabet_index + self.alphabet_index = alphabet_index or {"": 0} @classmethod def create(cls, pattern): @@ -308,10 +308,9 @@ class RegexpDFA: def match(self, s): st = 0 n = len(self.alphabet_index) - fail = len(self.rules) // n for c in s: - if c not in self.alphabet_index or st == fail: + if c not in self.alphabet_index: return False key = (st*n + self.alphabet_index[c]) st = self.rules[key]