Hi Everybody,
I am new to python and trying to learn it while working.
I need to find out the function name along with the parameters from a list of "*.C" Files using python regular expressions.
Example:
static void FunctionNameInC(const boolean_T *UnitDelay1_l, const
boolean_T *UnitDelay2_n)
{
Desired output is :
Function Name: FunctionNameInC
ParametrsList: const boolean_T *UnitDelay1_l, const
boolean_T *UnitDelay2_n
So far what I have tried is
import re
result=re.findall(r'\(\w+','static void FunctionNameInC(const boolean_T *UnitDelay1_l, const boolean_T *UnitDelay2_n)')
print result
output:
['(const']
which is far from acceptable,how to proceed with this?
(1) Problems I am facing, how do I recognize any line in a "*.c" file as a function definition . I thought of using the sequence "){" as identifying a function name,but my "C" code format is inconsistent at times it is
"){"
and at times it is
")\n{"
, how do I solve this issue in regex expression ,cause when I tried using in between
'\(\n\w+'
it failed horribly.
(2) Assuming problem 1 is over ,how will I backtrack in the string to print the function name,although I have tried using the
"^"
thing ,but to no success.
Any help is highly appreciated.
Regards
Nihar.
What I have tried:
So far what I have tried is
<pre>import re
result=re.findall(r'\(\w+','static void FunctionNameInC(const boolean_T *UnitDelay1_l, const boolean_T *UnitDelay2_n)')
print result
output:
['(const']