1use crate::lex::SyntaxKind;23#[derive(Clone, Copy, Default)]4pub struct TokenSet(u64);56impl TokenSet {7 pub const EMPTY: Self = Self(0);8 pub const ALL: Self = Self(u64::MAX);910 pub const fn new(kinds: &[SyntaxKind]) -> TokenSet {11 let mut res = 0u64;12 let mut i = 0;13 while i < kinds.len() {14 res |= mask(kinds[i]);15 i += 116 }17 TokenSet(res)18 }1920 pub const fn union(self, other: TokenSet) -> TokenSet {21 TokenSet(self.0 | other.0)22 }2324 pub const fn contains(&self, kind: SyntaxKind) -> bool {25 self.0 & mask(kind) != 026 }27}2829const fn mask(kind: SyntaxKind) -> u64 {30 1u64 << (kind as usize)31}