use crate::lexer::ValkyrieKeywords;
use oak_core::{Token, TokenType, UniversalTokenRole};
pub type ValkyrieToken = Token<ValkyrieTokenType>;
pub type ValkyrieSyntaxKind = ValkyrieTokenType;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ValkyrieTokenType {
Eof,
Whitespace,
Newline,
Error,
IntegerLiteral,
FloatLiteral,
BoolLiteral,
StringLiteral,
StringPrefix,
CharLiteral,
Identifier,
Label,
LineComment,
BlockComment,
Keyword(ValkyrieKeywords),
Ampersand,
AndAnd,
Arrow,
At,
Bang,
Caret,
Colon,
ColonColon,
ColonEq,
Comma,
Dollar,
Dot,
DotDot,
Eq,
EqEq,
GreaterEq,
GreaterThan,
LeftBrace,
LeftBracket,
LeftParen,
LeftShift,
LessEq,
LessThan,
LeftAngle,
RightAngle,
LeftOffset,
RightOffset,
Minus,
NotEq,
OrOr,
Percent,
Pipe,
Plus,
Question,
RightBrace,
RightBracket,
RightParen,
RightShift,
Semicolon,
Slash,
Star,
Tilde,
Underscore,
}
impl TokenType for ValkyrieTokenType {
type Role = UniversalTokenRole;
const END_OF_STREAM: Self = Self::Eof;
fn is_ignored(&self) -> bool {
matches!(self, Self::Whitespace | Self::Newline | Self::LineComment | Self::BlockComment)
}
fn role(&self) -> Self::Role {
match self {
Self::Whitespace | Self::Newline => UniversalTokenRole::Whitespace,
Self::LineComment | Self::BlockComment => UniversalTokenRole::Comment,
Self::Eof => UniversalTokenRole::Eof,
Self::Error => UniversalTokenRole::Error,
Self::Keyword(_) => UniversalTokenRole::Keyword,
Self::Identifier | Self::StringPrefix => UniversalTokenRole::Name,
Self::StringLiteral | Self::CharLiteral => UniversalTokenRole::Literal,
Self::IntegerLiteral | Self::FloatLiteral | Self::BoolLiteral => UniversalTokenRole::Literal,
_ => UniversalTokenRole::None,
}
}
}