[Caml-list] announce : Yacfe 0.2

Skip to first unread message

Yoann Padioleau

Oct 31, 2008, 12:22:22 PM10/31/08
to OCaml

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


A simple example of the code of a style-preserving program transformation
using the Yacfe API is available here:


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:
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply all
Reply to author
0 new messages