Crates.io | c3 |
lib.rs | c3 |
version | 0.11.2 |
source | src |
created_at | 2017-08-18 01:40:15.836784 |
updated_at | 2023-10-22 00:05:28.84587 |
description | Complete C AST. Enables analysis and generation of code derived from C. Built using LLVM 4/Clang using some fragile C++ APIs to work around missing data and ambiguities in libclang. |
homepage | https://gitlab.com/citrus-rs/c3 |
repository | https://gitlab.com/citrus-rs/c3.git |
max_upload_size | |
id | 27945 |
size | 140,720 |
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.