Regexps are not a proper tool for extracting some semantic information from source code files (though they're good for syntax highlighting - because syntax is often expressed through regular expressions). Regexps can't handle nested constructions, track what is going on, distingiush types and symbols.
I'd recommend some specialized tool that is really aware of the language structure, like ctags
or python-pygccxml
.
ctags
is a program that generates a list of entities in a C source with with their places (used to assist navigation through C code bases in text editors like vi
and emacs
). python-pygccxml
is a Python binding to C library libgccxml
that uses gcc internals to analyze the code and produces rich and structured output about program semantics.