Using PLY

huy nytimes at swiftdsl.com.au
Fri Sep 17 07:31:18 EDT 2004


Maurice LING wrote:
> Hi,
> 
> I know that PLY lex is able to do line counting. I am wondering if there 
> is a way to count the number of each keywords (tokens) in a given file? 
> For example, how many IF tokens etc?
> 
> Thanks
> Maurice


PLY can do much more then line counting. Build an AST then just count 
your IF tokens. If you can use ply to recognise your if tokens, then you 
can easility count them.

It's kinda vague what you are wanting to do ? Is it source code you are 
parsing or text with keywords ?

Huy



More information about the Python-list mailing list