| Crates.io | oak-groovy |
| lib.rs | oak-groovy |
| version | 0.0.1 |
| created_at | 2025-10-20 16:39:59.310127+00 |
| updated_at | 2026-01-23 04:28:37.618008+00 |
| description | Groovy dynamic programming language parser with support for modern Groovy syntax and JVM ecosystem integration. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1892311 |
| size | 74,534 |
High-performance incremental Groovy parser for the oak ecosystem with flexible configuration, optimized for build systems and dynamic language applications.
Oak Groovy is a robust parser for Apache Groovy, designed to handle complete Groovy syntax including modern language features and DSL capabilities. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for Groovy analysis and tooling.
Basic example:
use oak_groovy::{Parser, GroovyLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
def hello() {
println "Hello, Groovy!"
}
hello()
"#);
let result = parser.parse(&source);
println!("Parsed Groovy script successfully.");
Ok(())
}
use oak_groovy::{Parser, GroovyLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
class Person {
String name
int age
Person(String name, int age) {
this.name = name
this.age = age
}
def greet() {
println "Hello, I'm ${name} and I'm ${age} years old."
}
}
def person = new Person("Alice", 30)
person.greet()
"#);
let result = parser.parse(&source);
println!("Parsed Groovy class successfully.");
use oak_groovy::{Parser, GroovyLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
def numbers = [1, 2, 3, 4, 5]
def doubled = numbers.collect { it * 2 }
println "Original: ${numbers}"
println "Doubled: ${doubled}"
// Method reference
def strings = ["apple", "banana", "cherry"]
def lengths = strings.collect(String::length)
println "Lengths: ${lengths}"
"#);
let result = parser.parse(&source);
println!("Parsed Groovy closures successfully.");
use oak_groovy::{Parser, GroovyLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("def hello() { println 'Hello' }");
let result = parser.parse(&source);
// Token information is available in the parse result
use oak_groovy::{Parser, GroovyLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
def brokenMethod() {
def x = "string"
x++ // Type mismatch error
if (x == 5 { // Missing closing parenthesis
println "This won't compile"
}
}
"#);
let result = parser.parse(&source);
if let Err(e) = result.result {
println!("Parse error: {:?}", e);
}
The parser generates a comprehensive AST with the following main structures:
Oak-groovy 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.