summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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(())
}