Oaks is a comprehensive collection of parser combinator libraries for Rust, providing robust parsing solutions for multiple programming languages and data formats. Built on a solid foundation of parser combinators, Oaks offers both high-level convenience and low-level control.
- Multi-Language Support: 50+ programming languages and data formats
- High Performance: Zero-copy parsing with minimal allocations
- Extensible: Modular design allowing custom parsers and extensions
- No-std Compatible: Core library works without the standard library
- Comprehensive Error Handling: Detailed error messages with source locations
- Incremental Parsing: Support for partial and streaming parsing
- Syntax Highlighting: Built-in multi-language syntax highlighting
- Pretty Printing: Code formatting and pretty printing utilities
| Crate | Description | Status |
|---|---|---|
oak-core |
Core parser combinator primitives | β Active |
oak-highlight |
Multi-language syntax highlighter | β Active |
oak-pretty-print |
Code formatting and pretty printing | β Active |
oak-visualize |
AST visualization and graph rendering | π Development |
oaks |
Main unified library | β Active |
oak-c- C language parser with preprocessoroak-cpp- C++ language parseroak-rust- Rust language parseroak-zig- Zig language parseroak-go- Go language parseroak-d- D language parser
oak-javascript- JavaScript/ECMAScript parseroak-typescript- TypeScript parseroak-html- HTML parseroak-css- CSS parseroak-json- JSON parser with streamingoak-markdown- Markdown parser with CommonMark
oak-python- Python language parseroak-java- Java language parseroak-kotlin- Kotlin language parseroak-scala- Scala language parseroak-clojure- Clojure parseroak-fsharp- F# parser
oak-yaml- YAML parseroak-toml- TOML parseroak-ini- INI parseroak-csv- CSV parseroak-xml- XML parser
Basic usage example:
use oak_core::{Language, Lexer};
use oak_rust::{RustLanguage, RustLexer};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Tokenize Rust code
let input = "fn main() { println!(\"Hello, World!\"); }";
let lexer = RustLexer::new(input);
let tokens: Vec<_> = lexer.collect();
println!("Tokens: {:?}", tokens);
Ok(())
}Oaks follows a modular workspace architecture:
-
Core Libraries: Fundamental parser combinator primitives in
projects/oak-core: Core parsing infrastructure and traitsoak-highlight: Multi-language syntax highlightingoak-pretty-print: Code formatting utilitiesoak-visualize: AST visualization (in development)oaks: Unified API facade
-
Language Parsers: Individual parser implementations in
examples/- 50+ language-specific parsers
- Each parser built on top of
oak-core - Consistent API design across all languages
-
Development Tools: Build and development utilities
- Workspace-based development with Cargo
- Comprehensive test suites for each parser
- Documentation and examples
oaks/
βββ projects/ # Core libraries
β βββ oak-core/ # Core parsing infrastructure
β βββ oak-highlight/ # Syntax highlighting
β βββ oak-pretty-print/ # Code formatting
β βββ oak-visualize/ # AST visualization
β βββ oaks/ # Main unified library
βββ examples/ # Language parsers (50+ languages)
β βββ oak-rust/ # Rust parser
β βββ oak-c/ # C parser
β βββ oak-javascript/ # JavaScript parser
β βββ ... # Many more languages
βββ documents/ # Additional documentation
βββ target/ # Build artifacts
βββ Cargo.toml # Workspace configuration
- Rust nightly toolchain (required for
new_range_apifeature) - Cargo workspace support
# Build all crates
cargo build --release
# Build specific language parser
cargo build -p oak-rust
# Run tests
cargo test --release# Format code
npm run fmt
# Generate documentation
npm run doc
# Run all tests
npm run testuse oak_rust::{RustLexer, RustLanguage};
use oak_core::{Lexer, Language};
let input = "fn main() { println!(\"Hello, World!\"); }";
let lexer = RustLexer::new(input);
let tokens: Vec<_ > = lexer.collect();
println!("Found {} tokens", tokens.len());use oak_highlight::{Highlighter, Theme};
use oak_rust::RustLanguage;
let highlighter = Highlighter::new(RustLanguage::new());
let highlighted = highlighter.highlight_to_html(code, Theme::Github);use oak_rust::RustLanguage;
use oak_pretty_print::Formatter;
let formatter = Formatter::new(RustLanguage::new());
let formatted = formatter.format(code) ?;Oaks is actively developed and maintained. Current status:
- Core parser combinator framework (
oak-core) - Basic lexer infrastructure for all languages
- Syntax highlighting system (
oak-highlight) - Pretty printing framework (
oak-pretty-print) - Project structure for 50+ languages
- Full AST parsing for major languages (Rust, C, JavaScript, Python)
- Advanced error recovery mechanisms
- Incremental parsing capabilities
- Performance optimizations
- Documentation and examples
- Complete AST implementations for all languages
- Language server protocol support
- Advanced code analysis features
- IDE integrations
- Streaming parser support
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Built with love for the Rust community
- Inspired by parser combinator libraries like nom and combine
- Thanks to all contributors who have helped shape this project
- Repository
- Issue Tracker
- Development documentation in each crate's
readme.md - Examples in the
examples/directory
Happy Parsing! π