def _next_pattern(self):
current_state = self.state_stack[-<NUM_LIT:1>]<EOL>position = self._position<EOL>for pattern in self.patterns:<EOL><INDENT>if current_state not in pattern.states:<EOL><INDENT>continue<EOL><DEDENT>m = pattern.regex.match(self.source, position)<EOL>if not m:<EOL><INDENT>continue<EOL><DEDENT>position = m.end()<EOL>token = None<EOL>if pattern.next_state:<EOL><INDENT>self.state_stack.append(pattern.next_state)<EOL><DEDENT>if pattern.action:<EOL><INDENT>callback = getattr(self, pattern.action, None)<EOL>if callback is None:<EOL><INDENT>raise RuntimeError(<EOL>"<STR_LIT>" %<EOL>pattern.action)<EOL><DEDENT>if "<STR_LIT>" in m.groups():<EOL><INDENT>value = m.group("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>value = m.group(<NUM_LIT:0>)<EOL><DEDENT>token = callback(string=value, match=m,<EOL>pattern=pattern)<EOL><DEDENT>self._position = position<EOL>return token<EOL><DEDENT>self._error("<STR_LIT>",<EOL>start=self._position, end=self._position + <NUM_LIT:1>)<EOL>
Parses the next pattern by matching each in turn.