Silt-Lua, a Lua subset interpreter in 100% rust

This project was originally created to answer a problem with the current rust landscape in lacking a complete lua interpreter solution written in 100% rust. That may not necessarily be true anymore. Even still, the existing implementations at the time were missing crucial features and optimizations to satisfy the requirements of my closed source project Petrichor64, so here we are.

Core focus of the library is a basic interpreter with minor overhead and relative speed comparison to standard lua. The goal is for a perfect wasm32-unknown-unknown target build. No emscripten necessary! UserData will mirror traits used by the mlua and rlua crates to allow easy drop in.

Secondary goals are CLI, LSP, and full standard library compliance. Ideally loading third party libraries as well. There's also a concern for safety, as a number of unsafe code is present in the VM. In the future a safe and unsafe version of the VM will be hidden under a feature flag, on the assumption the unsafe version will operate marginally faster. Exact benchmarks will have to be determined.

There's also desire to add some custom non-lua syntax pulling syntactic sugar from other languages, such as allowing for !=, typing, and maybe even arrow functions. This superset of lua will fall under a feature flag and by default be disabled as who really wants my opinionated concept of a programming language? This supset satisfies personal requirements but I'm open to requests if an interest is shown. Even if this superset is enabled it will not conflict with standard lua.

This library been written from the ground up with observations of the lua language and documentation, source code has not been referenced so it's very possible the VM will always have some noticeable differences that will hopefully be ironed out eventually. This includes the byte code, as lua now operates under wordcode to work with it's register based VM. Feel free to submit an issue for anything particularly glaring. This project is a learning exercise so there is a good deal of naive approaches I'm taking to make this a reality.

Limitations

WebAssembly

A simple wasm module example can be compiled via wasm-pack. Print calls a global jprintln function if one exists. A live example can be viewed at MakeAvoy.com

Optional Additions (feature flags)

Keep in mind these may be polarizing and an LSP will flag them as an error

Examples

```rust

let source_in = r#" local d=5 function sum() local a=1 local b=2 local c=3 return a+b+c+d+8 end

return sum() "#;

let mut vm = Lua::new(); vm.loadstandardlibrary(); match vm.run(sourcein) { Ok(value) => { println!(">> {}", value); } Err(e) => { e.iter().foreach(|e| println!("!!Err: {}", e)); } } ```