| Crates.io | oak-dhall |
| lib.rs | oak-dhall |
| version | 0.0.1 |
| created_at | 2025-10-20 14:51:37.734357+00 |
| updated_at | 2026-01-23 04:21:31.900074+00 |
| description | Dhall language parser with support for functional programming and type system features. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1892041 |
| size | 57,416 |
Oak of Dhall is a powerful and efficient parser for the Dhall programming language, built using the oak parser combinator library. It provides a robust solution for parsing Dhall syntax, enabling various applications such as static analysis of Dhall code, refactoring tools, and automated code generation.
oak's optimized parsing techniques for speed.Here's a simple example demonstrating how to parse Dhall code:
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_dhall::{DhallParser, DhallLanguage};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut session = ParseSession::<DhallLanguage>::default();
let parser = DhallParser::new();
let source = SourceText::new(r#"
let greeting = "Hello, Dhall!"
in greeting
"#);
let result = parser.parse(&source, &[], &mut session);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed Dhall successfully.");
}
Ok(())
}
use oak_core::{Parser, SourceText, parser::session::ParseSession};
use oak_dhall::{DhallParser, DhallLanguage};
let mut session = ParseSession::<DhallLanguage>::default();
let parser = DhallParser::new();
let source = SourceText::new(r#"{ x = 1, y = 2 }"#);
let result = parser.parse(&source, &[], &mut session);
println!("Parsed Dhall expression successfully.");
The oak library allows for flexible customization of the parser. You can modify the grammar rules or add new ones to suit your specific needs, such as supporting experimental Dhall features. Refer to the oak documentation for more details on parser customization.
Oak of Dhall can be extended with error recovery mechanisms to handle malformed Dhall code gracefully, allowing for partial parsing and better resilience in real-world scenarios.
The generated AST for Dhall provides a hierarchical representation of the code elements. For instance, a let expression might result in an AST structure similar to this:
// Simplified AST representation for:
// let greeting = "Hello, Dhall!" in greeting
pex_dhall::ast::Node::LetExpression {
bindings: vec![
// ... binding details ...
],
expression: // ... expression details ...
}
Oak of Dhall is designed for performance. Benchmarks show efficient parsing of large Dhall codebases. Optimizations include memoization, efficient backtracking, and direct AST construction.
Oak of Dhall can be integrated into various tools and applications:
Explore the examples directory within the oak-dhall project for more usage examples and demonstrations of specific Dhall parsing features.
Contributions to Oak of Dhall are welcome! If you find a bug or have a feature request, please open an issue on the GitHub repository. For major changes, please open a discussion first.