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

Terence Parr parrt at cs.usfca.edu
Tue Jun 5 16:56:40 PDT 2007


On Jun 5, 2007, at 4:33 PM, Robin Davies wrote:

> Are there ways to attach a parser to a channel other than default?
>
> I'm working on a grammar that has need of a javaoc-like facilities,  
> and a C#-style preprocessor (i.e. very simple #if's and #defines);  
> and if channels actually do anything right now, I'm pretty certain  
> I could make use of it. Currently, I'm pushing token text for  
> ("#'  (~LF)* LF ) out to a secondary parser. But I can't help  
> feeling that there's a better way to do this.

I think that you can tell the token stream which channel to listen to:

	public CommonTokenStream(TokenSource tokenSource, int channel) {
		this(tokenSource);
		this.channel = channel;
	}

use that ctor and I should be happy.  The parser actually will have  
no idea what channel is listening to. :)

> (Absolutely loving ANTLR 3, btw. After all the grim alternatives --  
> LL(k), LALR(1) and/or hopelessly license-encumbered -- ANTLR v3 is  
> a marvelous change. In my opinion, the release of ANTLR v3 is  one  
> of the great landmarks in the recent history of software  
> development. Very exciting! Congratulations on your release.).

Thanks! There are number of people who have worked very hard on this  
release, including all of the target release people and of course  
Jean Bovet with his ANTLRWorks.

Ter



More information about the antlr-interest mailing list