lua_engine

Crates.iolua_engine
lib.rslua_engine
version0.1.1
sourcesrc
created_at2024-04-28 09:20:17.096336
updated_at2024-04-28 09:21:30.313814
descriptionsimple lua engine
homepage
repository
max_upload_size
id1223120
size108,656
crate-owners (github:vivint-smarthome:crate-owners)

documentation

README

Lua Engine

This is a simple implementation of a lua parser and execution engine

How to use it

use clap::Parser;

use lua_engine::evaluation::interpreter::Interpreter;
use lua_engine::evaluation::runtime::Runtime;
use lua_engine::evaluation::typing::{NumberType, Value};

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
    #[arg(short, long)]
    path: String,
}

fn main() {
    let args = Args::parse();

    let mut interpreter = Interpreter::new();
    let mut runtime = Runtime::new();

    interpreter.prepare_runtime(&mut runtime);
    runtime.add_global_variable("my_global", Value::Number(NumberType::Int(100)));

    if let Some(result) = interpreter.evaluate_file(args.path, &mut runtime) {
        println!("Received result: {:?}", result);
    }
}
Commit count: 0

cargo fmt