With ctags , one can search for functions, variables, structures and what not in the code, for e.g.. I wanted to get the line numbers where all conditional loops are called in the code.
For e.g.:
1 #include <stdio.h>
2
3 void funcA() {}
4 void funcB(int a){}
5
6 int main() {
7 int a = 0;
8
9 if(a == 1)
10 {
11 funcA();
12 }
13 else
14 {
15 funcB(a);
16 }
17
18 while(1);
19
20 return 0;
21 }
22
In the example code snippet, with ctags command options, one can find out
funcA @ line #3
funcB @ line #4
Is there any option in ctags to find 'if' loop called at line number 9, 'else' @ line #13. Likewise, 'while' @ line #18 ?
If not ctags, any other tool to parse through code to find out such conditionals loops? Writing own parser is another alternative, but then figuring out keywords whether in comments can get challenging.
You should be able to do this with Exuberant Ctags if you're willing to write your own regular expressions. See
--regex-<LANG>
under Options in the manual.As an alternative, you could try libclang to parse your code into an abstract syntax tree (AST), and find the interesting elements programmatically.