[antlr-interest] use channel=HIDDEN now

Kay Roepke kroepke at classdump.org
Tue Oct 17 03:56:20 PDT 2006


Ohh, afterthoughts, as soon as you send a mail ideas rush to your  
brain...

On Oct 17, 2006, at 12:39 PM, Kay Roepke wrote:

> 	tokenStream.channelOverrideMap.put(new Integer(YourLexerClass.WS),  
> new Integer(Token.DEFAULT_CHANNEL));

Fix: This must be:
	tokenStream.setTokenTypeChannel(YourLexerClass.WS,  
Token.DEFAULT_CHANNEL);
otherwise the channelOverrideMap will not be created. Doh!


> This is more of a hack, of course, but this way you don't have to  
> manually specify every single tokentype in the channelOverrideMap.

Clarification: This should read: "[...] manually specify every single  
tokentype not on the default channel in the channelOverrideMap."

Enhancement idea:
It might be useful to add a method to CommonTokenStream to make it  
override whole channels, not only based on tokentypes. With this you  
could say
	CommonTokenStream tokenStream = new CommonTokenStream(lexer);
	tokenStream.setChannelRedirection(Token.HIDDEN_CHANNEL,  
Token.DEFAULT_CHANNEL);

Maybe this rather should go into TokenRewriteStream, not sure.

-k, who has a rather severe lack of coffee today.





More information about the antlr-interest mailing list