| Crates.io | oak-ruby |
| lib.rs | oak-ruby |
| version | 0.0.1 |
| created_at | 2025-10-21 13:38:47.796072+00 |
| updated_at | 2026-01-23 05:18:17.017935+00 |
| description | Ruby dynamic programming language parser with support for object-oriented programming and modern Ruby features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893807 |
| size | 97,808 |
High-performance incremental Ruby parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
Oak Ruby is a robust parser for Ruby, designed to handle complete Ruby 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_ruby::{Parser, RubyLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
puts "Hello, World!"
name = "Ruby"
puts "Welcome to #{name}!"
"#);
let result = parser.parse(&source);
println!("Parsed Ruby successfully.");
Ok(())
}
use oak_ruby::{Parser, RubyLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
def add(a, b)
return a + b
end
result = add(5, 3)
puts "Result: #{result}"
"#);
let result = parser.parse(&source);
println!("Method parsed successfully.");
use oak_ruby::{Parser, RubyLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
class Calculator
def initialize
@result = 0
end
def add(value)
@result += value
self
end
def get_result
@result
end
end
"#);
let result = parser.parse(&source);
println!("Class parsed successfully.");
use oak_ruby::{Parser, RubyLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("x = 42");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_ruby::{Parser, RubyLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
# Invalid Ruby code example
def broken_function(
puts "Hello"
# Missing closing brace
"#);
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 Ruby 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.