luahscript

use hscript expression to make lua script
https://github.com/VapireMox/luahscript

To install, run:

haxelib install luahscript 0.0.4 

See using Haxelib in Haxelib documentation for more information.

README.md

Luahscript

Luahscript is a Haxe library that uses hscript to parse and execute Lua scripts. The project is still under development, but already supports compilation on multiple platforms.

Features

  • Uses hscript to parse Lua scripts
  • Supports compilation on multiple platforms: C++, Neko, Interp, JavaScript, and more
  • Provides complete Lua syntax support, including variables, control structures, functions, and tables
  • Supports metatables and metamethods
  • Offers error handling and debugging capabilities

Installation

Install Luahscript using haxelib:

haxelib install luahscript

If you need to experience new features, you can download lib in github:

haxelib git luahscript https://github.com/VapireMox/luahscript

Quick Start

Here's a simple example showing how to parse and execute a Lua script:

import luahscript.LuaParser;
import luahscript.LuaInterp;
import luahscript.exprs.LuaExpr;

class Main {
    public static function main() {
        // Define a simple Lua script
        var luaScript = '
            local function greet(name)
                return "Hello, " .. name .. "!"
            end
            
            return greet("World")
        ';
        
        // Parse the Lua script
        var parser = new LuaParser();
        var expr = parser.parseFromString(luaScript);
        
        // Create an interpreter and execute the script
        var interp = new LuaInterp();
        
        var result = interp.execute(expr);
        
        // Execute the returned function and trace the result
        // NOTE: The function from Lua are usually 'luahscript.LuaAndParams'. if want to obtain its value, call the "values" field, pls.
        trace(result("Hello Lua!", "5.4")); // Output: Hello, World!
    }
}

Documentation

Usage Examples

For more usage examples, please refer to the tests directory.(No completion!)

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork this repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a Pull Request

License

Luahscript is released under the Apache 2.0 License. See the LICENSE file for details.

Contributors
GeXie19
Version
0.0.4
Published
8 months ago
License
Apache

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub