aboutsummaryrefslogtreecommitdiff
path: root/src/syntax_kinds.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax_kinds.rs')
-rw-r--r--src/syntax_kinds.rs402
1 files changed, 208 insertions, 194 deletions
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs
index 5ab8b934b..aa19c2adf 100644
--- a/src/syntax_kinds.rs
+++ b/src/syntax_kinds.rs
@@ -1,201 +1,215 @@
1// Generated from grammar.ron 1#![allow(bad_style, missing_docs, unreachable_pub)]
2use tree::{SyntaxKind, SyntaxInfo}; 2#![cfg_attr(rustfmt, rustfmt_skip)]
3//! Generated from grammar.ron
4use tree::SyntaxInfo;
3 5
4pub const USE_KW: SyntaxKind = SyntaxKind(0); 6/// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
5pub const FN_KW: SyntaxKind = SyntaxKind(1); 7#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub const STRUCT_KW: SyntaxKind = SyntaxKind(2); 8#[repr(u32)]
7pub const ENUM_KW: SyntaxKind = SyntaxKind(3); 9pub enum SyntaxKind {
8pub const TRAIT_KW: SyntaxKind = SyntaxKind(4); 10 USE_KW,
9pub const IMPL_KW: SyntaxKind = SyntaxKind(5); 11 FN_KW,
10pub const TRUE_KW: SyntaxKind = SyntaxKind(6); 12 STRUCT_KW,
11pub const FALSE_KW: SyntaxKind = SyntaxKind(7); 13 ENUM_KW,
12pub const AS_KW: SyntaxKind = SyntaxKind(8); 14 TRAIT_KW,
13pub const EXTERN_KW: SyntaxKind = SyntaxKind(9); 15 IMPL_KW,
14pub const CRATE_KW: SyntaxKind = SyntaxKind(10); 16 TRUE_KW,
15pub const MOD_KW: SyntaxKind = SyntaxKind(11); 17 FALSE_KW,
16pub const PUB_KW: SyntaxKind = SyntaxKind(12); 18 AS_KW,
17pub const SELF_KW: SyntaxKind = SyntaxKind(13); 19 EXTERN_KW,
18pub const SUPER_KW: SyntaxKind = SyntaxKind(14); 20 CRATE_KW,
19pub const IN_KW: SyntaxKind = SyntaxKind(15); 21 MOD_KW,
20pub const WHERE_KW: SyntaxKind = SyntaxKind(16); 22 PUB_KW,
21pub const ERROR: SyntaxKind = SyntaxKind(17); 23 SELF_KW,
22pub const IDENT: SyntaxKind = SyntaxKind(18); 24 SUPER_KW,
23pub const UNDERSCORE: SyntaxKind = SyntaxKind(19); 25 IN_KW,
24pub const WHITESPACE: SyntaxKind = SyntaxKind(20); 26 WHERE_KW,
25pub const INT_NUMBER: SyntaxKind = SyntaxKind(21); 27 ERROR,
26pub const FLOAT_NUMBER: SyntaxKind = SyntaxKind(22); 28 IDENT,
27pub const SEMI: SyntaxKind = SyntaxKind(23); 29 UNDERSCORE,
28pub const COMMA: SyntaxKind = SyntaxKind(24); 30 WHITESPACE,
29pub const DOT: SyntaxKind = SyntaxKind(25); 31 INT_NUMBER,
30pub const DOTDOT: SyntaxKind = SyntaxKind(26); 32 FLOAT_NUMBER,
31pub const DOTDOTDOT: SyntaxKind = SyntaxKind(27); 33 SEMI,
32pub const DOTDOTEQ: SyntaxKind = SyntaxKind(28); 34 COMMA,
33pub const L_PAREN: SyntaxKind = SyntaxKind(29); 35 DOT,
34pub const R_PAREN: SyntaxKind = SyntaxKind(30); 36 DOTDOT,
35pub const L_CURLY: SyntaxKind = SyntaxKind(31); 37 DOTDOTDOT,
36pub const R_CURLY: SyntaxKind = SyntaxKind(32); 38 DOTDOTEQ,
37pub const L_BRACK: SyntaxKind = SyntaxKind(33); 39 L_PAREN,
38pub const R_BRACK: SyntaxKind = SyntaxKind(34); 40 R_PAREN,
39pub const L_ANGLE: SyntaxKind = SyntaxKind(35); 41 L_CURLY,
40pub const R_ANGLE: SyntaxKind = SyntaxKind(36); 42 R_CURLY,
41pub const AT: SyntaxKind = SyntaxKind(37); 43 L_BRACK,
42pub const POUND: SyntaxKind = SyntaxKind(38); 44 R_BRACK,
43pub const TILDE: SyntaxKind = SyntaxKind(39); 45 L_ANGLE,
44pub const QUESTION: SyntaxKind = SyntaxKind(40); 46 R_ANGLE,
45pub const COLON: SyntaxKind = SyntaxKind(41); 47 AT,
46pub const COLONCOLON: SyntaxKind = SyntaxKind(42); 48 POUND,
47pub const DOLLAR: SyntaxKind = SyntaxKind(43); 49 TILDE,
48pub const EQ: SyntaxKind = SyntaxKind(44); 50 QUESTION,
49pub const EQEQ: SyntaxKind = SyntaxKind(45); 51 COLON,
50pub const FAT_ARROW: SyntaxKind = SyntaxKind(46); 52 COLONCOLON,
51pub const NEQ: SyntaxKind = SyntaxKind(47); 53 DOLLAR,
52pub const EXCL: SyntaxKind = SyntaxKind(48); 54 EQ,
53pub const LIFETIME: SyntaxKind = SyntaxKind(49); 55 EQEQ,
54pub const CHAR: SyntaxKind = SyntaxKind(50); 56 FAT_ARROW,
55pub const BYTE: SyntaxKind = SyntaxKind(51); 57 NEQ,
56pub const STRING: SyntaxKind = SyntaxKind(52); 58 EXCL,
57pub const RAW_STRING: SyntaxKind = SyntaxKind(53); 59 LIFETIME,
58pub const BYTE_STRING: SyntaxKind = SyntaxKind(54); 60 CHAR,
59pub const RAW_BYTE_STRING: SyntaxKind = SyntaxKind(55); 61 BYTE,
60pub const PLUS: SyntaxKind = SyntaxKind(56); 62 STRING,
61pub const MINUS: SyntaxKind = SyntaxKind(57); 63 RAW_STRING,
62pub const STAR: SyntaxKind = SyntaxKind(58); 64 BYTE_STRING,
63pub const SLASH: SyntaxKind = SyntaxKind(59); 65 RAW_BYTE_STRING,
64pub const CARET: SyntaxKind = SyntaxKind(60); 66 PLUS,
65pub const PERCENT: SyntaxKind = SyntaxKind(61); 67 MINUS,
66pub const AMPERSAND: SyntaxKind = SyntaxKind(62); 68 STAR,
67pub const PIPE: SyntaxKind = SyntaxKind(63); 69 SLASH,
68pub const THIN_ARROW: SyntaxKind = SyntaxKind(64); 70 CARET,
69pub const COMMENT: SyntaxKind = SyntaxKind(65); 71 PERCENT,
70pub const DOC_COMMENT: SyntaxKind = SyntaxKind(66); 72 AMPERSAND,
71pub const SHEBANG: SyntaxKind = SyntaxKind(67); 73 PIPE,
72pub const FILE: SyntaxKind = SyntaxKind(68); 74 THIN_ARROW,
73pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(69); 75 COMMENT,
74pub const NAMED_FIELD: SyntaxKind = SyntaxKind(70); 76 DOC_COMMENT,
75pub const POS_FIELD: SyntaxKind = SyntaxKind(71); 77 SHEBANG,
76pub const FN_ITEM: SyntaxKind = SyntaxKind(72); 78 FILE,
77pub const EXTERN_CRATE_ITEM: SyntaxKind = SyntaxKind(73); 79 STRUCT_ITEM,
78pub const ATTR: SyntaxKind = SyntaxKind(74); 80 NAMED_FIELD,
79pub const META_ITEM: SyntaxKind = SyntaxKind(75); 81 POS_FIELD,
80pub const MOD_ITEM: SyntaxKind = SyntaxKind(76); 82 FN_ITEM,
81pub const USE_ITEM: SyntaxKind = SyntaxKind(77); 83 EXTERN_CRATE_ITEM,
82pub const USE_TREE: SyntaxKind = SyntaxKind(78); 84 ATTR,
83pub const PATH: SyntaxKind = SyntaxKind(79); 85 META_ITEM,
84pub const PATH_SEGMENT: SyntaxKind = SyntaxKind(80); 86 MOD_ITEM,
85pub const LITERAL: SyntaxKind = SyntaxKind(81); 87 USE_ITEM,
86pub const ALIAS: SyntaxKind = SyntaxKind(82); 88 USE_TREE,
87pub const VISIBILITY: SyntaxKind = SyntaxKind(83); 89 PATH,
90 PATH_SEGMENT,
91 LITERAL,
92 ALIAS,
93 VISIBILITY,
88 94
89static INFOS: [SyntaxInfo; 84] = [ 95 TOMBSTONE = !0 - 1,
90 SyntaxInfo { name: "USE_KW" }, 96 EOF = !0,
91 SyntaxInfo { name: "FN_KW" }, 97}
92 SyntaxInfo { name: "STRUCT_KW" }, 98pub(crate) use self::SyntaxKind::*;
93 SyntaxInfo { name: "ENUM_KW" }, 99
94 SyntaxInfo { name: "TRAIT_KW" }, 100impl SyntaxKind {
95 SyntaxInfo { name: "IMPL_KW" }, 101 pub(crate) fn info(self) -> &'static SyntaxInfo {
96 SyntaxInfo { name: "TRUE_KW" }, 102 match self {
97 SyntaxInfo { name: "FALSE_KW" }, 103 USE_KW => &SyntaxInfo { name: "USE_KW" },
98 SyntaxInfo { name: "AS_KW" }, 104 FN_KW => &SyntaxInfo { name: "FN_KW" },
99 SyntaxInfo { name: "EXTERN_KW" }, 105 STRUCT_KW => &SyntaxInfo { name: "STRUCT_KW" },
100 SyntaxInfo { name: "CRATE_KW" }, 106 ENUM_KW => &SyntaxInfo { name: "ENUM_KW" },
101 SyntaxInfo { name: "MOD_KW" }, 107 TRAIT_KW => &SyntaxInfo { name: "TRAIT_KW" },
102 SyntaxInfo { name: "PUB_KW" }, 108 IMPL_KW => &SyntaxInfo { name: "IMPL_KW" },
103 SyntaxInfo { name: "SELF_KW" }, 109 TRUE_KW => &SyntaxInfo { name: "TRUE_KW" },
104 SyntaxInfo { name: "SUPER_KW" }, 110 FALSE_KW => &SyntaxInfo { name: "FALSE_KW" },
105 SyntaxInfo { name: "IN_KW" }, 111 AS_KW => &SyntaxInfo { name: "AS_KW" },
106 SyntaxInfo { name: "WHERE_KW" }, 112 EXTERN_KW => &SyntaxInfo { name: "EXTERN_KW" },
107 SyntaxInfo { name: "ERROR" }, 113 CRATE_KW => &SyntaxInfo { name: "CRATE_KW" },
108 SyntaxInfo { name: "IDENT" }, 114 MOD_KW => &SyntaxInfo { name: "MOD_KW" },
109 SyntaxInfo { name: "UNDERSCORE" }, 115 PUB_KW => &SyntaxInfo { name: "PUB_KW" },
110 SyntaxInfo { name: "WHITESPACE" }, 116 SELF_KW => &SyntaxInfo { name: "SELF_KW" },
111 SyntaxInfo { name: "INT_NUMBER" }, 117 SUPER_KW => &SyntaxInfo { name: "SUPER_KW" },
112 SyntaxInfo { name: "FLOAT_NUMBER" }, 118 IN_KW => &SyntaxInfo { name: "IN_KW" },
113 SyntaxInfo { name: "SEMI" }, 119 WHERE_KW => &SyntaxInfo { name: "WHERE_KW" },
114 SyntaxInfo { name: "COMMA" }, 120 ERROR => &SyntaxInfo { name: "ERROR" },
115 SyntaxInfo { name: "DOT" }, 121 IDENT => &SyntaxInfo { name: "IDENT" },
116 SyntaxInfo { name: "DOTDOT" }, 122 UNDERSCORE => &SyntaxInfo { name: "UNDERSCORE" },
117 SyntaxInfo { name: "DOTDOTDOT" }, 123 WHITESPACE => &SyntaxInfo { name: "WHITESPACE" },
118 SyntaxInfo { name: "DOTDOTEQ" }, 124 INT_NUMBER => &SyntaxInfo { name: "INT_NUMBER" },
119 SyntaxInfo { name: "L_PAREN" }, 125 FLOAT_NUMBER => &SyntaxInfo { name: "FLOAT_NUMBER" },
120 SyntaxInfo { name: "R_PAREN" }, 126 SEMI => &SyntaxInfo { name: "SEMI" },
121 SyntaxInfo { name: "L_CURLY" }, 127 COMMA => &SyntaxInfo { name: "COMMA" },
122 SyntaxInfo { name: "R_CURLY" }, 128 DOT => &SyntaxInfo { name: "DOT" },
123 SyntaxInfo { name: "L_BRACK" }, 129 DOTDOT => &SyntaxInfo { name: "DOTDOT" },
124 SyntaxInfo { name: "R_BRACK" }, 130 DOTDOTDOT => &SyntaxInfo { name: "DOTDOTDOT" },
125 SyntaxInfo { name: "L_ANGLE" }, 131 DOTDOTEQ => &SyntaxInfo { name: "DOTDOTEQ" },
126 SyntaxInfo { name: "R_ANGLE" }, 132 L_PAREN => &SyntaxInfo { name: "L_PAREN" },
127 SyntaxInfo { name: "AT" }, 133 R_PAREN => &SyntaxInfo { name: "R_PAREN" },
128 SyntaxInfo { name: "POUND" }, 134 L_CURLY => &SyntaxInfo { name: "L_CURLY" },
129 SyntaxInfo { name: "TILDE" }, 135 R_CURLY => &SyntaxInfo { name: "R_CURLY" },
130 SyntaxInfo { name: "QUESTION" }, 136 L_BRACK => &SyntaxInfo { name: "L_BRACK" },
131 SyntaxInfo { name: "COLON" }, 137 R_BRACK => &SyntaxInfo { name: "R_BRACK" },
132 SyntaxInfo { name: "COLONCOLON" }, 138 L_ANGLE => &SyntaxInfo { name: "L_ANGLE" },
133 SyntaxInfo { name: "DOLLAR" }, 139 R_ANGLE => &SyntaxInfo { name: "R_ANGLE" },
134 SyntaxInfo { name: "EQ" }, 140 AT => &SyntaxInfo { name: "AT" },
135 SyntaxInfo { name: "EQEQ" }, 141 POUND => &SyntaxInfo { name: "POUND" },
136 SyntaxInfo { name: "FAT_ARROW" }, 142 TILDE => &SyntaxInfo { name: "TILDE" },
137 SyntaxInfo { name: "NEQ" }, 143 QUESTION => &SyntaxInfo { name: "QUESTION" },
138 SyntaxInfo { name: "EXCL" }, 144 COLON => &SyntaxInfo { name: "COLON" },
139 SyntaxInfo { name: "LIFETIME" }, 145 COLONCOLON => &SyntaxInfo { name: "COLONCOLON" },
140 SyntaxInfo { name: "CHAR" }, 146 DOLLAR => &SyntaxInfo { name: "DOLLAR" },
141 SyntaxInfo { name: "BYTE" }, 147 EQ => &SyntaxInfo { name: "EQ" },
142 SyntaxInfo { name: "STRING" }, 148 EQEQ => &SyntaxInfo { name: "EQEQ" },
143 SyntaxInfo { name: "RAW_STRING" }, 149 FAT_ARROW => &SyntaxInfo { name: "FAT_ARROW" },
144 SyntaxInfo { name: "BYTE_STRING" }, 150 NEQ => &SyntaxInfo { name: "NEQ" },
145 SyntaxInfo { name: "RAW_BYTE_STRING" }, 151 EXCL => &SyntaxInfo { name: "EXCL" },
146 SyntaxInfo { name: "PLUS" }, 152 LIFETIME => &SyntaxInfo { name: "LIFETIME" },
147 SyntaxInfo { name: "MINUS" }, 153 CHAR => &SyntaxInfo { name: "CHAR" },
148 SyntaxInfo { name: "STAR" }, 154 BYTE => &SyntaxInfo { name: "BYTE" },
149 SyntaxInfo { name: "SLASH" }, 155 STRING => &SyntaxInfo { name: "STRING" },
150 SyntaxInfo { name: "CARET" }, 156 RAW_STRING => &SyntaxInfo { name: "RAW_STRING" },
151 SyntaxInfo { name: "PERCENT" }, 157 BYTE_STRING => &SyntaxInfo { name: "BYTE_STRING" },
152 SyntaxInfo { name: "AMPERSAND" }, 158 RAW_BYTE_STRING => &SyntaxInfo { name: "RAW_BYTE_STRING" },
153 SyntaxInfo { name: "PIPE" }, 159 PLUS => &SyntaxInfo { name: "PLUS" },
154 SyntaxInfo { name: "THIN_ARROW" }, 160 MINUS => &SyntaxInfo { name: "MINUS" },
155 SyntaxInfo { name: "COMMENT" }, 161 STAR => &SyntaxInfo { name: "STAR" },
156 SyntaxInfo { name: "DOC_COMMENT" }, 162 SLASH => &SyntaxInfo { name: "SLASH" },
157 SyntaxInfo { name: "SHEBANG" }, 163 CARET => &SyntaxInfo { name: "CARET" },
158 SyntaxInfo { name: "FILE" }, 164 PERCENT => &SyntaxInfo { name: "PERCENT" },
159 SyntaxInfo { name: "STRUCT_ITEM" }, 165 AMPERSAND => &SyntaxInfo { name: "AMPERSAND" },
160 SyntaxInfo { name: "NAMED_FIELD" }, 166 PIPE => &SyntaxInfo { name: "PIPE" },
161 SyntaxInfo { name: "POS_FIELD" }, 167 THIN_ARROW => &SyntaxInfo { name: "THIN_ARROW" },
162 SyntaxInfo { name: "FN_ITEM" }, 168 COMMENT => &SyntaxInfo { name: "COMMENT" },
163 SyntaxInfo { name: "EXTERN_CRATE_ITEM" }, 169 DOC_COMMENT => &SyntaxInfo { name: "DOC_COMMENT" },
164 SyntaxInfo { name: "ATTR" }, 170 SHEBANG => &SyntaxInfo { name: "SHEBANG" },
165 SyntaxInfo { name: "META_ITEM" }, 171 FILE => &SyntaxInfo { name: "FILE" },
166 SyntaxInfo { name: "MOD_ITEM" }, 172 STRUCT_ITEM => &SyntaxInfo { name: "STRUCT_ITEM" },
167 SyntaxInfo { name: "USE_ITEM" }, 173 NAMED_FIELD => &SyntaxInfo { name: "NAMED_FIELD" },
168 SyntaxInfo { name: "USE_TREE" }, 174 POS_FIELD => &SyntaxInfo { name: "POS_FIELD" },
169 SyntaxInfo { name: "PATH" }, 175 FN_ITEM => &SyntaxInfo { name: "FN_ITEM" },
170 SyntaxInfo { name: "PATH_SEGMENT" }, 176 EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" },
171 SyntaxInfo { name: "LITERAL" }, 177 ATTR => &SyntaxInfo { name: "ATTR" },
172 SyntaxInfo { name: "ALIAS" }, 178 META_ITEM => &SyntaxInfo { name: "META_ITEM" },
173 SyntaxInfo { name: "VISIBILITY" }, 179 MOD_ITEM => &SyntaxInfo { name: "MOD_ITEM" },
174]; 180 USE_ITEM => &SyntaxInfo { name: "USE_ITEM" },
181 USE_TREE => &SyntaxInfo { name: "USE_TREE" },
182 PATH => &SyntaxInfo { name: "PATH" },
183 PATH_SEGMENT => &SyntaxInfo { name: "PATH_SEGMENT" },
184 LITERAL => &SyntaxInfo { name: "LITERAL" },
185 ALIAS => &SyntaxInfo { name: "ALIAS" },
186 VISIBILITY => &SyntaxInfo { name: "VISIBILITY" },
175 187
176pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo { 188 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
177 &INFOS[kind.0 as usize] 189 EOF => &SyntaxInfo { name: "EOF" },
190 }
191 }
178} 192}
179 193
180pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> { 194pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {
181 match ident { 195 match ident {
182 "use" => Some(USE_KW), 196 "use" => Some(USE_KW),
183 "fn" => Some(FN_KW), 197 "fn" => Some(FN_KW),
184 "struct" => Some(STRUCT_KW), 198 "struct" => Some(STRUCT_KW),
185 "enum" => Some(ENUM_KW), 199 "enum" => Some(ENUM_KW),
186 "trait" => Some(TRAIT_KW), 200 "trait" => Some(TRAIT_KW),
187 "impl" => Some(IMPL_KW), 201 "impl" => Some(IMPL_KW),
188 "true" => Some(TRUE_KW), 202 "true" => Some(TRUE_KW),
189 "false" => Some(FALSE_KW), 203 "false" => Some(FALSE_KW),
190 "as" => Some(AS_KW), 204 "as" => Some(AS_KW),
191 "extern" => Some(EXTERN_KW), 205 "extern" => Some(EXTERN_KW),
192 "crate" => Some(CRATE_KW), 206 "crate" => Some(CRATE_KW),
193 "mod" => Some(MOD_KW), 207 "mod" => Some(MOD_KW),
194 "pub" => Some(PUB_KW), 208 "pub" => Some(PUB_KW),
195 "self" => Some(SELF_KW), 209 "self" => Some(SELF_KW),
196 "super" => Some(SUPER_KW), 210 "super" => Some(SUPER_KW),
197 "in" => Some(IN_KW), 211 "in" => Some(IN_KW),
198 "where" => Some(WHERE_KW), 212 "where" => Some(WHERE_KW),
199 _ => None, 213 _ => None,
200 } 214 }
201} 215}