17 releases

new 0.7.8 Jun 13, 2025
0.7.7 Jan 19, 2025
0.7.5 May 18, 2024
0.7.1 Feb 20, 2024
0.4.0 Jul 15, 2022

#2635 in Parser implementations

Download history 3/week @ 2025-02-26 7/week @ 2025-03-05 28/week @ 2025-03-26 13/week @ 2025-04-02 9/week @ 2025-04-09 18/week @ 2025-04-16 11/week @ 2025-04-23 8/week @ 2025-05-07 1/week @ 2025-05-14 23/week @ 2025-06-04 173/week @ 2025-06-11

196 downloads per month
Used in 2 crates

MIT license

3.5MB
123K SLoC

C 122K SLoC // 0.0% comments JavaScript 1K SLoC // 0.0% comments Rust 34 SLoC // 0.1% comments

This crate provides sourcepawn language support for the tree-sitter parsing library.

Typically, you will use the language function to add this language to a tree-sitter Parser, and then use the parser to parse some code:

let code = "";
let mut parser = tree_sitter::Parser::new();
parser.set_language(tree_sitter_sourcepawn::language()).expect("Error loading sourcepawn grammar");
let tree = parser.parse(code, None).unwrap();

tree-sitter-sourcepawn

This crate provides a SourcePawn grammar for the tree-sitter parsing library. To use this crate, add it to the [dependencies] section of your Cargo.toml file, as well as the tree-sitter.

[dependencies]
tree-sitter = "0.24.7"
tree-sitter-sourcepawn = "0.7.8"

Typically, you will use the language function to add this grammar to a tree-sitter Parser, and then use the parser to parse some code.

The below example demonstrates a simple program that parses a SourcePawn variable and prints the result to your terminal.

use tree_sitter::Parser;

fn main() {
    let source = "int foo";
    let mut parser = Parser::new();
    parser
        .set_language(tree_sitter_sourcepawn::language())
        .expect("Error loading SourcePawn grammar");
    let tree = parser.parse(source, None);
    println!("{:#?}", tree.to_sexp());
}

Dependencies

~3–4MB
~78K SLoC