use oak_core::{ElementType, UniversalElementRole};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u8)]
pub enum LLvmElementType {
Root,
Identifier,
Number,
String,
Comment,
Whitespace,
Newline,
Error,
Eof,
LocalVar,
GlobalVar,
Metadata,
Equal,
Comma,
LParen,
RParen,
LBracket,
RBracket,
LBrace,
RBrace,
Star,
Colon,
Keyword,
Item,
Global,
Function,
Parameter,
Block,
Instruction,
Type,
Operand,
}
impl ElementType for LLvmElementType {
type Role = UniversalElementRole;
fn role(&self) -> Self::Role {
match self {
Self::Root => UniversalElementRole::Root,
Self::Function => UniversalElementRole::Container,
Self::Block => UniversalElementRole::Container,
Self::Instruction => UniversalElementRole::Statement,
Self::Global => UniversalElementRole::Binding,
Self::Error => UniversalElementRole::Error,
_ => UniversalElementRole::None,
}
}
}
impl From<crate::lexer::token_type::LLvmTokenType> for LLvmElementType {
fn from(token: crate::lexer::token_type::LLvmTokenType) -> Self {
unsafe { std::mem::transmute(token) }
}
}