This is a parser for the Squirrel language, written in Rust. It is primarily designed to parse Respawn's custom Squirrel dialect, but should be able to handle Squirrel 2 and 3 code as well.
Features:
- Completely source-preserving: all tokens and comments in the input string are included in the AST. This makes it perfect for source modification operations like code formatting.
- Friendly error messages: in general, the parser aims to show nice syntax error messages with useful contextual information. Unfortunately this isn't always possible due to syntax ambiguities, especially where Respawn's type system is involved.
- Parses all Northstar scripts and R5Reloaded scripts successfully. The resulting ASTs have not been verified.
There are probably bugs.
There are some examples included. Use cargo to run them:
- Print AST debug output:
$ cargo run --example print_ast
- Print an example lexer error:
$ cargo run --example print_lexer_error
- Print an example parser error:
$ cargo run --example print_parser_error
- Dry-run the parser on one file or a directory tree:
$ cargo run --release --example dryrun -- [path to file or directory]