use omena_syntax::SyntaxKind;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct TokenSet {
kinds: &'static [SyntaxKind],
}
impl TokenSet {
pub const fn new(kinds: &'static [SyntaxKind]) -> Self {
Self { kinds }
}
pub fn contains(self, kind: SyntaxKind) -> bool {
self.kinds.contains(&kind)
}
pub fn len(self) -> usize {
self.kinds.len()
}
pub fn is_empty(self) -> bool {
self.kinds.is_empty()
}
}
pub const RECOVERY_TOP: TokenSet = TokenSet::new(&[
SyntaxKind::AtKeyword,
SyntaxKind::Dot,
SyntaxKind::Hash,
SyntaxKind::RightBrace,
SyntaxKind::Semicolon,
]);
pub const RECOVERY_DECLARATION: TokenSet =
TokenSet::new(&[SyntaxKind::Semicolon, SyntaxKind::RightBrace]);
pub const RECOVERY_SELECTOR: TokenSet = TokenSet::new(&[
SyntaxKind::Comma,
SyntaxKind::LeftBrace,
SyntaxKind::RightBrace,
]);