insert source code from parser to lexer

Hello,

In parsing a function definition, at certain places, for example, after a "{",
I would like to dynamically insert some code, for example, "static int count=0; count++;". Injecting tokens can be a choice, but I have to create the tokens manually. So I would like to insert source code, and let the lexer to lex it into the new tokens.

Any suggestion how to proceed?

Thanks,
Hongbo