11 releases (7 breaking)

new 0.8.0 Mar 25, 2020
0.7.0 Nov 12, 2019
0.6.0 Oct 19, 2019
0.5.2 Jul 8, 2019
0.1.0 Oct 22, 2017

#75 in Parser implementations

Download history 25/week @ 2019-12-02 271/week @ 2019-12-09 2/week @ 2019-12-16 14/week @ 2019-12-23 56/week @ 2019-12-30 20/week @ 2020-01-06 233/week @ 2020-01-13 114/week @ 2020-01-20 13/week @ 2020-01-27 72/week @ 2020-02-03 61/week @ 2020-02-10 76/week @ 2020-02-17 68/week @ 2020-02-24 100/week @ 2020-03-02 101/week @ 2020-03-09 207/week @ 2020-03-16

418 downloads per month

MIT/Apache

1MB
21K SLoC

Lang-C

Build Status 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