Dear list, I am pleased to announce the first release of Yacfe, Yet Another C/C++ Front-End, which is an OCaml API to write style-preserving source-to-source transformations such as refactorings on C or C++ source code.
The goal of Yacfe is to parse the code as-is, and to represent it internally as-is. Yacfe thus maintain in the abstract syntax tree (AST) as much information as possible so that one can transform this AST and unparse it in a new file while preserving the coding style of the original file. Yacfe preserves the whitespaces, newlines, indentation, and comments from the original file, as well as the C preprocessor (cpp) macros and cpp directives. Other source-to-source transformation tools such as CIL [1] do not preserve this coding style as they first call cpp on the original file and perform the transformation on the preprocessed file. The AST of Yacfe on the opposite contains explicit constructions representing cpp directives, macro definitions, or cpp idioms such as macro iterators as in 'list_for_each(i, x) { printf("%d", x); }'. "What You See In The Yacfe AST Is What Was Written". The Yacfe abstract syntax tree is thus in fact more a concrete syntax tree (cf parsing_c/ast_c.ml). Yacfe is free software under GPL license and is available at http://aryx.kicks-ass.org/~pad/software-yacfe.php A simple example of the code of a style-preserving program transformation using the Yacfe API is available here: http://aryx.kicks-ass.org/~pad/software/project-yacfe/simple_zero_to_null.ml.html If you want to do fancy static analysis on C code, use CIL [1], it is better equiped for that task, more robust, more mature. If you want to do style-preserving source-to-source transformation, well, you may find Yacfe useful. [1] http://manju.cs.berkeley.edu/cil/ PS: Yacfe was extracted from the code of the Coccinelle project http://www.emn.fr/x-info/coccinelle/ for Linux device drivers evolutions. Yacfe was supported mainly by money from l'Ecole des Mines de Nantes as well as money from the University of Urbana-Champaign. _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs