diff options
author | Aleksey Kladov <[email protected]> | 2018-07-30 12:06:22 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-30 12:06:22 +0100 |
commit | 6983091d6d255bcfd17c4f8c14015d8abc77928d (patch) | |
tree | 153359a05ca3fd887b59fe47ee84a60be0e6dfaf /src/syntax_kinds/generated.rs.tera | |
parent | 9a4957d143397256dc04f715660f758a65fcb9d1 (diff) |
Cleanup tools
Diffstat (limited to 'src/syntax_kinds/generated.rs.tera')
-rw-r--r-- | src/syntax_kinds/generated.rs.tera | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/syntax_kinds/generated.rs.tera b/src/syntax_kinds/generated.rs.tera new file mode 100644 index 000000000..aa672d89a --- /dev/null +++ b/src/syntax_kinds/generated.rs.tera | |||
@@ -0,0 +1,59 @@ | |||
1 | #![allow(bad_style, missing_docs, unreachable_pub)] | ||
2 | #![cfg_attr(rustfmt, rustfmt_skip)] | ||
3 | use super::SyntaxInfo; | ||
4 | |||
5 | /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. | ||
6 | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
7 | pub enum SyntaxKind { | ||
8 | {%- for t in tokens %} | ||
9 | {{t}}, | ||
10 | {%- endfor -%} | ||
11 | {% for kw in keywords %} | ||
12 | {{kw | upper}}_KW, | ||
13 | {%- endfor -%} | ||
14 | {% for kw in contextual_keywords %} | ||
15 | {{kw | upper}}_KW, | ||
16 | {%- endfor -%} | ||
17 | {% for node in nodes %} | ||
18 | {{node}}, | ||
19 | {%- endfor %} | ||
20 | // Technical SyntaxKinds: they appear temporally during parsing, | ||
21 | // but never end up in the final tree | ||
22 | #[doc(hidden)] | ||
23 | TOMBSTONE, | ||
24 | #[doc(hidden)] | ||
25 | EOF, | ||
26 | } | ||
27 | use self::SyntaxKind::*; | ||
28 | |||
29 | impl SyntaxKind { | ||
30 | pub(crate) fn info(self) -> &'static SyntaxInfo { | ||
31 | match self { | ||
32 | {%- for t in tokens %} | ||
33 | {{t}} => &SyntaxInfo { name: "{{t}}" }, | ||
34 | {%- endfor -%} | ||
35 | {% for kw in keywords %} | ||
36 | {{kw | upper}}_KW => &SyntaxInfo { name: "{{kw | upper}}_KW" }, | ||
37 | {%- endfor -%} | ||
38 | {% for kw in contextual_keywords %} | ||
39 | {{kw | upper}}_KW => &SyntaxInfo { name: "{{kw | upper}}_KW" }, | ||
40 | {%- endfor -%} | ||
41 | {% for node in nodes %} | ||
42 | {{node}} => &SyntaxInfo { name: "{{node}}" }, | ||
43 | {%- endfor %} | ||
44 | |||
45 | TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, | ||
46 | EOF => &SyntaxInfo { name: "EOF" }, | ||
47 | } | ||
48 | } | ||
49 | pub(crate) fn from_keyword(ident: &str) -> Option<SyntaxKind> { | ||
50 | let kw = match ident { | ||
51 | {%- for kw in keywords %} | ||
52 | "{{kw}}" => {{kw | upper}}_KW, | ||
53 | {%- endfor %} | ||
54 | _ => return None, | ||
55 | }; | ||
56 | Some(kw) | ||
57 | } | ||
58 | } | ||
59 | |||