diff options
author | 2018-04-16 19:44:27 +0000 | |
---|---|---|
committer | 2018-04-16 19:44:27 +0000 | |
commit | 5ff9076e9c1a5cc2e9b57041699d0aa37ca8c768 (patch) | |
tree | 4169f3ae1a774a189b90baeefb1e1c3aaa0b5a44 /macros/src/lib.rs | |
parent | b55581dfe35040a4fdc93a1f38c1e1769d4d2535 (diff) | |
parent | bfa56e12f7a3ec3734e329f00d98ce9a953fce6d (diff) | |
download | rtic-5ff9076e9c1a5cc2e9b57041699d0aa37ca8c768.tar.gz rtic-5ff9076e9c1a5cc2e9b57041699d0aa37ca8c768.tar.zst rtic-5ff9076e9c1a5cc2e9b57041699d0aa37ca8c768.zip |
Merge #71
71: update parser r=japaric a=japaric
closes #69
this doesn't change functionality per se but improves diagnostics in some cases. Some hard errors
have becomes warnings, for example: when `resources` is empty, or when `idle.path` is set to the
default `idle` path.
Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'macros/src/lib.rs')
-rw-r--r-- | macros/src/lib.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/macros/src/lib.rs b/macros/src/lib.rs index c45646c2..728e6133 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -1,19 +1,19 @@ //! Procedural macros of the `cortex-m-rtfm` crate -#![deny(warnings)] +// #![deny(warnings)] #![feature(proc_macro)] #![recursion_limit = "128"] #[macro_use] -extern crate error_chain; +extern crate failure; extern crate proc_macro; +extern crate proc_macro2; +extern crate syn; #[macro_use] extern crate quote; extern crate rtfm_syntax as syntax; -extern crate syn; use proc_macro::TokenStream; -use syntax::App; -use syntax::error::*; +use syntax::{App, Result}; mod analyze; mod check; @@ -170,22 +170,17 @@ mod trans; #[proc_macro] pub fn app(ts: TokenStream) -> TokenStream { match run(ts) { - Err(e) => panic!("{}", error_chain::ChainedError::display(&e)), + Err(e) => panic!("error: {}", e), Ok(ts) => ts, } } fn run(ts: TokenStream) -> Result<TokenStream> { - let input = format!("{}", ts); - - let app = App::parse(&input).chain_err(|| "parsing")?; - let app = syntax::check::app(app).chain_err(|| "checking the AST")?; + let app = App::parse(ts)?.check()?; let app = check::app(app)?; let ownerships = analyze::app(&app); let tokens = trans::app(&app, &ownerships); - Ok(format!("{}", tokens) - .parse() - .map_err(|_| "BUG: error parsing the generated code")?) + Ok(tokens.into()) } |