[ANN] FrontC 4.1.0 (Vingt ans après)

More than twenty years after its original release FrontC is still alive and getting new updates. Mostly it started with my frustration with its Makefiles that ended up in switching to menhir and dune and adding cram tests that finally enabled us to safely touch the grammar definitions and introduce a few c99 … c11 language features as well as more GNU extensions. Our end goal is to get a robust and easy-to-use C parser that is capable of taking a C program on a modern Linux distribution and get it parsed into a C abstract tree. It is not that trivial as it may sound as modern C library headers (especially GNU libc) use non-standard or standard but very modern C features, and most of the OCaml parsers that I have seen are still unable to parse them, including parsers from FramaC, C11parser, and even compcert parser (mostly they do not handle complex floating-point types and various extension types and some GCC attributes).

Therefore, FrontC is still useful, especially if all that you want is to start doing program analysis with minimal initial effort, just do (but wait until it is merged1)

opam install FrontC

and start hacking!

With that said, FrontC is mostly maintained at leisure time by volunteers, so the pull requests are very welcome.

P.S. and if you’re looking for documentation, then just do

odig doc FrontC

1) But if you can’t wait you can install it with opam pin add FrontC --dev-repo

8 Likes

How does clangml compares to the other C parsers you have tried?
I used it in the past.
It is actively maintained I believe.

1 Like

Well, clangml offers bindings to clang so it should be as good (and as bad) as clang itself. In terms of the recognized language features, it is surely more advanced then any other pure OCaml parsers. And, what is more important, is that it recognizes C++.

What FrontC (and C11Parser) offers that clangml can’t offer, is C grammar specified in OCaml and an option to experiment with it (e.g., when adding a new feature to the language) as well as lower entry barrier when it comes to the AST and writing your analysis. And they are also much more lightweight when it matters.