def parse(self, generator):
        """Parse an iterable source of strings into a generator"""
        gen = iter(generator)
        for line in gen:
            block = {}
            for rule in self.rules:
                if rule[0](line):
                    block = rule[1](line, gen)
                    break
            yield block
Parse an iterable source of strings into a generator