Skip to content

cpdt/sqparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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]
    

About

Squirrel3 and Squirrel_re parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages