mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 14:25:18 +01:00
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.
This commit is contained in:
parent
b55581dfe3
commit
7fdf16eab9
13 changed files with 61 additions and 139 deletions
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue