lua_engine 0.1.1

simple lua engine
Documentation
  • Coverage
  • 0%
    0 out of 248 items documented0 out of 92 items with examples
  • Size
  • Source code size: 109.51 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 8.32 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • saeschdivara

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);
    }
}