Language-c99 is a Haskell library implementing the abstract syntax tree of C99. It strictly follows the C99 specification, as defined by the final committee draft. Typical C implementations in Haskell deviate from the standard to make using the library easier, or add features from newer C versions or compilers. These modifications make it harder to write high-assurance code, because there is no proof that the code actually adheres to the C99 AST.
Language-c99 has been made during the reimplementation of the C99 backend of Copilot. It gives us the extra certainty we need for the high-assurance systems Copilot has been designed for.
To aid writing code using the library, two support libraries give a more user-friendly wrapper on top of the bare C99 AST:
- language-c99-simple: A high level wrapper providing a user-friendly approach to writing C programs. For simplicity it targets a subset of C, which leaves the barely used features of C, resulting in a safer language.
- language-c99-util: Some simple functions for creating literal values and variable names. Additionally it contains a system to automatically wrap expressions to the required level. Typically it is not recommended to use this library to write code, language-c99-simple is much better suited for that.
The source to the libraries are hosted on github and be cloned easily:
git clone https://github.com/fdedden/language-c99 git clone https://github.com/fdedden/language-c99-util git clone https://github.com/fdedden/language-c99-simple
The repositories themselves can be found here:
All releases can be found on Hackage, and can be easily installed using
Currently the libraries are still in an early stage, and changes to API will occur before the 1.0 release!
Language-c99, language-c99-util and language-c99-simple are all distributed under the MIT license.