aboutsummaryrefslogtreecommitdiff
path: root/src/syntax_kinds/generated.rs
blob: 029972bb3a6d1298fd5fc522d2bdd1d8e4fcfa8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#![allow(bad_style, missing_docs, unreachable_pub)]
#![cfg_attr(rustfmt, rustfmt_skip)]
use super::SyntaxInfo;

/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum SyntaxKind {
    ERROR,
    IDENT,
    UNDERSCORE,
    WHITESPACE,
    INT_NUMBER,
    FLOAT_NUMBER,
    SEMI,
    COMMA,
    DOT,
    DOTDOT,
    DOTDOTDOT,
    DOTDOTEQ,
    L_PAREN,
    R_PAREN,
    L_CURLY,
    R_CURLY,
    L_BRACK,
    R_BRACK,
    L_ANGLE,
    R_ANGLE,
    AT,
    POUND,
    TILDE,
    QUESTION,
    COLON,
    COLONCOLON,
    DOLLAR,
    EQ,
    EQEQ,
    FAT_ARROW,
    NEQ,
    EXCL,
    LIFETIME,
    CHAR,
    BYTE,
    STRING,
    RAW_STRING,
    BYTE_STRING,
    RAW_BYTE_STRING,
    PLUS,
    MINUS,
    STAR,
    SLASH,
    CARET,
    PERCENT,
    AMPERSAND,
    PIPE,
    THIN_ARROW,
    COMMENT,
    DOC_COMMENT,
    SHEBANG,
    USE_KW,
    FN_KW,
    STRUCT_KW,
    ENUM_KW,
    TRAIT_KW,
    IMPL_KW,
    TRUE_KW,
    FALSE_KW,
    AS_KW,
    EXTERN_KW,
    CRATE_KW,
    MOD_KW,
    PUB_KW,
    SELF_KW,
    SUPER_KW,
    IN_KW,
    WHERE_KW,
    FOR_KW,
    LOOP_KW,
    WHILE_KW,
    IF_KW,
    MATCH_KW,
    CONST_KW,
    STATIC_KW,
    MUT_KW,
    UNSAFE_KW,
    TYPE_KW,
    REF_KW,
    LET_KW,
    AUTO_KW,
    DEFAULT_KW,
    UNION_KW,
    FILE,
    STRUCT_ITEM,
    ENUM_ITEM,
    FN_ITEM,
    EXTERN_CRATE_ITEM,
    MOD_ITEM,
    USE_ITEM,
    STATIC_ITEM,
    CONST_ITEM,
    TRAIT_ITEM,
    IMPL_ITEM,
    TYPE_ITEM,
    PAREN_TYPE,
    TUPLE_TYPE,
    NEVER_TYPE,
    PATH_TYPE,
    POINTER_TYPE,
    ARRAY_TYPE,
    SLICE_TYPE,
    REFERENCE_TYPE,
    PLACEHOLDER_TYPE,
    FN_POINTER_TYPE,
    FOR_TYPE,
    REF_PAT,
    BIND_PAT,
    PLACEHOLDER_PAT,
    TUPLE_EXPR,
    EXTERN_BLOCK,
    ENUM_VARIANT,
    NAMED_FIELD,
    POS_FIELD,
    ATTR,
    META_ITEM,
    USE_TREE,
    PATH,
    PATH_SEGMENT,
    LITERAL,
    ALIAS,
    VISIBILITY,
    TYPE_PARAM_LIST,
    WHERE_CLAUSE,
    LIFETIME_PARAM,
    TYPE_PARAM,
    ABI,
    NAME,
    NAME_REF,
    VALUE_PARAMETER,
    BLOCK,
    LET_STMT,
    // Technical SyntaxKinds: they appear temporally during parsing,
    // but never end up in the final tree
    #[doc(hidden)]
    TOMBSTONE,
    #[doc(hidden)]
    EOF,
}
use self::SyntaxKind::*;

impl SyntaxKind {
    pub(crate) fn info(self) -> &'static SyntaxInfo {
        match self {
            ERROR => &SyntaxInfo { name: "ERROR" },
            IDENT => &SyntaxInfo { name: "IDENT" },
            UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" },
            WHITESPACE => &SyntaxInfo { name: "WHITESPACE" },
            INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" },
            FLOAT_NUMBER => &SyntaxInfo { name: "FLOAT_NUMBER" },
            SEMI => &SyntaxInfo { name: "SEMI" },
            COMMA => &SyntaxInfo { name: "COMMA" },
            DOT => &SyntaxInfo { name: "DOT" },
            DOTDOT => &SyntaxInfo { name: "DOTDOT" },
            DOTDOTDOT => &SyntaxInfo { name: "DOTDOTDOT" },
            DOTDOTEQ => &SyntaxInfo { name: "DOTDOTEQ" },
            L_PAREN => &SyntaxInfo { name: "L_PAREN" },
            R_PAREN => &SyntaxInfo { name: "R_PAREN" },
            L_CURLY => &SyntaxInfo { name: "L_CURLY" },
            R_CURLY => &SyntaxInfo { name: "R_CURLY" },
            L_BRACK => &SyntaxInfo { name: "L_BRACK" },
            R_BRACK => &SyntaxInfo { name: "R_BRACK" },
            L_ANGLE => &SyntaxInfo { name: "L_ANGLE" },
            R_ANGLE => &SyntaxInfo { name: "R_ANGLE" },
            AT => &SyntaxInfo { name: "AT" },
            POUND => &SyntaxInfo { name: "POUND" },
            TILDE => &SyntaxInfo { name: "TILDE" },
            QUESTION => &SyntaxInfo { name: "QUESTION" },
            COLON => &SyntaxInfo { name: "COLON" },
            COLONCOLON => &SyntaxInfo { name: "COLONCOLON" },
            DOLLAR => &SyntaxInfo { name: "DOLLAR" },
            EQ => &SyntaxInfo { name: "EQ" },
            EQEQ => &SyntaxInfo { name: "EQEQ" },
            FAT_ARROW => &SyntaxInfo { name: "FAT_ARROW" },
            NEQ => &SyntaxInfo { name: "NEQ" },
            EXCL => &SyntaxInfo { name: "EXCL" },
            LIFETIME => &SyntaxInfo { name: "LIFETIME" },
            CHAR => &SyntaxInfo { name: "CHAR" },
            BYTE => &SyntaxInfo { name: "BYTE" },
            STRING => &SyntaxInfo { name: "STRING" },
            RAW_STRING => &SyntaxInfo { name: "RAW_STRING" },
            BYTE_STRING => &SyntaxInfo { name: "BYTE_STRING" },
            RAW_BYTE_STRING => &SyntaxInfo { name: "RAW_BYTE_STRING" },
            PLUS => &SyntaxInfo { name: "PLUS" },
            MINUS => &SyntaxInfo { name: "MINUS" },
            STAR => &SyntaxInfo { name: "STAR" },
            SLASH => &SyntaxInfo { name: "SLASH" },
            CARET => &SyntaxInfo { name: "CARET" },
            PERCENT => &SyntaxInfo { name: "PERCENT" },
            AMPERSAND => &SyntaxInfo { name: "AMPERSAND" },
            PIPE => &SyntaxInfo { name: "PIPE" },
            THIN_ARROW => &SyntaxInfo { name: "THIN_ARROW" },
            COMMENT => &SyntaxInfo { name: "COMMENT" },
            DOC_COMMENT => &SyntaxInfo { name: "DOC_COMMENT" },
            SHEBANG => &SyntaxInfo { name: "SHEBANG" },
            USE_KW => &SyntaxInfo { name: "USE_KW" },
            FN_KW => &SyntaxInfo { name: "FN_KW" },
            STRUCT_KW => &SyntaxInfo { name: "STRUCT_KW" },
            ENUM_KW => &SyntaxInfo { name: "ENUM_KW" },
            TRAIT_KW => &SyntaxInfo { name: "TRAIT_KW" },
            IMPL_KW => &SyntaxInfo { name: "IMPL_KW" },
            TRUE_KW => &SyntaxInfo { name: "TRUE_KW" },
            FALSE_KW => &SyntaxInfo { name: "FALSE_KW" },
            AS_KW => &SyntaxInfo { name: "AS_KW" },
            EXTERN_KW => &SyntaxInfo { name: "EXTERN_KW" },
            CRATE_KW => &SyntaxInfo { name: "CRATE_KW" },
            MOD_KW => &SyntaxInfo { name: "MOD_KW" },
            PUB_KW => &SyntaxInfo { name: "PUB_KW" },
            SELF_KW => &SyntaxInfo { name: "SELF_KW" },
            SUPER_KW => &SyntaxInfo { name: "SUPER_KW" },
            IN_KW => &SyntaxInfo { name: "IN_KW" },
            WHERE_KW => &SyntaxInfo { name: "WHERE_KW" },
            FOR_KW => &SyntaxInfo { name: "FOR_KW" },
            LOOP_KW => &SyntaxInfo { name: "LOOP_KW" },
            WHILE_KW => &SyntaxInfo { name: "WHILE_KW" },
            IF_KW => &SyntaxInfo { name: "IF_KW" },
            MATCH_KW => &SyntaxInfo { name: "MATCH_KW" },
            CONST_KW => &SyntaxInfo { name: "CONST_KW" },
            STATIC_KW => &SyntaxInfo { name: "STATIC_KW" },
            MUT_KW => &SyntaxInfo { name: "MUT_KW" },
            UNSAFE_KW => &SyntaxInfo { name: "UNSAFE_KW" },
            TYPE_KW => &SyntaxInfo { name: "TYPE_KW" },
            REF_KW => &SyntaxInfo { name: "REF_KW" },
            LET_KW => &SyntaxInfo { name: "LET_KW" },
            AUTO_KW => &SyntaxInfo { name: "AUTO_KW" },
            DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" },
            UNION_KW => &SyntaxInfo { name: "UNION_KW" },
            FILE => &SyntaxInfo { name: "FILE" },
            STRUCT_ITEM => &SyntaxInfo { name: "STRUCT_ITEM" },
            ENUM_ITEM => &SyntaxInfo { name: "ENUM_ITEM" },
            FN_ITEM => &SyntaxInfo { name: "FN_ITEM" },
            EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" },
            MOD_ITEM => &SyntaxInfo { name: "MOD_ITEM" },
            USE_ITEM => &SyntaxInfo { name: "USE_ITEM" },
            STATIC_ITEM => &SyntaxInfo { name: "STATIC_ITEM" },
            CONST_ITEM => &SyntaxInfo { name: "CONST_ITEM" },
            TRAIT_ITEM => &SyntaxInfo { name: "TRAIT_ITEM" },
            IMPL_ITEM => &SyntaxInfo { name: "IMPL_ITEM" },
            TYPE_ITEM => &SyntaxInfo { name: "TYPE_ITEM" },
            PAREN_TYPE => &SyntaxInfo { name: "PAREN_TYPE" },
            TUPLE_TYPE => &SyntaxInfo { name: "TUPLE_TYPE" },
            NEVER_TYPE => &SyntaxInfo { name: "NEVER_TYPE" },
            PATH_TYPE => &SyntaxInfo { name: "PATH_TYPE" },
            POINTER_TYPE => &SyntaxInfo { name: "POINTER_TYPE" },
            ARRAY_TYPE => &SyntaxInfo { name: "ARRAY_TYPE" },
            SLICE_TYPE => &SyntaxInfo { name: "SLICE_TYPE" },
            REFERENCE_TYPE => &SyntaxInfo { name: "REFERENCE_TYPE" },
            PLACEHOLDER_TYPE => &SyntaxInfo { name: "PLACEHOLDER_TYPE" },
            FN_POINTER_TYPE => &SyntaxInfo { name: "FN_POINTER_TYPE" },
            FOR_TYPE => &SyntaxInfo { name: "FOR_TYPE" },
            REF_PAT => &SyntaxInfo { name: "REF_PAT" },
            BIND_PAT => &SyntaxInfo { name: "BIND_PAT" },
            PLACEHOLDER_PAT => &SyntaxInfo { name: "PLACEHOLDER_PAT" },
            TUPLE_EXPR => &SyntaxInfo { name: "TUPLE_EXPR" },
            EXTERN_BLOCK => &SyntaxInfo { name: "EXTERN_BLOCK" },
            ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
            NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" },
            POS_FIELD => &SyntaxInfo { name: "POS_FIELD" },
            ATTR => &SyntaxInfo { name: "ATTR" },
            META_ITEM => &SyntaxInfo { name: "META_ITEM" },
            USE_TREE => &SyntaxInfo { name: "USE_TREE" },
            PATH => &SyntaxInfo { name: "PATH" },
            PATH_SEGMENT => &SyntaxInfo { name: "PATH_SEGMENT" },
            LITERAL => &SyntaxInfo { name: "LITERAL" },
            ALIAS => &SyntaxInfo { name: "ALIAS" },
            VISIBILITY => &SyntaxInfo { name: "VISIBILITY" },
            TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" },
            WHERE_CLAUSE => &SyntaxInfo { name: "WHERE_CLAUSE" },
            LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" },
            TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" },
            ABI => &SyntaxInfo { name: "ABI" },
            NAME => &SyntaxInfo { name: "NAME" },
            NAME_REF => &SyntaxInfo { name: "NAME_REF" },
            VALUE_PARAMETER => &SyntaxInfo { name: "VALUE_PARAMETER" },
            BLOCK => &SyntaxInfo { name: "BLOCK" },
            LET_STMT => &SyntaxInfo { name: "LET_STMT" },

            TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
            EOF => &SyntaxInfo { name: "EOF" },
        }
    }
    pub(crate) fn from_keyword(ident: &str) -> Option<SyntaxKind> {
        let kw = match ident {
            "use" => USE_KW,
            "fn" => FN_KW,
            "struct" => STRUCT_KW,
            "enum" => ENUM_KW,
            "trait" => TRAIT_KW,
            "impl" => IMPL_KW,
            "true" => TRUE_KW,
            "false" => FALSE_KW,
            "as" => AS_KW,
            "extern" => EXTERN_KW,
            "crate" => CRATE_KW,
            "mod" => MOD_KW,
            "pub" => PUB_KW,
            "self" => SELF_KW,
            "super" => SUPER_KW,
            "in" => IN_KW,
            "where" => WHERE_KW,
            "for" => FOR_KW,
            "loop" => LOOP_KW,
            "while" => WHILE_KW,
            "if" => IF_KW,
            "match" => MATCH_KW,
            "const" => CONST_KW,
            "static" => STATIC_KW,
            "mut" => MUT_KW,
            "unsafe" => UNSAFE_KW,
            "type" => TYPE_KW,
            "ref" => REF_KW,
            "let" => LET_KW,
            _ => return None,
        };
        Some(kw)
    }
}