| Crates.io | oak-yaml |
| lib.rs | oak-yaml |
| version | 0.0.1 |
| created_at | 2025-10-22 05:53:01.301183+00 |
| updated_at | 2026-01-23 05:38:15.038139+00 |
| description | High-performance incremental YAML parser for the oak ecosystem with flexible configuration, optimized for configuration files and data serialization. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1895038 |
| size | 75,395 |
High-performance incremental YAML parser for the oak ecosystem with flexible configuration, optimized for data serialization and configuration file processing.
Oak of yaml is a robust parser for YAML, designed to handle complete YAML syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for data serialization and configuration processing.
Basic example:
use oak_yaml::YamlParser;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = YamlParser::new();
let yaml_content = r#"
server:
host: localhost
port: 8080
database:
url: postgresql://localhost/mydb
pool_size: 10
"#;
let document = parser.parse_document(yaml_content)?;
println!("Parsed YAML document successfully.");
Ok(())
}
use oak_yaml::{YamlParser, ast::Document};
let parser = YamlParser::new();
let yaml_content = r#"
name: John Doe
age: 30
hobbies:
- reading
- hiking
- coding
"#;
let document = parser.parse_document(yaml_content)?;
println!("Person name: {:?}", document.get_value("name"));
use oak_yaml::{YamlParser, ast::Mapping};
let parser = YamlParser::new();
let mapping_content = r#"
config:
debug: true
timeout: 30
retries: 3
"#;
let mapping = parser.parse_mapping(mapping_content)?;
println!("Debug mode: {:?}", mapping.get_value("debug"));
use oak_yaml::{YamlParser, lexer::Token};
let parser = YamlParser::new();
let tokens = parser.tokenize("key: value\nlist:\n - item1\n - item2")?;
for token in tokens {
println!("{:?}", token.kind);
}
use oak_yaml::YamlParser;
let parser = YamlParser::new();
let invalid_yaml = r#"
config:
key: value
nested: invalid_indentation
"#;
match parser.parse_document(invalid_yaml) {
Ok(document) => println!("Parsed YAML document successfully."),
Err(e) => {
println!("Parse error at line {} column {}: {}",
e.line(), e.column(), e.message());
if let Some(context) = e.context() {
println!("Error context: {}", context);
}
}
}
The parser generates a comprehensive AST with the following main structures:
Oak of yaml 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.