[antlr-interest] White space skip in antlr 3.1

Gavin Lambert antlr at mirality.co.nz
Tue Jan 15 10:39:38 PST 2008


At 00:45 16/01/2008, Adam Connelly wrote:

>I think I've noticed that before.  I tend to just set the channel 
>to hidden:
>
>WS       :           (' '|'\t'|'\f'|'\n'|'\r')+{ $channel=HIDDEN; 
>};
>
>This means that the parser does not see the whitespace, but isn't 
>exactly the same as skip() (I don't think) although I don't know 
>the difference.  Anyhow, it's always worked for me in C#.

skip() will avoid generating a token entirely.  $channel = HIDDEN 
will still generate a token, but mark it as on a different channel 
from the normal parsing, which will make the parser ignore it but 
leave it accessible to actions if need be. 



More information about the antlr-interest mailing list