1use oak_core::SyntaxKind;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub enum TexSyntaxKind {
6 Root,
8 SourceFile,
9 Document,
10
11 Command,
13 Environment,
14 BeginEnvironment,
15 EndEnvironment,
16
17 MathMode,
19 InlineMath,
20 DisplayMath,
21 Group,
22
23 Argument,
25 OptionalArgument,
26 MandatoryArgument,
27
28 Text,
30 Paragraph,
31 Section,
32 Subsection,
33 Subsubsection,
34
35 List,
37 Item,
38 Table,
39 Row,
40 Cell,
41
42 Label,
44 Reference,
45 Citation,
46
47 Figure,
49 Caption,
50
51 Error,
53
54 DocumentClass,
56 UsePackage,
57 Begin,
58 End,
59 Section_,
60 Subsection_,
61 Subsubsection_,
62 Chapter,
63 Part,
64 Title,
65 Author,
66 Date,
67 MakeTitle,
68 TableOfContents,
69 NewPage,
70 ClearPage,
71
72 BeginKeyword,
74 EndKeyword,
75 DocumentclassKeyword,
76 UsepackageKeyword,
77 SectionKeyword,
78 SubsectionKeyword,
79 SubsubsectionKeyword,
80 ChapterKeyword,
81 PartKeyword,
82 TitleKeyword,
83 AuthorKeyword,
84 DateKeyword,
85 MaketitleKeyword,
86 TableofcontentsKeyword,
87 ItemKeyword,
88 LabelKeyword,
89 RefKeyword,
90 CiteKeyword,
91 IncludegraphicsKeyword,
92 TextbfKeyword,
93 TextitKeyword,
94 EmphKeyword,
95
96 Frac,
98 Sqrt,
99 Sum,
100 Int,
101 Lim,
102 Alpha,
103 Beta,
104 Gamma,
105 Delta,
106 Epsilon,
107
108 TextBf,
110 TextIt,
111 TextSc,
112 TextTt,
113 Emph,
114 Underline,
115
116 Identifier,
118 StringLiteral,
119 Number,
120
121 Backslash,
123 LeftBrace,
124 RightBrace,
125 LeftBracket,
126 RightBracket,
127 LeftParen,
128 RightParen,
129 Dollar,
130 DoubleDollar,
131 Ampersand,
132 Percent,
133 Hash,
134 Caret,
135 Underscore,
136 Tilde,
137
138 Equal,
140 Equals,
141 Plus,
142 Minus,
143 Star,
144 Slash,
145 Pipe,
146 Less,
147 LessThan,
148 Greater,
149 GreaterThan,
150 Exclamation,
151 Question,
152 At,
153 Colon,
154 Semicolon,
155 Comma,
156 Dot,
157
158 Comment,
160 Whitespace,
161 Newline,
162
163 Eof,
165}
166
167impl SyntaxKind for TexSyntaxKind {
168 fn is_trivia(&self) -> bool {
169 matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
170 }
171
172 fn is_comment(&self) -> bool {
173 matches!(self, Self::Comment)
174 }
175
176 fn is_whitespace(&self) -> bool {
177 matches!(self, Self::Whitespace | Self::Newline)
178 }
179
180 fn is_token_type(&self) -> bool {
181 !matches!(
182 self,
183 Self::Document
184 | Self::Command
185 | Self::Environment
186 | Self::Argument
187 | Self::OptionalArgument
188 | Self::MandatoryArgument
189 | Self::Text
190 | Self::List
191 | Self::Table
192 | Self::Reference
193 | Self::Figure
194 | Self::Error
195 )
196 }
197
198 fn is_element_type(&self) -> bool {
199 matches!(
200 self,
201 Self::Document
202 | Self::Command
203 | Self::Environment
204 | Self::Argument
205 | Self::OptionalArgument
206 | Self::MandatoryArgument
207 | Self::Text
208 | Self::List
209 | Self::Table
210 | Self::Reference
211 | Self::Figure
212 | Self::Error
213 )
214 }
215}