CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Find C/C++ Function definitions/prototype

 



SomeshSaraf
New User

May 8, 2009, 12:21 AM

Post #1 of 2 (2180 views)
Find C/C++ Function definitions/prototype Can't Post

Hi,

I need some help in how to find a C and C++ function declarations using Perl regular expression. This regular expression should be able to detect that a function definition has been encountered.

To be more specific I will take an example:

If we have a C or C++ function:

void XyzFunc(void)
{
}

in C++

void Xyz::XyzFunc(void)
{
}


then the regular expression should be able to detect above function definition.

I wrote a regular expression but the problem i am facing is that 'if' 'while' etc are getting recognized as funcitons. Also some of complex C/C++ statements are also getting recognized as functions.

Let me know if any more information required.

-Somesh


1arryb
User

May 8, 2009, 1:27 PM

Post #2 of 2 (2165 views)
Re: [SomeshSaraf] Find C/C++ Function definitions/prototype [In reply to] Can't Post

Hi Somesh,

Try googling "perl c++ parser". I did and it looks like the easiest way might be to run your c++ header files through ctags or gcc-xml then deal with that output in your perl program. C++ parsing is non-trivial: don't try it at home. Wink

Good luck,

Larry

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives