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:
- Fork this repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a Pull Request
License
Luahscript is released under the Apache 2.0 License. See the LICENSE file for details.