aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/syntax_kind
diff options
context:
space:
mode:
authorSergey Parilin <[email protected]>2019-05-08 16:35:32 +0100
committerSergey Parilin <[email protected]>2019-05-13 13:19:57 +0100
commit57bb618fd3f11d9ac817f76a965316723aa69ee9 (patch)
treed754b59aec2e1f80849b518ce6565839108f63dd /crates/ra_parser/src/syntax_kind
parentef782adc293deb287128f005dbab2038ba3ccdc1 (diff)
Implemented T! macro for syntax kinds
Diffstat (limited to 'crates/ra_parser/src/syntax_kind')
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs95
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs.tera14
2 files changed, 109 insertions, 0 deletions
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 6f984aea1..1a08cc6eb 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -241,6 +241,101 @@ pub enum SyntaxKind {
241} 241}
242use self::SyntaxKind::*; 242use self::SyntaxKind::*;
243 243
244#[macro_export]
245macro_rules! T {
246 (;) => { $crate::SyntaxKind::SEMI };
247 (,) => { $crate::SyntaxKind::COMMA };
248 (() => { $crate::SyntaxKind::L_PAREN };
249 ()) => { $crate::SyntaxKind::R_PAREN };
250 ('{') => { $crate::SyntaxKind::L_CURLY };
251 ('}') => { $crate::SyntaxKind::R_CURLY };
252 ('[') => { $crate::SyntaxKind::L_BRACK };
253 (']') => { $crate::SyntaxKind::R_BRACK };
254 (<) => { $crate::SyntaxKind::L_ANGLE };
255 (>) => { $crate::SyntaxKind::R_ANGLE };
256 (@) => { $crate::SyntaxKind::AT };
257 (#) => { $crate::SyntaxKind::POUND };
258 (~) => { $crate::SyntaxKind::TILDE };
259 (?) => { $crate::SyntaxKind::QUESTION };
260 ($) => { $crate::SyntaxKind::DOLLAR };
261 (&) => { $crate::SyntaxKind::AMP };
262 (|) => { $crate::SyntaxKind::PIPE };
263 (+) => { $crate::SyntaxKind::PLUS };
264 (*) => { $crate::SyntaxKind::STAR };
265 (/) => { $crate::SyntaxKind::SLASH };
266 (^) => { $crate::SyntaxKind::CARET };
267 (%) => { $crate::SyntaxKind::PERCENT };
268 (_) => { $crate::SyntaxKind::UNDERSCORE };
269 (.) => { $crate::SyntaxKind::DOT };
270 (..) => { $crate::SyntaxKind::DOTDOT };
271 (...) => { $crate::SyntaxKind::DOTDOTDOT };
272 (..=) => { $crate::SyntaxKind::DOTDOTEQ };
273 (:) => { $crate::SyntaxKind::COLON };
274 (::) => { $crate::SyntaxKind::COLONCOLON };
275 (=) => { $crate::SyntaxKind::EQ };
276 (==) => { $crate::SyntaxKind::EQEQ };
277 (=>) => { $crate::SyntaxKind::FAT_ARROW };
278 (!) => { $crate::SyntaxKind::EXCL };
279 (!=) => { $crate::SyntaxKind::NEQ };
280 (-) => { $crate::SyntaxKind::MINUS };
281 (->) => { $crate::SyntaxKind::THIN_ARROW };
282 (<=) => { $crate::SyntaxKind::LTEQ };
283 (>=) => { $crate::SyntaxKind::GTEQ };
284 (+=) => { $crate::SyntaxKind::PLUSEQ };
285 (-=) => { $crate::SyntaxKind::MINUSEQ };
286 (|=) => { $crate::SyntaxKind::PIPEEQ };
287 (&=) => { $crate::SyntaxKind::AMPEQ };
288 (^=) => { $crate::SyntaxKind::CARETEQ };
289 (/=) => { $crate::SyntaxKind::SLASHEQ };
290 (*=) => { $crate::SyntaxKind::STAREQ };
291 (%=) => { $crate::SyntaxKind::PERCENTEQ };
292 (&&) => { $crate::SyntaxKind::AMPAMP };
293 (||) => { $crate::SyntaxKind::PIPEPIPE };
294 (<<) => { $crate::SyntaxKind::SHL };
295 (>>) => { $crate::SyntaxKind::SHR };
296 (<<=) => { $crate::SyntaxKind::SHLEQ };
297 (>>=) => { $crate::SyntaxKind::SHREQ };
298 (async) => { $crate::SyntaxKind::ASYNC_KW };
299 (use) => { $crate::SyntaxKind::USE_KW };
300 (fn) => { $crate::SyntaxKind::FN_KW };
301 (struct) => { $crate::SyntaxKind::STRUCT_KW };
302 (enum) => { $crate::SyntaxKind::ENUM_KW };
303 (trait) => { $crate::SyntaxKind::TRAIT_KW };
304 (impl) => { $crate::SyntaxKind::IMPL_KW };
305 (dyn) => { $crate::SyntaxKind::DYN_KW };
306 (true) => { $crate::SyntaxKind::TRUE_KW };
307 (false) => { $crate::SyntaxKind::FALSE_KW };
308 (as) => { $crate::SyntaxKind::AS_KW };
309 (extern) => { $crate::SyntaxKind::EXTERN_KW };
310 (crate) => { $crate::SyntaxKind::CRATE_KW };
311 (mod) => { $crate::SyntaxKind::MOD_KW };
312 (pub) => { $crate::SyntaxKind::PUB_KW };
313 (self) => { $crate::SyntaxKind::SELF_KW };
314 (super) => { $crate::SyntaxKind::SUPER_KW };
315 (in) => { $crate::SyntaxKind::IN_KW };
316 (where) => { $crate::SyntaxKind::WHERE_KW };
317 (for) => { $crate::SyntaxKind::FOR_KW };
318 (loop) => { $crate::SyntaxKind::LOOP_KW };
319 (while) => { $crate::SyntaxKind::WHILE_KW };
320 (continue) => { $crate::SyntaxKind::CONTINUE_KW };
321 (break) => { $crate::SyntaxKind::BREAK_KW };
322 (if) => { $crate::SyntaxKind::IF_KW };
323 (else) => { $crate::SyntaxKind::ELSE_KW };
324 (match) => { $crate::SyntaxKind::MATCH_KW };
325 (const) => { $crate::SyntaxKind::CONST_KW };
326 (static) => { $crate::SyntaxKind::STATIC_KW };
327 (mut) => { $crate::SyntaxKind::MUT_KW };
328 (unsafe) => { $crate::SyntaxKind::UNSAFE_KW };
329 (type) => { $crate::SyntaxKind::TYPE_KW };
330 (ref) => { $crate::SyntaxKind::REF_KW };
331 (let) => { $crate::SyntaxKind::LET_KW };
332 (move) => { $crate::SyntaxKind::MOVE_KW };
333 (return) => { $crate::SyntaxKind::RETURN_KW };
334 (auto) => { $crate::SyntaxKind::AUTO_KW };
335 (default) => { $crate::SyntaxKind::DEFAULT_KW };
336 (union) => { $crate::SyntaxKind::UNION_KW };
337}
338
244impl From<u16> for SyntaxKind { 339impl From<u16> for SyntaxKind {
245 fn from(d: u16) -> SyntaxKind { 340 fn from(d: u16) -> SyntaxKind {
246 assert!(d <= (__LAST as u16)); 341 assert!(d <= (__LAST as u16));
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs.tera b/crates/ra_parser/src/syntax_kind/generated.rs.tera
index 5b9ff21af..ccb8ca4ba 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs.tera
+++ b/crates/ra_parser/src/syntax_kind/generated.rs.tera
@@ -33,6 +33,20 @@ pub enum SyntaxKind {
33} 33}
34use self::SyntaxKind::*; 34use self::SyntaxKind::*;
35 35
36#[macro_export]
37macro_rules! T {
38{%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %}
39 {%- if t.0 == '{' or t.0 == '}' or t.0 == '[' or t.0 == ']' %}
40 ('{{t.0}}') => { $crate::SyntaxKind::{{t.1}} };
41 {%- else %}
42 ({{t.0}}) => { $crate::SyntaxKind::{{t.1}} };
43 {%- endif %}
44{%- endfor -%}
45{% for kw in concat(a=keywords, b=contextual_keywords) %}
46 ({{kw}}) => { $crate::SyntaxKind::{{kw | upper}}_KW };
47{%- endfor %}
48}
49
36impl From<u16> for SyntaxKind { 50impl From<u16> for SyntaxKind {
37 fn from(d: u16) -> SyntaxKind { 51 fn from(d: u16) -> SyntaxKind {
38 assert!(d <= (__LAST as u16)); 52 assert!(d <= (__LAST as u16));