oak_von/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 VonElementType {
7 Whitespace,
9 Newline,
11 Comment,
13 Eof,
15 LeftBrace,
17 RightBrace,
19 LeftBracket,
21 RightBracket,
23 Comma,
25 Colon,
27 Eq,
29 StringLiteral,
31 NumberLiteral,
33 BoolLiteral,
35 NullLiteral,
37 Identifier,
39 Value,
41 Object,
43 Array,
45 ObjectEntry,
47 Enum,
49 ErrorNode,
51 Error,
53 Root,
55 ArrayElement,
57}
58
59impl ElementType for VonElementType {
60 type Role = UniversalElementRole;
61
62 fn role(&self) -> Self::Role {
63 match self {
64 Self::Root => UniversalElementRole::Root,
65
66 Self::Error => UniversalElementRole::Error,
67 _ => UniversalElementRole::None,
68 }
69 }
70}
71
72impl From<crate::lexer::token_type::VonTokenType> for VonElementType {
73 fn from(token: crate::lexer::token_type::VonTokenType) -> Self {
74 unsafe { std::mem::transmute(token) }
75 }
76}