[antlr-interest] White space skip in antlr 3.1

Adam Connelly adam.rpconnelly at googlemail.com
Wed Jan 16 04:44:44 PST 2008


So I take it that in general (unless you have memory limitations or
want to avoid creating unnecessary tokens) you want to use $channel =
HIDDEN?

Adam

On 15/01/2008, Gavin Lambert <antlr at mirality.co.nz> wrote:
> 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