1 unstable release
0.1.0 | Aug 2, 2022 |
---|
#395 in Text editors
58KB
1.5K
SLoC
tree-sitter-strings
This crate provides a Strings grammar for the [tree-sitter][] parsing library. To
use this crate, add it to the [dependencies]
section of your Cargo.toml
file. (Note that you will probably also need to depend on the
[tree-sitter
][tree-sitter crate] crate to use the parsed result in any useful
way.)
lib.rs
:
This crate provides a strings grammar for the tree-sitter parsing library.
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:
use tree_sitter::Parser;
let code = r#"
class Test {
int double(int x) {
return x * 2;
}
}
"#;
let mut parser = Parser::new();
parser.set_language(tree_sitter_strings::language()).expect("Error loading strings grammar");
let parsed = parser.parse(code, None);
Dependencies
~2.7–4MB
~76K SLoC