[antlr-interest] Get tokens in the Hidden channel

Jayani Withanawasam jayaniw at ecollege.com
Wed Sep 7 05:47:03 PDT 2011


Found the solution!

 

You can retrieve comments from CommonTokenStream.

It contains all the tokens including tokens in the hidden channel.

 

Thanks everyone!

Jayani.

 

From: Jayani Withanawasam 
Sent: Tuesday, September 06, 2011 9:10 PM
To: antlr-interest at antlr.org.
Cc: Rajitha Jayawickrama
Subject: Get tokens in the Hidden channel 

 

Hi all,

 

In my lexer, the comments (single line and multi line) are sent to
hidden channel, thus prevent them from passing to the parser.

 

Here's the related code:

 

COMMENT     :     '--' (~('\r' | '\n'))* NLfrag { $channel = HIDDEN; }
;

 

Is there any way to get these tokens from hidden channel and do some
processing on them?

My target language is C# .Net 2.0 and ANTLR version is 3.1.

 

Appreciate your help on this.

 

Thanks,

Jayani Withanawasam

 



More information about the antlr-interest mailing list