var on parser
This commit is contained in:
+12
-11
@@ -1,11 +1,10 @@
|
||||
mod transpiler;
|
||||
mod parser;
|
||||
mod lexer;
|
||||
mod compile;
|
||||
mod lexer;
|
||||
mod lsp;
|
||||
use std::{fs, path::Path};
|
||||
mod parser;
|
||||
mod transpiler;
|
||||
use clap::Parser;
|
||||
use lexer::LexerState;
|
||||
use std::{fs, path::Path};
|
||||
use transpiler::Transpiler;
|
||||
|
||||
use crate::lsp::run_lsp_server;
|
||||
@@ -28,22 +27,24 @@ fn main() {
|
||||
match args.stdio {
|
||||
true => {
|
||||
run_lsp_server();
|
||||
},
|
||||
}
|
||||
false => {
|
||||
let file_content = fs::read_to_string("main.wt")
|
||||
.expect("Error reading file");
|
||||
let file_content = fs::read_to_string("main.wt").expect("Error reading file");
|
||||
if Path::new("build").exists() {
|
||||
fs::remove_dir_all("build").expect("err rm build");
|
||||
}
|
||||
fs::create_dir("build").expect("error making build");
|
||||
let mut trsp = Transpiler::default();
|
||||
let transpiled_code = trsp.transpile(file_content, 0, LexerState { line: 1, column: 0 });
|
||||
let transpiled_code = trsp.transpile(file_content, 0);
|
||||
|
||||
match args.rust {
|
||||
Some(ref rust_file_name) => {
|
||||
// Write transpiled code to Rust file
|
||||
compile::write_to_rust_file(&transpiled_code, ("build/".to_string()+rust_file_name).as_str())
|
||||
.expect("Error writing to Rust file");
|
||||
compile::write_to_rust_file(
|
||||
&transpiled_code,
|
||||
("build/".to_string() + rust_file_name).as_str(),
|
||||
)
|
||||
.expect("Error writing to Rust file");
|
||||
println!("Transpiled code written to {}", rust_file_name);
|
||||
}
|
||||
None => {
|
||||
|
||||
Reference in New Issue
Block a user