C Parser in C # or .Net in general

For my thesis, I need to implement a certain static analysis of the C code, and I am desperately looking for frameworks / libraries that would allow me to parse the C source code, divide it into separate functions, so that each function determines which variables are changed in the function body and automatically receives specific annotations for the code. Is there any good framework written in C # or even as a .Net class for this purpose?

+4
source share
4 answers

How about googling for "C Parser written in C #"?

I got this as the first link: http://code.google.com/p/cpp-ripper/

Also, I think C grammar can be found in quite a few places, so can you just open your .NET lex / yacc version and go from there?

+8
source

You may need to check the ANTLR. It comes with versions of several versions, including C and C #. The ANTLR website has free grammars , including C.

+2
source

I had a similar problem and did a research on the YACC tools for C #. I chose the Gold Parsing System with a semantic engine. My project analyzed SQL queries and generated logical query plans (from a subset of T-SQL grammar).

I really recommend it. These 2 libraries make the parsing painless and allow you to map the grammar to the object model in your code. It feels very intuitive and makes my project successful :) However, it may not have some advanced ANTLR features, so keep a close eye on your needs.

Gold Project http://www.devincook.com/goldparser/

Semantic Lib Engine http://code.google.com/p/bsn-goldparser

+1
source

If you like to use the GPL'd code, you may need the GCC source code. If you need to do this in .Net, you can always use p / invoke to call code from the GCC libraries.

0
source

All Articles