[antlr-interest] Occasionally match hidden channel

Zenzike zenzike at gmail.com
Thu Dec 18 10:04:55 PST 2008


I'm trying to make it so that input only occasionally matches tokens
that are sent to the hidden channel.
My grammar has something along the following:

SLASHSLASH : '\\\\' {$channel=HIDDEN};     // For the symbols "\\"

This is regarded as whitespace in the language I'm trying to define,
and should be able to
appear between any two tokens. However, occasionally, I want to make
sure that there is definitely
a SLASHSLASH token between two other tokens.

As far as I can tell, the way to do this is to hide the SLASHSLASH
(which I have done),
and in places where it is needed, I should query the hidden channel --
but I can't find
any documentation about how this done (although there seems to be
plenty saying that it is possible!)

Something like this would be ideal:

rule : TOKEN1 {channel.hidden.match(SLASHSLASH)} TOKEN2 ;

What is the right syntax?

Many thanks!

zenzike


More information about the antlr-interest mailing list