def using(_other, **kwargs):
gt_kwargs = {}<EOL>if '<STR_LIT:state>' in kwargs:<EOL><INDENT>s = kwargs.pop('<STR_LIT:state>')<EOL>if isinstance(s, (list, tuple)):<EOL><INDENT>gt_kwargs['<STR_LIT>'] = s<EOL><DEDENT>else:<EOL><INDENT>gt_kwargs['<STR_LIT>'] = ('<STR_LIT:root>', s)<EOL><DEDENT><DEDENT>if _other is this:<EOL><INDENT>def callback(lexer, match, ctx=None):<EOL><INDENT>if kwargs:<EOL><INDENT>kwargs.update(lexer.options)<EOL>lx = lexer.__class__(**kwargs)<EOL><DEDENT>else:<EOL><INDENT>lx = lexer<EOL><DEDENT>s = match.start()<EOL>for i, t, v in lx.get_tokens_unprocessed(match.group(), **gt_kwargs):<EOL><INDENT>yield i + s, t, v<EOL><DEDENT>if ctx:<EOL><INDENT>ctx.pos = match.end()<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>def callback(lexer, match, ctx=None):<EOL><INDENT>kwargs.update(lexer.options)<EOL>lx = _other(**kwargs)<EOL>s = match.start()<EOL>for i, t, v in lx.get_tokens_unprocessed(match.group(), **gt_kwargs):<EOL><INDENT>yield i + s, t, v<EOL><DEDENT>if ctx:<EOL><INDENT>ctx.pos = match.end()<EOL><DEDENT><DEDENT><DEDENT>return callback<EOL>
Callback that processes the match with a different lexer.

The keyword arguments are forwarded to the lexer, except `state` which
is handled separately.

`state` specifies the state that the new lexer will start in, and can
be an enumerable such as ('root', 'inline', 'string') or a simple
string which is assumed to be on top of the root state.

Note: For that to work, `_other` must not be an `ExtendedRegexLexer`.