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 Table,
17 TableRow,
18 TableCell,
19 Figure,
20 Image,
21 Link,
22
23 Text,
25 Strong,
26 Emphasis,
27 Code,
28 Math,
29 InlineMath,
30 DisplayMath,
31 Raw,
32 Quote,
33
34 Script,
36 Expression,
37 FunctionCall,
38 Variable,
39 Assignment,
40 Conditional,
41 Loop,
42 Import,
43 Include,
44
45 Set,
47 Show,
48 Style,
49 Color,
50 Font,
51 Size,
52
53 Let,
55 If,
56 Else,
57 For,
58 While,
59 Break,
60 Continue,
61 Return,
62 True,
63 False,
64
65 Plus,
67 Minus,
68 Star,
69 Slash,
70 Percent,
71 Equal,
72 EqualEqual,
73 NotEqual,
74 Less,
75 Greater,
76 LessEqual,
77 GreaterEqual,
78 And,
79 Or,
80 Not,
81
82 LeftParen,
84 RightParen,
85 LeftBrace,
86 RightBrace,
87 LeftBracket,
88 RightBracket,
89 Semicolon,
90 Comma,
91 Dot,
92 Colon,
93 Hash,
94 At,
95 Dollar,
96 Underscore,
97
98 StringLiteral,
100 NumericLiteral,
101 Identifier,
102
103 LineComment,
105 BlockComment,
106 Whitespace,
107 Newline,
108
109 Eof,
111 Error,
112}
113
114impl TokenType for TypstSyntaxKind {
115 const END_OF_STREAM: Self = Self::Eof;
116 type Role = UniversalTokenRole;
117
118 fn role(&self) -> Self::Role {
119 match self {
120 TypstSyntaxKind::Whitespace | TypstSyntaxKind::Newline => UniversalTokenRole::Whitespace,
121 TypstSyntaxKind::LineComment | TypstSyntaxKind::BlockComment => UniversalTokenRole::Comment,
122 Self::Eof => UniversalTokenRole::Eof,
123 _ => UniversalTokenRole::None,
124 }
125 }
126}
127
128impl ElementType for TypstSyntaxKind {
129 type Role = UniversalElementRole;
130
131 fn role(&self) -> Self::Role {
132 match self {
133 Self::Error => UniversalElementRole::Error,
134 _ => UniversalElementRole::None,
135 }
136 }
137}