Working explicit module system

This commit is contained in:
2026-06-11 16:05:45 +02:00
parent 2256ef2a9f
commit c37392046a
2 changed files with 57 additions and 22 deletions
+9 -4
View File
@@ -3,7 +3,10 @@ use std::{
path::{Path, PathBuf},
};
use mist_parser::{ast::TopLevel, error::ParseError};
use mist_parser::{
ast::{Identifier, TopLevel, Visibility},
error::ParseError,
};
pub fn build(root: &PathBuf) {
let src_dir = root.join("src");
@@ -112,7 +115,7 @@ pub fn transpile_file(path: &Path, output_path: &Path) -> Result<(), String> {
let source = fs::read_to_string(path)
.map_err(|e| format!("failed to read file {}: {}", path.display(), e))?;
let parser_result = mist_parser::parse(&source, true).map_err(|e| match e {
let parser_result = mist_parser::parse(&source).map_err(|e| match e {
ParseError::Ast(e) => {
// Using components carefully to prevent out-of-bounds or zero layout crashes
let start_pos = e.span.start_pos().line_col();
@@ -146,10 +149,12 @@ pub fn transpile_file(path: &Path, output_path: &Path) -> Result<(), String> {
Ok(())
}
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, (Option<(Visibility, Identifier)>, Vec<TopLevel>)>> {
let mut gc = mist_codegen::RustCodegen::new();
Ok(gc.generate(mist_parser::parse(&source, true)?.1))
Ok(gc.generate(mist_parser::parse(&source)?.1))
}
fn should_skip(source: &Path, output: &Path) -> bool {