5 releases
Uses new Rust 2024
| new 0.0.4 | Feb 18, 2026 |
|---|---|
| 0.0.3 | Feb 12, 2026 |
| 0.0.2 | Feb 1, 2026 |
| 0.0.1 | Jan 23, 2026 |
| 0.0.0 | Oct 21, 2025 |
#1448 in Programming languages
475KB
8K
SLoC
🚀 Oak Python Parser
Elegance and Speed for the Python Ecosystem — A high-performance, incremental Python parser built on the Oak framework. Optimized for modern Python (3.10+) features, type checking, and real-time developer tools.
🎯 Project Vision
Python's growth has led to massive codebases where analysis and tooling speed are paramount. oak-python aims to provide a robust, Rust-powered parsing infrastructure that can handle the unique challenges of Python's indentation-based syntax while delivering sub-millisecond performance. By leveraging Oak's incremental parsing architecture, we enable the creation of highly responsive IDEs, static analyzers, and refactoring tools that can process large Python projects in real-time. Whether you are building a custom type checker, a security scanner, or an advanced code completion engine, oak-python provides the high-fidelity AST and efficiency needed to keep pace with Python's rapid evolution.
✨ Core Features
- ⚡ Blazing Fast: Leverages Rust's performance and memory safety to provide sub-millisecond parsing, essential for high-frequency developer tools and real-time analysis.
- 🔄 Incremental by Nature: Built-in support for partial updates—re-parse only modified code blocks. Ideal for large Python projects and real-time feedback loops.
- 🌳 High-Fidelity AST: Generates a comprehensive Abstract Syntax Tree capturing the full depth of modern Python:
- Indentation Awareness: Precise tracking of indentation levels for correct block scope identification.
- Type Hints: Full support for PEP 484 type annotations and modern type syntax (e.g.,
|for unions). - Async/Await: Deep integration of asynchronous programming constructs.
- Pattern Matching: Robust support for PEP 634 structural pattern matching (
matchandcase). - Decorators & F-Strings: Detailed mapping of function/class decorators and complex f-string expressions.
- 🛡️ Industrial-Grade Fault Tolerance: Engineered to handle incomplete or malformed code gracefully, providing precise diagnostics—crucial for maintaining a smooth developer experience during active coding.
- 🧩 Deep Ecosystem Integration: Seamlessly works with
oak-lspfor full LSP support andoak-mcpfor intelligent code discovery and analysis.
🏗️ Architecture
The parser follows the Green/Red Tree architecture (inspired by Roslyn), which allows for:
- Efficient Immutability: Share nodes across different versions of the tree without copying.
- Lossless Syntax Trees: Retains all trivia (whitespace and comments), enabling faithful code formatting and refactoring.
- Type Safety: Strongly-typed "Red" nodes provide a convenient and safe API for tree traversal and analysis.
🤝 Contributing
We welcome contributions of all kinds! If you find a bug, have a feature request, or want to contribute code, please check our issues or submit a pull request.
Dependencies
~5–10MB
~104K SLoC