Code Monkey home page Code Monkey logo

ecp's Introduction

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.

ecp's People

Contributors

fengcen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.