Posted By

prsannalkr on 01/29/09


Tagged

perl


Versions (?)

List C & CPP function names from a file using perl


 / Published in: Perl
 

  1. Hi All,
  2.  
  3. Need a help to get the function name and associated line number in a file using perl.
  4.  
  5.  
  6.  
  7. For example:
  8.  
  9. Consider file name is a.c and it is having functions definition in the following format
  10.  
  11.  
  12.  
  13. Return type
  14.  
  15. Function_Name(
  16.  
  17. Int a,
  18.  
  19. Char *b
  20.  
  21.  
  22. )
  23.  
  24. {
  25.  
  26. ……..
  27.  
  28. ……
  29.  
  30. }
  31.  
  32.  
  33.  
  34. I need out put in the following format:
  35.  
  36.  
  37.  
  38. Line No : Function_Name
  39.  
  40.  
  41.  
  42.  
  43.  
  44. NOTE: Need to consider the case of opening brace “{” of function definition may start immediately after closing parenthesis of function. Ex: func_Name(.., ..) { as in above it appeared in the new line.
  45.  
  46.  
  47.  
  48. Kindly help me out to solve this problem at the earliest. It’s a requirement in our project.

Report this snippet  

You need to login to post a comment.