luau-parser

Crates.ioluau-parser
lib.rsluau-parser
version
sourcesrc
created_at2025-04-07 16:14:23.000894+00
updated_at2025-05-22 20:17:30.720616+00
descriptionA blazingly fast Luau parser with robust error recovery.
homepagehttps://github.com/msix29/luau-parser
repositoryhttps://github.com/msix29/luau-parser
max_upload_size
id1624423
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
msix29 (msix29)

documentation

https://docs.rs/luau-parser

README

Luau Parser

A blazingly fast, lossless, Luau parser, with robust error recovery. Lossless, meaning that none of the details of the code are lost, and that all of it is stored in the returned syntax tree, and thus, the original source code can be printed back by using the Cst::print function.

This parser has error detection and fills in tokens to account for such circumstances, for example, given:

local function

the produced CST would have tokens that evaluate to:

local function *error*() end

and appropriate errors for these missing tokens are stored to be used by consumers.

Usage

use luau_parser::prelude::Parser;

let code = r#"local foo = "Hello, World!""#;
let uri = ""; // This should be the path of the file being parsed
              // (Used for the `cache` feature).

let mut parser = Parser::new(code);
let cst = parser.parse(uri);

println!("{:#?}", cst);
assert!(!cst.block.is_empty());

Note

  • This parser does not stop parsing when it finds an error
  • This parser only parses the code into an understandable syntax tree, it does not guarantee that the code itself is error free. Usage of undefined items will not produce wrong results.
  • This parser only works for luau, although for lua versions compatible with luau, it can still be used, for example, lua 5.1, but features limited to a version of lua won't work, for example attributes in lua 5.3.
Commit count: 0

cargo fmt