3 releases (breaking)

0.3.0 Feb 5, 2023
0.2.0 Feb 4, 2023
0.1.0 Jan 31, 2023

#4 in #squirrel

MIT license

245KB
5.5K SLoC

sqparse

Crates.io Docs.rs MIT licensed Build status

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.

Examples

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]
    

Dependencies

~2MB
~28K SLoC