| Crates.io | oak-python |
| lib.rs | oak-python |
| version | 0.0.1 |
| created_at | 2025-10-21 13:38:47.449584+00 |
| updated_at | 2026-01-23 04:44:19.174488+00 |
| description | High-performance incremental Python parser for the oak ecosystem with flexible configuration, supporting dynamic programming and rapid development workflows. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893806 |
| size | 123,933 |
High-performance incremental Python parser for the oak ecosystem with flexible configuration, optimized for static analysis and code generation.
Oak Python is a robust parser for Python, designed to handle complete Python 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_core::{Parser, SourceText, parser::session::ParseSession};
use oak_python::{PythonParser, PythonLanguage};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut session = ParseSession::<PythonLanguage>::default();
let parser = PythonParser::new();
let source = SourceText::new(r#"
def greet(name):
print(f"Hello, {name}!")
greet("World")
"#);
let result = parser.parse(&[], &mut session);
println!("Parsed Python successfully.");
Ok(())
}
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_python::{PythonParser, PythonLanguage};
let mut session = ParseSession::<PythonLanguage>::default();
let parser = PythonParser::new();
let source = SourceText::new(r#"
def add(a, b):
return a + b
"#);
let result = parser.parse(&[], &mut session);
println!("Function parsed successfully.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_python::{PythonParser, PythonLanguage};
let mut session = ParseSession::<PythonLanguage>::default();
let parser = PythonParser::new();
let source = SourceText::new(r#"
class Person:
def __init__(self, name):
self.name = name
"#);
let result = parser.parse(&[], &mut session);
println!("Class parsed successfully.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_python::{PythonParser, PythonLanguage};
let mut session = ParseSession::<PythonLanguage>::default();
let parser = PythonParser::new();
let source = SourceText::new("x = 42");
let result = parser.parse(&[], &mut session);
println!("Token parsing completed.");
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_python::{PythonParser, PythonLanguage};
let mut session = ParseSession::<PythonLanguage>::default();
let parser = PythonParser::new();
let source = SourceText::new(r#"
def greet(name)
print(f"Hello, {name}!")
# Missing colon
"#);
let result = parser.parse(&[], &mut session);
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 Python 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.