use crate::{parse::builder::GrammarBuilder, types::IntoSyntaxKind};
use super::classes;
#[inline]
pub fn keyword_bytes(g: &mut GrammarBuilder, word: &'static [u8]) {
g.literal(word);
g.not_followed_by(|g| {
g.class(classes::IDENT_CONT);
});
}
#[inline]
pub fn keyword_token<K: IntoSyntaxKind>(g: &mut GrammarBuilder, kind: K, word: &'static [u8]) {
g.token(kind, |g| {
keyword_bytes(g, word);
});
}
pub fn any_keyword_bytes(g: &mut GrammarBuilder, words: &[&'static [u8]]) {
match words {
[] => {}
[w] => keyword_bytes(g, w),
[w, rest @ ..] => g.choice(
|g| {
keyword_bytes(g, w);
},
|g| {
any_keyword_bytes(g, rest);
},
),
}
}