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
257 downloads per month
Used in sourcepawn_lsp
3.5MB
122K
SLoC
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