Oak TOML Parser
High-performance incremental TOML parser for the oak ecosystem with flexible configuration, optimized for configuration file processing and data serialization.
🎯 Overview
Oak of toml is a robust parser for TOML, designed to handle complete TOML syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for configuration processing and data serialization.
✨ Features
- Complete TOML Syntax: Supports all TOML 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 TomlParser;
📋 Parsing Examples
Document Parsing
use ;
let parser = new;
let toml_content = r#"
[server]
host = "localhost"
port = 8080
[database]
url = "postgresql://localhost/mydb"
pool_size = 10
"#;
let document = parser.parse_document?;
println!;
Table Parsing
use ;
let parser = new;
let table_content = r#"
[package]
name = "my-project"
version = "1.0.0"
description = "A sample project"
"#;
let table = parser.parse_table?;
println!;
🔧 Advanced Features
Token-Level Parsing
use ;
let parser = new;
let tokens = parser.tokenize?;
for token in tokens
Error Handling
use TomlParser;
let parser = new;
let invalid_toml = r#"
[section
key = "value"
"#;
match parser.parse_document
🏗️ AST Structure
The parser generates a comprehensive AST with the following main structures:
- Document: Root container for TOML documents
- Table: TOML tables with key-value pairs
- Array: TOML arrays of values
- Value: Various value types (string, integer, float, boolean, datetime)
- Key: Table and key names
📊 Performance
- Streaming: Parse large TOML 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 toml integrates seamlessly with:
- Configuration Management: Parse and validate application configurations
- Build Tools: Process Cargo.toml and similar configuration files
- Data Serialization: Serialize and deserialize TOML data
- IDE Support: Language server protocol compatibility
- DevOps Tools: Configuration validation and processing
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete TOML 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.