def scan(self, tokens, max_matches=six.MAXSIZE, overlap=False):
""""""
if not self.streamlined:
self.streamline()
matches = 0
i = 0
length = len(tokens)
while i < length and matches < max_matches:
try:
results, next_i = self.parse(tokens, i)
except ParseException as err:
i += 1
else:
if next_i > i:
matches += 1
if len(results) == 1:
results = results[0]
yield results, i, next_i
if overlap:
i += 1
else:
i = next_i
else:
i += 1
评论列表
文章目录