Fixed API

This commit is contained in:
2026-06-10 05:44:58 +02:00
parent 1619250ba5
commit 14e88e2e4d
3 changed files with 10 additions and 6 deletions
+4 -2
View File
@@ -133,7 +133,9 @@ pub fn transpile_file(path: &Path, output_path: &Path) -> Result<(), String> {
}); });
// If parsing fails, return the error string back gracefully so the LSP can show it // If parsing fails, return the error string back gracefully so the LSP can show it
let ast = parser_result.map_err(|e| format!("parse failed in {}:\n{}", path.display(), e))?; let ast = parser_result
.map_err(|e| format!("parse failed in {}:\n{}", path.display(), e))?
.1;
let mut gc = mist_codegen::RustCodegen::new(); let mut gc = mist_codegen::RustCodegen::new();
let output = gc.generate(ast); let output = gc.generate(ast);
@@ -147,7 +149,7 @@ pub fn transpile_file(path: &Path, output_path: &Path) -> Result<(), String> {
pub fn transpile_text<'a>(source: &'a str) -> Result<String, ParseError<'a, Vec<TopLevel>>> { pub fn transpile_text<'a>(source: &'a str) -> Result<String, ParseError<'a, Vec<TopLevel>>> {
let mut gc = mist_codegen::RustCodegen::new(); let mut gc = mist_codegen::RustCodegen::new();
Ok(gc.generate(mist_parser::parse(&source)?)) Ok(gc.generate(mist_parser::parse(&source)?.1))
} }
fn should_skip(source: &Path, output: &Path) -> bool { fn should_skip(source: &Path, output: &Path) -> bool {
+2 -2
View File
@@ -7,7 +7,7 @@ use std::process;
pub class Module { pub class Module {
pub name String; pub name String;
pub path PathBuf; pub path PathBuf;
pub children Vec<Self>; pub children Vec<Box<Module>>;
pub constructor(mist_path PathBuf) { pub constructor(mist_path PathBuf) {
self.children = Vec::new(); self.children = Vec::new();
@@ -74,7 +74,7 @@ pub class Module {
} }
} }
pub fn master_package(mist_path PathBuf) Module { pub fn master_package(mist_path PathBuf) Box<Module> {
let mut root_mod = Module::new(mist_path.clone()); let mut root_mod = Module::new(mist_path.clone());
let parent_dir = mist_path.parent() let parent_dir = mist_path.parent()
+4 -2
View File
@@ -88,7 +88,7 @@ fn transpile_file(path *PathBuf, output_file *PathBuf, mod_decl *str) {
let mut gc = mist_codegen::RustCodegen::new(); let mut gc = mist_codegen::RustCodegen::new();
let output = gc.generate(match (mist_parser::parse(&source)) { let [[vis, api], ast] = match (mist_parser::parse(&source)) {
Ok[ast] => ast; Ok[ast] => ast;
Err[e] => { Err[e] => {
match (e) { match (e) {
@@ -118,7 +118,9 @@ fn transpile_file(path *PathBuf, output_file *PathBuf, mod_decl *str) {
} }
} }
} }
}); };
let output = gc.generate(ast);
let res = fs::write(&output_file, format!("{mod_decl}{output}")); let res = fs::write(&output_file, format!("{mod_decl}{output}"));