Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

fengcen/ecp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ecp

Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.

easily build compiler plugins.

Document

Sorry, you need to build the document with cargo doc.

Prerequisites

ecp required latest Nightly Rust.

Why use "compiler plugin" instead of "Macros 1.1"?

I need not only "custom derive", but also more "compiler plugin" features. Currently "Macros 1.1" is also unstable.

"Macros 1.1" has been stabilize in Rust 1.15, so you should use it.

I will consider adding support for syn.

Usage

Add dependencies to Cargo.toml

[dependencies]
ecp = "^0.1"

In your main.rs or lib.rs:

#![feature(quote, plugin_registrar, rustc_private)]
extern crate syntax;
extern crate ecp;

Examples

Create a simple macro which prints "Hello world!":

#![feature(quote, plugin_registrar, rustc_private)]
extern crate syntax;
extern crate ecp;
use ecp::prelude::*;

#[plugin_registrar]
pub fn register(reg: &mut Registry) {
    reg.register_macro("test", test);
}

pub fn test(cx: &mut ExtCtxt, _: Span, _: &[TokenTree]) -> Box<MacResult + 'static> {
    MacEager::expr(quote_expr!(cx, println!("Hello world!")))
}

License

ecp is primarily distributed under the terms of the MIT license. See LICENSE for details.

About

[ABANDONED] easily build compiler plugins.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages