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

Terence Parr parrt at cs.usfca.edu
Tue Jun 5 11:52:09 PDT 2007


On Jun 5, 2007, at 9:08 AM, Luke A. Guest wrote:

> 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.

It neatly solves the problem of " how to why not throw away but avoid  
parsing whitespace and comments"? This is a seriously huge problem if  
you're trying to build something that merely tweaks input. I also  
have the token rewrite stream stuff now, which is often a better  
solution if you don't need to build trees.
Ter



More information about the antlr-interest mailing list