2

What I'm doing?

I'm building a C code analyzer. to do some checks at the compile time. and if passed, compile it.

What do I want?

for my goal, I should lex and parse user source code. maybe in the future, I write a lexer and parser for this, but now I just want some tools to do this for me and just give me the final AST, so I can go through that and do my analysis. so: I want something like a library that gets some source code in c, parses it, and gets me an ast structure.

What I did?

I searched for some tools to do that. it seems clang has some facilities and libraries for this, but I couldn't find any helpful thing. Does anyone know some useful ways or things for this goal?

thank you for helping me!

Redwan
  • 97
  • 6
  • 1
    Both clang and gcc can be used to parse C (amongst other languages). Since they are both production compilers, they can probably be relied upon to accurately parse the source code. Unfortunately, the quality of the documentation lags behind, so you'll need to read and research. – rici Mar 31 '22 at 20:00
  • 2
    We try to avoid arguments of the form "which is the best X" so software recommendations are out of scope here. Also, you are most likely to get a good response if you ask a specific question. Your best bet is to decide which library you want to try and see if you can at least find enough documentation to get started. Then try to do something simple, and if you run into a specific difficulty, ask about that. Good luck with the project. – rici Mar 31 '22 at 20:27
  • See https://stackoverflow.com/q/34502255/120163 – Ira Baxter Apr 03 '22 at 08:41

0 Answers0