Look at what the perl script at http://www.gson.org/egypt/ does -- if you are using gcc, you can compile with certain options to generate info from the source code into an intermediate file and then parse this intermediate file with a script to get the info you need. A bit complex, but useful if you are trying to read through code you are maintaining. A compiler is better than a regex for this, I think, for C.
Also ctags/etags like another comment mentioned as also the cscope utility.
Re:Introduction to sed
by freemarketteddy on Sunday October 09, 2011 @02:48AM
(#3089869)
I checked out Egypt.It is pretty cool but unfortunately it doesnt seem to have support for Objective C.
In particular, `ctags -x` generates human-readable tabular output (instead of the normal output designed for parsing by text editors) and annotates each symbol to indicate whether it's a variable, function, macro, etc.
If you want to get a list of all function names from file "foo.c", you could do something like:
ctags -x foo.c | awk '$2=="function"{print $1}'
I know it can be done through sed,but a perfect regex for parsing functions and nothing else can be complex and I am wondering if someone has already done it.