Syntex Code Generation Framework

Build Status Latest Version

syntex is a library that enables compile time syntax extension expansion. This allows users to use libraries like regex_macros in a rust 1.0 compatible context.

Configuring with Cargo

To create a package:

```toml [package] name = "helloworldmacros" version = "0.2.0" authors = [ "erick.tryzelaar@gmail.com" ]

[dependencies] syntex = "" syntex_syntax = "" ```

To use it:

Cargo.toml:

```toml [package] name = "hello_world" version = "0.3.0" authors = [ "erick.tryzelaar@gmail.com" ] build = "build.rs"

[build-dependencies] syntex = "*" ```

build.rs:

```rust extern crate syntex; extern crate helloworldmacros;

use std::env; use std::path::Path;

fn main() { let mut registry = syntex::Registry::new(); helloworldmacros::register(&mut registry);

let src = Path::new("src/main.rs.in");
let dst = Path::new(&env::var("OUT_DIR").unwrap()).join("main.rs");

registry.expand("hello_world", &src, &dst).unwrap();

} ```

src/main.rs:

rust // Include the real main include!(concat!(env!("OUT_DIR"), "/main.rs"));

src/main.rs.in:

rust fn main() { let s = hello_world!(); println!("{}", s); }

Limitations

Unfortunately because there is no stable plugin support in Rust yet, there are some things that syntex cannot do: