>the LALR generator is one of mine and the idea here would be to select>automatically the right lexer from the currently accepted tokens. I>have the feeling that it must be doable. The target is to be able to>write grammars with such dependencies naturally without any (user>level) grammar actions and very minimal lexer meta-information (such as>which lexer produces which tokens).

You have not written if your generator supports LALR(k) or just LALR(1).
In the later case my suggestion is that you change your generator to an
LR(1) generator. Not only will you get an easy implementation of what
you want. You will also catch syntax errors right after the offending
token is put in the window, such that you can get better error reporting
and recovery. Do not be afraid the parsers will be too big. That would
have been the case 25 years ago, but not for the last 10 years.

If you don't to go that way, then do as I suggested in my previous
posting: Say you have a parse stack W and a terminal been pushed on the
stack. Now you want to know if a terminal t is acceptable. Then you
copy W onto a new stack W' and use W' to parse with t in the window. If
t is stacked, then t is acceptable. My guess is that you will find this
approach will make the parsers a bit slow.

The later approach is so simple to implement, that I think somebody
would have put it into some parser generator if it was a facility, that
would scanning and parsing significantly easier. To me it looks like
you have an idea for a solution with no problem.