| Crates.io | oak-swift |
| lib.rs | oak-swift |
| version | 0.0.1 |
| created_at | 2025-10-22 02:32:29.303295+00 |
| updated_at | 2026-01-23 05:19:46.846868+00 |
| description | High-performance incremental Swift parser for the oak ecosystem with flexible configuration, supporting iOS/macOS development and modern language features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1894828 |
| size | 86,781 |
High-performance incremental Swift parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
Oak Swift is a robust parser for Swift, designed to handle complete Swift 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_swift::{Parser, SwiftLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
func hello() {
print("Hello, World!")
}
hello()
"#);
let result = parser.parse(&source);
println!("Parsed Swift successfully.");
Ok(())
}
use oak_swift::{Parser, SwiftLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
func add(a: Int, b: Int) -> Int {
return a + b
}
let result = add(a: 5, b: 3)
print("Result: \(result)")
"#);
let result = parser.parse(&source);
println!("Function parsed successfully.");
use oak_swift::{Parser, SwiftLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
struct Point {
var x: Double
var y: Double
func distance(to other: Point) -> Double {
let dx = self.x - other.x
let dy = self.y - other.y
return sqrt(dx * dx + dy * dy)
}
}
"#);
let result = parser.parse(&source);
println!("Struct parsed successfully.");
use oak_swift::{Parser, SwiftLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("let x: Int = 42");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_swift::{Parser, SwiftLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
// Invalid Swift code example
func brokenFunction(
print("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 Swift 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.