This project is read-only.

Extract C# code related Metrics

Aug 11, 2011 at 11:21 AM


I am totally new to Antlr C# grammar. I am trying to use this grammar to extract C# code related metrics like Halstead and Object Oriented (according to C&K Model).

I am stuck on extracting details as following.

I need to extract operators and operands from the source code. If you could please explain bellow scenarios I could be able to overcome this (Need to know in which place that I need to catch the detail from the grammar).


(1)    Int x = 1;


Operators { = }

Operands { int , x, 1 }


(2)    For( int k = 0; k < 10; k++) { }


Operators { for(), = , =, ++ }

Operands { int, k, 0, k, 10, k }

I need to get only the count of these Operators and Operands by incrementing a variable. Please be kind enough to help me. Thanks.