Modifying Token Stream

Is there a way to modify the token stream as it is being lexed?

I need to look for a token followed by a comment with a particular content and replace them with a string literal.

I am writing a custom tool that uses a MatchCallback to match certain nodes, but the identifiers that I need to replace are not valid (they will be code-genned before compilation), so I need to replace them with something that is actually valid (and useful).