1 unstable release
new 0.1.0 | May 1, 2025 |
---|
#287 in Game dev
116 downloads per month
690KB
15K
SLoC
roblox-rs-core
Core library for the roblox-rs compiler.
Overview
roblox-rs-core
is the engine behind the roblox-rs
compiler, responsible for parsing Rust source code, transforming it to Luau AST, and generating optimized Luau code for the Roblox platform.
Features
- Rust AST parsing via
syn
- Type system mapping from Rust to Luau
- AST transformation pipeline
- Optimized Luau code generation
- Support for Roblox APIs and patterns
Usage
While this library is primarily used by the roblox-rs-cli
package, you can also use it directly in your Rust code:
use roblox_rs_core::{compile, CompileOptions};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rust_source = r#"
fn add(a: i32, b: i32) -> i32 {
a + b
}
"#;
let options = CompileOptions {
optimize: true,
target_dir: "out".into(),
..Default::default()
};
let luau_output = compile(rust_source, options)?;
println!("Generated Luau: {}", luau_output);
Ok(())
}
Architecture
The compilation process occurs in several stages:
- Parse Rust source into AST using
syn
- Analyze types and build a type map
- Transform Rust AST into an intermediate representation
- Generate Luau AST from the intermediate representation
- Emit optimized Luau code
API Documentation
Detailed API documentation is coming soon. For now, see the examples directory for sample usage.
Related
roblox-rs-cli
: Command-line interface using this libraryroblox-rs
: The main project repository
License
This project is licensed under the MIT License - see the LICENSE file for details.
Dependencies
~2–13MB
~156K SLoC