use oak_core::{ElementType, UniversalElementRole};
use crate::lexer::token_type::ValkyrieTokenType;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ValkyrieElementType {
Root,
Eof,
Whitespace,
Newline,
LineComment,
BlockComment,
Error,
Attribute,
NamePath,
Type,
Namespace,
Class,
Structure,
ParameterList,
BlockExpression,
IdentifierExpression,
PathExpression,
Statement,
LetStatement,
ExprStatement,
Expression,
CallExpression,
Param,
ReturnExpression,
LiteralExpression,
BooleanLiteral,
BinaryExpression,
UnaryExpression,
ParenthesizedExpression,
IndexExpression,
OffsetExpression,
FieldExpression,
IfExpression,
MatchExpression,
LoopExpression,
BreakExpression,
ContinueExpression,
YieldExpression,
RaiseExpression,
CatchExpression,
ResumeExpression,
WithExpression,
ApplyBlock,
ObjectExpression,
LambdaExpression,
Micro,
Mezzo,
Macro,
Struct,
Enum,
Enums,
Trait,
AssociatedType,
Impl,
Field,
Method,
Variant,
Property,
Flags,
Widget,
Singleton,
EffectDefinition,
UsingStatement,
TemplateText,
TemplateControl,
Interpolation,
TemplateComment,
Pattern,
ArgList,
GenericParameterList,
GenericArgumentList,
MatchArm,
Parameter,
AnonymousClass,
GenericParameter,
SuperCallExpression,
}
impl ElementType for ValkyrieElementType {
type Role = UniversalElementRole;
fn role(&self) -> Self::Role {
match self {
Self::Root => UniversalElementRole::Root,
Self::Error => UniversalElementRole::Error,
_ => UniversalElementRole::None,
}
}
}
impl From<ValkyrieTokenType> for ValkyrieElementType {
fn from(token: ValkyrieTokenType) -> Self {
match token {
ValkyrieTokenType::Eof => Self::Eof,
ValkyrieTokenType::Whitespace => Self::Whitespace,
ValkyrieTokenType::Newline => Self::Newline,
ValkyrieTokenType::LineComment => Self::LineComment,
ValkyrieTokenType::BlockComment => Self::BlockComment,
ValkyrieTokenType::Error => Self::Error,
_ => Self::Error,
}
}
}