use crate::lexer::token_type::BatTokenType;
use oak_core::{ElementType, UniversalElementRole};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum BatElementType {
Token(BatTokenType),
Root,
CommandStatement,
IfStatement,
ForStatement,
SetStatement,
LabelDefinition,
Error,
}
impl From<BatTokenType> for BatElementType {
fn from(token: BatTokenType) -> Self {
Self::Token(token)
}
}
impl oak_core::ElementType for BatElementType {
type Role = UniversalElementRole;
fn is_root(&self) -> bool {
matches!(self, Self::Root)
}
fn is_error(&self) -> bool {
matches!(self, Self::Error)
}
fn role(&self) -> Self::Role {
match self {
Self::Root => UniversalElementRole::Root,
Self::LabelDefinition => UniversalElementRole::Definition,
Self::CommandStatement | Self::IfStatement | Self::ForStatement | Self::SetStatement => UniversalElementRole::Statement,
Self::Error => UniversalElementRole::Error,
_ => UniversalElementRole::None,
}
}
}