π₯ Announcing mojo-toml v0.3.0 - Native TOML Parser for Mojo
Historical forum post for the v0.3.0 release. Rework version numbers, feature counts, and roadmap items before reusing for newer releases.
Iβm excited to share mojo-toml - the first native TOML 1.0 parser for Mojo! Parse configuration files with zero Python dependencies and blazing-fast performance.
π What is mojo-toml?
mojo-toml enables Mojo developers to read TOML configuration files natively, perfect for: - Application configuration - Build systems (like pixi.toml!) - Project settings - Any structured data needs
β¨ Key Features
Complete TOML 1.0 Support
- β All basic types: strings, integers, floats, booleans
- β Arrays with nesting and mixed types
- β
Inline tables:
{key = "value"} - β
Table headers:
[section] - β
Nested tables:
[a.b.c] - β
Dotted keys:
a.b.c = "value" - β Comments and multiline strings
Quality & Reliability
- β 96 comprehensive tests across 10 test files
- β Duplicate key detection
- β Clear error messages with line/column context
- β Successfully parses real-world files (tested with pixi.toml)
Performance
- β‘ 26 microseconds for simple documents
- β‘ 2 milliseconds for real pixi.toml files
- β‘ 10 microseconds table access overhead (negligible!)
π¦ Installation
Option 1: Via Pixi (when available in modular-community)
# pixi.toml
[project]
channels = ["conda-forge", "https://conda.modular.com/max", "https://repo.prefix.dev/modular-community"]
[dependencies]
mojo-toml = "*"Option 2: Direct from GitHub
git clone https://github.com/DataBooth/mojo-toml.git
cd mojo-toml
pixi run test-all # Verify installationπ― Quick Example
from toml import parse
fn main() raises:
# Parse TOML string
var config = parse("""
[database]
host = "localhost"
port = 5432
[app]
name = "my-app"
debug = true
""")
# Access nested values
var db = config["database"].as_table()
print("Host:", db["host"].as_string())
print("Port:", db["port"].as_int())
var app = config["app"].as_table()
print("App:", app["name"].as_string())
print("Debug:", app["debug"].as_bool())
π Whatβs New in v0.3.0
This release brings major quality and performance improvements:
Critical Fixes
- β Proper dotted key support (creates nested structures)
- β Duplicate key detection with clear errors
- β Enhanced error messages with line/column context
- β Named type constants (replaced magic numbers)
Parser Improvements
- π
Parser.reset()method for instance reusability - π οΈ Helper methods and better code organization
- π Enhanced documentation
Testing & Documentation
- π Reorganized into 10 logical test suites
- π Comprehensive performance benchmarks
- π New performance and test organization guides
- π¨ Enhanced examples with detailed reporting
π¬ Under the Hood
Built entirely in native Mojo with: - Custom lexer for tokenisation (25 tests) - Recursive descent parser (10 core tests) - Zero Python dependencies - Proper nested Dict structures - Comprehensive error handling
π Learn More
- GitHub: https://github.com/DataBooth/mojo-toml
- Latest Release: https://github.com/DataBooth/mojo-toml/releases/tag/v0.3.0
- Documentation: See README.md and docs/ directory
- Tests: 96 tests demonstrating all features
π€ Contributing
Contributions welcome! The project follows: - Clear test organisation (see docs/TEST_ORGANIZATION.md) - Comprehensive testing (96 tests and growing) - Performance documentation (see docs/PERFORMANCE.md)
π Roadmap
Future enhancements planned: - Array of tables: [[array]] - Hex/Octal/Binary integers - Native datetime parsing - TOML writer/serialiser - SIMD optimisations
π¬ Feedback Welcome
This is a community project and Iβd love to hear: - How youβre using it - Feature requests - Bug reports - Performance feedback
Try it out and let me know what you think! π
Links: - GitHub: https://github.com/DataBooth/mojo-toml - Release: https://github.com/DataBooth/mojo-toml/releases/tag/v0.3.0 - License: MIT
Built with β€οΈ for the Mojo community