| Crates.io | oak-nim |
| lib.rs | oak-nim |
| version | 0.0.1 |
| created_at | 2025-10-21 04:39:51.408156+00 |
| updated_at | 2026-01-23 04:42:17.29252+00 |
| description | Nim language parser with support for modern Nim syntax and systems programming features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893272 |
| size | 113,297 |
High-performance incremental Nim parser for the oak ecosystem with flexible configuration, optimized for systems programming and metaprogramming.
Oak Nim is a robust parser for Nim, designed to handle complete Nim 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_nim::{Parser, NimLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
proc add(a, b: int): int =
result = a + b
echo "Hello, Nim!"
"#);
let result = parser.parse(&source);
println!("Parsed Nim successfully.");
Ok(())
}
use oak_nim::{Parser, NimLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
proc factorial(n: int): int =
if n <= 1:
return 1
else:
return n * factorial(n - 1)
"#);
let result = parser.parse(&source);
println!("Procedure parsed successfully.");
use oak_nim::{Parser, NimLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
type
Person = object
name: string
age: int
Animal = ref object of RootObj
species: string
age: int
"#);
let result = parser.parse(&source);
println!("Object definitions parsed successfully.");
use oak_nim::{Parser, NimLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("let x = 42");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_nim::{Parser, NimLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
# Invalid Nim code example
proc broken_function(
echo "Hello"
# Missing closing parenthesis and return
"#);
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 Nim 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.