54 | | while text: |
55 | | eaten = 0 |
56 | | for match in self.regexes[self.state].finditer(text): |
57 | | for name, toktext in match.groupdict().iteritems(): |
58 | | if toktext is not None: |
59 | | tok = self.toks[name] |
60 | | new_state = tok.next |
61 | | eaten += len(toktext) |
62 | | yield (tok.name, toktext) |
63 | | if new_state: |
64 | | self.state = new_state |
| 54 | end = len(text) |
| 55 | state = self.state |
| 56 | regexes = self.regexes |
| 57 | toks = self.toks |
| 58 | start = 0 |
| 59 | |
| 60 | while start < end: |
| 61 | for match in regexes[state].finditer(text, start): |
| 62 | name = match.lastgroup |
| 63 | tok = toks[name] |
| 64 | toktext = match.group(name) |
| 65 | start += len(toktext) |
| 66 | yield (tok.name, toktext) |
| 67 | |
| 68 | if tok.next: |
| 69 | state = tok.next |