ppx 0.2.0

C-style pre-processor library
Documentation
ppx-0.2.0 has been yanked.

PPX

Crates.io Version Crates.io License docs.rs GitHub Actions Workflow Status

Small C-style macro expansion library.

Example

let result = ppx::parse_string(
    "
    #param A
    #define B hello
    #define fn(name), name!
    
    B A fn(John)
    ",
    base_dir,
    ["world"].into_iter()
);
// result = "hello world, John!"

More examples in the tests folder.

Features

  • #param: A parameter that can be passed when including the file, or from the parse* functions.

  • #define: Define a simple substition, or a function-like macro

  • #include: Include another file and parse it as well. Optionally accepts parameters which will be used for substituting the names specified by #param.

  • Macros include_ppx! and include_ppx_string!: Parse a template at compile time instead of at runtime. Enable macros with feature macro or macro-stable.

  • vfs feature: allows using virtual filesystem from the vfs crate as the input.

planned

  • #if

Development

Running tests

cargo test --workspace

Or better, with the cargo-all-features subcommand:

cargo +nightly all-features test --workspace

License

MIT or Apache-2.0.