summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2019-09-01 22:46:03 +0200
committerNadrieril2019-09-01 22:46:03 +0200
commit3e9aa3e46bd5906469751c908a0daedfe26dac22 (patch)
tree68b3bf8e798e36029b5044a166d8570db93fbe2d
parent1baef509afe52ab285e73469fc597de8f4e166b6 (diff)
Make make_parser into a proc_macro_attribute
That way rustfmt will format the contents of the parser.
Diffstat (limited to '')
-rw-r--r--dhall_proc_macros/src/lib.rs4
-rw-r--r--dhall_proc_macros/src/parser.rs12
-rw-r--r--dhall_syntax/src/parser.rs3
3 files changed, 12 insertions, 7 deletions
diff --git a/dhall_proc_macros/src/lib.rs b/dhall_proc_macros/src/lib.rs
index 46d93e9..92cf981 100644
--- a/dhall_proc_macros/src/lib.rs
+++ b/dhall_proc_macros/src/lib.rs
@@ -15,8 +15,8 @@ pub fn derive_static_type(input: TokenStream) -> TokenStream {
derive::derive_static_type(input)
}
-#[proc_macro]
-pub fn make_parser(input: TokenStream) -> TokenStream {
+#[proc_macro_attribute]
+pub fn make_parser(_attr: TokenStream, input: TokenStream) -> TokenStream {
TokenStream::from(match parser::make_parser(input) {
Ok(tokens) => tokens,
Err(err) => err.to_compile_error(),
diff --git a/dhall_proc_macros/src/parser.rs b/dhall_proc_macros/src/parser.rs
index 2618bec..1c75279 100644
--- a/dhall_proc_macros/src/parser.rs
+++ b/dhall_proc_macros/src/parser.rs
@@ -4,8 +4,8 @@ use syn::parse::{Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::{
- bracketed, parenthesized, parse_quote, token, Error, Expr, Ident, ItemFn,
- Pat, ReturnType, Token, Type,
+ braced, bracketed, parenthesized, parse_quote, token, Error, Expr, Ident,
+ ItemFn, Pat, ReturnType, Token, Type,
};
mod rule_kw {
@@ -58,9 +58,13 @@ struct ParseChildrenInput {
impl Parse for Rules {
fn parse(input: ParseStream) -> Result<Self> {
+ let _: Token![impl ] = input.parse()?;
+ let _: Token![_] = input.parse()?;
+ let contents;
+ braced!(contents in input);
let mut rules = Vec::new();
- while !input.is_empty() {
- rules.push(input.parse()?)
+ while !contents.is_empty() {
+ rules.push(contents.parse()?)
}
Ok(Rules(rules))
}
diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs
index fa2d7c5..2864a97 100644
--- a/dhall_syntax/src/parser.rs
+++ b/dhall_syntax/src/parser.rs
@@ -215,7 +215,8 @@ fn make_precclimber() -> PrecClimber<Rule> {
)
}
-make_parser! {
+#[make_parser]
+impl _ {
fn EOI(_: ParseInput<Rule>) -> ParseResult<()> {
Ok(())
}