You could override the nextToken() function and return your virtual token under the specific condition you have. Without going to the runtime I see no way to do this, however.
How to insert text or token into the token stream in the lexer?
Question
I would like to insert a token right before EOF during lexing. Is this possible with antlr3 (C-target)?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow