Hi,
I’d like to parse a C file to identify how much cases are in a switch and thought that I could use the parser from sublimetext.
The file I intend to analyze can have 2 different types of implementation :
- a switch with only 2 cases :
switch(Data)
{
case 0: value = 10 ; break;
case 1 : value = 20 ;break;
default:
somevar = false;
value = 0 ;
----
break;
}
==> for instance would print “section with 2 case”
- a switch with many (unlimited) cases :
switch(Data)
{
case Constant1 : value = 10 ; break;
case constant2 : value = 20 ;break;
case constant3 : value = 30 ;break;
case constant4 : value = 40 ;break;
default:
somevar = false;
value = 0 ;
----
break;
}
==> would print “section with case : Constant1, Constant2, Constant3, Constant4”
I’ve tried to do that directly in Python which seems to be hard to do. Instead I think a python plugin could use the parser.