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.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/tools/src/bin/gen.rs b/tools/src/bin/gen.rs
index 7cb164316..e772922ba 100644
--- a/tools/src/bin/gen.rs
+++ b/tools/src/bin/gen.rs
@@ -36,7 +36,7 @@ impl Grammar {
36 acc.push_str("#![allow(bad_style, missing_docs, unreachable_pub)]\n"); 36 acc.push_str("#![allow(bad_style, missing_docs, unreachable_pub)]\n");
37 acc.push_str("#![cfg_attr(rustfmt, rustfmt_skip)]\n"); 37 acc.push_str("#![cfg_attr(rustfmt, rustfmt_skip)]\n");
38 acc.push_str("//! Generated from grammar.ron\n"); 38 acc.push_str("//! Generated from grammar.ron\n");
39 acc.push_str("use tree::SyntaxInfo;\n"); 39 acc.push_str("use super::SyntaxInfo;\n");
40 acc.push_str("\n"); 40 acc.push_str("\n");
41 41
42 let syntax_kinds: Vec<String> = self.tokens 42 let syntax_kinds: Vec<String> = self.tokens
@@ -82,19 +82,19 @@ impl Grammar {
82 acc.push_str(" EOF => &SyntaxInfo { name: \"EOF\" },\n"); 82 acc.push_str(" EOF => &SyntaxInfo { name: \"EOF\" },\n");
83 acc.push_str(" }\n"); 83 acc.push_str(" }\n");
84 acc.push_str(" }\n"); 84 acc.push_str(" }\n");
85 acc.push_str("}\n");
86 acc.push_str("\n");
87 85
88 // fn ident_to_keyword 86 // fn from_keyword
89 acc.push_str("pub(crate) fn ident_to_keyword(ident: &str) -> Option<SyntaxKind> {\n"); 87 acc.push_str(" pub(crate) fn from_keyword(ident: &str) -> Option<SyntaxKind> {\n");
90 acc.push_str(" match ident {\n"); 88 acc.push_str(" match ident {\n");
91 // NB: no contextual_keywords here! 89 // NB: no contextual_keywords here!
92 for kw in self.keywords.iter() { 90 for kw in self.keywords.iter() {
93 write!(acc, " {:?} => Some({}),\n", kw, kw_token(kw)).unwrap(); 91 write!(acc, " {:?} => Some({}),\n", kw, kw_token(kw)).unwrap();
94 } 92 }
95 acc.push_str(" _ => None,\n"); 93 acc.push_str(" _ => None,\n");
94 acc.push_str(" }\n");
96 acc.push_str(" }\n"); 95 acc.push_str(" }\n");
97 acc.push_str("}\n"); 96 acc.push_str("}\n");
97 acc.push_str("\n");
98 acc 98 acc
99 } 99 }
100} 100}
@@ -104,7 +104,7 @@ fn grammar_file() -> PathBuf {
104} 104}
105 105
106fn generated_file() -> PathBuf { 106fn generated_file() -> PathBuf {
107 base_dir().join("src/syntax_kinds.rs") 107 base_dir().join("src/syntax_kinds/generated.rs")
108} 108}
109 109
110fn scream(word: &str) -> String { 110fn scream(word: &str) -> String {