summaryrefslogtreecommitdiff
path: root/dhall_proc_macros/src
diff options
context:
space:
mode:
Diffstat (limited to 'dhall_proc_macros/src')
-rw-r--r--dhall_proc_macros/src/lib.rs4
-rw-r--r--dhall_proc_macros/src/parser.rs12
2 files changed, 10 insertions, 6 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))
}