This is part of Rhue's insides. If you just want to run scripts from Rust, use rhue, it's the only crate whose API is meant to stay stable. Everything else (this one included) can change between minor versions.
use parse_chunk;
let chunk = parse_chunk.unwrap;
assert_eq!;
let errors = parse_chunk.unwrap_err;
assert_eq!; // it recovers and keeps going
It takes all of Luau's type syntax (annotations, aliases with generics and defaults, type packs, read/write properties, typeof, ::) and keeps it in the AST for rhue-types. The compiler just ignores it.
A few things worth knowing:
- every name occurrence gets a dense
NameId, so later passes keep side tables in aVecinstead of hashing nodes - nesting is capped at
MAX_DEPTH, including long1 + 1 + 1 ...chains, so hostile input can't build a tree deep enough to blow the stack - it stops collecting after
MAX_ERRORS, the rest are usually cascades anyway parse_exprandparse_typeparse just an expression or just a type (the REPL and host declarations use those)
License
MIT or Apache-2.0, same as the rest of Rhue.