1use oak_core::{ElementType, TokenType, UniversalElementRole, UniversalTokenRole};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub enum TypstSyntaxKind {
6 Root,
8 Document,
9 Block,
10
11 Heading,
13 Paragraph,
14 List,
15 ListItem,
16 EnumItem,
17 Table,
18 TableRow,
19 TableCell,
20 Figure,
21 Image,
22 Link,
23
24 Text,
26 Strong,
27 Emphasis,
28 Code,
29 Math,
30 InlineMath,
31 DisplayMath,
32 Raw,
33 Quote,
34
35 Script,
37 Expression,
38 FunctionCall,
39 Variable,
40 Assignment,
41 Conditional,
42 Loop,
43 Import,
44 Include,
45
46 Set,
48 Show,
49 Style,
50 Color,
51 Font,
52 Size,
53
54 Let,
56 If,
57 Else,
58 For,
59 While,
60 Break,
61 Continue,
62 Return,
63 True,
64 False,
65
66 Plus,
68 Minus,
69 Star,
70 Slash,
71 Percent,
72 Equal,
73 EqualEqual,
74 NotEqual,
75 Less,
76 Greater,
77 LessEqual,
78 GreaterEqual,
79 And,
80 Or,
81 Not,
82
83 LeftParen,
85 RightParen,
86 LeftBrace,
87 RightBrace,
88 LeftBracket,
89 RightBracket,
90 Semicolon,
91 Comma,
92 Dot,
93 Colon,
94 Hash,
95 At,
96 Dollar,
97 Underscore,
98 Backtick,
99
100 StringLiteral,
102 NumericLiteral,
103 Identifier,
104
105 LineComment,
107 BlockComment,
108 Whitespace,
109 Newline,
110
111 Eof,
113 Error,
114}
115
116impl TokenType for TypstSyntaxKind {
117 const END_OF_STREAM: Self = Self::Eof;
118 type Role = UniversalTokenRole;
119
120 fn role(&self) -> Self::Role {
121 match self {
122 TypstSyntaxKind::Whitespace | TypstSyntaxKind::Newline => UniversalTokenRole::Whitespace,
123 TypstSyntaxKind::LineComment | TypstSyntaxKind::BlockComment => UniversalTokenRole::Comment,
124 Self::Eof => UniversalTokenRole::Eof,
125 _ => UniversalTokenRole::None,
126 }
127 }
128}
129
130impl ElementType for TypstSyntaxKind {
131 type Role = UniversalElementRole;
132
133 fn role(&self) -> Self::Role {
134 match self {
135 Self::Error => UniversalElementRole::Error,
136 _ => UniversalElementRole::None,
137 }
138 }
139}