def bygroups(*args):
def callback(lexer, match, ctx=None):<EOL><INDENT>for i, action in enumerate(args):<EOL><INDENT>if action is None:<EOL><INDENT>continue<EOL><DEDENT>elif type(action) is _TokenType:<EOL><INDENT>data = match.group(i + <NUM_LIT:1>)<EOL>if data:<EOL><INDENT>yield match.start(i + <NUM_LIT:1>), action, data<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if ctx:<EOL><INDENT>ctx.pos = match.start(i + <NUM_LIT:1>)<EOL><DEDENT>for item in action(lexer, _PseudoMatch(match.start(i + <NUM_LIT:1>),<EOL>match.group(i + <NUM_LIT:1>)), ctx):<EOL><INDENT>if item:<EOL><INDENT>yield item<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if ctx:<EOL><INDENT>ctx.pos = match.end()<EOL><DEDENT><DEDENT>return callback<EOL>
Callback that yields multiple actions for each group in the match.