jhjourdan / C11parser

A correct C89/C90/C99/C11/C18 parser written using Menhir and OCaml
Other
192 stars 17 forks source link

C11parser

A correct C89/C90/C99/C11/C18 parser written using Menhir and OCaml

The operation and design of this parser are described in detail in the following journal paper (in process of review for publication):

A simple, possibly correct LR parser for C11
Jacques-Henri Jourdan and François Pottier
2017

How to use the parser?

You need to have installed

In order to build it, you can just type make.

The executable that is produced takes a preprocessed C file in its standard input and raises an exception in the case of a parse error.

The following command-line options are available:

If you want to use this parser in a C front-end, you should fill the semantic actions of .mly files with your own code for building your AST:

The test suite

We provide, in the tests/ directory, a series of tests that are particularly difficult to handle in a correct C parser. They are all valid C18 fragments, except for:

In order to run the test suite, you need the cram tool, available on most major linux distributions. Then, simply type make test.