What's wrong with the parser communicating its state to the lexer at the
same time it asks the lexer for the next token?

I'm about to do exactly this for a C-like language that has its own
macro processor. Some of the macros are only valid in certain contexts.
If I pass a little context information to lex from the parser, all the
macros can be handled by lex. Fortunately, this is a by-hand lex and
parser; who knows how to teach lex and yacc this trick without globals?