switch to new codegen

This commit is contained in:
Aleksey Kladov
2019-08-18 21:44:24 +03:00
parent 839d9cce89
commit 229d7943d8
4 changed files with 32 additions and 14 deletions

View File

@@ -1,7 +1,21 @@
use std::path::Path;
use std::{fs, path::Path};
use crate::{Mode, Result};
use ron;
pub fn generate_ast(grammar_src: &Path, dst: &Path, mode: Mode) -> Result<()> {
use crate::{project_root, Mode, Result, AST, GRAMMAR};
pub fn generate(mode: Mode) -> Result<()> {
let grammar = project_root().join(GRAMMAR);
// let syntax_kinds = project_root().join(SYNTAX_KINDS);
let ast = project_root().join(AST);
generate_ast(&grammar, &ast, mode)
}
fn generate_ast(grammar_src: &Path, dst: &Path, mode: Mode) -> Result<()> {
let src: ron::Value = {
let text = fs::read_to_string(grammar_src)?;
ron::de::from_str(&text)?
};
eprintln!("{:?}", src);
Ok(())
}