Restrict grammer of 2.0 macros
The arguments must be parenthesized and the body must be braced.
diff --git a/src/tt.rs b/src/tt.rs
new file mode 100644
index 0000000..8a7f0e5
--- /dev/null
+++ b/src/tt.rs
@@ -0,0 +1,47 @@
+use proc_macro2::{TokenNode, TokenTree};
+use cursor::Cursor;
+use {parse_error, PResult};
+
+#[cfg(feature = "full")]
+use proc_macro2::Delimiter;
+
+pub fn delimited(input: Cursor) -> PResult<TokenTree> {
+ match input.token_tree() {
+ Some((
+ rest,
+ token @ TokenTree {
+ kind: TokenNode::Group(..),
+ ..
+ },
+ )) => Ok((rest, token)),
+ _ => parse_error(),
+ }
+}
+
+#[cfg(feature = "full")]
+pub fn braced(input: Cursor) -> PResult<TokenTree> {
+ match input.token_tree() {
+ Some((
+ rest,
+ token @ TokenTree {
+ kind: TokenNode::Group(Delimiter::Brace, ..),
+ ..
+ },
+ )) => Ok((rest, token)),
+ _ => parse_error(),
+ }
+}
+
+#[cfg(feature = "full")]
+pub fn parenthesized(input: Cursor) -> PResult<TokenTree> {
+ match input.token_tree() {
+ Some((
+ rest,
+ token @ TokenTree {
+ kind: TokenNode::Group(Delimiter::Parenthesis, ..),
+ ..
+ },
+ )) => Ok((rest, token)),
+ _ => parse_error(),
+ }
+}