13 releases (7 breaking)
0.11.2 | Oct 22, 2023 |
---|---|
0.11.0 | Sep 20, 2017 |
0.10.0 | Sep 16, 2017 |
#2554 in Parser implementations
Used in citrus
520KB
14K
SLoC
C3: A tree of C nodes
This crate parses C files and exposes them as an abstract syntax tree.
The AST is a relaxed version of C's usual structure (e.g. everything pretends to be an expression), but contains enough information to rebuild complete source code. The AST also allows for some Rust features not found in C files. This is enables Citrus to convert C to Rust.
It uses LLVM and Clang's unstable C++ API. Currently, it supports LLVM 4 or 5, and requires static linking with libclang.
The stable Clang API does not expose a real AST, but a flattened, incomplete and ambiguous view of it. This crate works around the bad parts to extract more complete view of C files from Clang.
On the Rust side it's based on bindgen.
Building
Dependencies
~215–550KB
~12K SLoC