πŸ”₯ 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