From 415c891d641fa305e7ddbbbcc78db990dd5d3564 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 29 Jul 2018 15:16:07 +0300 Subject: Reorganize --- tools/src/bin/gen.rs | 18 +++++++++--------- tools/src/bin/parse.rs | 5 ++--- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'tools/src/bin') 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 { acc.push_str("#![allow(bad_style, missing_docs, unreachable_pub)]\n"); acc.push_str("#![cfg_attr(rustfmt, rustfmt_skip)]\n"); acc.push_str("//! Generated from grammar.ron\n"); - acc.push_str("use tree::SyntaxInfo;\n"); + acc.push_str("use super::SyntaxInfo;\n"); acc.push_str("\n"); let syntax_kinds: Vec = self.tokens @@ -82,19 +82,19 @@ impl Grammar { acc.push_str(" EOF => &SyntaxInfo { name: \"EOF\" },\n"); acc.push_str(" }\n"); acc.push_str(" }\n"); - acc.push_str("}\n"); - acc.push_str("\n"); - // fn ident_to_keyword - acc.push_str("pub(crate) fn ident_to_keyword(ident: &str) -> Option {\n"); - acc.push_str(" match ident {\n"); + // fn from_keyword + acc.push_str(" pub(crate) fn from_keyword(ident: &str) -> Option {\n"); + acc.push_str(" match ident {\n"); // NB: no contextual_keywords here! for kw in self.keywords.iter() { - write!(acc, " {:?} => Some({}),\n", kw, kw_token(kw)).unwrap(); + write!(acc, " {:?} => Some({}),\n", kw, kw_token(kw)).unwrap(); } - acc.push_str(" _ => None,\n"); + acc.push_str(" _ => None,\n"); + acc.push_str(" }\n"); acc.push_str(" }\n"); acc.push_str("}\n"); + acc.push_str("\n"); acc } } @@ -104,7 +104,7 @@ fn grammar_file() -> PathBuf { } fn generated_file() -> PathBuf { - base_dir().join("src/syntax_kinds.rs") + base_dir().join("src/syntax_kinds/generated.rs") } fn 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; use std::io::Read; -use libsyntax2::{parse_green, tokenize}; +use libsyntax2::{parse}; use libsyntax2::utils::dump_tree_green; fn main() { let text = read_input(); - let tokens = tokenize(&text); - let file = parse_green(text, &tokens); + let file = parse(text); let tree = dump_tree_green(&file); println!("{}", tree); } -- cgit v1.2.3