| Crates.io | oak-cpp |
| lib.rs | oak-cpp |
| version | 0.0.1 |
| created_at | 2025-10-20 12:20:56.237823+00 |
| updated_at | 2026-01-23 04:18:35.050141+00 |
| description | C++ systems programming language parser with support for modern C++ features and object-oriented programming. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1891841 |
| size | 77,280 |
High-performance incremental C++ parser for the oak ecosystem with flexible configuration, optimized for code analysis and compilation.
Oak C++ is a robust parser for C++, designed to handle complete 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_cpp::{Parser, CppLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
#include <iostream>
class Greeter {
public:
void greet() {
std::cout << "Hello, C++!" << std::endl;
}
};
int main() {
Greeter greeter;
greeter.greet();
return 0;
}
"#);
let result = parser.parse(&source);
println!("Parsed C++ program successfully.");
Ok(())
}
use oak_cpp::{Parser, CppLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
class MyClass {
public:
int myMethod(int x) { return x * 2; }
};
"#);
let result = parser.parse(&source);
println!("Parsed C++ class successfully.");
use oak_cpp::{Parser, CppLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
template <typename T>
T max(T a, T b) {
return (a > b) ? a : b;
}
"#);
let result = parser.parse(&source);
println!("Parsed C++ template successfully.");
use oak_cpp::{Parser, CppLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("int main() { return 0; }");
let result = parser.parse(&source);
// Token information is available in the parse result
use oak_cpp::{Parser, CppLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
int main() {
std::cout << "Hello, World!" << std::endl
return 0;
}
"#);
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 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.