def match(self, regex: Pattern) -> bool:
    match = regex.match(self.definition, self.pos)
    if (match is not None):
        self._previous_state = (self.pos, self.last_match)
        self.pos = match.end()
        self.last_match = match
        return True
    return False
def match(self, regex: Pattern) -> bool:
    match = regex.match(self.definition, self.pos)
    if (match is not None):
        self._previous_state = (self.pos, self.last_match)
        self.pos = match.end()
        self.last_match = match
        return True
    return False