From d334b5a1db9ec6a57f54077d422a3f4b3c8c1178 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 21 Feb 2019 13:27:45 +0300 Subject: move parser to a separate crate --- crates/ra_syntax/src/parsing/token_set.rs | 41 ------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 crates/ra_syntax/src/parsing/token_set.rs (limited to 'crates/ra_syntax/src/parsing/token_set.rs') diff --git a/crates/ra_syntax/src/parsing/token_set.rs b/crates/ra_syntax/src/parsing/token_set.rs deleted file mode 100644 index 24152a38a..000000000 --- a/crates/ra_syntax/src/parsing/token_set.rs +++ /dev/null @@ -1,41 +0,0 @@ -use crate::SyntaxKind; - -#[derive(Clone, Copy)] -pub(crate) struct TokenSet(u128); - -impl TokenSet { - pub(crate) const fn empty() -> TokenSet { - TokenSet(0) - } - - pub(crate) const fn singleton(kind: SyntaxKind) -> TokenSet { - TokenSet(mask(kind)) - } - - pub(crate) const fn union(self, other: TokenSet) -> TokenSet { - TokenSet(self.0 | other.0) - } - - pub(crate) fn contains(&self, kind: SyntaxKind) -> bool { - self.0 & mask(kind) != 0 - } -} - -const fn mask(kind: SyntaxKind) -> u128 { - 1u128 << (kind as usize) -} - -#[macro_export] -macro_rules! token_set { - ($($t:ident),*) => { TokenSet::empty()$(.union(TokenSet::singleton($t)))* }; - ($($t:ident),* ,) => { token_set!($($t),*) }; -} - -#[test] -fn token_set_works_for_tokens() { - use crate::SyntaxKind::*; - let ts = token_set![EOF, SHEBANG]; - assert!(ts.contains(EOF)); - assert!(ts.contains(SHEBANG)); - assert!(!ts.contains(PLUS)); -} -- cgit v1.2.3