Allow peeking delimiters
diff --git a/src/token.rs b/src/token.rs
index 1d355a3..27a49d9 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -105,6 +105,8 @@
#[cfg(feature = "extra-traits")]
use std::hash::{Hash, Hasher};
+#[cfg(feature = "parsing")]
+use proc_macro2::Delimiter;
#[cfg(any(feature = "printing", feature = "parsing"))]
use proc_macro2::Spacing;
use proc_macro2::{Ident, Span};
@@ -371,6 +373,9 @@
parsing::delim($token, tokens, $name, f)
}
}
+
+ #[cfg(feature = "parsing")]
+ impl private::Sealed for $name {}
)*
};
}
@@ -437,6 +442,39 @@
}
}
+#[cfg(feature = "parsing")]
+impl Token for Paren {
+ fn peek(lookahead: &Lookahead1) -> bool {
+ lookahead::is_delimiter(lookahead, Delimiter::Parenthesis)
+ }
+
+ fn display() -> String {
+ "parentheses".to_owned()
+ }
+}
+
+#[cfg(feature = "parsing")]
+impl Token for Brace {
+ fn peek(lookahead: &Lookahead1) -> bool {
+ lookahead::is_delimiter(lookahead, Delimiter::Brace)
+ }
+
+ fn display() -> String {
+ "curly braces".to_owned()
+ }
+}
+
+#[cfg(feature = "parsing")]
+impl Token for Bracket {
+ fn peek(lookahead: &Lookahead1) -> bool {
+ lookahead::is_delimiter(lookahead, Delimiter::Bracket)
+ }
+
+ fn display() -> String {
+ "square brackets".to_owned()
+ }
+}
+
define_keywords! {
"as" pub struct As /// `as`
"async" pub struct Async /// `async`