Jump to content

  • Log In with Google      Sign In   
  • Create Account

Tool (c/c++) for parsing/evaluating a c header file?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 CaptainMurphy   Members   -  Reputation: 262

Like
0Likes
Like

Posted 28 March 2012 - 03:27 PM

Hi, I'm looking for a tool/library to parse a c header file, while also evaluating the preprocessor macros and any calculations like the values of enum items or any constant math expressions.(things usually done during compile time e.g."#define bla ~4 << 2").

I've been using swig with the xml output, but I find it painful to generate all the xml files, and then parsing them and calculating all the math expressions, enums, and then storing values of identifiers to be used in further math expression. Also swig has trouble with some uses of unions in structs as well.

I've been searching, but I haven't really found anything to fit that criteria. though there seems to be a lot of libaries out there that do parsing, so I am hoping that I've missed or overlooked one that could help me.

Thanks.

Sponsor:

#2 TheUnbeliever   Members   -  Reputation: 961

Like
1Likes
Like

Posted 28 March 2012 - 09:40 PM

I haven't used it, so take this with a huge pinch of salt, but I believe this is one of the main use-cases for LLVM. See, for example, Writing an LLVM Pass.
[TheUnbeliever]

#3 CaptainMurphy   Members   -  Reputation: 262

Like
0Likes
Like

Posted 28 March 2012 - 10:10 PM

I haven't used it, so take this with a huge pinch of salt, but I believe this is one of the main use-cases for LLVM. See, for example, Writing an LLVM Pass.


Looks promising, thanks.

... taking forever to compile though :)

#4 Ashaman73   Crossbones+   -  Reputation: 7992

Like
0Likes
Like

Posted 29 March 2012 - 12:55 AM

I use mcpp a standard c/c++ preprocessor to build my shader/xml files.

#5 CaptainMurphy   Members   -  Reputation: 262

Like
0Likes
Like

Posted 30 March 2012 - 03:53 AM

I use mcpp a standard c/c++ preprocessor to build my shader/xml files.


Looks pretty useful, but not enough for what I need.

I've given up on anything c/c++ based, can't get any of the libraries/tools to compile under windows/mingw/cygwin.

Python seems to have a few c parsing tools like pycparser, and it takes hardly any effort to install unlike c/c++.

#6 RobTheBloke   Crossbones+   -  Reputation: 2341

Like
0Likes
Like

Posted 12 April 2012 - 09:39 AM

gccxml ?

#7 Martins Mozeiko   Crossbones+   -  Reputation: 1422

Like
0Likes
Like

Posted 12 April 2012 - 02:45 PM

Boost.Wave




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS