Oak YAML Parser
High-performance incremental YAML parser for the oak ecosystem with flexible configuration, optimized for data serialization and configuration file processing.
🎯 Overview
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.
✨ Features
- Complete YAML Syntax: Supports all YAML features including modern specifications
- Full AST Generation: Generates comprehensive Abstract Syntax Trees
- Lexer Support: Built-in tokenization with proper span information
- Error Recovery: Graceful handling of syntax errors with detailed diagnostics
🚀 Quick Start
Basic example:
use YamlParser;
📋 Parsing Examples
Document Parsing
use ;
let parser = new;
let yaml_content = r#"
name: John Doe
age: 30
hobbies:
- reading
- hiking
- coding
"#;
let document = parser.parse_document?;
println!;
Mapping Parsing
use ;
let parser = new;
let mapping_content = r#"
config:
debug: true
timeout: 30
retries: 3
"#;
let mapping = parser.parse_mapping?;
println!;
🔧 Advanced Features
Token-Level Parsing
use ;
let parser = new;
let tokens = parser.tokenize?;
for token in tokens
Error Handling
use YamlParser;
let parser = new;
let invalid_yaml = r#"
config:
key: value
nested: invalid_indentation
"#;
match parser.parse_document
🏗️ AST Structure
The parser generates a comprehensive AST with the following main structures:
- Document: Root container for YAML documents
- Mapping: YAML key-value mappings
- Sequence: YAML arrays/sequences
- Scalar: YAML scalar values (string, number, boolean, null)
- Anchor: YAML anchor references
- Alias: YAML alias references
📊 Performance
- Streaming: Parse large YAML files without loading entirely into memory
- Incremental: Re-parse only changed sections
- Memory Efficient: Smart AST node allocation
- Fast Recovery: Quick error recovery for better IDE integration
🔗 Integration
Oak of yaml integrates seamlessly with:
- Configuration Management: Parse and validate application configurations
- Data Serialization: Serialize and deserialize YAML data
- API Processing: Handle YAML API requests and responses
- IDE Support: Language server protocol compatibility
- DevOps Tools: Configuration validation and processing
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete YAML document parsing
- Configuration file analysis
- Data extraction and transformation
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.