blob: e0cba88efbd29ed4b579efc1c977d02cbe7458bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// #![deny(warnings)]
#![allow(warnings)]
#![feature(proc_macro)]
#![recursion_limit = "256"]
#[macro_use]
extern crate failure;
extern crate proc_macro;
extern crate proc_macro2;
extern crate syn;
#[macro_use]
extern crate quote;
extern crate either;
extern crate rtfm_syntax as syntax;
use proc_macro::TokenStream;
use syntax::{App, Result};
mod analyze;
mod check;
mod trans;
#[proc_macro]
pub fn app(ts: TokenStream) -> TokenStream {
match run(ts) {
Err(e) => panic!("error: {}", e),
Ok(ts) => ts,
}
}
fn run(ts: TokenStream) -> Result<TokenStream> {
let app = App::parse(ts)?.check()?;
check::app(&app)?;
let ctxt = analyze::app(&app);
let tokens = trans::app(&ctxt, &app);
Ok(tokens.into())
}
|