List C & CPP function names from a file using perl


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  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.  
  35. I need out put in the following format:
  36.  
  37.  
  38.  
  39. Line No : Function_Name
  40.  
  41.  
  42.  
  43.  
  44.  
  45. 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.
  46.  
  47.  
  48.  
  49. Kindly help me out to solve this problem at the earliest. It’s a requirement in our project.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.