def iterscan(self, string, idx=<NUM_LIT:0>, context=None):
match = self.scanner.scanner(string, idx).match<EOL>actions = self.actions<EOL>lastend = idx<EOL>end = len(string)<EOL>while True:<EOL><INDENT>m = match()<EOL>if m is None:<EOL><INDENT>break<EOL><DEDENT>matchbegin, matchend = m.span()<EOL>if lastend == matchend:<EOL><INDENT>break<EOL><DEDENT>action = actions[m.lastindex]<EOL>if action is not None:<EOL><INDENT>rval, next_pos = action(m, context)<EOL>if next_pos is not None and next_pos != matchend:<EOL><INDENT>matchend = next_pos<EOL>match = self.scanner.scanner(string, matchend).match<EOL><DEDENT>yield rval, matchend<EOL><DEDENT>lastend = matchend<EOL><DEDENT>
Yield match, end_idx for each match