20 releases (13 breaking)

Uses old Rust 2015

0.15.1 Sep 4, 2023
0.15.0 Jan 18, 2023
0.14.0 Oct 4, 2022
0.13.0 Jun 21, 2022
0.1.0 Oct 22, 2017

#555 in Parser implementations

Download history 1664/week @ 2024-07-27 709/week @ 2024-08-03 1522/week @ 2024-08-10 311/week @ 2024-08-17 342/week @ 2024-08-24 183/week @ 2024-08-31 258/week @ 2024-09-07 1705/week @ 2024-09-14 3364/week @ 2024-09-21 3474/week @ 2024-09-28 3885/week @ 2024-10-05 2745/week @ 2024-10-12 284/week @ 2024-10-19 392/week @ 2024-10-26 82/week @ 2024-11-02 103/week @ 2024-11-09

968 downloads per month
Used in 2 crates

MIT/Apache

1MB
21K SLoC

Lang-C

Documentation

Ligtweight parser of C language for Rust users. Almost full support for C11 revision of the language. Several GCC and Clang extensions are also supported as an option.

extern crate lang_c;
use lang_c::driver::{Config, parse}; 

fn main() {
    let config = Config::default();
    println!("{:?}", parse(&config, "example.c"));
}

Bugs

Just open an issue, bug reports and patches are most welcome.

License

Dual-licenced under Apache 2.0 or MIT licenses (see LICENSE-APACHE and LICENSE-MIT for legal terms).

Development

A number of external tools are used during development:

Parser (src/parser.rs) is built from a PEG grammar in grammar.rustpeg. It is updated manually and then committed, not generated on every build, thus no rust-peg in the list of dependencies.

For debugging purposes, it is handy to have a version rust-peg built with tracing enabled.

A makefile is used to script the development process:

  • make update parser, build the library and run the tests;
  • make trace rebuilds parser using rust-peg-trace, which is expected to be a version of rust-peg command with trace feature enabled
  • make check can be used as pre-commit git hook to make sure parser is up to date

No runtime deps

Features