Compare commits

...
Author SHA1 Message Date
selimaj-dev fe96e3aec6 Release 0.1.7-alpha.2
[email protected]
[email protected]

Generated by cargo-workspaces
2026-06-02 13:41:28 +02:00
selimaj-dev 72010faf03 Fixed tuple pattern 2026-06-02 12:37:15 +02:00
selimaj-dev e5df8df9b0 Release 0.1.7-alpha.1
[email protected]
[email protected]
[email protected]

Generated by cargo-workspaces
2026-06-01 13:50:49 +02:00
selimaj-dev ee40450f3a Merge pull request #57 from mist-go/module-system
Module system
2026-06-01 13:49:21 +02:00
selimaj-dev be6d2de39c improved code quality 2026-06-01 13:10:46 +02:00
selimaj-dev aff15f67c7 Working module system 2026-06-01 12:26:20 +02:00
selimaj-dev cfd1910f39 Working transpiler 2026-06-01 12:10:33 +02:00
selimaj-dev 082981f0bd Working module reading 2026-06-01 11:40:01 +02:00
selimaj-dev b384f55c77 Updated analyzer to remove the need for .mist/lib 2026-05-31 12:56:54 +02:00
selimaj-dev c4756262e1 ts sucks 2026-05-31 12:47:24 +02:00
selimaj-dev 74f10cc74b Removed lsp dev 2026-05-31 12:45:53 +02:00
selimaj-dev acef0888a3 Thinking of better ways to make analyzer work 2026-05-31 12:42:55 +02:00
selimaj-dev 18ab88af64 Thinking of better ways to make analyzer work 2026-05-31 12:41:48 +02:00
selimaj-dev 5e6cdc84b9 Updated cargo version 2026-05-31 12:39:10 +02:00
12 changed files with 170 additions and 177 deletions
Generated
+4 -4
View File
@@ -442,7 +442,7 @@ dependencies = [
[[package]] [[package]]
name = "mist-analyzer" name = "mist-analyzer"
version = "0.1.7-alpha.0" version = "0.1.7-alpha.1"
dependencies = [ dependencies = [
"cargo_metadata", "cargo_metadata",
"dashmap 6.1.0", "dashmap 6.1.0",
@@ -457,7 +457,7 @@ dependencies = [
[[package]] [[package]]
name = "mist-api" name = "mist-api"
version = "0.1.7-alpha.0" version = "0.1.7-alpha.1"
dependencies = [ dependencies = [
"cargo_metadata", "cargo_metadata",
"mist-codegen", "mist-codegen",
@@ -475,7 +475,7 @@ dependencies = [
[[package]] [[package]]
name = "mist-lang" name = "mist-lang"
version = "0.1.7-alpha.0" version = "0.1.7-alpha.2"
dependencies = [ dependencies = [
"mist-analyzer", "mist-analyzer",
"mist-api", "mist-api",
@@ -483,7 +483,7 @@ dependencies = [
[[package]] [[package]]
name = "mist-parser" name = "mist-parser"
version = "0.1.7-alpha.0" version = "0.1.7-alpha.2"
dependencies = [ dependencies = [
"pest", "pest",
"pest_derive", "pest_derive",
+1 -5
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "mist-lang" name = "mist-lang"
version = "0.1.7-alpha.0" version = "0.1.7-alpha.2"
edition = "2024" edition = "2024"
description = "The Mist programming language compiler" description = "The Mist programming language compiler"
license = "Apache-2.0" license = "Apache-2.0"
@@ -41,10 +41,6 @@ mist-api = { path = "crates/mist-api", version = "0.1.7-alpha.0" }
name = "mist" name = "mist"
path = ".mist/src/main.rs" path = ".mist/src/main.rs"
[[bin]]
name = "mist-lsp"
path = ".mist/lsp/main.rs"
[[bin]] [[bin]]
name = "mist-analyzer" name = "mist-analyzer"
path = ".mist/src/analyzer.rs" path = ".mist/src/analyzer.rs"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "mist-analyzer" name = "mist-analyzer"
version = "0.1.7-alpha.0" version = "0.1.7-alpha.1"
edition = "2024" edition = "2024"
description = "The Mist programming language Analyzer LSP" description = "The Mist programming language Analyzer LSP"
license = "Apache-2.0" license = "Apache-2.0"
+2 -3
View File
@@ -573,7 +573,7 @@ pub fn from_mist_to_rust(mut path: PathBuf) -> PathBuf {
let mut comps: Vec<Component> = path.components().collect(); let mut comps: Vec<Component> = path.components().collect();
if let Some(pos) = comps.iter().rposition(|c| c.as_os_str() == "src") { if let Some(pos) = comps.iter().rposition(|c| c.as_os_str() == "src") {
let replacement = std::path::Path::new(".mist/lsp"); let replacement = std::path::Path::new(".mist/src");
comps.splice(pos..=pos, replacement.components()); comps.splice(pos..=pos, replacement.components());
comps.iter().collect() comps.iter().collect()
} else { } else {
@@ -587,8 +587,7 @@ pub fn from_rust_to_mist(mut path: PathBuf) -> PathBuf {
let comps: Vec<Component> = path.components().collect(); let comps: Vec<Component> = path.components().collect();
// pattern we originally inserted: ".mist/lsp" let pattern: Vec<Component> = std::path::Path::new(".mist/src").components().collect();
let pattern: Vec<Component> = std::path::Path::new(".mist/lsp").components().collect();
// find the last occurrence of the pattern // find the last occurrence of the pattern
if let Some(pos) = comps if let Some(pos) = comps
+1 -1
View File
@@ -7,7 +7,7 @@ use mist_parser::{ast::TopLevel, error::ParseError};
pub fn build(root: &PathBuf) { pub fn build(root: &PathBuf) {
let src_dir = root.join("src"); let src_dir = root.join("src");
let out_dir = root.join(".mist/lsp"); let out_dir = root.join(".mist/src");
if let Err(e) = build_dir(root, &src_dir, &src_dir, &out_dir) { if let Err(e) = build_dir(root, &src_dir, &src_dir, &out_dir) {
eprintln!("Warning: Build directory run aborted safely: {e}"); eprintln!("Warning: Build directory run aborted safely: {e}");
+12 -5
View File
@@ -1,7 +1,18 @@
[package] [package]
name = "mist-api" name = "mist-api"
version = "0.1.7-alpha.0" version = "0.1.7-alpha.1"
edition = "2024" edition = "2024"
description = "The Mist programming language module system"
license = "Apache-2.0"
repository = "https://github.com/mist-go/mist"
keywords = ["compiler", "language", "mist", "module-system"]
categories = ["compilers"]
include = [
".mist/src/**",
"Cargo.toml",
"README.md",
]
[dependencies] [dependencies]
serde = { version = "1.0.228", features = ["serde_derive"] } serde = { version = "1.0.228", features = ["serde_derive"] }
@@ -13,7 +24,3 @@ mist-codegen = { workspace = true }
[lib] [lib]
name = "mist_api" name = "mist_api"
path = ".mist/src/lib.rs" path = ".mist/src/lib.rs"
[[bin]]
name = "mist_lsp"
path = ".mist/lsp/main.rs"
+48 -11
View File
@@ -3,6 +3,7 @@ use <std::path::PathBuf>;
use <std::fs>; use <std::fs>;
use <std::process>; use <std::process>;
#[derive(Debug)]
pub class Module { pub class Module {
pub String name; pub String name;
pub PathBuf path; pub PathBuf path;
@@ -14,15 +15,23 @@ pub class Module {
self.path = mist_path; self.path = mist_path;
if (self.path.is_dir()) { if (self.path.is_dir()) {
var entries = match (fs::read_dir(&self.path)) { PathBuf dir = self.path.clone();
// Behavior 2: It's a directory node. Check for gateway package.mist first.
PathBuf pkg_gate = self.path.join("package.mist");
if (pkg_gate.exists()) {
self.path = pkg_gate;
}
self.scan_directory(&dir, &rust_path);
}
}
void scan_directory(self mut*, Path* search_dir, Path* rust_path) {
var entries = match (fs::read_dir(search_dir)) {
Ok[entries] => entries; Ok[entries] => entries;
Err[e] => { Err[e] => {
eprintln!( eprintln!("error: failed to read directory {}\n {}", search_dir.display(), e);
"error: failed to read directory {}\n {}",
self.path.display(),
e
);
process::exit(1); process::exit(1);
} }
}; };
@@ -32,13 +41,16 @@ pub class Module {
Ok[entry] => entry; Ok[entry] => entry;
Err[e] => { Err[e] => {
eprintln!("error: failed to read directory entry\n {}", e); eprintln!("error: failed to read directory entry\n {}", e);
process::exit(1); process::exit(1);
} }
}; };
PathBuf child_path = entry.path(); PathBuf child_path = entry.path();
if (child_path == self.path) {
continue;
}
String child_name = child_path.file_stem() String child_name = child_path.file_stem()
.and_then(|var s| s.to_str()) .and_then(|var s| s.to_str())
.expect("Failed to get module name") .expect("Failed to get module name")
@@ -46,23 +58,48 @@ pub class Module {
PathBuf child_output = rust_path.join(&child_name).with_extension("rs"); PathBuf child_output = rust_path.join(&child_name).with_extension("rs");
if (should_skip(&child_path, &child_output)) { if (!child_path.is_dir() && should_skip(&child_path, &child_output)) {
continue; continue;
} }
self.children.push(new Module(child_name, child_path, child_output)); self.children.push(new Module(child_name, child_path, child_output));
} }
} }
pub PathBuf output_dir(self*, PathBuf* parent_dir) {
if (self.path.is_dir() || Some("package.mist") == self.path.file_name().unwrap().to_str()) {
parent_dir.join(&self.name)
} else {
parent_dir.clone()
} }
} }
pub Module new_package(PathBuf mist_path, PathBuf rust_path) { pub PathBuf output_path(self*, PathBuf* parent_dir) {
if (self.path.is_dir() || Some("package.mist") == self.path.file_name().unwrap().to_str()) {
parent_dir.join(&self.name).join("mod.rs")
} else {
parent_dir.join(&self.name).with_extension("rs")
}
}
}
pub Module master_package(PathBuf mist_path, PathBuf rust_path) {
String name = mist_path.file_stem() String name = mist_path.file_stem()
.and_then(|var s| s.to_str()) .and_then(|var s| s.to_str())
.expect("Failed to get module name") .expect("Failed to get module name")
.to_string(); .to_string();
new Module(name, mist_path, rust_path) var mut root_mod = new Module(name, mist_path.clone(), rust_path.clone());
if (!mist_path.is_dir()) {
PathBuf parent_dir = mist_path.parent()
.expect("Failed to get parent directory of root file")
.to_path_buf();
root_mod.scan_directory(&parent_dir, &rust_path);
}
root_mod
} }
bool should_skip(Path* source, Path* output) { bool should_skip(Path* source, Path* output) {
+31 -71
View File
@@ -6,6 +6,7 @@ use <std::time>;
use <std::env>; use <std::env>;
use <mist_parser::error>; use <mist_parser::error>;
use <crate::modules>;
pub PathBuf build(bool force) { pub PathBuf build(bool force) {
var start = time::Instant::now(); var start = time::Instant::now();
@@ -15,7 +16,9 @@ pub PathBuf build(bool force) {
PathBuf src = root.join("src"); PathBuf src = root.join("src");
PathBuf out = root.join(".mist/src"); PathBuf out = root.join(".mist/src");
build_dir(&root, &src, &src, &out, force); var master = modules::master_package(src.join("main.mist"), out.join("main.rs"));
master.transpile(&out);
var elapsed = start.elapsed(); var elapsed = start.elapsed();
@@ -27,70 +30,41 @@ pub PathBuf build(bool force) {
root root
} }
void build_dir(Path* root, Path* base_src, Path* current, Path* out, bool force) { impl modules::Module {
var entries = match (fs::read_dir(current)) { String transpile(self*, PathBuf* parent_dir) {
Ok[entries] => entries; PathBuf dir = self.output_dir(&parent_dir);
Err[e] => { PathBuf output_file = self.output_path(&parent_dir);
var _ = fs::create_dir_all(&dir);
String mut output = String::new();
for (child : &self.children) {
output.push_str(&child.transpile(&dir));
}
if (self.path.is_dir()) {
var res = fs::write(&output_file, output);
if (res.is_err()) {
eprintln!( eprintln!(
"error: failed to read directory {}\n {}", "error: failed to write output {}\n {}",
current.display(), output_file.display(),
e res.unwrap_err(),
); );
process::exit(1); process::exit(1);
} }
}; } else {
transpile_file(&self.path, &output_file, &output);
for (entry : entries) {
var entry = match (entry) {
Ok[entry] => entry;
Err[e] => {
eprintln!("error: failed to read directory entry\n {}", e);
process::exit(1);
}
};
PathBuf path = entry.path();
if (path.is_dir()) {
build_dir(root, base_src, &path, out, force);
continue;
} }
Path* relative = path.strip_prefix(base_src).expect("Failed to strip base src from path"); format!("pub mod {};\n", self.name)
}
if (path.extension().and_then(|var e| e.to_str()) != Some("mist")) {
PathBuf dest = out.join(relative);
Option<Path*> parent = dest.parent();
if (parent.is_some()) {
fs::create_dir_all(parent.unwrap()).expect("failed to create output directory");
} }
if (!force && should_skip(&path, &dest)) { void transpile_file(PathBuf* path, PathBuf* output_file, str* mod_decl) {
continue String source = match (fs::read_to_string(path)) {
}
fs::copy(&path, dest).expect("Failed to copy non-mist file");
continue;
}
PathBuf output_file = out.join(relative).with_extension("rs");
if (!force && should_skip(&path, &output_file)) {
continue;
}
Option<Path*> parent = output_file.parent();
if (parent.is_some()) {
fs::create_dir_all(parent.unwrap()).expect("failed to create output directory");
}
String source = match (fs::read_to_string(&path)) {
Ok[s] => s; Ok[s] => s;
Err[e] => { Err[e] => {
eprintln!("error: failed to read file {}\n {}", path.display(), e); eprintln!("error: failed to read file {}\n {}", path.display(), e);
@@ -133,7 +107,7 @@ void build_dir(Path* root, Path* base_src, Path* current, Path* out, bool force)
} }
}); });
var res = fs::write(&output_file, output); var res = fs::write(&output_file, format!("{mod_decl}{output}"));
if (res.is_err()) { if (res.is_err()) {
eprintln!( eprintln!(
@@ -145,18 +119,4 @@ void build_dir(Path* root, Path* base_src, Path* current, Path* out, bool force)
process::exit(1); process::exit(1);
} }
} }
}
bool should_skip(Path* source, Path* output) {
var src_time = fs::metadata(source)
.ok()
.and_then(|var v| v.modified().ok());
var out_time = fs::metadata(output)
.ok()
.and_then(|var v| v.modified().ok());
out_time
.map(|var out_time| out_time >= src_time.unwrap())
.unwrap_or_default()
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "mist-parser" name = "mist-parser"
version = "0.1.7-alpha.0" version = "0.1.7-alpha.2"
edition = "2024" edition = "2024"
description = "The Mist programming language parser" description = "The Mist programming language parser"
license = "Apache-2.0" license = "Apache-2.0"
+1 -1
View File
@@ -139,7 +139,7 @@ multi_pat_template = _{
} }
tuple_pattern = { tuple_pattern = {
"[" ~ multi_pat_template ~ "]" "[" ~ pattern ~ "," ~ multi_pat_template ~ "]"
} }
named_tuple_pattern = { named_tuple_pattern = {
-6
View File
@@ -1,9 +1,3 @@
pub mod app;
pub mod task;
pub mod plugin;
pub mod logger;
pub mod event;
void main() { void main() {
var mut app_instance = new app::Application("mist-app"); var mut app_instance = new app::Application("mist-app");