diff options
Diffstat (limited to 'crates/ra_syntax/src/syntax_kinds/generated.rs.tera')
-rw-r--r-- | crates/ra_syntax/src/syntax_kinds/generated.rs.tera | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/crates/ra_syntax/src/syntax_kinds/generated.rs.tera b/crates/ra_syntax/src/syntax_kinds/generated.rs.tera deleted file mode 100644 index 837437136..000000000 --- a/crates/ra_syntax/src/syntax_kinds/generated.rs.tera +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | {# THIS File is not automatically generated: | ||
2 | the below applies to the result of this template | ||
3 | #}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run | ||
4 | // Do not edit manually | ||
5 | |||
6 | #![allow(bad_style, missing_docs, unreachable_pub)] | ||
7 | #![cfg_attr(rustfmt, rustfmt_skip)] | ||
8 | use super::SyntaxInfo; | ||
9 | |||
10 | /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. | ||
11 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
12 | pub enum SyntaxKind { | ||
13 | // Technical SyntaxKinds: they appear temporally during parsing, | ||
14 | // but never end up in the final tree | ||
15 | #[doc(hidden)] | ||
16 | TOMBSTONE, | ||
17 | #[doc(hidden)] | ||
18 | EOF, | ||
19 | |||
20 | {%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} | ||
21 | {{t.1}}, | ||
22 | {%- endfor -%} | ||
23 | {% for kw in concat(a=keywords, b=contextual_keywords) %} | ||
24 | {{kw | upper}}_KW, | ||
25 | {%- endfor -%} | ||
26 | {% for t in concat(a=literals, b=tokens, c=nodes) %} | ||
27 | {{t}}, | ||
28 | {%- endfor %} | ||
29 | } | ||
30 | use self::SyntaxKind::*; | ||
31 | |||
32 | impl SyntaxKind { | ||
33 | pub fn is_keyword(self) -> bool { | ||
34 | match self { | ||
35 | {%- for kw in concat(a=keywords, b=contextual_keywords) %} | ||
36 | | {{kw | upper}}_KW | ||
37 | {%- endfor %} | ||
38 | => true, | ||
39 | _ => false | ||
40 | } | ||
41 | } | ||
42 | |||
43 | pub fn is_punct(self) -> bool { | ||
44 | match self { | ||
45 | {%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} | ||
46 | | {{t.1}} | ||
47 | {%- endfor %} | ||
48 | => true, | ||
49 | _ => false | ||
50 | } | ||
51 | } | ||
52 | pub fn is_literal(self) -> bool { | ||
53 | match self { | ||
54 | {%- for t in literals %} | ||
55 | | {{t}} | ||
56 | {%- endfor %} | ||
57 | => true, | ||
58 | _ => false | ||
59 | } | ||
60 | } | ||
61 | |||
62 | pub(crate) fn info(self) -> &'static SyntaxInfo { | ||
63 | match self { | ||
64 | {%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} | ||
65 | {{t.1}} => &SyntaxInfo { name: "{{t.1}}" }, | ||
66 | {%- endfor -%} | ||
67 | {% for kw in concat(a=keywords, b=contextual_keywords) %} | ||
68 | {{kw | upper}}_KW => &SyntaxInfo { name: "{{kw | upper}}_KW" }, | ||
69 | {%- endfor -%} | ||
70 | {% for t in concat(a=literals, b=tokens, c=nodes) %} | ||
71 | {{t}} => &SyntaxInfo { name: "{{t}}" }, | ||
72 | {%- endfor %} | ||
73 | TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, | ||
74 | EOF => &SyntaxInfo { name: "EOF" }, | ||
75 | } | ||
76 | } | ||
77 | pub(crate) fn from_keyword(ident: &str) -> Option<SyntaxKind> { | ||
78 | let kw = match ident { | ||
79 | {%- for kw in keywords %} | ||
80 | "{{kw}}" => {{kw | upper}}_KW, | ||
81 | {%- endfor %} | ||
82 | _ => return None, | ||
83 | }; | ||
84 | Some(kw) | ||
85 | } | ||
86 | |||
87 | pub(crate) fn from_char(c: char) -> Option<SyntaxKind> { | ||
88 | let tok = match c { | ||
89 | {%- for t in single_byte_tokens %} | ||
90 | '{{t.0}}' => {{t.1}}, | ||
91 | {%- endfor %} | ||
92 | _ => return None, | ||
93 | }; | ||
94 | Some(tok) | ||
95 | } | ||
96 | } | ||