Crates.io | mink |
lib.rs | mink |
version | 0.1.1 |
source | src |
created_at | 2022-08-13 16:12:48.033739 |
updated_at | 2022-08-13 16:15:52.650264 |
description | (WIP) Portable and modular scripting language for all |
homepage | |
repository | |
max_upload_size | |
id | 644924 |
size | 33,679 |
Mink is a fast, simple and modular scripting language built on top of Rust. While it was originally targeted as a language for game engines, it now lives as a general-purpose language for any project.
Mink's syntax is simple, clear and explicit. On the user-end, it allows for dynamic typing and fast prototyping.
On the developer-end, Mink focuses on providing a simple but powerful API. Mink is completely modular as a language, allowing developers to implement their own libraries with ease (even the standard library!).
print("Hi, Diego!")
use mink::*;
fn main() {
let mut vm = Mink::new();
let script = Script::new("greeting", include_str!("greeting.mink"));
vm.add_script(script);
vm.exec("greeting");
}
// mathlib.rs
use mink::*;
pub fn lib() -> Library {
let mut lib = Library::new("math", true);
lib.add_func(Function::new("mag", Some(2), math_mag));
lib
}
fn math_mag(_: &Mink, args: Vec<Value>) -> Value {
let x = args[0].num();
let y = args[1].num();
Value::Num((x * x + y * y).sqrt())
}
// main.rs
mod mathlib;
use mink::*;
fn main() {
let vm = Mink::new();
vm.add_lib(mathlib::lib());
}