sqparse

Crates.iosqparse
lib.rssqparse
version0.3.0
sourcesrc
created_at2023-01-31 13:18:22.958835
updated_at2023-02-05 12:21:00.656626
descriptionSquirrel3 and Squirrel_re parser.
homepagehttps://github.com/cpdt/sqparse
repositoryhttps://github.com/cpdt/sqparse
max_upload_size
id772681
size252,294
Tom Barham (cpdt)

documentation

README

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]
    
Commit count: 24

cargo fmt