| Crates.io | oak-objective-c |
| lib.rs | oak-objective-c |
| version | 0.0.1 |
| created_at | 2025-10-22 11:32:14.186238+00 |
| updated_at | 2026-01-23 04:42:45.877068+00 |
| description | Objective-C object-oriented programming language parser with support for Apple platform development and runtime features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1895510 |
| size | 128,131 |
High-performance incremental Objective-C parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
Oak Objective-C is a robust parser for Objective-C, designed to handle complete Objective-C 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_objective_c::{Parser, ObjectiveCLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
#import <Foundation/Foundation.h>
@interface Person : NSObject {
NSString *name;
NSInteger age;
}
- (instancetype)initWithName:(NSString *)name age:(NSInteger)age;
- (void)greet;
@end
@implementation Person
- (instancetype)initWithName:(NSString *)name age:(NSInteger)age {
self = [super init];
if (self) {
self.name = name;
self.age = age;
}
return self;
}
- (void)greet {
NSLog(@"Hello, I'm %@ and I'm %ld years old", self.name, (long)self.age);
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
Person *person = [[Person alloc] initWithName:@"John" age:30];
[person greet];
}
return 0;
}
"#);
let result = parser.parse(&source);
println!("Parsed Objective-C successfully.");
Ok(())
}
use oak_objective_c::{Parser, ObjectiveCLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
@interface Calculator : NSObject
- (NSInteger)add:(NSInteger)a to:(NSInteger)b;
- (NSInteger)subtract:(NSInteger)a from:(NSInteger)b;
- (NSInteger)multiply:(NSInteger)a by:(NSInteger)b;
@end
"#);
let result = parser.parse(&source);
println!("Interface parsed successfully.");
use oak_objective_c::{Parser, ObjectiveCLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
@implementation Calculator
- (NSInteger)add:(NSInteger)a to:(NSInteger)b {
return a + b;
}
- (NSInteger)subtract:(NSInteger)a from:(NSInteger)b {
return b - a;
}
- (NSInteger)multiply:(NSInteger)a by:(NSInteger)b {
return a * b;
}
@end
"#);
let result = parser.parse(&source);
println!("Implementation parsed successfully.");
use oak_objective_c::{Parser, ObjectiveCLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("NSString *message = @\"Hello World\";");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_objective_c::{Parser, ObjectiveCLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
// Invalid Objective-C code example
@interface BrokenClass : NSObject {
NSString *name
// Missing semicolon
}
- (void)brokenMethod {
NSLog(@"Hello")
// Missing semicolon
}
@end
"#);
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 Objective-C 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.