[antlr-interest] How to do a specific operation once on every token in the _parser_?

Terence Parr parrt at cs.usfca.edu
Wed Oct 4 10:13:09 PDT 2006


On Oct 4, 2006, at 7:18 AM, Jan Harder wrote:

> Hello,
>
> I wrote a parser for visual basic using ANTLR 2.7.6 and I want to  
> compute the halstead metric for parts of the code. Basically, this  
> means that I need to classify all tokens in two groups  
> (identifiers, literals vs. everything else) and count the  
> occurrences of tokens with the same text. The classification and  
> the counting is very easy to do, but my problem is that I am not  
> sure _where_ to do this.

How about just subclassing the common token stream and adding your  
counting in there?
Ter



More information about the antlr-interest mailing list