oak_sass/parser/
element_type.rs1use oak_core::{ElementType, UniversalElementRole};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum SassElementType {
7 SourceFile,
9 Root,
11 Selector,
13 Variable,
15 Mixin,
17 Function,
19 Value,
21 Object,
23 Array,
25 String,
27 Number,
29 Boolean,
31 Null,
33 ObjectEntry,
35 ArrayElement,
37 ErrorNode,
39 LeftBrace,
41 RightBrace,
43 LeftBracket,
45 RightBracket,
47 Comma,
49 Colon,
51 Whitespace,
53 Comment,
55 Eof,
57 Error,
59}
60
61impl ElementType for SassElementType {
62 type Role = UniversalElementRole;
63
64 fn role(&self) -> Self::Role {
65 match self {
66 Self::SourceFile | Self::Root => UniversalElementRole::Root,
67 Self::Error => UniversalElementRole::Error,
68 _ => UniversalElementRole::None,
69 }
70 }
71}
72
73impl From<crate::lexer::token_type::SassTokenType> for SassElementType {
74 fn from(token: crate::lexer::token_type::SassTokenType) -> Self {
75 use crate::lexer::token_type::SassTokenType as T;
76 match token {
77 T::Whitespace => Self::Whitespace,
78 T::LineComment | T::BlockComment => Self::Comment,
79 T::Eof => Self::Eof,
80 T::Error => Self::Error,
81 T::LeftBrace => Self::LeftBrace,
82 T::RightBrace => Self::RightBrace,
83 T::LeftBracket => Self::LeftBracket,
84 T::RightBracket => Self::RightBracket,
85 T::Comma => Self::Comma,
86 T::Colon => Self::Colon,
87 _ => Self::Error, }
89 }
90}