My original grammar uses the skip command to ignore whitespaces in the parsing process.
WS : [ \t]+ -> skip ;
However for refactoring methods I need to send whitespace tokens to a hidden channel to use the TokenStreamRewriter according to this receipe: ANTLR4: TokenStreamRewriter output doesn't have proper format (removes whitespaces)
WS : [ \t]+ -> channel(HIDDEN);
The problem is now that the parser recognizes whitespaces as tokens which I want to avoid in the default parsing process.
Is it possible to switch between two different implementations of the same rule dependent on the regular parsing process or the parsing process for refactoring methods (with the same grammar)?
Do I need semantic predicates for this? Or is there a method available in the CommonTokenStream to skip or enable whitespacces?