I have a school project to develop a static analyzer in C for C.
Where to begin? What resources can help me?
I guess I will need to parse C, so what are good parsers for C or tools for creating C parsers?
First, I will go over to antlr , look at the beginning of the manual , it has a lot of information about parsing, etc., I personally use antlr, since it gives a choice of the purpose of code generation .
antlr c ++, .
.
, Clang ( , , , , / ).
, C?
langauge (, #, Java, Python), ANTLR .
C , lex yacc (flex bison) , , , .
, Uno , . lex/yacc . ++.
, , SpinRoot. Wikipedia .
- . Antlr , C ( ++). - , gcc -E.
gcc -E
As for the rest, you can take a look at some of the existing sources of analyzers, namely Clang and CIL , read about SSA representation and abstract interpretation . Choosing the right intermediate view for your code is the key.
I doubt this can be a simple task in simple C, so you are likely to end up injecting some kind of DSL on top of it to handle AST and transformations. It sounds like more than a typical school project.
Source: https://habr.com/ru/post/1790355/More articles:Easy access to the database - javaThe product name of the custom product is not stored in a non-standard repository - magentogdb claims it doesn't know how to run - xcodeC # WinForms drags controls with the mouse - c #Библиотека лимонного графика на R с использованием Rcpp - moduleHover Intent Plugin - jqueryUsing struct as SSE vector type in gcc? - c ++Checking the size of the tr1 array at compile time - c ++VIM - Самый быстрый способ захватить неудобный текстовый блок - vimsearch in part of array list - java - javaAll Articles