Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
C++ parser
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-01-17 (19:15)
From: Basile STARYNKEVITCH <basile@s...>
Subject: Re: [Caml-list] C++ parser
Guillaume Yziquel wrote:
> For a new project, I'd use GCC XML.

[[sorry for this reply, which is barely related to Ocaml, but may be of interest to several Ocaml fans interested in C++ 

There is however a small caveat. AFAIK, GCC XML is not much maintained, and depends upon an old GCC version (but I might 
be wrong on both points). Latest release of GCC XML seems to be 0.6 from february 2004.

Next (4.5.0) release of GCC will provide two major new features: link time optimization [=LTO] & plugins.

Both features are useful for any kind of C++ static analysis programs; a plugin can define new passes, and the LTO 
feature enable them to be run at "link" time, that is to merge information from several compilation units. And indeed 
GCC have powerful & common internal representations of the compiled source code, which is the same for C, C++, Fortran, 
Ada, Java .. source inputs to GCC.

So one could consider coding a plugin for GCC which extracts the exact information required by your (Ocaml) static 
analyser. In addition (sorry for the shameless self-promotion), if you like functional programming, you might even code 
your plugin as a MELT module. MELT is a plugin (written by me) which enables you to express your GCC pass in a 
higher-level Lisp-like mostly dynamic language (with closures, powerful pattern matching [in particular pattern matching 
on GCC internal representations like Gimple], objects - but unfortunately no static typing with type inference).

Feel free to ask me more (preferably off list, or preferably on the list) about MELT.


email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***