| Crates.io | sollua |
| lib.rs | sollua |
| version | 0.1.0 |
| created_at | 2025-11-22 06:14:42.01602+00 |
| updated_at | 2025-11-22 06:14:42.01602+00 |
| description | An elegantly fast lua 5.4 parser. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1944879 |
| size | 1,377,583 |
A Simple, fast, beautiful Lua 5.4 parsing Rust crate.
Other options are extremely outdated, slow, generate ugly AST's, or just refuse to compile for release builds. Luckily Sollua is a modern, extremely fast, beautifly crafted parsing crate anyone and their grandmothers could use. Sollua is the perfect option for developers who want to create powerful compilers, language servers, semantic analyzers, etc.
Sollua supports every feature present in Lua 5.4 EXCEPT!!! the following:
[=[content]=]0xff.ff (who uses these??)Each result is the average after running 5 tests.
The files used in each test are in the lua directory of the repository.
| Crate | 1000 Funcs (7337 Lines) | 2500 Funcs (18337 Lines) | 5000 Funcs (36669 Lines) |
|---|---|---|---|
| sollua | 9 ms | 19.2 ms | 33.2 ms |
| luaparse | 44.6 ms | 125 ms | 246 ms |
| full_moon | 48 ms | 137 ms | 246 |
cargo add sollua
use sollua::lexer::Lexer;
use sollua::parser::Parser;
fn main() {
let source = "function add(a, b) return a + b end";
let mut tokens = Lexer::new(source).collect();
let mut parser = parser::new(source, &tokens);
let ast = parser.parse();
println!("AST: \n{:?}", ast);
if parser.errors.len() > 0 {
for error in &parser.errors {
println!("Parser error: {:?}", error);
}
}
}
Expected Output:
AST:
[
Statement(
FunctionDeclaration {
name_path: [
"add",
],
is_method: false,
parameters: [
"a",
"b",
],
body: Statement(
Block(
[
Statement(
Return(
[
BinaryOp {
left: Variable(
"a",
),
operator: Plus,
right: Variable(
"b",
),
},
],
),
),
],
),
),
},
),
]