diff options
author | Aleksey Kladov <[email protected]> | 2018-07-30 16:11:33 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-30 16:11:33 +0100 |
commit | beaddb478097223c87e507bf9367d85d86df5d06 (patch) | |
tree | 7490bad360bc226403183d8900c16f170f712626 /src/syntax_kinds | |
parent | 60e8a845cafb9630caa034b886368160a12dcd64 (diff) |
Intern static tokens
Diffstat (limited to 'src/syntax_kinds')
-rw-r--r-- | src/syntax_kinds/generated.rs | 75 | ||||
-rw-r--r-- | src/syntax_kinds/generated.rs.tera | 13 |
2 files changed, 88 insertions, 0 deletions
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs index 9dcf8992f..571b64af4 100644 --- a/src/syntax_kinds/generated.rs +++ b/src/syntax_kinds/generated.rs | |||
@@ -353,5 +353,80 @@ impl SyntaxKind { | |||
353 | }; | 353 | }; |
354 | Some(tok) | 354 | Some(tok) |
355 | } | 355 | } |
356 | |||
357 | pub(crate) fn static_text(self) -> Option<&'static str> { | ||
358 | let tok = match self { | ||
359 | SEMI => ";", | ||
360 | COMMA => ",", | ||
361 | L_PAREN => "(", | ||
362 | R_PAREN => ")", | ||
363 | L_CURLY => "{", | ||
364 | R_CURLY => "}", | ||
365 | L_BRACK => "[", | ||
366 | R_BRACK => "]", | ||
367 | L_ANGLE => "<", | ||
368 | R_ANGLE => ">", | ||
369 | AT => "@", | ||
370 | POUND => "#", | ||
371 | TILDE => "~", | ||
372 | QUESTION => "?", | ||
373 | DOLLAR => "$", | ||
374 | AMPERSAND => "&", | ||
375 | PIPE => "|", | ||
376 | PLUS => "+", | ||
377 | STAR => "*", | ||
378 | SLASH => "/", | ||
379 | CARET => "^", | ||
380 | PERCENT => "%", | ||
381 | DOT => ".", | ||
382 | DOTDOT => "..", | ||
383 | DOTDOTDOT => "...", | ||
384 | DOTDOTEQ => "..=", | ||
385 | COLON => ":", | ||
386 | COLONCOLON => "::", | ||
387 | EQ => "=", | ||
388 | EQEQ => "==", | ||
389 | FAT_ARROW => "=>", | ||
390 | EXCL => "!", | ||
391 | NEQ => "!=", | ||
392 | MINUS => "-", | ||
393 | THIN_ARROW => "->", | ||
394 | |||
395 | USE_KW => "use", | ||
396 | FN_KW => "fn", | ||
397 | STRUCT_KW => "struct", | ||
398 | ENUM_KW => "enum", | ||
399 | TRAIT_KW => "trait", | ||
400 | IMPL_KW => "impl", | ||
401 | TRUE_KW => "true", | ||
402 | FALSE_KW => "false", | ||
403 | AS_KW => "as", | ||
404 | EXTERN_KW => "extern", | ||
405 | CRATE_KW => "crate", | ||
406 | MOD_KW => "mod", | ||
407 | PUB_KW => "pub", | ||
408 | SELF_KW => "self", | ||
409 | SUPER_KW => "super", | ||
410 | IN_KW => "in", | ||
411 | WHERE_KW => "where", | ||
412 | FOR_KW => "for", | ||
413 | LOOP_KW => "loop", | ||
414 | WHILE_KW => "while", | ||
415 | IF_KW => "if", | ||
416 | MATCH_KW => "match", | ||
417 | CONST_KW => "const", | ||
418 | STATIC_KW => "static", | ||
419 | MUT_KW => "mut", | ||
420 | UNSAFE_KW => "unsafe", | ||
421 | TYPE_KW => "type", | ||
422 | REF_KW => "ref", | ||
423 | LET_KW => "let", | ||
424 | AUTO_KW => "auto", | ||
425 | DEFAULT_KW => "default", | ||
426 | UNION_KW => "union", | ||
427 | _ => return None, | ||
428 | }; | ||
429 | Some(tok) | ||
430 | } | ||
356 | } | 431 | } |
357 | 432 | ||
diff --git a/src/syntax_kinds/generated.rs.tera b/src/syntax_kinds/generated.rs.tera index 2a47c6632..d719c8312 100644 --- a/src/syntax_kinds/generated.rs.tera +++ b/src/syntax_kinds/generated.rs.tera | |||
@@ -58,5 +58,18 @@ impl SyntaxKind { | |||
58 | }; | 58 | }; |
59 | Some(tok) | 59 | Some(tok) |
60 | } | 60 | } |
61 | |||
62 | pub(crate) fn static_text(self) -> Option<&'static str> { | ||
63 | let tok = match self { | ||
64 | {%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} | ||
65 | {{t.1}} => "{{t.0}}", | ||
66 | {%- endfor %} | ||
67 | {% for kw in concat(a=keywords, b=contextual_keywords) %} | ||
68 | {{kw | upper}}_KW => "{{kw}}", | ||
69 | {%- endfor %} | ||
70 | _ => return None, | ||
71 | }; | ||
72 | Some(tok) | ||
73 | } | ||
61 | } | 74 | } |
62 | 75 | ||