aboutsummaryrefslogtreecommitdiff
path: root/src/bin/gen.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/gen.rs')
-rw-r--r--src/bin/gen.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/bin/gen.rs b/src/bin/gen.rs
index 5ebf3e2e8..8f6402f5c 100644
--- a/src/bin/gen.rs
+++ b/src/bin/gen.rs
@@ -2,8 +2,8 @@ extern crate serde;
2#[macro_use] 2#[macro_use]
3extern crate serde_derive; 3extern crate serde_derive;
4 4
5extern crate ron;
6extern crate file; 5extern crate file;
6extern crate ron;
7 7
8use std::path::PathBuf; 8use std::path::PathBuf;
9use std::fmt::Write; 9use std::fmt::Write;
@@ -33,11 +33,12 @@ impl Grammar {
33 acc.push_str("use tree::{SyntaxKind, SyntaxInfo};\n"); 33 acc.push_str("use tree::{SyntaxKind, SyntaxInfo};\n");
34 acc.push_str("\n"); 34 acc.push_str("\n");
35 35
36 let syntax_kinds: Vec<String> = 36 let syntax_kinds: Vec<String> = self.keywords
37 self.keywords.iter().map(|kw| kw_token(kw)) 37 .iter()
38 .chain(self.tokens.iter().cloned()) 38 .map(|kw| kw_token(kw))
39 .chain(self.nodes.iter().cloned()) 39 .chain(self.tokens.iter().cloned())
40 .collect(); 40 .chain(self.nodes.iter().cloned())
41 .collect();
41 42
42 for (idx, kind) in syntax_kinds.iter().enumerate() { 43 for (idx, kind) in syntax_kinds.iter().enumerate() {
43 let sname = scream(kind); 44 let sname = scream(kind);
@@ -48,7 +49,11 @@ impl Grammar {
48 ).unwrap(); 49 ).unwrap();
49 } 50 }
50 acc.push_str("\n"); 51 acc.push_str("\n");
51 write!(acc, "static INFOS: [SyntaxInfo; {}] = [\n", syntax_kinds.len()).unwrap(); 52 write!(
53 acc,
54 "static INFOS: [SyntaxInfo; {}] = [\n",
55 syntax_kinds.len()
56 ).unwrap();
52 for kind in syntax_kinds.iter() { 57 for kind in syntax_kinds.iter() {
53 let sname = scream(kind); 58 let sname = scream(kind);
54 write!( 59 write!(
@@ -91,4 +96,4 @@ fn scream(word: &str) -> String {
91 96
92fn kw_token(keyword: &str) -> String { 97fn kw_token(keyword: &str) -> String {
93 format!("{}_KW", scream(keyword)) 98 format!("{}_KW", scream(keyword))
94} \ No newline at end of file 99}