aboutsummaryrefslogtreecommitdiff
path: root/tools/src/bin/gen.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/bin/gen.rs')
-rw-r--r--tools/src/bin/gen.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/src/bin/gen.rs b/tools/src/bin/gen.rs
index 17cdea7a1..7cb164316 100644
--- a/tools/src/bin/gen.rs
+++ b/tools/src/bin/gen.rs
@@ -20,6 +20,7 @@ fn main() {
20#[derive(Deserialize)] 20#[derive(Deserialize)]
21struct Grammar { 21struct Grammar {
22 keywords: Vec<String>, 22 keywords: Vec<String>,
23 contextual_keywords: Vec<String>,
23 tokens: Vec<String>, 24 tokens: Vec<String>,
24 nodes: Vec<String>, 25 nodes: Vec<String>,
25} 26}
@@ -38,10 +39,11 @@ impl Grammar {
38 acc.push_str("use tree::SyntaxInfo;\n"); 39 acc.push_str("use tree::SyntaxInfo;\n");
39 acc.push_str("\n"); 40 acc.push_str("\n");
40 41
41 let syntax_kinds: Vec<String> = self.keywords 42 let syntax_kinds: Vec<String> = self.tokens
42 .iter() 43 .iter()
43 .map(|kw| kw_token(kw)) 44 .cloned()
44 .chain(self.tokens.iter().cloned()) 45 .chain(self.keywords.iter().map(|kw| kw_token(kw)))
46 .chain(self.contextual_keywords.iter().map(|kw| kw_token(kw)))
45 .chain(self.nodes.iter().cloned()) 47 .chain(self.nodes.iter().cloned())
46 .collect(); 48 .collect();
47 49
@@ -86,6 +88,7 @@ impl Grammar {
86 // fn ident_to_keyword 88 // fn ident_to_keyword
87 acc.push_str("pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {\n"); 89 acc.push_str("pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {\n");
88 acc.push_str(" match ident {\n"); 90 acc.push_str(" match ident {\n");
91 // NB: no contextual_keywords here!
89 for kw in self.keywords.iter() { 92 for kw in self.keywords.iter() {
90 write!(acc, " {:?} => Some({}),\n", kw, kw_token(kw)).unwrap(); 93 write!(acc, " {:?} => Some({}),\n", kw, kw_token(kw)).unwrap();
91 } 94 }