use oak_core::{TokenType, UniversalTokenRole};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum CssTokenType {
Whitespace,
Newline,
Comment,
StringLiteral,
NumberLiteral,
ColorLiteral,
UrlLiteral,
Identifier,
ClassName,
IdSelector,
TagName,
PseudoClass,
PseudoElement,
AttributeName,
PropertyName,
FunctionName,
Important,
Inherit,
Initial,
Unset,
Auto,
None,
Normal,
Px,
Em,
Rem,
Percent,
Vh,
Vw,
Pt,
Cm,
Mm,
In,
Pc,
Ex,
Ch,
Vmin,
Vmax,
Colon,
Semicolon,
Comma,
Dot,
Hash,
Plus,
Minus,
Star,
Slash,
Equals,
Tilde,
Pipe,
Caret,
Dollar,
GreaterThan,
LeftParen,
RightParen,
LeftBrace,
RightBrace,
LeftBracket,
RightBracket,
AtImport,
AtMedia,
AtKeyframes,
AtFontFace,
AtCharset,
AtNamespace,
AtSupports,
AtPage,
AtDocument,
AtRule,
Eof,
Error,
}
impl TokenType for CssTokenType {
const END_OF_STREAM: Self = Self::Eof;
type Role = UniversalTokenRole;
fn is_ignored(&self) -> bool {
matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
}
fn is_comment(&self) -> bool {
matches!(self, Self::Comment)
}
fn is_whitespace(&self) -> bool {
matches!(self, Self::Whitespace | Self::Newline)
}
fn role(&self) -> Self::Role {
match self {
Self::Whitespace | Self::Newline => UniversalTokenRole::Whitespace,
Self::Comment => UniversalTokenRole::Comment,
Self::StringLiteral | Self::NumberLiteral | Self::ColorLiteral | Self::UrlLiteral => UniversalTokenRole::Literal,
Self::Identifier | Self::ClassName | Self::IdSelector | Self::TagName | Self::PseudoClass | Self::PseudoElement | Self::AttributeName | Self::PropertyName | Self::FunctionName => UniversalTokenRole::Name,
Self::Important
| Self::Inherit
| Self::Initial
| Self::Unset
| Self::Auto
| Self::None
| Self::Normal
| Self::AtImport
| Self::AtMedia
| Self::AtKeyframes
| Self::AtFontFace
| Self::AtCharset
| Self::AtNamespace
| Self::AtSupports
| Self::AtPage
| Self::AtDocument => UniversalTokenRole::Keyword,
Self::Colon | Self::Semicolon | Self::Comma | Self::Dot | Self::Hash | Self::Plus | Self::Minus | Self::Star | Self::Slash | Self::Equals | Self::Tilde | Self::Pipe | Self::Caret | Self::Dollar | Self::GreaterThan => {
UniversalTokenRole::Operator
}
Self::LeftParen | Self::RightParen | Self::LeftBrace | Self::RightBrace | Self::LeftBracket | Self::RightBracket => UniversalTokenRole::Punctuation,
Self::Eof => UniversalTokenRole::Eof,
Self::Error => UniversalTokenRole::Error,
_ => UniversalTokenRole::None,
}
}
}