aboutsummaryrefslogtreecommitdiff
path: root/macros/src/lib.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-04-08 18:23:27 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-04-16 21:32:29 +0200
commit7fdf16eab948ea04c1e56fdb5a704ed88780f5c6 (patch)
treea7438c2353382d5d46a391a1a81f7d05f9e83d65 /macros/src/lib.rs
parentb55581dfe35040a4fdc93a1f38c1e1769d4d2535 (diff)
downloadrtic-7fdf16eab948ea04c1e56fdb5a704ed88780f5c6.tar.gz
rtic-7fdf16eab948ea04c1e56fdb5a704ed88780f5c6.tar.zst
rtic-7fdf16eab948ea04c1e56fdb5a704ed88780f5c6.zip
update parser
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.
Diffstat (limited to 'macros/src/lib.rs')
-rw-r--r--macros/src/lib.rs21
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())
}