Sign in to follow this  
Nitage

C++ parser library?

Recommended Posts

Nitage    1107
I'm looking for a way to parse C++ in order to make a code analyzer (the end product will issue a series of warnings and errors that a compiler would miss). Does anyone know of a C++ parser library that could help me to accomplish this?

Share this post


Link to post
Share on other sites
Bregma    9214
Beware, C++ cannot be parsed by a context-free grammar. Simply parsing the syntax will not give you enough meaningful information that you can do better than a compiler at finding code problems. Just to parse C++ properly you have to perform semantic analysis.

Share this post


Link to post
Share on other sites
idbaxter    122
A full C++ parsing engine with complete name and type resolution
is available from
http://www.semanticdesigns.com/Products/FrontEnds/CppFrontEnd.html
You can customize it to enable arbitrary checks, and therefore
produce your "warnings and errors a compiler would miss".

Which warning and errors are you considering?

-- IDB

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Wixner
boost::spirit might work
http://www.boost.org/libs/spirit/index.html


As already suggested, boost::spirit lacks currently support for some features required to properly parse C++ without hackish workarounds.
However, if you check out the Google Summer of Code pages, you will see that boost is a SoC mentor organization, and on their "project ideas" page there is a proposal for a C++ parser implementation using the Boost/Spirit libraries.
This sounds like an interesting and challenging project, so if anybody here is an eligible student, you may want to consider checking it out.

http://code.google.com/soc/boost/about.html

Share this post


Link to post
Share on other sites
Kitt3n    468
Now what would really be cool is to use that code-parser to make
an 'header optimization-tool, moving headers from .h's to .cpp's
and using forward declaration where possible'...

Ah, going through that manually just plain sucks lol :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this