4 releases
| 0.4.1 | May 9, 2026 |
|---|---|
| 0.4.0 | Dec 8, 2024 |
| 0.3.7 | May 7, 2024 |
| 0.3.6 | May 7, 2024 |
#407 in Parser implementations
169,243 downloads per month
Used in 10 crates
(7 directly)
34MB
1M
SLoC
This crate provides Kotlin language support for the tree-sitter parsing library.
Typically, you will use the [LANGUAGE][] constant to add this language to a tree-sitter Parser, and then use the parser to parse some code:
use tree_sitter::Parser;
let code = r#"
class Test {
fun double(x: Int): Int {
return x * 2
}
}
"#;
let mut parser = Parser::new();
let language = tree_sitter_kotlin::LANGUAGE;
parser
.set_language(&language.into())
.expect("Error loading Kotlin grammar");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());
Kotlin Grammar for Tree-sitter
This crate provides a Kotlin grammar for the tree-sitter parsing library. To use this crate, add it to the [dependencies] section of your Cargo.toml file:
tree-sitter = "0.23"
tree-sitter-kotlin = "0.3.9"
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:
let code = r#"
data class Point(
val x: Int,
val y: Int
)
"#;
let mut parser = Parser::new();
parser.set_language(&tree_sitter_kotlin::language()).expect("Error loading Kotlin grammar");
let parsed = parser.parse(code, None);