#tree-sitter #parser #incremental #parse-tree #sourcepawn

tree-sitter-sourcepawn

sourcepawn grammar for the tree-sitter parsing library

16 releases

0.7.7 Jan 19, 2025
0.7.5 May 18, 2024
0.7.1 Feb 20, 2024
0.6.0 Jul 23, 2023
0.4.0 Jul 15, 2022

#231 in Text editors

Download history 30/week @ 2024-11-27 208/week @ 2024-12-04 171/week @ 2024-12-11 10/week @ 2024-12-18 55/week @ 2025-01-01 28/week @ 2025-01-08 218/week @ 2025-01-15 21/week @ 2025-01-22 12/week @ 2025-02-05

257 downloads per month
Used in sourcepawn_lsp

MIT license

3.5MB
122K SLoC

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

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.7"

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());
}

lib.rs:

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();

Dependencies

~3–4.5MB
~80K SLoC