def parse(self, s):
if not s:
return
else:
for match in self.re_token.finditer(s):
imatch = self.re_indent.fullmatch(match.group(1))
if imatch:
text = imatch.group(1)
self.indent = imatch.group(2)
else:
text = match.group(1)
self.indent = ""
if match.group(2) is None:
if match.end() != len(s):
raise Exception(
"Not terminated token: %r" % s[match.end():])
yield (text, None, None, None)
break
else:
fmatch = self.re_field.fullmatch(match.group(2))
if not fmatch:
raise Exception(
"Cannot parse token: %r" % match.group(2))
yield (text, fmatch.group(1), fmatch.group(3),
fmatch.group(2))
评论列表
文章目录