1use oak_core::{Source, Token, TokenType, UniversalElementRole, UniversalTokenRole};
2#[cfg(feature = "serde")]
3use serde::{Deserialize, Serialize};
4
5impl TokenType for LeanTokenType {
6 type Role = UniversalTokenRole;
7 const END_OF_STREAM: Self = Self::Error;
8
9 fn is_ignored(&self) -> bool {
10 false
11 }
12
13 fn role(&self) -> Self::Role {
14 match self {
15 _ => UniversalTokenRole::None,
16 }
17 }
18}
19
20pub type LeanToken = Token<LeanTokenType>;
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
23#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
24pub enum LeanTokenType {
25 Root,
27 Eof,
28
29 Axiom,
31 Constant,
32 Def,
33 Example,
34 Inductive,
35 Lemma,
36 Namespace,
37 Open,
38 Private,
39 Protected,
40 Section,
41 Structure,
42 Theorem,
43 Universe,
44 Variable,
45 Variables,
46 End,
47 Import,
48 Export,
49 Prelude,
50 Noncomputable,
51 Partial,
52 Unsafe,
53 Mutual,
54 Where,
55 Have,
56 Show,
57 Suffices,
58 Let,
59 In,
60 If,
61 Then,
62 Else,
63 Match,
64 With,
65 Fun,
66 Do,
67 For,
68 While,
69 Break,
70 Continue,
71 Return,
72 Try,
73 Catch,
74 Finally,
75 Throw,
76
77 Identifier,
79 IntegerLiteral,
80 FloatLiteral,
81 StringLiteral,
82 CharLiteral,
83
84 Plus, Minus, Star, Slash, Percent, Caret, Hash, Ampersand, Pipe, Tilde, Bang, Question, At, Dollar, Arrow, FatArrow, Eq, Ne, Lt, Le, Gt, Ge, And, Or, Not, Append, Cons, LeftParen, RightParen, LeftBrace, RightBrace, LeftBracket, RightBracket, LeftAngle, RightAngle, Semicolon, Colon, Comma, Dot, DotDot, ColonEq, ColonColon, Whitespace,
132 Newline,
133 Comment,
134
135 Error,
137
138 SourceFile,
140 Function,
141 ParameterList,
142 Parameter,
143 BlockExpression,
144 LetStatement,
145 ExpressionStatement,
146 IdentifierExpression,
147 LiteralExpression,
148 BooleanLiteral,
149 ParenthesizedExpression,
150 BinaryExpression,
151 UnaryExpression,
152 CallExpression,
153 FieldExpression,
154 IndexExpression,
155 IfExpression,
156 MatchExpression,
157 LoopExpression,
158 WhileExpression,
159 ForExpression,
160 BreakExpression,
161 ContinueExpression,
162 ReturnExpression,
163 StructExpression,
164 TupleExpression,
165 ArrayExpression,
166 RangeExpression,
167 ClosureExpression,
168 AsyncBlockExpression,
169 UnsafeBlockExpression,
170 TryExpression,
171 AwaitExpression,
172 MacroCall,
173 Path,
174 PathSegment,
175 GenericArgs,
176 TypePath,
177 TupleType,
178 ArrayType,
179 SliceType,
180 ReferenceType,
181 PointerType,
182 FunctionType,
183 TraitObjectType,
184 ImplTraitType,
185 InferredType,
186 NeverType,
187 Pattern,
188 IdentifierPattern,
189 WildcardPattern,
190 TuplePattern,
191 StructPattern,
192 TupleStructPattern,
193 SlicePattern,
194 ReferencePattern,
195 LiteralPattern,
196 RangePattern,
197 OrPattern,
198 RestPattern,
199 StructDeclaration,
200 EnumDeclaration,
201 UnionDeclaration,
202 TraitDeclaration,
203 ImplDeclaration,
204 ModuleDeclaration,
205 UseDeclaration,
206 ConstDeclaration,
207 StaticDeclaration,
208 TypeAliasDeclaration,
209 ExternBlock,
210 ExternFunction,
211 Attribute,
212 Visibility,
213 GenericParams,
214 GenericParam,
215 TypeParam,
216 ConstParam,
217 LifetimeParam,
218 WhereClause,
219 WherePredicate,
220 ReturnType,
221 FieldList,
222 Field,
223 Variant,
224 VariantList,
225 AssociatedItem,
226 TraitItem,
227 ImplItem,
228}