1use oak_core::{ElementType, Token, TokenType, UniversalElementRole, UniversalTokenRole};
2use serde::{Deserialize, Serialize};
3
4pub type OrgModeToken = Token<OrgModeSyntaxKind>;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
7pub enum OrgModeSyntaxKind {
8 Document,
10 Heading,
11 Section,
12 Paragraph,
13 List,
14 ListItem,
15 Table,
16 TableRow,
17 TableCell,
18 Block,
19 CodeBlock,
20 QuoteBlock,
21 ExampleBlock,
22 VerseBlock,
23 CommentBlock,
24 DrawerBlock,
25 PropertyDrawer,
26 LogbookDrawer,
27 Link,
28 InlineCode,
29 Bold,
30 Italic,
31 Underline,
32 Strikethrough,
33 Verbatim,
34 Timestamp,
35 Tag,
36 Priority,
37 TodoKeyword,
38 DoneKeyword,
39
40 HeadingLevel1,
43 HeadingLevel2,
44 HeadingLevel3,
45 HeadingLevel4,
46 HeadingLevel5,
47 HeadingLevel6,
48
49 Todo,
51 Done,
52 Next,
53 Waiting,
54 Cancelled,
55
56 PriorityA,
58 PriorityB,
59 PriorityC,
60
61 Star,
63 Plus,
64 Minus,
65 Hash,
66 Pipe,
67 Colon,
68 LeftBracket,
69 RightBracket,
70 LeftParen,
71 RightParen,
72 LeftBrace,
73 RightBrace,
74 LessThan,
75 GreaterThan,
76 Equal,
77 Underscore,
78 Tilde,
79 Slash,
80 Backslash,
81
82 Text,
84 Number,
85 Date,
86 Time,
87 Url,
88 Email,
89
90 Newline,
92 Whitespace,
93 Comment,
94 BlockDelimiter,
95 PropertyName,
96 PropertyValue,
97 TagName,
98
99 Error,
101 Eof,
102}
103
104impl TokenType for OrgModeSyntaxKind {
105 const END_OF_STREAM: Self = Self::Eof;
106 type Role = UniversalTokenRole;
107
108 fn role(&self) -> Self::Role {
109 match self {
110 Self::Whitespace | Self::Newline => UniversalTokenRole::Whitespace,
111 Self::Comment | Self::CommentBlock => UniversalTokenRole::Comment,
112 Self::Eof => UniversalTokenRole::Eof,
113 _ => UniversalTokenRole::None,
114 }
115 }
116}
117
118impl ElementType for OrgModeSyntaxKind {
119 type Role = UniversalElementRole;
120
121 fn role(&self) -> Self::Role {
122 match self {
123 Self::Error => UniversalElementRole::Error,
124 _ => UniversalElementRole::None,
125 }
126 }
127}