mon-core

Crates.iomon-core
lib.rsmon-core
version0.0.3
created_at2025-11-15 18:16:25.718891+00
updated_at2025-11-23 01:09:29.459328+00
descriptionA robust parser and validator for the Mycel Object Notation (MON) language, designed for fast, efficient, and human-friendly configuration.
homepagehttps://github.com/Mycel-Lang/mon
repositoryhttps://github.com/Mycel-Lang/mon-core
max_upload_size
id1934636
size359,155
(ImTheShrub)

documentation

https://docs.rs/mon-core

README

MON-Core

CI Crates.io Documentation License: MIT Rust Version

mon-core is the reference Rust implementation of the MON (Mycel Object Notation) language — a human-focused configuration and data format designed to be readable, safe, and predictable.

This crate provides the parser, analyzer, validator, and core data model used by MON-based tooling, servers, CLIs, and compilers.

for more information please look at out website: www.mycel-lang.org


Table of Contents


Overview

MON aims to replace overly rigid formats (JSON) and overly permissive ones (YAML) with a syntax that stays readable without giving up safety or predictability.

mon-core implements:

  • A forgiving parser with clear, context-rich error messages
  • A semantic analyzer with anchor/alias resolution
  • Type checking via #struct, #enum, and validated bindings
  • An internal IR suitable for compilers and higher-level tooling

If you want to embed MON into your Rust application or build tooling around the language, this is the crate.

For more information about mon docs are here :D

Features

  • Clean syntax: unquoted keys, comments, trailing commas
  • Human-friendly booleans: on / off as well as true / false
  • Anchors & aliases: safe reuse with explicit copy semantics (&name, *name)
  • Deep merges: ...*anchor for structured overrides
  • Types built in: #struct, #enum, and :: for validation
  • Modular imports: import { A, B } from "./file.mon"
  • Detailed errors: location-aware, colorized, actionable

Example

import { ServerSettings } from "./schemas.mon"

{
    &base: {
        host: "localhost",
        port: 8080,
    },

    User: #struct {
        id(Number),
        name(String),
        roles([String...]),
    },

    admin :: User = {
        id: 1,
        name: "Alice",
        roles: ["admin", "editor"],
    },

    dev: {
        ...*base,
        port: 9001,
        debug: on,
    },
}

Rust Quick Start

Add to Cargo.toml:

[dependencies]
mon-core = "0.1"

Parse and analyze:

use mon_core::analyze;

fn main() {
    let text = r#"
        settings: {
            name: "Example",
            enabled: on,
        }
    "#;

    match analyze(text, "config.mon") {
        Ok(result) => {
            println!("JSON:\n{}", result.to_json().unwrap());
        }
        Err(err) => {
            eprintln!("MON error:\n{err}");
        }
    }
}

Error Handling

MON is designed to fail loudly and helpfully.

Example error (format depends on your terminal capabilities):

error[E0012]: expected Number, got String
  --> config.mon:7:12
   |
 6 |   age: "twenty",
   |             ^^^ expected a Number here

Errors include:

  • the source span
  • the inferred and expected types
  • suggestions when applicable

Development

Build:

cargo build

Test:

cargo test --all-features

Checks:

cargo check

The project follows standard Rust layout. Documentation lives in docs/. Any language or spec changes must be reflected there.


Roadmap

  • Improved parser recovery modes
  • Type system stabilization
  • Performance pass on alias/anchor resolution
  • Better import graph validation
  • Tooling support (formatter, LSP)

License

Licensed under the MIT license. See LICENSE for details.


for more information please look at out website: www.mycel-lang.org

Made with ❤️

Commit count: 0

cargo fmt