From 60e8a845cafb9630caa034b886368160a12dcd64 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Jul 2018 18:02:13 +0300 Subject: simplify codegen --- src/syntax_kinds/generated.rs.tera | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'src/syntax_kinds/generated.rs.tera') diff --git a/src/syntax_kinds/generated.rs.tera b/src/syntax_kinds/generated.rs.tera index 21e471b71..2a47c6632 100644 --- a/src/syntax_kinds/generated.rs.tera +++ b/src/syntax_kinds/generated.rs.tera @@ -5,23 +5,14 @@ use super::SyntaxInfo; /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum SyntaxKind { -{%- for t in single_byte_tokens %} - {{t.1}}, -{%- endfor -%} -{% for t in multi_byte_tokens %} +{%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} {{t.1}}, {%- endfor -%} -{% for t in tokens %} - {{t}}, -{%- endfor -%} -{% for kw in keywords %} +{% for kw in concat(a=keywords, b=contextual_keywords) %} {{kw | upper}}_KW, {%- endfor -%} -{% for kw in contextual_keywords %} - {{kw | upper}}_KW, -{%- endfor -%} -{% for node in nodes %} - {{node}}, +{% for t in concat(a=tokens, b=nodes) %} + {{t}}, {%- endfor %} // Technical SyntaxKinds: they appear temporally during parsing, // but never end up in the final tree @@ -35,25 +26,15 @@ use self::SyntaxKind::*; impl SyntaxKind { pub(crate) fn info(self) -> &'static SyntaxInfo { match self { -{%- for t in single_byte_tokens %} +{%- for t in concat(a=single_byte_tokens, b=multi_byte_tokens) %} {{t.1}} => &SyntaxInfo { name: "{{t.1}}" }, {%- endfor -%} -{% for t in multi_byte_tokens %} - {{t.1}} => &SyntaxInfo { name: "{{t.1}}" }, -{%- endfor -%} -{% for t in tokens %} - {{t}} => &SyntaxInfo { name: "{{t}}" }, -{%- endfor -%} -{% for kw in keywords %} +{% for kw in concat(a=keywords, b=contextual_keywords) %} {{kw | upper}}_KW => &SyntaxInfo { name: "{{kw | upper}}_KW" }, {%- endfor -%} -{% for kw in contextual_keywords %} - {{kw | upper}}_KW => &SyntaxInfo { name: "{{kw | upper}}_KW" }, -{%- endfor -%} -{% for node in nodes %} - {{node}} => &SyntaxInfo { name: "{{node}}" }, +{% for t in concat(a=tokens, b=nodes) %} + {{t}} => &SyntaxInfo { name: "{{t}}" }, {%- endfor %} - TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, EOF => &SyntaxInfo { name: "EOF" }, } -- cgit v1.2.3