| Crates.io | oak-kotlin |
| lib.rs | oak-kotlin |
| version | 0.0.1 |
| created_at | 2025-10-21 15:48:45.325847+00 |
| updated_at | 2026-01-23 04:36:04.640353+00 |
| description | High-performance incremental Kotlin parser for the oak ecosystem with flexible configuration, supporting modern JVM development and functional programming. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1894037 |
| size | 77,541 |
High-performance incremental Kotlin parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
Oak Kotlin is a robust parser for Kotlin, designed to handle complete Kotlin syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for static analysis and code generation.
Basic example:
use oak_kotlin::{Parser, KotlinLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
fun main() {
println("Hello, Kotlin!")
}
"#);
let result = parser.parse(&source);
println!("Parsed Kotlin successfully.");
Ok(())
}
use oak_kotlin::{Parser, KotlinLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
fun calculateArea(radius: Double): Double {
return Math.PI * radius * radius
}
fun main() {
val area = calculateArea(5.0)
println("Area: $area")
}
"#);
let result = parser.parse(&source);
println!("Function parsed successfully.");
use oak_kotlin::{Parser, KotlinLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
class Person(val name: String, var age: Int) {
fun greet() {
println("Hello, I'm $name and I'm $age years old")
}
fun haveBirthday() {
age++
println("Happy birthday! Now I'm $age")
}
}
fun main() {
val person = Person("Alice", 25)
person.greet()
person.haveBirthday()
}
"#);
let result = parser.parse(&source);
println!("Class parsed successfully.");
use oak_kotlin::{Parser, KotlinLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("val x = 42");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_kotlin::{Parser, KotlinLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
// Invalid Kotlin code example
fun brokenFunction {
println("Hello")
// Missing function parameters and return type
}
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak Kotlin integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.