small fix
This commit is contained in:
+4
-2
@@ -2,7 +2,7 @@ mod transpiler;
|
|||||||
mod parser;
|
mod parser;
|
||||||
mod lexer;
|
mod lexer;
|
||||||
mod compile;
|
mod compile;
|
||||||
use std::fs;
|
use std::{fs, path::Path};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use lexer::LexerState;
|
use lexer::LexerState;
|
||||||
use transpiler::Options;
|
use transpiler::Options;
|
||||||
@@ -24,7 +24,9 @@ fn main() {
|
|||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let file_content = fs::read_to_string(&args.file)
|
let file_content = fs::read_to_string(&args.file)
|
||||||
.expect("Error reading file");
|
.expect("Error reading file");
|
||||||
|
if Path::new("wyst_tmp").exists() {
|
||||||
|
fs::remove_dir_all("wyst_tmp").expect("err rm wyst_tmp");
|
||||||
|
}
|
||||||
fs::create_dir("wyst_tmp").expect("error making wyst_tmp");
|
fs::create_dir("wyst_tmp").expect("error making wyst_tmp");
|
||||||
let transpiled_code = transpiler::transpile(file_content, 0, LexerState { line: 1, column: 0 }, &mut Options::default());
|
let transpiled_code = transpiler::transpile(file_content, 0, LexerState { line: 1, column: 0 }, &mut Options::default());
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -26,6 +26,7 @@ fn clean_incl(input: &str) -> String {
|
|||||||
pub fn transpile_mod(ast: Ast, options: &mut Options, s: &str) -> String {
|
pub fn transpile_mod(ast: Ast, options: &mut Options, s: &str) -> String {
|
||||||
let modfile = ast.tokens[0].value.as_str();
|
let modfile = ast.tokens[0].value.as_str();
|
||||||
let modname = format!("{}_{}", clean_incl(modfile.split(".").collect::<Vec<_>>()[0]), options.clone().modnum);
|
let modname = format!("{}_{}", clean_incl(modfile.split(".").collect::<Vec<_>>()[0]), options.clone().modnum);
|
||||||
|
println!("{}", s.to_string()+modfile);
|
||||||
let file_content = fs::read_to_string(s.to_string()+modfile)
|
let file_content = fs::read_to_string(s.to_string()+modfile)
|
||||||
.expect("Error reading file");
|
.expect("Error reading file");
|
||||||
let transpiled_code = transpile(file_content, 0, LexerState { line: 1, column: 0 }, &mut Options::default());
|
let transpiled_code = transpile(file_content, 0, LexerState { line: 1, column: 0 }, &mut Options::default());
|
||||||
@@ -172,7 +173,7 @@ pub fn transpile(input: String, indent: u32, state: LexerState, options: &mut Op
|
|||||||
} else if ast.ast_type == AstType::StructVar {
|
} else if ast.ast_type == AstType::StructVar {
|
||||||
result += format!("let mut {}: {} = {} {}{}{}", ast.tokens[1].value.as_str(), ast.tokens[0].value.as_str(), ast.tokens[0].value.as_str(), "{", ast.tokens[2].value.as_str(), "}").as_str();
|
result += format!("let mut {}: {} = {} {}{}{}", ast.tokens[1].value.as_str(), ast.tokens[0].value.as_str(), ast.tokens[0].value.as_str(), "{", ast.tokens[2].value.as_str(), "}").as_str();
|
||||||
} else if ast.ast_type == AstType::Include {
|
} else if ast.ast_type == AstType::Include {
|
||||||
let modname = transpile_mod(ast, options, "/lib");
|
let modname = transpile_mod(ast, options, "lib/");
|
||||||
result += "mod ";
|
result += "mod ";
|
||||||
result += modname.as_str();
|
result += modname.as_str();
|
||||||
result += ";\n";
|
result += ";\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user