Regular expression to match (C) function calls
-
09-06-2019 - |
Question
Does anyone have a regular expression for matching function calls in C programs ?
Solution 2
After a bit more searching I decided to let the compiler do the hard work.
Get the compiler to produce a Register Transfer Language (RTL) file using the -dr options of gcc.
The produced RTL file has the suffix .rtl or .expand.
This file is far easier to parse as the functions calls are already identified.
OTHER TIPS
Since C isn't a regular language and C function calls can contain arbitrary argument expressions, I fear the answer to your question is “no.”
I doubt you can find a regex that matches all (and only) the function calls in some source code. But maybe you could use a tool like Understand, or your IDE, to browse your code.