2020-10-26 18:16:42 -07:00
|
|
|
use crate::common::*;
|
2019-11-10 23:17:47 -08:00
|
|
|
|
2020-10-26 18:16:42 -07:00
|
|
|
#[derive(Debug, Eq, PartialEq, IntoStaticStr, Display, Copy, Clone, EnumString)]
|
|
|
|
#[strum(serialize_all = "kebab_case")]
|
|
|
|
pub(crate) enum Keyword {
|
|
|
|
Alias,
|
|
|
|
Else,
|
|
|
|
Export,
|
|
|
|
If,
|
|
|
|
Set,
|
|
|
|
Shell,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Keyword {
|
|
|
|
pub(crate) fn from_lexeme(lexeme: &str) -> Option<Keyword> {
|
|
|
|
lexeme.parse().ok()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn lexeme(self) -> &'static str {
|
|
|
|
self.into()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> PartialEq<&'a str> for Keyword {
|
|
|
|
fn eq(&self, other: &&'a str) -> bool {
|
|
|
|
self.lexeme() == *other
|
|
|
|
}
|
|
|
|
}
|