| Crates.io | oak-lua |
| lib.rs | oak-lua |
| version | 0.0.1 |
| created_at | 2025-10-22 02:32:45.946797+00 |
| updated_at | 2026-01-23 04:41:26.885415+00 |
| description | High-performance incremental Lua parser for the oak ecosystem with flexible configuration, supporting lightweight scripting and embedded development. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1894829 |
| size | 119,640 |
High-performance incremental Lua parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
Oak Lua is a robust parser for Lua, designed to handle complete Lua syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for static analysis and code generation.
Basic example:
use oak_lua::{Parser, LuaLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
function greet(name)
print("Hello, " .. name)
end
local message = "Welcome to Lua!"
greet(message)
"#);
let result = parser.parse(&source);
println!("Parsed Lua successfully.");
Ok(())
}
use oak_lua::{Parser, LuaLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
function factorial(n)
if n <= 1 then
return 1
else
return n * factorial(n - 1)
end
end
"#);
let result = parser.parse(&source);
println!("Function parsed successfully.");
use oak_lua::{Parser, LuaLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
local config = {
name = "server",
port = 8080,
enabled = true,
users = {"admin", "guest"}
}
"#);
let result = parser.parse(&source);
println!("Table parsed successfully.");
use oak_lua::{Parser, LuaLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("local x = 42");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_lua::{Parser, LuaLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
-- Invalid Lua code example
function broken_function(
print("Hello"
-- Missing closing parenthesis and end
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak Lua integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.