aboutsummaryrefslogtreecommitdiff
path: root/tools/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/bin')
-rw-r--r--tools/src/bin/gen.rs18
-rw-r--r--tools/src/bin/parse.rs5
2 files changed, 11 insertions, 12 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 {
diff --git a/tools/src/bin/parse.rs b/tools/src/bin/parse.rs
index 5e4dc261f..cb3414711 100644
--- a/tools/src/bin/parse.rs
+++ b/tools/src/bin/parse.rs
@@ -2,13 +2,12 @@ extern crate libsyntax2;
2 2
3use std::io::Read; 3use std::io::Read;
4 4
5use libsyntax2::{parse_green, tokenize}; 5use libsyntax2::{parse};
6use libsyntax2::utils::dump_tree_green; 6use libsyntax2::utils::dump_tree_green;
7 7
8fn main() { 8fn main() {
9 let text = read_input(); 9 let text = read_input();
10 let tokens = tokenize(&text); 10 let file = parse(text);
11 let file = parse_green(text, &tokens);
12 let tree = dump_tree_green(&file); 11 let tree = dump_tree_green(&file);
13 println!("{}", tree); 12 println!("{}", tree);
14} 13}