[antlr-interest] What are channels and what are they used for?

Luke A. Guest laguest at archangeli.co.uk
Tue Jun 5 09:08:59 PDT 2007


On Tue, 2007-06-05 at 09:01 -0700, Terence Parr wrote:
> Hi. :)  token channels are a way to avoid discarding tokens (still  
> send tokens to the parser) w/o having the parser see them.  So, you  
> could send whitespace on one channel, javadoc on another, and the  
> java tokens on the default channel.  Then actions can access the  
> hidden channels for translation.

Ok, interesting idea (I spose). Not come across this before.

Is there any reason why 99 was defined as the hidden channel rather than
stating default=1 and hidden=0. You've already stated that there is no
upper bound on the number of channels, so it would make more sense, I'd
say.

For example, when I was trying to define my specification for
ANTLR.Token, I originally thought that hidden=99, so I created:

   type Channel_Type is range 0 .. 99;
   
   Default_Channel : constant Channel_Type := Channel_Type'First;
   Hidden_Channel  : constant Channel_Type := Channel_Type'Last;

Which is wrong now I know ;)

Thanks,
Luke.




More information about the antlr-interest mailing list